summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2016-07-25 22:00:22 +0800
committerLiming Gao <liming.gao@intel.com>2016-08-01 12:58:23 +0800
commit2f014788940cc23cc300aeead476e02853ee90ec (patch)
tree2909207acb76acba05671f52c790afcf420aa5bc /MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
parent0aa09042dd7f42979ac1bad091d8ce824494eadb (diff)
downloadedk2-2f014788940cc23cc300aeead476e02853ee90ec.tar.gz
edk2-2f014788940cc23cc300aeead476e02853ee90ec.tar.bz2
edk2-2f014788940cc23cc300aeead476e02853ee90ec.zip
MdeModulePkg UefiBootManagerLib: Support LoadFile Protocol based on FV
New LoadFileOnFv2 driver will install LoadFile protocol based on FV file. Update UefiBootManagerLib to find BootMenuApp with LoadFile protocol. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Diffstat (limited to 'MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c116
1 files changed, 76 insertions, 40 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 18259e9a30..d5818ca069 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1940,6 +1940,7 @@ BmEnumerateBootOptions (
UINTN Removable;
UINTN Index;
CHAR16 *Description;
+ UINT32 BootAttributes;
ASSERT (BootOptionCount != NULL);
@@ -2059,7 +2060,7 @@ BmEnumerateBootOptions (
}
//
- // Parse load file, assuming UEFI Network boot option
+ // Parse load file protocol
//
gBS->LocateHandleBuffer (
ByProtocol,
@@ -2078,11 +2079,19 @@ BmEnumerateBootOptions (
);
ASSERT (BootOptions != NULL);
+ //
+ // If LoadFile includes BootMenuApp, its boot attribue will be set to APP and HIDDEN.
+ //
+ BootAttributes = LOAD_OPTION_ACTIVE;
+ if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {
+ BootAttributes = LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN;
+ }
+
Status = EfiBootManagerInitializeLoadOption (
&BootOptions[(*BootOptionCount)++],
LoadOptionNumberUnassigned,
LoadOptionTypeBoot,
- LOAD_OPTION_ACTIVE,
+ BootAttributes,
Description,
DevicePathFromHandle (Handles[Index]),
NULL,
@@ -2197,51 +2206,78 @@ BmRegisterBootManagerMenu (
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
VOID *Data;
UINTN DataSize;
- Data = NULL;
- Status = GetSectionFromFv (
- PcdGetPtr (PcdBootManagerMenuFile),
- EFI_SECTION_PE32,
- 0,
- (VOID **) &Data,
- &DataSize
- );
- if (Data != NULL) {
- FreePool (Data);
- }
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
- return EFI_NOT_FOUND;
- }
-
+ DevicePath = NULL;
//
- // Get BootManagerMenu application's description from EFI User Interface Section.
+ // Try to find BootMenuApp from LoadFile protocol
//
- Status = GetSectionFromFv (
- PcdGetPtr (PcdBootManagerMenuFile),
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **) &Description,
- &DescriptionLength
- );
- if (EFI_ERROR (Status)) {
- Description = NULL;
+ gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiLoadFileProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ for (Index = 0; Index < HandleCount; Index++) {
+ if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {
+ DevicePath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));
+ Description = BmGetBootDescription (Handles[Index]);
+ break;
+ }
+ }
+ if (HandleCount != 0) {
+ FreePool (Handles);
}
- EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));
- Status = gBS->HandleProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
- DevicePath = AppendDevicePathNode (
- DevicePathFromHandle (LoadedImage->DeviceHandle),
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
- );
- ASSERT (DevicePath != NULL);
+ if (DevicePath == NULL) {
+ Data = NULL;
+ Status = GetSectionFromFv (
+ PcdGetPtr (PcdBootManagerMenuFile),
+ EFI_SECTION_PE32,
+ 0,
+ (VOID **) &Data,
+ &DataSize
+ );
+ if (Data != NULL) {
+ FreePool (Data);
+ }
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Get BootManagerMenu application's description from EFI User Interface Section.
+ //
+ Status = GetSectionFromFv (
+ PcdGetPtr (PcdBootManagerMenuFile),
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **) &Description,
+ &DescriptionLength
+ );
+ if (EFI_ERROR (Status)) {
+ Description = NULL;
+ }
+
+ EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ DevicePath = AppendDevicePathNode (
+ DevicePathFromHandle (LoadedImage->DeviceHandle),
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ );
+ ASSERT (DevicePath != NULL);
+ }
Status = EfiBootManagerInitializeLoadOption (
BootOption,