summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/BdsDxe/BdsEntry.c')
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BdsEntry.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index 32bcbf3..98b3931 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -837,7 +837,7 @@ BdsEntry (
FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
Status = EfiBootManagerInitializeLoadOption (
&LoadOption,
- 0,
+ LoadOptionNumberUnassigned,
LoadOptionTypePlatformRecovery,
LOAD_OPTION_ACTIVE,
L"Default PlatformRecovery",
@@ -846,9 +846,24 @@ BdsEntry (
0
);
ASSERT_EFI_ERROR (Status);
- EfiBootManagerLoadOptionToVariable (&LoadOption);
+ LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
+ if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) {
+ for (Index = 0; Index < LoadOptionCount; Index++) {
+ //
+ // The PlatformRecovery#### options are sorted by OptionNumber.
+ // Find the the smallest unused number as the new OptionNumber.
+ //
+ if (LoadOptions[Index].OptionNumber != Index) {
+ break;
+ }
+ }
+ LoadOption.OptionNumber = Index;
+ Status = EfiBootManagerLoadOptionToVariable (&LoadOption);
+ ASSERT_EFI_ERROR (Status);
+ }
EfiBootManagerFreeLoadOption (&LoadOption);
FreePool (FilePath);
+ EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
//
// Report Status Code to indicate connecting drivers will happen