]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
CorebootPayload/PlatformBDS: Impl PlatformBootManagerUnableToBoot
[mirror_edk2.git] / CorebootPayloadPkg / Library / PlatformBootManagerLib / PlatformBootManager.c
index a31384af00e4a95fcfac125b9828e88224d94648..368e89d58616a6aa4d367ac1a2f3f0357397550f 100644 (file)
@@ -2,7 +2,7 @@
   This file include all platform action which can be customized\r
   by IBV/OEM.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,16 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "PlatformBootManager.h"\r
 #include "PlatformConsole.h"\r
 \r
-VOID\r
-EFIAPI\r
-InternalBdsEmptyCallbackFuntion (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  return;\r
-}\r
-\r
 VOID\r
 InstallReadyToLock (\r
   VOID\r
@@ -34,24 +24,13 @@ InstallReadyToLock (
   EFI_STATUS                            Status;\r
   EFI_HANDLE                            Handle;\r
   EFI_SMM_ACCESS2_PROTOCOL              *SmmAccess;\r
-  EFI_EVENT                             EndOfDxeEvent;\r
 \r
   DEBUG((DEBUG_INFO,"InstallReadyToLock  entering......\n"));\r
   //\r
   // Inform the SMM infrastructure that we're entering BDS and may run 3rd party code hereafter\r
   // Since PI1.2.1, we need signal EndOfDxe as ExitPmAuth\r
   //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  InternalBdsEmptyCallbackFuntion,\r
-                  NULL,\r
-                  &gEfiEndOfDxeEventGroupGuid,\r
-                  &EndOfDxeEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  gBS->SignalEvent (EndOfDxeEvent);\r
-  gBS->CloseEvent (EndOfDxeEvent);\r
+  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
   DEBUG((DEBUG_INFO,"All EndOfDxe callbacks have returned successfully\n"));\r
 \r
   //\r
@@ -181,6 +160,7 @@ PlatformBootManagerBeforeConsole (
 {\r
   EFI_INPUT_KEY                Enter;\r
   EFI_INPUT_KEY                F2;\r
+  EFI_INPUT_KEY                Down;\r
   EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
 \r
   PlatformConsoleInit ();\r
@@ -201,15 +181,23 @@ PlatformBootManagerBeforeConsole (
   EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
 \r
   //\r
-  // Register UEFI Shell\r
+  // Also add Down key to Boot Manager Menu since some serial terminals don't support F2 key.\r
   //\r
-  PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);\r
+  Down.ScanCode    = SCAN_DOWN;\r
+  Down.UnicodeChar = CHAR_NULL;\r
+  EfiBootManagerGetBootManagerMenu (&BootOption);\r
+  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &Down, NULL);\r
 \r
   //\r
   // Install ready to lock.\r
   // This needs to be done before option rom dispatched.\r
   //\r
   InstallReadyToLock ();\r
+\r
+  //\r
+  // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.\r
+  //\r
+  EfiBootManagerDispatchDeferredImages ();\r
 }\r
 \r
 /**\r
@@ -237,10 +225,15 @@ PlatformBootManagerAfterConsole (
   EfiBootManagerConnectAll ();\r
   EfiBootManagerRefreshAllBootOption ();\r
 \r
+  //\r
+  // Register UEFI Shell\r
+  //\r
+  PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);\r
+  \r
   Print (\r
     L"\n"\r
-    L"F2      to enter Boot Manager Menu.\n"\r
-    L"ENTER   to boot directly.\n"\r
+    L"F2 or Down      to enter Boot Manager Menu.\n"\r
+    L"ENTER           to boot directly.\n"\r
     L"\n"\r
   );\r
 \r
@@ -259,3 +252,20 @@ PlatformBootManagerWaitCallback (
 {\r
   return;\r
 }\r
+\r
+/**\r
+  The function is called when no boot option could be launched,\r
+  including platform recovery options and options pointing to applications\r
+  built into firmware volumes.\r
+\r
+  If this function returns, BDS attempts to enter an infinite loop.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerUnableToBoot (\r
+  VOID\r
+  )\r
+{\r
+  return;\r
+}\r
+\r