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: Jordan Justen <jordan.l.justen@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Anthony Perard <anthony.perard@citrix.com>,
	Julien Grall <julien.grall@linaro.org>
Subject: [PATCH v3 3/7] OvmfPkg/PlatformBds: Implement PlatformBootManagerUnableToBoot
Date: Tue,  3 Jul 2018 14:37:39 +0800	[thread overview]
Message-ID: <20180703063743.373172-4-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20180703063743.373172-1-ruiyu.ni@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien.grall@linaro.org>
---
 .../Library/PlatformBootManagerLib/BdsPlatform.c   | 61 +++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 57870cb856..e56ffc141a 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
@@ -1676,3 +1676,62 @@ PlatformBootManagerWaitCallback (
     );
 }
 
+/**
+  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 attempts to enter an infinite loop.
+**/
+VOID
+EFIAPI
+PlatformBootManagerUnableToBoot (
+  VOID
+  )
+{
+  EFI_STATUS                   Status;
+  EFI_INPUT_KEY                Key;
+  EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
+  UINTN                        Index;
+
+  //
+  // BootManagerMenu doesn't contain the correct information when return status is EFI_NOT_FOUND.
+  //
+  Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
+  if (EFI_ERROR (Status)) {
+    return;
+  }
+  //
+  // 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
+      );
+    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
+      //
+    }
+  }
+
+  for (;;) {
+    EfiBootManagerBoot (&BootManagerMenu);
+  }
+}
+
-- 
2.16.1.windows.1



  parent reply	other threads:[~2018-07-03  6:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03  6:37 [PATCH v3 0/7] Add platform hook for ultimate boot failure Ruiyu Ni
2018-07-03  6:37 ` [PATCH v3 1/7] MdeModulePkg/PlatformBootManager: Add PlatformBootManagerUnableToBoot Ruiyu Ni
2018-07-03 15:27   ` Laszlo Ersek
2018-07-03  6:37 ` [PATCH v3 2/7] CorebootPayload/PlatformBDS: Impl PlatformBootManagerUnableToBoot Ruiyu Ni
2018-07-03 22:58   ` You, Benjamin
2018-07-03  6:37 ` Ruiyu Ni [this message]
2018-07-03 15:37   ` [PATCH v3 3/7] OvmfPkg/PlatformBds: Implement PlatformBootManagerUnableToBoot Laszlo Ersek
2018-07-04  1:27     ` Ni, Ruiyu
2018-07-03  6:37 ` [PATCH v3 4/7] Nt32Pkg/PlatformBDS: " Ruiyu Ni
2018-07-04  1:09   ` Wu, Hao A
2018-07-03  6:37 ` [PATCH v3 5/7] QuarkPlatform/PlatformBDS: " Ruiyu Ni
2018-07-03  6:37 ` [PATCH v3 6/7] MdeModulePkg/BdsDxe: Revert "fall back to UI loop before hanging" Ruiyu Ni
2018-07-03 15:28   ` Laszlo Ersek
2018-07-03  6:37 ` [PATCH v3 7/7] MdeModulePkg/BdsDxe: Call PlatformBootManagerUnableToBoot() Ruiyu Ni
2018-07-03 15:29   ` Laszlo Ersek
2018-07-03 15:52 ` [PATCH v3 0/7] Add platform hook for ultimate boot failure Laszlo Ersek
2018-07-04  1:08   ` Ni, Ruiyu
2018-07-04  1:46     ` 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=20180703063743.373172-4-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