23 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x08, 0xe2, 0x0e, 0x90, 0x6c, 0xb6, 0xde }
25EFI_GUID mBmAutoCreateBootOptionGuid = {
26 0x8108ac4e, 0x9f11, 0x4d59, { 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2 }
65 mBmRefreshLegacyBootOption = RefreshLegacyBootOption;
66 mBmLegacyBoot = LegacyBoot;
82 if ((BootOption->OptionalDataSize == sizeof (
EFI_GUID)) &&
108 CHAR16 OptionName[BM_OPTION_NAME_LEN];
110 UINTN BootOptionCount;
113 OptionNumber = LoadOptionNumberUnassigned;
118 if (OptionToFind->OptionNumber != LoadOptionNumberUnassigned) {
123 mBmLoadOptionName[OptionToFind->OptionType],
124 OptionToFind->OptionNumber
128 if (!EFI_ERROR (Status)) {
129 ASSERT (OptionToFind->OptionNumber == BootOption.OptionNumber);
130 if ((OptionToFind->Attributes == BootOption.Attributes) &&
131 (
StrCmp (OptionToFind->Description, BootOption.Description) == 0) &&
133 (OptionToFind->OptionalDataSize == BootOption.OptionalDataSize) &&
134 (
CompareMem (OptionToFind->OptionalData, BootOption.OptionalData, OptionToFind->OptionalDataSize) == 0)
137 OptionNumber = OptionToFind->OptionNumber;
147 if (OptionNumber == LoadOptionNumberUnassigned) {
151 if ((BootOptions ==
NULL) && (BootOptionCount > 0)) {
152 ASSERT (BootOptions !=
NULL);
153 return LoadOptionNumberUnassigned;
158 OptionNumber = BootOptions[Index].OptionNumber;
193 FvFileNode = FilePath;
194 Status =
gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &FvFileNode, &FvHandle);
195 if (!EFI_ERROR (Status)) {
211 gBS->HandleProtocol (
213 &gEfiLoadedImageProtocolGuid,
214 (
VOID **)&LoadedImage
219 if (FullPath !=
NULL) {
226 gBS->LocateHandleBuffer (
228 &gEfiFirmwareVolume2ProtocolGuid,
233 for (Index = 0; Index < FvHandleCount; Index++) {
244 if (FullPath !=
NULL) {
249 if (FvHandles !=
NULL) {
276 Status =
gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &Handle);
277 if (!EFI_ERROR (Status)) {
312 UINT8 DeviceSubClass;
313 UINT8 DeviceProtocol;
324 Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
325 if (EFI_ERROR (Status)) {
329 if ((UsbClass->VendorId != 0xffff) &&
330 (UsbClass->VendorId != DevDesc.IdVendor))
335 if ((UsbClass->ProductId != 0xffff) &&
336 (UsbClass->ProductId != DevDesc.IdProduct))
341 DeviceClass = DevDesc.DeviceClass;
342 DeviceSubClass = DevDesc.DeviceSubClass;
343 DeviceProtocol = DevDesc.DeviceProtocol;
344 if (DeviceClass == 0) {
349 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);
350 if (EFI_ERROR (Status)) {
354 DeviceClass = IfDesc.InterfaceClass;
355 DeviceSubClass = IfDesc.InterfaceSubClass;
356 DeviceProtocol = IfDesc.InterfaceProtocol;
362 if ((UsbClass->DeviceClass != 0xff) &&
363 (UsbClass->DeviceClass != DeviceClass))
368 if ((UsbClass->DeviceSubClass != 0xff) &&
369 (UsbClass->DeviceSubClass != DeviceSubClass))
374 if ((UsbClass->DeviceProtocol != 0xff) &&
375 (UsbClass->DeviceProtocol != DeviceProtocol))
408 CHAR16 *SerialNumberStr;
420 Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
421 if (EFI_ERROR (Status)) {
425 if ((DevDesc.IdVendor != UsbWwid->VendorId) ||
426 (DevDesc.IdProduct != UsbWwid->ProductId))
434 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);
435 if (EFI_ERROR (Status)) {
439 if (IfDesc.InterfaceNumber != UsbWwid->InterfaceNumber) {
446 if (DevDesc.StrSerialNumber == 0) {
455 Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize);
456 if (EFI_ERROR (Status) || (TableSize == 0) || (LangIdTable ==
NULL)) {
463 CompareStr = (CHAR16 *)(
UINTN)(UsbWwid + 1);
465 if (CompareStr[CompareLen - 1] == L
'\0') {
472 for (Index = 0; Index < TableSize /
sizeof (UINT16); Index++) {
473 SerialNumberStr =
NULL;
474 Status = UsbIo->UsbGetStringDescriptor (
477 DevDesc.StrSerialNumber,
480 if (EFI_ERROR (Status) || (SerialNumberStr ==
NULL)) {
484 Length =
StrLen (SerialNumberStr);
485 if ((Length >= CompareLen) &&
486 (
CompareMem (SerialNumberStr + Length - CompareLen, CompareStr, CompareLen *
sizeof (CHAR16)) == 0))
527 ASSERT (UsbIoHandleCount !=
NULL);
532 Status =
gBS->LocateHandleBuffer (
534 &gEfiUsbIoProtocolGuid,
539 if (EFI_ERROR (Status)) {
540 *UsbIoHandleCount = 0;
544 for (Index = 0; Index < *UsbIoHandleCount; ) {
548 Status =
gBS->HandleProtocol (
550 &gEfiUsbIoProtocolGuid,
555 if (!EFI_ERROR (Status) && (UsbIoDevicePath !=
NULL)) {
559 if (
CompareMem (UsbIoDevicePath, DevicePath, ParentDevicePathSize) == 0) {
569 (*UsbIoHandleCount)--;
570 CopyMem (&UsbIoHandles[Index], &UsbIoHandles[Index + 1], (*UsbIoHandleCount - Index) *
sizeof (
EFI_HANDLE));
612 UINTN ParentDevicePathSize;
621 GetNext = (BOOLEAN)(FullPath ==
NULL);
622 ParentDevicePathSize = (
UINTN)ShortformNode - (
UINTN)FilePath;
624 Handles =
BmFindUsbDevice (FilePath, ParentDevicePathSize, &HandleCount);
626 for (Index = 0; Index < HandleCount; Index++) {
628 if (FilePath ==
NULL) {
637 if (NextFullPath ==
NULL) {
653 if (Handles !=
NULL) {
687 Status =
gBS->LocateHandleBuffer (
ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
NULL, &HandleCount, &Handles);
688 if (EFI_ERROR (Status)) {
693 GetNext = (BOOLEAN)(FullPath ==
NULL);
699 for (MediaType = 0; MediaType < 3; MediaType++) {
700 for (Index = 0; Index < HandleCount; Index++) {
701 Status =
gBS->HandleProtocol (Handles[Index], &gEfiBlockIoProtocolGuid, (
VOID *)&BlockIo);
702 if (EFI_ERROR (Status)) {
708 ((MediaType == 2) && (BlockIo ==
NULL))
722 if (NextFullPath !=
NULL) {
727 if (Handles !=
NULL) {
760 Status =
gBS->LocateHandleBuffer (
ByProtocol, &gEfiLoadFileProtocolGuid,
NULL, &HandleCount, &Handles);
761 if (EFI_ERROR (Status)) {
767 GetNext = (BOOLEAN)(FullPath ==
NULL);
768 for (Index = 0; Index < HandleCount; Index++) {
771 if (NextFullPath ==
NULL) {
783 if (RamDiskDevicePath !=
NULL) {
793 if (Handles !=
NULL) {
816 TempDevicePath = *CachedDevicePath;
821 if (*CachedDevicePath ==
NULL) {
826 TempDevicePath = *CachedDevicePath;
828 if (TempDevicePath !=
NULL) {
837 TempDevicePath = *CachedDevicePath;
877 UINTN BlockIoHandleCount;
885 UINTN CachedDevicePathSize;
890 BOOLEAN ConnectAllAttempted;
904 CachedDevicePath =
NULL;
905 Status =
gRT->SetVariable (
916 if (CachedDevicePath !=
NULL) {
917 TempNewDevicePath = CachedDevicePath;
932 if (!EFI_ERROR (Status)) {
947 if (FullPath !=
NULL) {
957 Status =
gRT->SetVariable (
978 }
while (TempNewDevicePath !=
NULL);
985 BlockIoBuffer =
NULL;
987 ConnectAllAttempted =
FALSE;
989 if (BlockIoBuffer !=
NULL) {
993 Status =
gBS->LocateHandleBuffer (
ByProtocol, &gEfiBlockIoProtocolGuid,
NULL, &BlockIoHandleCount, &BlockIoBuffer);
994 if (EFI_ERROR (Status)) {
995 BlockIoHandleCount = 0;
996 BlockIoBuffer =
NULL;
1002 for (Index = 0; Index < BlockIoHandleCount; Index++) {
1004 if (BlockIoDevicePath ==
NULL) {
1016 if (FullPath !=
NULL) {
1023 Status =
gRT->SetVariable (
1026 EFI_VARIABLE_BOOTSERVICE_ACCESS |
1041 if (MatchFound || ConnectAllAttempted) {
1046 ConnectAllAttempted =
TRUE;
1049 if (CachedDevicePath !=
NULL) {
1053 if (BlockIoBuffer !=
NULL) {
1086 UINTN NumberSimpleFileSystemHandles;
1090 GetNext = (BOOLEAN)(FullPath ==
NULL);
1094 TempDevicePath = DevicePath;
1095 Status =
gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &TempDevicePath, &Handle);
1096 if (!EFI_ERROR (Status)) {
1099 NextFullPath =
FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);
1104 return NextFullPath;
1111 Status =
gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);
1128 Status =
gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (
VOID **)&BlockIo);
1130 if (EFI_ERROR (Status)) {
1135 if (Buffer !=
NULL) {
1136 BlockIo->ReadBlocks (
1149 NextFullPath =
NULL;
1151 gBS->LocateHandleBuffer (
1153 &gEfiSimpleFileSystemProtocolGuid,
1155 &NumberSimpleFileSystemHandles,
1156 &SimpleFileSystemHandles
1158 for (Index = 0; Index < NumberSimpleFileSystemHandles; Index++) {
1167 if ((Size <= TempSize) && (
CompareMem (TempDevicePath, DevicePath, Size) == 0)) {
1168 NextFullPath =
FileDevicePath (SimpleFileSystemHandles[Index], EFI_REMOVABLE_MEDIA_FILE_NAME);
1174 NextFullPath =
NULL;
1179 if (SimpleFileSystemHandles !=
NULL) {
1180 FreePool (SimpleFileSystemHandles);
1183 return NextFullPath;
1251 Status =
gBS->LocateHandleBuffer (
1253 &gEfiBlockIoProtocolGuid,
1258 if (EFI_ERROR (Status)) {
1264 for (Index = 0; Index < HandleCount; Index++) {
1266 Status =
gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
1267 if (!EFI_ERROR (Status) &&
1268 (Handle == LoadFileHandle) &&
1274 Handle = Handles[Index];
1279 if (Handles !=
NULL) {
1283 if (Index == HandleCount) {
1287 *RamDiskHandle = Handle;
1289 if (Handle !=
NULL) {
1318 Status =
gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
1319 if (!EFI_ERROR (Status) &&
1329 ASSERT (RamDiskDevicePath !=
NULL);
1331 return RamDiskDevicePath;
1353 UINT64 StartingAddr;
1356 ASSERT (RamDiskDevicePath !=
NULL);
1358 *RamDiskSizeInPages = 0;
1363 Status =
gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &RamDiskDevicePath, &Handle);
1390 VOID *RamDiskBuffer;
1391 UINTN RamDiskSizeInPages;
1393 ASSERT (RamDiskDevicePath !=
NULL);
1400 if (mRamDisk ==
NULL) {
1405 Status = mRamDisk->Unregister (RamDiskDevicePath);
1431 Status =
gBS->OpenProtocol (
1433 &gEfiLoadFileProtocolGuid,
1437 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1443 Status = LoadFile->LoadFile (LoadFile, FilePath,
TRUE, &BufferSize, FileBuffer);
1444 if ((Status != EFI_WARN_FILE_SYSTEM) && (Status != EFI_BUFFER_TOO_SMALL)) {
1448 if (Status == EFI_BUFFER_TOO_SMALL) {
1463 if (FileBuffer ==
NULL) {
1466 CHAR16 *LoadFileText;
1470 if (LoadFilePath ==
NULL) {
1471 LoadFileText =
NULL;
1480 "%a:%a: failed to allocate reserved pages: "
1481 "BufferSize=%Lu LoadFile=\"%s\" FilePath=\"%s\"\n",
1489 if (FileText !=
NULL) {
1493 if (LoadFileText !=
NULL) {
1501 Status = LoadFile->LoadFile (LoadFile, FilePath,
TRUE, &BufferSize, FileBuffer);
1502 if (EFI_ERROR (Status)) {
1508 if (FullPath ==
NULL) {
1558 Status =
gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
1571 Status =
gBS->LocateHandleBuffer (
1573 &gEfiLoadFileProtocolGuid,
1578 if (EFI_ERROR (Status)) {
1583 for (Index = 0; Index < HandleCount; Index++) {
1590 Handle = Handles[Index];
1600 for (Index = 0; Index < HandleCount; Index++) {
1601 if ((Handles ==
NULL) || (Handles[Index] ==
NULL)) {
1606 if (NewDevicePath ==
NULL) {
1611 if (HttpPath ==
NULL) {
1621 Handle = Handles[Index];
1629 if (Handles !=
NULL) {
1634 if (Handle ==
NULL) {
1691 ASSERT (FilePath !=
NULL);
1697 Status =
gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &Node, &Handle);
1698 if (EFI_ERROR (Status)) {
1699 Status =
gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &Node, &Handle);
1715 if (FullPath ==
NULL) {
1736 Status =
gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, &Handle);
1737 if (EFI_ERROR (Status)) {
1755 if (FilePath == Node) {
1773 if (FullPath !=
NULL) {
1788 Status =
gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &Node, &Handle);
1789 if (!EFI_ERROR (Status)) {
1816 Status =
gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
1817 if (!EFI_ERROR (Status)) {
1819 if (NameGuid !=
NULL) {
1843 IN UINT32 ErrorCode,
1854 (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) ||
1855 (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)
1858 ZeroMem (&ExtendedData,
sizeof (ExtendedData));
1863 (EFI_SOFTWARE_DXE_BS_DRIVER | ErrorCode),
1868 sizeof (ExtendedData) -
sizeof (ExtendedData.
DataHeader)
1903 UINTN OriginalOptionNumber;
1911 if (BootOption ==
NULL) {
1915 if ((BootOption->FilePath ==
NULL) || (BootOption->OptionType != LoadOptionTypeBoot)) {
1916 BootOption->Status = EFI_INVALID_PARAMETER;
1924 if (OptionNumber == LoadOptionNumberUnassigned) {
1926 if (!EFI_ERROR (Status)) {
1930 OptionNumber = Uint16;
1931 OriginalOptionNumber = BootOption->OptionNumber;
1932 BootOption->OptionNumber = OptionNumber;
1934 BootOption->OptionNumber = OriginalOptionNumber;
1937 if (EFI_ERROR (Status)) {
1938 DEBUG ((DEBUG_ERROR,
"[Bds] Failed to create Boot#### for a temporary boot - %r!\n", Status));
1939 BootOption->Status = Status;
1947 Uint16 = (UINT16)OptionNumber;
1950 &gEfiGlobalVariableGuid,
1951 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
1961 DEBUG ((DEBUG_INFO,
"[Bds] Booting Boot Manager Menu.\n"));
1982 (BOOLEAN)((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_BOOT)
1989 if (BootOption->Description ==
NULL) {
1990 DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"[Bds]Booting from unknown device path\n"));
1992 DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"[Bds]Booting %s\n", BootOption->Description));
1998 RamDiskDevicePath =
NULL;
2000 Status = EFI_NOT_FOUND;
2004 if (FileBuffer !=
NULL) {
2008 Status =
gBS->LoadImage (
2018 if (FileBuffer !=
NULL) {
2022 if (FilePath !=
NULL) {
2026 if (EFI_ERROR (Status)) {
2033 if (Status == EFI_SECURITY_VIOLATION) {
2034 gBS->UnloadImage (ImageHandle);
2040 if (RamDiskDevicePath !=
NULL) {
2049 BootOption->Status = Status;
2059 if (mBmLegacyBoot !=
NULL) {
2076 mBmLegacyBoot (BootOption);
2078 BootOption->Status = EFI_UNSUPPORTED;
2088 Status =
gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (
VOID **)&ImageInfo);
2093 ImageInfo->
LoadOptions = BootOption->OptionalData;
2104 gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00,
NULL);
2115 Status =
gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &BootOption->ExitData);
2116 DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"Image Return Status = %r\n", Status));
2117 BootOption->Status = Status;
2122 if (RamDiskDevicePath !=
NULL) {
2127 if (EFI_ERROR (Status)) {
2139 gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000,
NULL);
2145 Status =
gBS->LocateProtocol (&gEfiBootLogoProtocolGuid,
NULL, (
VOID **)&BootLogo);
2146 if (!EFI_ERROR (Status) && (BootLogo !=
NULL)) {
2147 Status = BootLogo->SetBootLogo (BootLogo,
NULL, 0, 0, 0, 0);
2154 Status =
gRT->SetVariable (
2156 &gEfiGlobalVariableGuid,
2166 ASSERT (Status ==
EFI_SUCCESS || Status == EFI_NOT_FOUND);
2189 if ((BlockIoDevicePath ==
NULL) || (HardDriveDevicePath ==
NULL)) {
2210 if ((Node->
PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
2211 (Node->
MBRType == HardDriveDevicePath->MBRType) &&
2212 (Node->
SignatureType == HardDriveDevicePath->SignatureType) &&
2244 UINTN *BootOptionCount
2254 CHAR16 *Description;
2256 ASSERT (BootOptionCount !=
NULL);
2258 *BootOptionCount = 0;
2264 gBS->LocateHandleBuffer (
2266 &gEfiBlockIoProtocolGuid,
2272 for (Removable = 0; Removable < 2; Removable++) {
2273 for (Index = 0; Index < HandleCount; Index++) {
2274 Status =
gBS->HandleProtocol (
2276 &gEfiBlockIoProtocolGuid,
2279 if (EFI_ERROR (Status)) {
2286 if (BlkIo->Media->LogicalPartition) {
2293 if (BlkIo->Media->RemovableMedia == ((Removable == 0) ?
FALSE :
TRUE)) {
2300 if ((BlkIo->Media->RemovableMedia ==
TRUE) &&
2301 (BlkIo->Media->MediaPresent ==
FALSE))
2312 ASSERT (BootOptions !=
NULL);
2315 &BootOptions[(*BootOptionCount)++],
2316 LoadOptionNumberUnassigned,
2330 if (HandleCount != 0) {
2337 gBS->LocateHandleBuffer (
2339 &gEfiSimpleFileSystemProtocolGuid,
2344 for (Index = 0; Index < HandleCount; Index++) {
2345 Status =
gBS->HandleProtocol (
2347 &gEfiBlockIoProtocolGuid,
2350 if (!EFI_ERROR (Status)) {
2363 ASSERT (BootOptions !=
NULL);
2366 &BootOptions[(*BootOptionCount)++],
2367 LoadOptionNumberUnassigned,
2379 if (HandleCount != 0) {
2386 gBS->LocateHandleBuffer (
2388 &gEfiLoadFileProtocolGuid,
2393 for (Index = 0; Index < HandleCount; Index++) {
2407 ASSERT (BootOptions !=
NULL);
2410 &BootOptions[(*BootOptionCount)++],
2411 LoadOptionNumberUnassigned,
2423 if (HandleCount != 0) {
2442 UINTN NvBootOptionCount;
2444 UINTN BootOptionCount;
2446 UINTN UpdatedBootOptionCount;
2453 if (mBmRefreshLegacyBootOption !=
NULL) {
2454 mBmRefreshLegacyBootOption ();
2462 for (Index = 0; Index < BootOptionCount; Index++) {
2464 BootOptions[Index].OptionalDataSize =
sizeof (
EFI_GUID);
2470 Status =
gBS->LocateProtocol (
2471 &gEdkiiPlatformBootManagerProtocolGuid,
2473 (
VOID **)&PlatformBootManager
2475 if (!EFI_ERROR (Status)) {
2480 Status = PlatformBootManager->RefreshAllBootOptions (
2483 &UpdatedBootOptions,
2484 &UpdatedBootOptionCount
2486 if (!EFI_ERROR (Status)) {
2488 BootOptions = UpdatedBootOptions;
2489 BootOptionCount = UpdatedBootOptionCount;
2498 for (Index = 0; Index < NvBootOptionCount; Index++) {
2521 for (Index = 0; Index < BootOptionCount; Index++) {
2555 CHAR16 *Description;
2556 UINTN DescriptionLength;
2567 gBS->LocateHandleBuffer (
2569 &gEfiLoadFileProtocolGuid,
2574 for (Index = 0; Index < HandleCount; Index++) {
2582 if (HandleCount != 0) {
2586 if (DevicePath ==
NULL) {
2593 if (EFI_ERROR (Status)) {
2594 DEBUG ((DEBUG_WARN,
"[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
2595 return EFI_NOT_FOUND;
2598 ASSERT (DevicePath !=
NULL);
2604 EFI_SECTION_USER_INTERFACE,
2606 (
VOID **)&Description,
2609 if (EFI_ERROR (Status)) {
2616 LoadOptionNumberUnassigned,
2618 LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN,
2619 (Description !=
NULL) ? Description : L
"Boot Manager Menu",
2626 if (Description !=
NULL) {
2632 UINTN BootOptionCount;
2661 UINTN BootOptionCount;
2667 for (Index = 0; Index < BootOptionCount; Index++) {
2671 BootOptions[Index].OptionNumber,
2672 BootOptions[Index].OptionType,
2673 BootOptions[Index].Attributes,
2674 BootOptions[Index].Description,
2675 BootOptions[Index].FilePath,
2676 BootOptions[Index].OptionalData,
2677 BootOptions[Index].OptionalDataSize
2689 if (Index == BootOptionCount) {
2737 Status =
gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid,
NULL, (
VOID **)&VariablePolicy);
2738 if (!EFI_ERROR (Status)) {
2739 Status = RegisterBasicVariablePolicy (
2744 VARIABLE_POLICY_NO_MAX_SIZE,
2747 VARIABLE_POLICY_TYPE_NO_LOCK
2755 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED) && (Status != EFI_WRITE_PROTECTED)) {
2756 DEBUG ((DEBUG_ERROR,
"%a: - Error setting policy for HDDP - Status=%r\n", __func__, Status));
2760 if (Event !=
NULL) {
2761 gBS->CloseEvent (Event);
2764 DEBUG ((DEBUG_ERROR,
"%a: - Unable to locate variable policy protocol - Status=%r\n", __func__, Status));
2787 &gEdkiiVariablePolicyProtocolGuid,
UINT64 EFIAPI ReadUnaligned64(IN CONST VOID *Buffer)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID * BmGetRamDiskMemoryInfo(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath, OUT UINTN *RamDiskSizeInPages)
EFI_DEVICE_PATH_PROTOCOL * BmExpandNetworkFileSystem(IN EFI_HANDLE LoadFileHandle, OUT EFI_HANDLE *RamDiskHandle)
EFI_DEVICE_PATH_PROTOCOL * BmExpandFileDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath)
VOID EFIAPI EfiBootManagerBoot(IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
EFI_HANDLE * BmFindUsbDevice(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN ParentDevicePathSize, OUT UINTN *UsbIoHandleCount)
VOID *EFIAPI EfiBootManagerGetLoadOptionBuffer(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, OUT UINTN *FileSize)
BOOLEAN BmIsBootManagerMenuFilePath(EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID EFIAPI BmEndOfBdsPerfCode(IN EFI_EVENT Event, IN VOID *Context)
EFI_DEVICE_PATH_PROTOCOL * BmExpandUriDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath)
EFI_STATUS BmRegisterBootManagerMenu(OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
EFI_STATUS EFIAPI UefiBootManagerLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_DEVICE_PATH_PROTOCOL * BmExpandPartitionDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI EfiBootManagerGetNextLoadOptionDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath)
VOID EFIAPI OnVariablePolicyNotification(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI EfiBootManagerRefreshAllBootOption(VOID)
BOOLEAN BmMatchUsbClass(IN EFI_USB_IO_PROTOCOL *UsbIo, IN USB_CLASS_DEVICE_PATH *UsbClass)
EFI_DEVICE_PATH_PROTOCOL * BmExpandUsbDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath, IN EFI_DEVICE_PATH_PROTOCOL *ShortformNode)
EFI_DEVICE_PATH_PROTOCOL * BmGetNextLoadOptionDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath)
EFI_DEVICE_PATH_PROTOCOL * BmExpandLoadFiles(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
VOID BmReportLoadFailure(IN UINT32 ErrorCode, IN EFI_STATUS FailureStatus)
VOID EFIAPI EfiBootManagerRegisterLegacyBootSupport(EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption, EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot)
EFI_BOOT_MANAGER_LOAD_OPTION * BmEnumerateBootOptions(UINTN *BootOptionCount)
UINTN BmFindBootOptionInVariable(IN EFI_BOOT_MANAGER_LOAD_OPTION *OptionToFind)
EFI_DEVICE_PATH_PROTOCOL * BmGetRamDiskDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_GUID mBmHardDriveBootVariableGuid
VOID BmDestroyRamDisk(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath)
BOOLEAN BmMatchUsbWwid(IN EFI_USB_IO_PROTOCOL *UsbIo, IN USB_WWID_DEVICE_PATH *UsbWwid)
EFI_DEVICE_PATH_PROTOCOL * BmAdjustFvFilePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_STATUS EFIAPI EfiBootManagerGetBootManagerMenu(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
BOOLEAN BmIsAutoCreateBootOption(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
VOID BmCachePartitionDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL **CachedDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL * BmExpandMediaDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_DEVICE_PATH_PROTOCOL *FullPath)
BOOLEAN BmMatchPartitionDevicePathNode(IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath, IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath)
EFI_DEVICE_PATH_PROTOCOL * BmExpandLoadFile(IN EFI_HANDLE LoadFileHandle, IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
BOOLEAN BmMatchHttpBootDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *Left, IN EFI_DEVICE_PATH_PROTOCOL *Right)
BOOLEAN BmIsFvFilePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID BmMakeBootOptionDescriptionUnique(EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, UINTN BootOptionCount)
CHAR16 * BmGetBootDescription(IN EFI_HANDLE Handle)
EFI_STATUS BmConnectUsbShortFormDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID BmRepairAllControllers(UINTN ReconnectRepairCount)
VOID EFIAPI BmStopHotkeyService(IN EFI_EVENT Event, IN VOID *Context)
VOID * BmGetNextLoadOptionBuffer(IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, OUT UINTN *FileSize)
EFI_STATUS BmGetFreeOptionNumber(IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType, OUT UINT16 *FreeOptionNumber)
VOID BmSetMemoryTypeInformationVariable(IN BOOLEAN Boot)
EFI_STATUS BmSetVariableAndReportStatusCodeOnError(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
EFI_DEVICE_PATH_PROTOCOL * BmDelPartMatchInstance(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
BOOLEAN BmMatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
#define MEDIA_FILEPATH_DP
#define HARDWARE_DEVICE_PATH
#define MEDIA_RAM_DISK_DP
#define MEDIA_PIWG_FW_FILE_DP
#define MEDIA_HARDDRIVE_DP
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
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 FileDevicePath(IN EFI_HANDLE Device OPTIONAL, IN CONST CHAR16 *FileName)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathValid(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN MaxSize)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetNextDevicePathInstance(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT UINTN *Size)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
BOOLEAN EFIAPI ReportErrorCodeEnabled(VOID)
EFI_STATUS EFIAPI GetFileDevicePathFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT EFI_DEVICE_PATH_PROTOCOL **FvFileDevicePath)
EFI_STATUS EFIAPI GetSectionFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateAlignedReservedPages(IN UINTN Pages, IN UINTN Alignment)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define REPORT_STATUS_CODE_EX(Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize)
#define REPORT_STATUS_CODE(Type, Value)
#define PcdGet32(TokenName)
#define PcdGetPtr(TokenName)
#define EFI_PROGRESS_CODE
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_GUID gEfiRamDiskProtocolGuid
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS EFIAPI EfiBootManagerLoadOptionToVariable(IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption)
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)
VOID(EFIAPI * EFI_BOOT_MANAGER_LEGACY_BOOT)(IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
EFI_STATUS EFIAPI EfiBootManagerAddLoadOptionVariable(IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN Position)
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount)
EFI_STATUS EFIAPI EfiBootManagerVariableToLoadOption(IN CHAR16 *VariableName, IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption)
VOID(EFIAPI * EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION)(VOID)
EFI_STATUS EFIAPI EfiBootManagerConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect, OUT EFI_HANDLE *MatchingHandle OPTIONAL)
INTN EFIAPI EfiBootManagerFindLoadOption(IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key, IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array, IN UINTN Count)
EFI_STATUS EFIAPI EfiBootManagerDeleteLoadOptionVariable(IN UINTN OptionNumber, IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType)
VOID EFIAPI EfiBootManagerConnectAll(VOID)
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_STATUS EFIAPI EfiCreateEventLegacyBootEx(IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN VOID *NotifyContext OPTIONAL, OUT EFI_EVENT *LegacyBootEvent)
EFI_STATUS EFIAPI GetVariable2(IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
VOID EFIAPI EfiSignalEventReadyToBoot(VOID)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
EFI_GUID *EFIAPI EfiGetNameGuidFromFwVolDevicePathNode(IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode)
#define EFI_VARIABLE_NON_VOLATILE
EFI_BLOCK_IO_MEDIA * Media
VOID * LoadOptions
A pointer to the image's binary load options.
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
EFI_STATUS_CODE_DATA DataHeader