diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h index 0fdb23dcbd..e333ffd86b 100644 --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h @@ -418,12 +418,16 @@ EfiBootManagerBoot ( ); /** - Return the Boot Manager Menu. - + Return the boot option corresponding to the Boot Manager Menu. + It may automatically create one if the boot option hasn't been created yet. + @param BootOption Return the Boot Manager Menu. @retval EFI_SUCCESS The Boot Manager Menu is successfully returned. - @retval EFI_NOT_FOUND The Boot Manager Menu is not found. + @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found. + @retval others Return status of gRT->SetVariable (). BootOption still points + to the Boot Manager Menu even the Status is not EFI_SUCCESS + and EFI_NOT_FOUND. **/ EFI_STATUS EFIAPI diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index d016517014..4da401d23c 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -2,7 +2,7 @@ Library functions which relates with booting. Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -2159,7 +2159,7 @@ EfiBootManagerRefreshAllBootOption ( } /** - This function is called to create the boot option for the Boot Manager Menu. + This function is called to get or create the boot option for the Boot Manager Menu. The Boot Manager Menu is shown after successfully booting a boot option. Assume the BootManagerMenuFile is in the same FV as the module links to this library. @@ -2167,8 +2167,10 @@ EfiBootManagerRefreshAllBootOption ( @param BootOption Return the boot option of the Boot Manager Menu @retval EFI_SUCCESS Successfully register the Boot Manager Menu. - @retval Status Return status of gRT->SetVariable (). BootOption still points - to the Boot Manager Menu even the Status is not EFI_SUCCESS. + @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found. + @retval others Return status of gRT->SetVariable (). BootOption still points + to the Boot Manager Menu even the Status is not EFI_SUCCESS + and EFI_NOT_FOUND. **/ EFI_STATUS BmRegisterBootManagerMenu ( @@ -2181,7 +2183,28 @@ BmRegisterBootManagerMenu ( EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; + 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; + } + + // + // Get BootManagerMenu application's description from EFI User Interface Section. + // Status = GetSectionFromFv ( PcdGetPtr (PcdBootManagerMenuFile), EFI_SECTION_USER_INTERFACE, @@ -2237,12 +2260,14 @@ BmRegisterBootManagerMenu ( /** Return the boot option corresponding to the Boot Manager Menu. It may automatically create one if the boot option hasn't been created yet. - + @param BootOption Return the Boot Manager Menu. @retval EFI_SUCCESS The Boot Manager Menu is successfully returned. - @retval Status Return status of gRT->SetVariable (). BootOption still points - to the Boot Manager Menu even the Status is not EFI_SUCCESS. + @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found. + @retval others Return status of gRT->SetVariable (). BootOption still points + to the Boot Manager Menu even the Status is not EFI_SUCCESS + and EFI_NOT_FOUND. **/ EFI_STATUS EFIAPI diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 741ddc302b..c86cd7a576 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -5,8 +5,9 @@ After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked to enter BDS phase. -(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -273,7 +274,7 @@ BOOLEAN BootBootOptions ( IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, IN UINTN BootOptionCount, - IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu + IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu OPTIONAL ) { UINTN Index; @@ -312,7 +313,7 @@ BootBootOptions ( // interactive mode, the boot manager will stop processing the BootOrder variable and // present a boot manager menu to the user. // - if (BootOptions[Index].Status == EFI_SUCCESS) { + if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) { EfiBootManagerBoot (BootManagerMenu); break; } @@ -425,22 +426,32 @@ BdsFormalizeConsoleVariable ( Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable. + Create a boot option for BootManagerMenu if it hasn't been created yet + **/ VOID BdsFormalizeOSIndicationVariable ( VOID ) { - EFI_STATUS Status; - UINT64 OsIndicationSupport; - UINT64 OsIndication; - UINTN DataSize; - UINT32 Attributes; + EFI_STATUS Status; + UINT64 OsIndicationSupport; + UINT64 OsIndication; + UINTN DataSize; + UINT32 Attributes; + EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; // // OS indicater support variable // - OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; + Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); + if (Status != EFI_NOT_FOUND) { + OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; + EfiBootManagerFreeLoadOption (&BootManagerMenu); + } else { + OsIndicationSupport = EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; + } + Status = gRT->SetVariable ( EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, &gEfiGlobalVariableGuid, @@ -601,6 +612,7 @@ BdsEntry ( BOOLEAN PlatformRecovery; BOOLEAN BootSuccess; EFI_DEVICE_PATH_PROTOCOL *FilePath; + EFI_STATUS BootManagerMenuStatus; HotkeyTriggered = NULL; Status = EFI_SUCCESS; @@ -851,9 +863,9 @@ BdsEntry ( ); // - // BootManagerMenu always contains the correct information even call fails. + // BootManagerMenu doesn't contain the correct information when return status is EFI_NOT_FOUND. // - EfiBootManagerGetBootManagerMenu (&BootManagerMenu); + BootManagerMenuStatus = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); BootFwUi = (BOOLEAN) ((OsIndication & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); PlatformRecovery = (BOOLEAN) ((OsIndication & EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY) != 0); @@ -878,7 +890,7 @@ BdsEntry ( // // Launch Boot Manager Menu directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot // - if (BootFwUi) { + if (BootFwUi && (BootManagerMenuStatus != EFI_NOT_FOUND)) { // // Follow generic rule, Call BdsDxeOnConnectConInCallBack to connect ConIn before enter UI // @@ -923,7 +935,9 @@ BdsEntry ( if (!EFI_ERROR (Status)) { EfiBootManagerBoot (&LoadOption); EfiBootManagerFreeLoadOption (&LoadOption); - if ((LoadOption.Status == EFI_SUCCESS) && (LoadOption.OptionNumber != BootManagerMenu.OptionNumber)) { + if ((LoadOption.Status == EFI_SUCCESS) && + (BootManagerMenuStatus != EFI_NOT_FOUND) && + (LoadOption.OptionNumber != BootManagerMenu.OptionNumber)) { // // Boot to Boot Manager Menu upon EFI_SUCCESS // Exception: Do not boot again when the BootNext points to Boot Manager Menu. @@ -938,12 +952,14 @@ BdsEntry ( // Retry to boot if any of the boot succeeds // LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypeBoot); - BootSuccess = BootBootOptions (LoadOptions, LoadOptionCount, &BootManagerMenu); + BootSuccess = BootBootOptions (LoadOptions, LoadOptionCount, (BootManagerMenuStatus != EFI_NOT_FOUND) ? &BootManagerMenu : NULL); EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); } while (BootSuccess); } - EfiBootManagerFreeLoadOption (&BootManagerMenu); + if (BootManagerMenuStatus != EFI_NOT_FOUND) { + EfiBootManagerFreeLoadOption (&BootManagerMenu); + } if (!BootSuccess) { LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);