MdeModulePkg/BootManagerMenu: Fix bug that boots to undesired option
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19542 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
4aec9fe30f
commit
7df23f85f5
|
@ -242,7 +242,48 @@ IsBootManagerMenu (
|
||||||
|
|
||||||
return (BOOLEAN) (!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
|
return (BOOLEAN) (!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return whether to ignore the boot option.
|
||||||
|
|
||||||
|
@param BootOption Pointer to EFI_BOOT_MANAGER_LOAD_OPTION to check.
|
||||||
|
|
||||||
|
@retval TRUE Ignore the boot optin.
|
||||||
|
@retval FALSE Do not ignore the boot option.
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IgnoreBootOption (
|
||||||
|
IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ignore myself.
|
||||||
|
//
|
||||||
|
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) &ImageDevicePath);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
if (CompareMem (BootOption->FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do not ignore Boot Manager Menu.
|
||||||
|
//
|
||||||
|
if (IsBootManagerMenu (BootOption)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ignore the hidden/inactive boot option.
|
||||||
|
//
|
||||||
|
if (((BootOption->Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption->Attributes & LOAD_OPTION_ACTIVE) == 0)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This funciton uses to initialize boot menu data
|
This funciton uses to initialize boot menu data
|
||||||
|
@ -262,18 +303,13 @@ InitializeBootMenuData (
|
||||||
OUT BOOT_MENU_POPUP_DATA *BootMenuData
|
OUT BOOT_MENU_POPUP_DATA *BootMenuData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN StrIndex;
|
UINTN StrIndex;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
|
|
||||||
|
|
||||||
if (BootOption == NULL || BootMenuData == NULL) {
|
if (BootOption == NULL || BootMenuData == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) &ImageDevicePath);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
BootMenuData->TitleToken[0] = STRING_TOKEN (STR_BOOT_POPUP_MENU_TITLE_STRING);
|
BootMenuData->TitleToken[0] = STRING_TOKEN (STR_BOOT_POPUP_MENU_TITLE_STRING);
|
||||||
BootMenuData->PtrTokens = AllocateZeroPool (BootOptionCount * sizeof (EFI_STRING_ID));
|
BootMenuData->PtrTokens = AllocateZeroPool (BootOptionCount * sizeof (EFI_STRING_ID));
|
||||||
ASSERT (BootMenuData->PtrTokens != NULL);
|
ASSERT (BootMenuData->PtrTokens != NULL);
|
||||||
|
@ -282,18 +318,7 @@ InitializeBootMenuData (
|
||||||
// Skip boot option which created by BootNext Variable
|
// Skip boot option which created by BootNext Variable
|
||||||
//
|
//
|
||||||
for (StrIndex = 0, Index = 0; Index < BootOptionCount; Index++) {
|
for (StrIndex = 0, Index = 0; Index < BootOptionCount; Index++) {
|
||||||
//
|
if (IgnoreBootOption (&BootOption[Index])) {
|
||||||
// Don't display the hidden/inactive boot option except setup application.
|
|
||||||
//
|
|
||||||
if ((((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) &&
|
|
||||||
!IsBootManagerMenu (&BootOption[Index])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Don't display myself
|
|
||||||
//
|
|
||||||
if (CompareMem (BootOption[Index].FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,13 +665,10 @@ BootFromSelectOption (
|
||||||
ASSERT (BootOptions != NULL);
|
ASSERT (BootOptions != NULL);
|
||||||
|
|
||||||
for (ItemNum = 0, Index = 0; Index < BootOptionCount; Index++) {
|
for (ItemNum = 0, Index = 0; Index < BootOptionCount; Index++) {
|
||||||
//
|
if (IgnoreBootOption (&BootOptions[Index])) {
|
||||||
// Don't display the hidden/inactive boot option except setup application.
|
|
||||||
//
|
|
||||||
if ((((BootOptions[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOptions[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) &&
|
|
||||||
!IsBootManagerMenu (&BootOptions[Index])) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemNum++ == SelectItem) {
|
if (ItemNum++ == SelectItem) {
|
||||||
EfiBootManagerBoot (&BootOptions[Index]);
|
EfiBootManagerBoot (&BootOptions[Index]);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue