From: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
To: Ruiyu Ni <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Laszlo Ersek <lersek@redhat.com>,
Michael Turner <Michael.Turner@microsoft.com>,
"Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
Subject: Re: [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate boot failure
Date: Thu, 28 Jun 2018 09:02:26 +0000 [thread overview]
Message-ID: <CS1PR8401MB0933983261A58461805D6BF4A84F0@CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20180628074020.53444-1-ruiyu.ni@intel.com>
Hi Ray,
Does the ultimate boot failure include the case where the system doesn't have "BootManagerMenu" application? If so, I think we should move EfiBootManagerUnableBoot() call out of BdsBootManagerMenuLoop(). The BdsBootManagerMenuLoop() is only called when system has BootManagerMenu application. Therefore, if the system doesn't have BootManagerMenu application, the EfiBootManagerUnableBoot() will have no chance to be called for handling the ultimate boot failure case.
Regards,
Sunny Wang
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, June 28, 2018 3:40 PM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>; Michael Turner <Michael.Turner@microsoft.com>
Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate boot failure
When no boot option could be launched including platform recovery options and options pointing to applications built into firmware volumes, a platform callback registered through
EfiBootManagerRegisterUnableBootHandler() is called.
If there is no platform callback registered, default behavior is to print an error message to the screen and wait for user input.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
MdeModulePkg/Include/Library/UefiBootManagerLib.h | 48 +++++++++++++++++++++++ MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 41 +++++++++++++++++++
MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 44 +++++++++++----------
3 files changed, 113 insertions(+), 20 deletions(-)
diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
index bfc0cb86f8..0035c41082 100644
--- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
@@ -800,4 +800,52 @@ EFIAPI
EfiBootManagerDispatchDeferredImages (
VOID
);
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to
+applications
+ built into firmware volumes.
+
+ The platform may register this function to inform the user about the above fact.
+ If this function returns, BDS core attempts to enter an infinite loop
+of pulling
+ up the Boot Manager Menu (if the platform includes the Boot Manager Menu).
+ If the Boot Manager Menu is unavailable, BDS will hang.
+**/
+typedef
+VOID
+(EFIAPI *EFI_BOOT_MANAGER_UNABLE_BOOT) (
+ VOID
+ );
+
+/**
+ Register the callback function when no boot option could be launched,
+ including platform recovery options and options pointing to
+applications
+ built into firmware volumes.
+
+ @param Handler The callback function.
+**/
+VOID
+EFIAPI
+EfiBootManagerRegisterUnableBootHandler (
+ EFI_BOOT_MANAGER_UNABLE_BOOT Handler
+ );
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to
+applications
+ built into firmware volumes.
+
+ If this function returns, BDS core attempts to enter an infinite loop
+ of pulling up the Boot Manager Menu (if the platform includes the Boot Manager Menu).
+ If the Boot Manager Menu is unavailable, BDS will hang.
+
+ @retval EFI_SUCCESS The unable-boot callback is called successfully.
+ @retval EFI_UNSUPPORTED There is no unable-boot callback registered.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerUnableBoot (
+ VOID
+ );
+
#endif
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 6a23477eb8..122068267d 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -19,6 +19,7 @@ EFI_RAM_DISK_PROTOCOL *mRamDisk = NULL;
EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION mBmRefreshLegacyBootOption = NULL;
EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = NULL;
+EFI_BOOT_MANAGER_UNABLE_BOOT mBmUnableBoot = NULL;
///
/// This GUID is used for an EFI Variable that stores the front device pathes @@ -2461,3 +2462,43 @@ EfiBootManagerGetBootManagerMenu (
}
}
+/**
+ Register the callback function when no boot option could be launched,
+ including platform recovery options and options pointing to
+applications
+ built into firmware volumes.
+
+ @param Handler The callback function.
+**/
+VOID
+EFIAPI
+EfiBootManagerRegisterUnableBootHandler (
+ EFI_BOOT_MANAGER_UNABLE_BOOT Handler
+ )
+{
+ mBmUnableBoot = Handler;
+}
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to
+applications
+ built into firmware volumes.
+
+ If this function returns, BDS core attempts to enter an infinite loop
+ of pulling up the Boot Manager Menu (if the platform includes the Boot Manager Menu).
+ If the Boot Manager Menu is unavailable, BDS will hang.
+
+ @retval EFI_SUCCESS The unable-boot callback is called successfully.
+ @retval EFI_UNSUPPORTED There is no unable-boot callback registered.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerUnableBoot (
+ VOID
+ )
+{
+ if (mBmUnableBoot != NULL) {
+ mBmUnableBoot ();
+ return EFI_SUCCESS;
+ }
+ return EFI_UNSUPPORTED;
+}
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index 49e403e181..0cb9b04dfb 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -649,32 +649,36 @@ BdsBootManagerMenuLoop (
IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu
)
{
+ EFI_STATUS Status;
EFI_INPUT_KEY Key;
- //
- // Normally BdsDxe does not print anything to the system console, but this is
- // a last resort -- the end-user will likely not see any DEBUG messages
- // logged in this situation.
- //
- // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn
- // here to see if it makes sense to request and wait for a keypress.
- //
- if (gST->ConIn != NULL) {
- AsciiPrint (
- "%a: No bootable option or device was found.\n"
- "%a: Press any key to enter the Boot Manager Menu.\n",
- gEfiCallerBaseName,
- gEfiCallerBaseName
- );
- BdsWaitForSingleEvent (gST->ConIn->WaitForKey, 0);
-
+ Status = EfiBootManagerUnableBoot (); if (EFI_ERROR (Status)) {
+ //
+ // If platform doesn't register any unable-boot callback, this is
+ // a last resort -- the end-user will likely not see any DEBUG messages
+ // logged in this situation.
//
- // Drain any queued keys.
+ // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn
+ // here to see if it makes sense to request and wait for a keypress.
//
- while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {
+ if (gST->ConIn != NULL) {
+ AsciiPrint (
+ "%a: No bootable option or device was found.\n"
+ "%a: Press any key to enter the Boot Manager Menu.\n",
+ gEfiCallerBaseName,
+ gEfiCallerBaseName
+ );
+ BdsWaitForSingleEvent (gST->ConIn->WaitForKey, 0);
+
//
- // just throw away Key
+ // Drain any queued keys.
//
+ while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {
+ //
+ // just throw away Key
+ //
+ }
}
}
--
2.16.1.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2018-06-28 9:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 7:40 [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate boot failure Ruiyu Ni
2018-06-28 9:02 ` Wang, Sunny (HPS SW) [this message]
2018-06-28 15:04 ` Laszlo Ersek
2018-06-29 4:16 ` Wang, Sunny (HPS SW)
2018-06-29 7:25 ` Ni, Ruiyu
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=CS1PR8401MB0933983261A58461805D6BF4A84F0@CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.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