public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] OvmfPkg/BDS: Provide platform callback for ultimate boot failure
@ 2018-06-29  6:05 Ruiyu Ni
  2018-06-29 12:49 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-06-29  6:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Laszlo Ersek

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-29 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-29  6:05 [PATCH] OvmfPkg/BDS: Provide platform callback for ultimate boot failure Ruiyu Ni
2018-06-29 12:49 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox