From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ED4E0202E53DB for ; Thu, 28 Jun 2018 23:05:31 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2018 23:05:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,285,1526367600"; d="scan'208";a="52786092" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga007.jf.intel.com with ESMTP; 28 Jun 2018 23:05:27 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Laszlo Ersek Date: Fri, 29 Jun 2018 14:05:48 +0800 Message-Id: <20180629060548.100012-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] OvmfPkg/BDS: Provide platform callback for ultimate boot failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2018 06:05:32 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Laszlo Ersek --- .../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.
+ Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
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