MdeModulePkg UefiBootManagerLib: Add BmIsBootMenuAppFilePath internal API

This function abstracts the common logic to find BootMenuApp file.

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:
Liming Gao 2016-07-25 22:00:21 +08:00
parent f6b633c743
commit 0aa09042dd
1 changed files with 30 additions and 19 deletions

View File

@ -1529,6 +1529,34 @@ EfiBootManagerGetLoadOptionBuffer (
return BmGetFileBufferFromLoadFiles (FilePath, FullPath, FileSize); return BmGetFileBufferFromLoadFiles (FilePath, FullPath, FileSize);
} }
/**
Check if it's a Device Path pointing to BootMenuApp.
@param DevicePath Input device path.
@retval TRUE The device path is BootMenuApp File Device Path.
@retval FALSE The device path is NOT BootMenuApp File Device Path.
**/
BOOLEAN
BmIsBootMenuAppFilePath (
EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_HANDLE FvHandle;
VOID *NameGuid;
EFI_STATUS Status;
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
if (!EFI_ERROR (Status)) {
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
if (NameGuid != NULL) {
return CompareGuid (NameGuid, PcdGetPtr (PcdBootManagerMenuFile));
}
}
return FALSE;
}
/** /**
Attempt to boot the EFI boot option. This routine sets L"BootCurent" and Attempt to boot the EFI boot option. This routine sets L"BootCurent" and
also signals the EFI ready to boot event. If the device path for the option also signals the EFI ready to boot event. If the device path for the option
@ -1562,9 +1590,7 @@ EfiBootManagerBoot (
UINTN OptionNumber; UINTN OptionNumber;
UINTN OriginalOptionNumber; UINTN OriginalOptionNumber;
EFI_DEVICE_PATH_PROTOCOL *FilePath; EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath; EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
EFI_HANDLE FvHandle;
VOID *FileBuffer; VOID *FileBuffer;
UINTN FileSize; UINTN FileSize;
EFI_BOOT_LOGO_PROTOCOL *BootLogo; EFI_BOOT_LOGO_PROTOCOL *BootLogo;
@ -1619,12 +1645,7 @@ EfiBootManagerBoot (
// 3. Signal the EVT_SIGNAL_READY_TO_BOOT event when we are about to load and execute // 3. Signal the EVT_SIGNAL_READY_TO_BOOT event when we are about to load and execute
// the boot option. // the boot option.
// //
Node = BootOption->FilePath; if (BmIsBootMenuAppFilePath (BootOption->FilePath)) {
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &FvHandle);
if (!EFI_ERROR (Status) && CompareGuid (
EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) Node),
PcdGetPtr (PcdBootManagerMenuFile)
)) {
DEBUG ((EFI_D_INFO, "[Bds] Booting Boot Manager Menu.\n")); DEBUG ((EFI_D_INFO, "[Bds] Booting Boot Manager Menu.\n"));
BmStopHotkeyService (NULL, NULL); BmStopHotkeyService (NULL, NULL);
} else { } else {
@ -2272,20 +2293,11 @@ EfiBootManagerGetBootManagerMenu (
UINTN BootOptionCount; UINTN BootOptionCount;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
UINTN Index; UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_HANDLE FvHandle;
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) { for (Index = 0; Index < BootOptionCount; Index++) {
Node = BootOptions[Index].FilePath; if (BmIsBootMenuAppFilePath (BootOptions[Index].FilePath)) {
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &FvHandle);
if (!EFI_ERROR (Status)) {
if (CompareGuid (
EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) Node),
PcdGetPtr (PcdBootManagerMenuFile)
)
) {
Status = EfiBootManagerInitializeLoadOption ( Status = EfiBootManagerInitializeLoadOption (
BootOption, BootOption,
BootOptions[Index].OptionNumber, BootOptions[Index].OptionNumber,
@ -2298,7 +2310,6 @@ EfiBootManagerGetBootManagerMenu (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
break; break;
}
} }
} }