UINTN Removable;\r
UINTN Index;\r
CHAR16 *Description;\r
+ UINT32 BootAttributes;\r
\r
ASSERT (BootOptionCount != NULL);\r
\r
}\r
\r
//\r
- // Parse load file, assuming UEFI Network boot option\r
+ // Parse load file protocol\r
//\r
gBS->LocateHandleBuffer (\r
ByProtocol,\r
);\r
ASSERT (BootOptions != NULL);\r
\r
+ //\r
+ // If LoadFile includes BootMenuApp, its boot attribue will be set to APP and HIDDEN.\r
+ //\r
+ BootAttributes = LOAD_OPTION_ACTIVE;\r
+ if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {\r
+ BootAttributes = LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN;\r
+ }\r
+\r
Status = EfiBootManagerInitializeLoadOption (\r
&BootOptions[(*BootOptionCount)++],\r
LoadOptionNumberUnassigned,\r
LoadOptionTypeBoot,\r
- LOAD_OPTION_ACTIVE,\r
+ BootAttributes,\r
Description,\r
DevicePathFromHandle (Handles[Index]),\r
NULL,\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *Handles;\r
+ UINTN Index;\r
VOID *Data;\r
UINTN DataSize;\r
\r
- Data = NULL;\r
- Status = GetSectionFromFv (\r
- PcdGetPtr (PcdBootManagerMenuFile),\r
- EFI_SECTION_PE32,\r
- 0,\r
- (VOID **) &Data,\r
- &DataSize\r
- );\r
- if (Data != NULL) {\r
- FreePool (Data);\r
- }\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
+ DevicePath = NULL;\r
//\r
- // Get BootManagerMenu application's description from EFI User Interface Section.\r
+ // Try to find BootMenuApp from LoadFile protocol\r
//\r
- Status = GetSectionFromFv (\r
- PcdGetPtr (PcdBootManagerMenuFile),\r
- EFI_SECTION_USER_INTERFACE,\r
- 0,\r
- (VOID **) &Description,\r
- &DescriptionLength\r
- );\r
- if (EFI_ERROR (Status)) {\r
- Description = NULL;\r
+ gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiLoadFileProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &Handles\r
+ );\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+ if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {\r
+ DevicePath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));\r
+ Description = BmGetBootDescription (Handles[Index]);\r
+ break;\r
+ }\r
+ }\r
+ if (HandleCount != 0) {\r
+ FreePool (Handles);\r
}\r
\r
- EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));\r
- Status = gBS->HandleProtocol (\r
- gImageHandle,\r
- &gEfiLoadedImageProtocolGuid,\r
- (VOID **) &LoadedImage\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- DevicePath = AppendDevicePathNode (\r
- DevicePathFromHandle (LoadedImage->DeviceHandle),\r
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
- );\r
- ASSERT (DevicePath != NULL);\r
+ if (DevicePath == NULL) {\r
+ Data = NULL;\r
+ Status = GetSectionFromFv (\r
+ PcdGetPtr (PcdBootManagerMenuFile),\r
+ EFI_SECTION_PE32,\r
+ 0,\r
+ (VOID **) &Data,\r
+ &DataSize\r
+ );\r
+ if (Data != NULL) {\r
+ FreePool (Data);\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ //\r
+ // Get BootManagerMenu application's description from EFI User Interface Section.\r
+ //\r
+ Status = GetSectionFromFv (\r
+ PcdGetPtr (PcdBootManagerMenuFile),\r
+ EFI_SECTION_USER_INTERFACE,\r
+ 0,\r
+ (VOID **) &Description,\r
+ &DescriptionLength\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Description = NULL;\r
+ }\r
+\r
+ EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));\r
+ Status = gBS->HandleProtocol (\r
+ gImageHandle,\r
+ &gEfiLoadedImageProtocolGuid,\r
+ (VOID **) &LoadedImage\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ DevicePath = AppendDevicePathNode (\r
+ DevicePathFromHandle (LoadedImage->DeviceHandle),\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
+ );\r
+ ASSERT (DevicePath != NULL);\r
+ }\r
\r
Status = EfiBootManagerInitializeLoadOption (\r
BootOption,\r