TianoCore EDK2 master
Loading...
Searching...
No Matches
LinuxBootBm.c
Go to the documentation of this file.
1
14#include <Uefi.h>
15
16#include <Guid/EventGroup.h>
17#include <Library/BaseLib.h>
19#include <Library/DebugLib.h>
22#include <Library/PcdLib.h>
25#include <Library/UefiLib.h>
28#include <Protocol/PlatformBootManager.h>
29
39VOID
41 CONST EFI_GUID *FileGuid,
42 CHAR16 *Description,
43 UINT32 Attributes
44 )
45{
46 EFI_STATUS Status;
47 INTN OptionIndex;
50 UINTN BootOptionCount;
52 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
53 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
54
55 Status = gBS->HandleProtocol (
57 &gEfiLoadedImageProtocolGuid,
58 (VOID **)&LoadedImage
59 );
60 ASSERT_EFI_ERROR (Status);
61
62 EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
63 DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
64 ASSERT (DevicePath != NULL);
65 DevicePath = AppendDevicePathNode (
66 DevicePath,
67 (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
68 );
69 ASSERT (DevicePath != NULL);
70
72 &NewOption,
73 LoadOptionNumberUnassigned,
74 LoadOptionTypeBoot,
75 Attributes,
76 Description,
77 DevicePath,
78 NULL,
79 0
80 );
81 ASSERT_EFI_ERROR (Status);
82 FreePool (DevicePath);
83
84 BootOptions = EfiBootManagerGetLoadOptions (
85 &BootOptionCount,
86 LoadOptionTypeBoot
87 );
88
89 OptionIndex = EfiBootManagerFindLoadOption (
90 &NewOption,
91 BootOptions,
92 BootOptionCount
93 );
94
95 if (OptionIndex == -1) {
96 Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
97 ASSERT_EFI_ERROR (Status);
98 }
99
100 EfiBootManagerFreeLoadOption (&NewOption);
101 EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
102}
103
112VOID
113EFIAPI
115 VOID
116 )
117{
118 //
119 // Signal EndOfDxe PI Event
120 //
121 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
122}
123
134VOID
135EFIAPI
137 VOID
138 )
139{
140 EFI_GUID LinuxBootFileGuid;
141
142 CopyGuid (&LinuxBootFileGuid, PcdGetPtr (PcdLinuxBootFileGuid));
143
144 if (!CompareGuid (&LinuxBootFileGuid, &gZeroGuid)) {
145 //
146 // Register LinuxBoot
147 //
149 &LinuxBootFileGuid,
150 L"LinuxBoot",
151 LOAD_OPTION_ACTIVE
152 );
153 } else {
154 DEBUG ((DEBUG_ERROR, "%a: PcdLinuxBootFileGuid was not set!\n", __func__));
155 }
156}
157
164VOID
165EFIAPI
167 UINT16 TimeoutRemain
168 )
169{
170 return;
171}
172
180VOID
181EFIAPI
183 VOID
184 )
185{
186 return;
187}
UINT64 UINTN
INT64 INTN
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI PlatformBootManagerBeforeConsole(VOID)
Definition: LinuxBootBm.c:114
VOID EFIAPI PlatformBootManagerWaitCallback(UINT16 TimeoutRemain)
Definition: LinuxBootBm.c:166
VOID EFIAPI PlatformBootManagerUnableToBoot(VOID)
Definition: LinuxBootBm.c:182
STATIC VOID PlatformRegisterFvBootOption(CONST EFI_GUID *FileGuid, CHAR16 *Description, UINT32 Attributes)
Definition: LinuxBootBm.c:40
VOID EFIAPI PlatformBootManagerAfterConsole(VOID)
Definition: LinuxBootBm.c:136
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOption(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption)
EFI_BOOT_MANAGER_LOAD_OPTION *EFIAPI EfiBootManagerGetLoadOptions(OUT UINTN *LoadOptionCount, IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType)
EFI_STATUS EFIAPI EfiBootManagerAddLoadOptionVariable(IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN Position)
Definition: BmLoadOption.c:367
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount)
INTN EFIAPI EfiBootManagerFindLoadOption(IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key, IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array, IN UINTN Count)
Definition: BmLoadOption.c:548
EFI_STATUS EFIAPI EfiBootManagerInitializeLoadOption(IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN OptionNumber, IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType, IN UINT32 Attributes, IN CHAR16 *Description, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN UINT8 *OptionalData, IN UINT32 OptionalDataSize)
EFI_HANDLE gImageHandle
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiEventGroupSignal(IN CONST EFI_GUID *EventGroup)
Definition: UefiLib.c:314
VOID EFIAPI EfiInitializeFwVolDevicepathNode(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, IN CONST EFI_GUID *NameGuid)
Definition: UefiNotTiano.c:325
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:53
Definition: Base.h:213