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>
This commit is contained in:
@ -1940,6 +1940,7 @@ BmEnumerateBootOptions (
|
|||||||
UINTN Removable;
|
UINTN Removable;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR16 *Description;
|
CHAR16 *Description;
|
||||||
|
UINT32 BootAttributes;
|
||||||
|
|
||||||
ASSERT (BootOptionCount != NULL);
|
ASSERT (BootOptionCount != NULL);
|
||||||
|
|
||||||
@ -2059,7 +2060,7 @@ BmEnumerateBootOptions (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse load file, assuming UEFI Network boot option
|
// Parse load file protocol
|
||||||
//
|
//
|
||||||
gBS->LocateHandleBuffer (
|
gBS->LocateHandleBuffer (
|
||||||
ByProtocol,
|
ByProtocol,
|
||||||
@ -2078,11 +2079,19 @@ BmEnumerateBootOptions (
|
|||||||
);
|
);
|
||||||
ASSERT (BootOptions != NULL);
|
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 (
|
Status = EfiBootManagerInitializeLoadOption (
|
||||||
&BootOptions[(*BootOptionCount)++],
|
&BootOptions[(*BootOptionCount)++],
|
||||||
LoadOptionNumberUnassigned,
|
LoadOptionNumberUnassigned,
|
||||||
LoadOptionTypeBoot,
|
LoadOptionTypeBoot,
|
||||||
LOAD_OPTION_ACTIVE,
|
BootAttributes,
|
||||||
Description,
|
Description,
|
||||||
DevicePathFromHandle (Handles[Index]),
|
DevicePathFromHandle (Handles[Index]),
|
||||||
NULL,
|
NULL,
|
||||||
@ -2197,51 +2206,78 @@ BmRegisterBootManagerMenu (
|
|||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||||
|
UINTN HandleCount;
|
||||||
|
EFI_HANDLE *Handles;
|
||||||
|
UINTN Index;
|
||||||
VOID *Data;
|
VOID *Data;
|
||||||
UINTN DataSize;
|
UINTN DataSize;
|
||||||
|
|
||||||
Data = NULL;
|
DevicePath = NULL;
|
||||||
Status = GetSectionFromFv (
|
//
|
||||||
PcdGetPtr (PcdBootManagerMenuFile),
|
// Try to find BootMenuApp from LoadFile protocol
|
||||||
EFI_SECTION_PE32,
|
//
|
||||||
0,
|
gBS->LocateHandleBuffer (
|
||||||
(VOID **) &Data,
|
ByProtocol,
|
||||||
&DataSize
|
&gEfiLoadFileProtocolGuid,
|
||||||
);
|
NULL,
|
||||||
if (Data != NULL) {
|
&HandleCount,
|
||||||
FreePool (Data);
|
&Handles
|
||||||
|
);
|
||||||
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
|
if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {
|
||||||
|
DevicePath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));
|
||||||
|
Description = BmGetBootDescription (Handles[Index]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (EFI_ERROR (Status)) {
|
if (HandleCount != 0) {
|
||||||
DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
|
FreePool (Handles);
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (DevicePath == NULL) {
|
||||||
// Get BootManagerMenu application's description from EFI User Interface Section.
|
Data = NULL;
|
||||||
//
|
Status = GetSectionFromFv (
|
||||||
Status = GetSectionFromFv (
|
PcdGetPtr (PcdBootManagerMenuFile),
|
||||||
PcdGetPtr (PcdBootManagerMenuFile),
|
EFI_SECTION_PE32,
|
||||||
EFI_SECTION_USER_INTERFACE,
|
0,
|
||||||
0,
|
(VOID **) &Data,
|
||||||
(VOID **) &Description,
|
&DataSize
|
||||||
&DescriptionLength
|
);
|
||||||
);
|
if (Data != NULL) {
|
||||||
if (EFI_ERROR (Status)) {
|
FreePool (Data);
|
||||||
Description = NULL;
|
}
|
||||||
}
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));
|
//
|
||||||
Status = gBS->HandleProtocol (
|
// Get BootManagerMenu application's description from EFI User Interface Section.
|
||||||
gImageHandle,
|
//
|
||||||
&gEfiLoadedImageProtocolGuid,
|
Status = GetSectionFromFv (
|
||||||
(VOID **) &LoadedImage
|
PcdGetPtr (PcdBootManagerMenuFile),
|
||||||
);
|
EFI_SECTION_USER_INTERFACE,
|
||||||
ASSERT_EFI_ERROR (Status);
|
0,
|
||||||
DevicePath = AppendDevicePathNode (
|
(VOID **) &Description,
|
||||||
DevicePathFromHandle (LoadedImage->DeviceHandle),
|
&DescriptionLength
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
);
|
||||||
);
|
if (EFI_ERROR (Status)) {
|
||||||
ASSERT (DevicePath != NULL);
|
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 (
|
Status = EfiBootManagerInitializeLoadOption (
|
||||||
BootOption,
|
BootOption,
|
||||||
|
Reference in New Issue
Block a user