MdeModulePkg: Add PlatformRecovery#### pointing to default file path

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18862 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni 2015-11-17 10:14:13 +00:00 committed by niruiyu
parent cc4812f63e
commit d175f4e612

View File

@ -823,11 +823,12 @@ BdsEntry (
UINT16 BootTimeOut; UINT16 BootTimeOut;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
UINTN Index; UINTN Index;
EFI_BOOT_MANAGER_LOAD_OPTION BootOption; EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;
UINT16 *BootNext; UINT16 *BootNext;
CHAR16 BootNextVariableName[sizeof ("Boot####")]; CHAR16 BootNextVariableName[sizeof ("Boot####")];
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
BOOLEAN BootFwUi; BOOLEAN BootFwUi;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
HotkeyTriggered = NULL; HotkeyTriggered = NULL;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -942,6 +943,27 @@ BdsEntry (
// //
InitializeLanguage (TRUE); 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);
Status = EfiBootManagerInitializeLoadOption (
&LoadOption,
0,
LoadOptionTypePlatformRecovery,
LOAD_OPTION_ACTIVE,
L"Default PlatformRecovery",
FilePath,
NULL,
0
);
ASSERT_EFI_ERROR (Status);
EfiBootManagerLoadOptionToVariable (&LoadOption);
EfiBootManagerFreeLoadOption (&LoadOption);
FreePool (FilePath);
// //
// Report Status Code to indicate connecting drivers will happen // Report Status Code to indicate connecting drivers will happen
// //
@ -1120,17 +1142,17 @@ BdsEntry (
// //
if (BootNext != NULL) { if (BootNext != NULL) {
UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), L"Boot%04x", *BootNext); UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), L"Boot%04x", *BootNext);
Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &BootOption); Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &LoadOption);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
EfiBootManagerBoot (&BootOption); EfiBootManagerBoot (&LoadOption);
EfiBootManagerFreeLoadOption (&BootOption); EfiBootManagerFreeLoadOption (&LoadOption);
if (BootOption.Status == EFI_SUCCESS) { if (LoadOption.Status == EFI_SUCCESS) {
// //
// Boot to Boot Manager Menu upon EFI_SUCCESS // Boot to Boot Manager Menu upon EFI_SUCCESS
// //
EfiBootManagerGetBootManagerMenu (&BootOption); EfiBootManagerGetBootManagerMenu (&LoadOption);
EfiBootManagerBoot (&BootOption); EfiBootManagerBoot (&LoadOption);
EfiBootManagerFreeLoadOption (&BootOption); EfiBootManagerFreeLoadOption (&LoadOption);
} }
} }
} }