From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>, Hao Wu <hao.a.wu@intel.com>,
Ray Ni <ray.ni@intel.com>, Star Zeng <star.zeng@intel.com>,
Liming Gao <liming.gao@intel.com>,
Sean Brogan <sean.brogan@microsoft.com>,
Michael Turner <Michael.Turner@microsoft.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>
Subject: [PATCH 2/2] MdeModulePkg/BdsDxe: Use a pcd to control PlatformRecovery
Date: Mon, 3 Jun 2019 14:43:58 +0800 [thread overview]
Message-ID: <20190603064358.13296-3-zhichao.gao@intel.com> (raw)
In-Reply-To: <20190603064358.13296-1-zhichao.gao@intel.com>
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.
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>
---
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +-
MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 89 ++++++++++++++----------
2 files changed, 55 insertions(+), 37 deletions(-)
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index 6913389d34..7f94ca17df 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -5,7 +5,7 @@
# gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry
# interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.
#
-# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -95,6 +95,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
[Depex]
TRUE
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index 9d312bd982..3d84d5a8aa 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -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;
}
Status = gRT->SetVariable (
@@ -662,6 +666,7 @@ BdsEntry (
BOOLEAN BootSuccess;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_STATUS BootManagerMenuStatus;
+ EFI_BOOT_MANAGER_LOAD_OPTION PlatformDefaultBootOption;
HotkeyTriggered = NULL;
Status = EFI_SUCCESS;
@@ -763,41 +768,45 @@ 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);
- Status = EfiBootManagerInitializeLoadOption (
- &LoadOption,
- LoadOptionNumberUnassigned,
- LoadOptionTypePlatformRecovery,
- LOAD_OPTION_ACTIVE,
- L"Default PlatformRecovery",
- FilePath,
- NULL,
- 0
- );
- ASSERT_EFI_ERROR (Status);
- 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;
+ if (FilePath != NULL) {
+ Status = EfiBootManagerInitializeLoadOption (
+ &PlatformDefaultBootOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypePlatformRecovery,
+ LOAD_OPTION_ACTIVE,
+ L"Default PlatformRecovery",
+ FilePath,
+ NULL,
+ 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) {
+ 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;
+ }
+ }
+ PlatformDefaultBootOption.OptionNumber = Index;
+ Status = EfiBootManagerLoadOptionToVariable (&PlatformDefaultBootOption);
+ ASSERT_EFI_ERROR (Status);
}
+ EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
}
- LoadOption.OptionNumber = Index;
- Status = EfiBootManagerLoadOptionToVariable (&LoadOption);
- ASSERT_EFI_ERROR (Status);
+ FreePool (FilePath);
}
- EfiBootManagerFreeLoadOption (&LoadOption);
- FreePool (FilePath);
- EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
//
// Report Status Code to indicate connecting drivers will happen
@@ -1043,10 +1052,18 @@ BdsEntry (
}
if (!BootSuccess) {
- LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);
- ProcessLoadOptions (LoadOptions, LoadOptionCount);
- EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
+ 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 ();
--
2.21.0.windows.1
next prev parent reply other threads:[~2019-06-03 6:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 6:43 [PATCH 0/2] Use a pcd to control Platform Recovery behavior Gao, Zhichao
2019-06-03 6:43 ` [PATCH 1/2] MdeModulePkg: Add a pcd to set the OS indications bit Gao, Zhichao
2019-06-03 6:59 ` Ni, Ray
2019-06-03 6:43 ` Gao, Zhichao [this message]
2019-06-03 6:59 ` [PATCH 2/2] MdeModulePkg/BdsDxe: Use a pcd to control PlatformRecovery Ni, Ray
2019-06-03 7:13 ` Gao, Zhichao
2019-06-03 7:26 ` Ni, Ray
2019-06-03 7:42 ` Gao, Zhichao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190603064358.13296-3-zhichao.gao@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox