Skip to content

Commit

Permalink
MdeModulePkg: BdsDxe: Introduce infinite boot retries
Browse files Browse the repository at this point in the history
This is a feature of infinite boot retries based on a newly created PCD.
When true, the system will never stop retrying the boot options.

PCD default is FALSE to match existing functionality.

This change is tested on QEMU based virtual platforms and physical
platforms.

Co-authored-by: Kun Qin <[email protected]>
Co-authored-by: Aaron Pop <[email protected]>
Co-authored-by: Michael Kubacki <[email protected]>
  • Loading branch information
4 people authored and os-d committed Jun 24, 2024
1 parent 5abeae3 commit 323c245
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
9 changes: 9 additions & 0 deletions MdeModulePkg/MdeModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,15 @@
# @Prompt Delay access XHCI register after it issues HCRST (us)
gEfiMdeModulePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x30001060

# MU_CHANGE [BEGIN] - Support indefinite boot retries
# # Some platforms require that all EfiLoadOptions are retried until one of the options
# # succeeds. When True, this Pcd will force Bds to retry all the valid EfiLoadOptions
# # indefinitely until one of the options succeeds.
# # TRUE - Efi boot options will be retried indefinitely.
# # FALSE - Efi boot options will not be retried.
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries|FALSE|BOOLEAN|0x40000152
# MU_CHANGE [END]

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Dynamic type PCD can be registered callback function for Pcd setting action.
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
Expand Down
1 change: 1 addition & 0 deletions MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries ## CONSUMES // MU_CHANGE

[Depex]
TRUE
Expand Down
36 changes: 26 additions & 10 deletions MdeModulePkg/Universal/BdsDxe/BdsEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ BootBootOptions (
//
// Attempt boot each boot option
//

for (Index = 0; Index < BootOptionCount; Index++) {
//
// According to EFI Specification, if a load option is not marked
Expand All @@ -413,16 +414,31 @@ BootBootOptions (
//
EfiBootManagerBoot (&BootOptions[Index]);

//
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
// supports boot manager menu, and if firmware is configured to boot in an
// interactive mode, the boot manager will stop processing the BootOrder variable and
// present a boot manager menu to the user.
//
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
EfiBootManagerBoot (BootManagerMenu);
break;
// MU_CHANGE [BEGIN] - Support infinite boot retries
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
// better location.
if (!PcdGetBool (PcdSupportInfiniteBootRetries)) {
// MU_CHANGE [END] - Support infinite boot retries

//
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
// supports boot manager menu, and if firmware is configured to boot in an
// interactive mode, the boot manager will stop processing the BootOrder variable and
// present a boot manager menu to the user.
//
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
EfiBootManagerBoot (BootManagerMenu);
break;
}

// MU_CHANGE [BEGIN]- Support infinite boot retries
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
// better location.
}

// MU_CHANGE [END]- Support infinite boot retries
}

return (BOOLEAN)(Index < BootOptionCount);
Expand Down Expand Up @@ -1093,7 +1109,7 @@ BdsEntry (
LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypeBoot);
BootSuccess = BootBootOptions (LoadOptions, LoadOptionCount, (BootManagerMenuStatus != EFI_NOT_FOUND) ? &BootManagerMenu : NULL);
EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
} while (BootSuccess);
} while (BootSuccess || PcdGetBool (PcdSupportInfiniteBootRetries)); // MU_CHANGE add PcdSupportInfiniteBootRetries support
}

if (BootManagerMenuStatus != EFI_NOT_FOUND) {
Expand Down

0 comments on commit 323c245

Please sign in to comment.