MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery####
Current implementation always creates PlatformRecovery0000 pointing to \EFI\BOOT\BOOT$(ARCH).efi but it may overwrite PlatformRecovery#### created before (maybe by a DXE driver). The patch only uses the smallest unused option number for the \EFI\BOOT\BOOT$(ARCH).efi PlatformRecovery#### to avoid overwriting already-created PlatformRecovery####. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jie Lin <jie.lin@intel.com> Reviewed-by: Sunny Wang <sunnywang@hpe.com>
This commit is contained in:
@@ -837,7 +837,7 @@ BdsEntry (
|
|||||||
FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
|
FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
|
||||||
Status = EfiBootManagerInitializeLoadOption (
|
Status = EfiBootManagerInitializeLoadOption (
|
||||||
&LoadOption,
|
&LoadOption,
|
||||||
0,
|
LoadOptionNumberUnassigned,
|
||||||
LoadOptionTypePlatformRecovery,
|
LoadOptionTypePlatformRecovery,
|
||||||
LOAD_OPTION_ACTIVE,
|
LOAD_OPTION_ACTIVE,
|
||||||
L"Default PlatformRecovery",
|
L"Default PlatformRecovery",
|
||||||
@@ -846,9 +846,24 @@ BdsEntry (
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
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);
|
EfiBootManagerFreeLoadOption (&LoadOption);
|
||||||
FreePool (FilePath);
|
FreePool (FilePath);
|
||||||
|
EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Report Status Code to indicate connecting drivers will happen
|
// Report Status Code to indicate connecting drivers will happen
|
||||||
|
Reference in New Issue
Block a user