mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/BdsDxe: Use a pcd to control PlatformRecovery
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1678 Use the PcdPlatformRecoverySupport to control the function of platform recovery in BDS. First, set the variable's ("OsIndicationsSupported") EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY bit base on the pcd. It would affect the variable "OsIndications". While the platform does not support the platform recovery, it is inappropriate to set a PlatformRecovery#### variable. So skip setting the variable. But it should remain the behavior of booting from a default file path (such as \EFI\BOOT\BOOTX64.EFI) to be compatible with the previous version UEFI spec. Add memory check before build platform default boot option. If fail to allocate memory for the defualt boot file path, put the system into dead loop to indicate it is unable to boot. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Michael Turner <Michael.Turner@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
parent
f81b738653
commit
0889500ce1
|
@ -96,6 +96,7 @@
|
|||
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
|
|
|
@ -546,10 +546,14 @@ BdsFormalizeOSIndicationVariable (
|
|||
//
|
||||
Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
|
||||
if (Status != EFI_NOT_FOUND) {
|
||||
OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;
|
||||
OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
|
||||
EfiBootManagerFreeLoadOption (&BootManagerMenu);
|
||||
} else {
|
||||
OsIndicationSupport = EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;
|
||||
OsIndicationSupport = 0;
|
||||
}
|
||||
|
||||
if (PcdGetBool (PcdPlatformRecoverySupport)) {
|
||||
OsIndicationSupport |= EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;
|
||||
}
|
||||
|
||||
if (PcdGetBool(PcdCapsuleOnDiskSupport)) {
|
||||
|
@ -666,6 +670,7 @@ BdsEntry (
|
|||
BOOLEAN BootSuccess;
|
||||
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
||||
EFI_STATUS BootManagerMenuStatus;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION PlatformDefaultBootOption;
|
||||
|
||||
HotkeyTriggered = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
|
@ -767,14 +772,13 @@ BdsEntry (
|
|||
//
|
||||
InitializeLanguage (TRUE);
|
||||
|
||||
//
|
||||
// System firmware must include a PlatformRecovery#### variable specifying
|
||||
// a short-form File Path Media Device Path containing the platform default
|
||||
// file path for removable media
|
||||
//
|
||||
FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
|
||||
if (FilePath == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "Fail to allocate memory for defualt boot file path. Unable to boot.\n"));
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&LoadOption,
|
||||
&PlatformDefaultBootOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypePlatformRecovery,
|
||||
LOAD_OPTION_ACTIVE,
|
||||
|
@ -784,8 +788,15 @@ BdsEntry (
|
|||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// System firmware must include a PlatformRecovery#### variable specifying
|
||||
// a short-form File Path Media Device Path containing the platform default
|
||||
// file path for removable media if the platform supports Platform Recovery.
|
||||
//
|
||||
if (PcdGetBool (PcdPlatformRecoverySupport)) {
|
||||
LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
|
||||
if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) {
|
||||
if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, LoadOptions, LoadOptionCount) == -1) {
|
||||
for (Index = 0; Index < LoadOptionCount; Index++) {
|
||||
//
|
||||
// The PlatformRecovery#### options are sorted by OptionNumber.
|
||||
|
@ -795,13 +806,13 @@ BdsEntry (
|
|||
break;
|
||||
}
|
||||
}
|
||||
LoadOption.OptionNumber = Index;
|
||||
Status = EfiBootManagerLoadOptionToVariable (&LoadOption);
|
||||
PlatformDefaultBootOption.OptionNumber = Index;
|
||||
Status = EfiBootManagerLoadOptionToVariable (&PlatformDefaultBootOption);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
EfiBootManagerFreeLoadOption (&LoadOption);
|
||||
FreePool (FilePath);
|
||||
EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
|
||||
}
|
||||
FreePool (FilePath);
|
||||
|
||||
//
|
||||
// Report Status Code to indicate connecting drivers will happen
|
||||
|
@ -1047,10 +1058,18 @@ BdsEntry (
|
|||
}
|
||||
|
||||
if (!BootSuccess) {
|
||||
if (PlatformRecovery) {
|
||||
LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
|
||||
ProcessLoadOptions (LoadOptions, LoadOptionCount);
|
||||
EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
|
||||
} else {
|
||||
//
|
||||
// When platform recovery is not enabled, still boot to platform default file path.
|
||||
//
|
||||
EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption);
|
||||
}
|
||||
}
|
||||
EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption);
|
||||
|
||||
DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n"));
|
||||
PlatformBootManagerUnableToBoot ();
|
||||
|
|
Loading…
Reference in New Issue