public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH] OvmfPkg/BDS: Provide platform callback for ultimate boot failure
Date: Fri, 29 Jun 2018 14:05:48 +0800	[thread overview]
Message-ID: <20180629060548.100012-1-ruiyu.ni@intel.com> (raw)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
 .../Library/PlatformBootManagerLib/BdsPlatform.c   | 56 ++++++++++++++++++++--
 1 file changed, 51 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 57870cb856..3b59ba9397 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -1,7 +1,7 @@
 /** @file
   Platform BDS customizations.
 
-  Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution.  The full text of the license may be found at
@@ -337,6 +337,50 @@ SaveS3BootScript (
 //
 // BDS Platform Functions
 //
+
+VOID
+EFIAPI
+UnableToBoot (
+  VOID
+  )
+{
+  EFI_STATUS                      Status;
+  UINTN                           Index;
+  EFI_INPUT_KEY                   Key;
+  EFI_BOOT_MANAGER_LOAD_OPTION    BootManagerMenu;
+  //
+  // 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
+      );
+    Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
+    ASSERT_EFI_ERROR (Status);
+    ASSERT (Index == 0);
+
+    //
+    // Drain any queued keys.
+    //
+    while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {
+      //
+      // just throw away Key
+      //
+    }
+  }
+
+  Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
+  if (!EFI_ERROR (Status)) {
+    while (TRUE) {
+      EfiBootManagerBoot (&BootManagerMenu);
+    }
+  }
+}
+
 /**
   Do the platform init, can be customized by OEM/IBV
 
@@ -410,6 +454,8 @@ PlatformBootManagerBeforeConsole (
 
   PlatformRegisterOptionsAndKeys ();
 
+  EfiBootManagerRegisterUnableToBootHandler (UnableToBoot);
+
   //
   // Install both VIRTIO_DEVICE_PROTOCOL and (dependent) EFI_RNG_PROTOCOL
   // instances on Virtio PCI RNG devices.
@@ -1531,14 +1577,14 @@ PlatformBootManagerAfterConsole (
   //
   PlatformBdsConnectSequence ();
 
-  EfiBootManagerRefreshAllBootOption ();
+  //EfiBootManagerRefreshAllBootOption ();
 
   //
   // Register UEFI Shell
   //
-  PlatformRegisterFvBootOption (
-    PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
-    );
+  //PlatformRegisterFvBootOption (
+  //  PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
+  //  );
 
   RemoveStaleFvFileOptions ();
   SetBootOrderFromQemu ();
-- 
2.16.1.windows.1



             reply	other threads:[~2018-06-29  6:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29  6:05 Ruiyu Ni [this message]
2018-06-29 12:49 ` [PATCH] OvmfPkg/BDS: Provide platform callback for ultimate boot failure Laszlo Ersek

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=20180629060548.100012-1-ruiyu.ni@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