Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <[email protected]>
Cc: Laszlo Ersek <[email protected]>
---
 .../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

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to