]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiPayloadPkg: Get platform specific logic via protocol for BDS
authorZhiguang Liu <zhiguang.liu@intel.com>
Thu, 10 Jun 2021 01:49:17 +0000 (09:49 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 16 Jun 2021 05:20:19 +0000 (05:20 +0000)
Currently, BDS driver will link a PlatformBootManagerLib, which contains
platform specific logic. This patch get the platform specific logic from
a protocol, so that platform logic for Boot manager can be in another
binary.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h [new file with mode: 0644]
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
UefiPayloadPkg/UefiPayloadPkg.dec

diff --git a/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h b/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h
new file mode 100644 (file)
index 0000000..59544e4
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+  This file defines the Univeral Payload Platform BootManager Protocol.\r
+\r
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__\r
+#define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__\r
+\r
+\r
+/**\r
+  Do the platform specific action before the console is connected.\r
+\r
+  Such as:\r
+    Update console variable;\r
+    Register new Driver#### or Boot####;\r
+    Signal ReadyToLock event.\r
+\r
+  This function will override the default behavior in PlatformBootManagerLib\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE) (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Do the platform specific action after the console is connected.\r
+\r
+  Such as:\r
+    Dynamically switch output mode;\r
+    Signal console ready platform customized event;\r
+    Run diagnostics like memory testing;\r
+    Connect certain devices;\r
+    Dispatch aditional option roms.\r
+\r
+  This function will override the default behavior in PlatformBootManagerLib\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE) (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function is called each second during the boot manager waits the timeout.\r
+  This function will override the default behavior in PlatformBootManagerLib\r
+\r
+  @param TimeoutRemain  The remaining timeout.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK) (\r
+  UINT16          TimeoutRemain\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
+  This function will override the default behavior in PlatformBootManagerLib\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT) (\r
+  VOID\r
+  );\r
+\r
+///\r
+/// Provides an interface to override the default behavior in PlatformBootManagerLib,\r
+/// so platform can provide its own platform specific logic through this protocol\r
+///\r
+typedef struct {\r
+  UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE        BeforeConsole;\r
+  UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE         AfterConsole;\r
+  UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK         WaitCallback;\r
+  UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT        UnableToBoot;\r
+} UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL;\r
+\r
+extern GUID gUniversalPayloadPlatformBootManagerOverrideProtocolGuid;\r
+\r
+#endif\r
index 7fa3a048b74184a00e05b033581931208d641765..fce48d26a1a5b55e0fdbdbf1626d0c3f8fa39c63 100644 (file)
@@ -2,13 +2,16 @@
   This file include all platform action which can be customized\r
   by IBV/OEM.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include "PlatformBootManager.h"\r
 #include "PlatformConsole.h"\r
+#include <Protocol/PlatformBootManagerOverride.h>\r
+\r
+UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL  *mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;\r
 \r
 VOID\r
 InstallReadyToLock (\r
@@ -156,6 +159,16 @@ PlatformBootManagerBeforeConsole (
   EFI_INPUT_KEY                F2;\r
   EFI_INPUT_KEY                Down;\r
   EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
+  EFI_STATUS                   Status;\r
+\r
+  Status = gBS->LocateProtocol (&gUniversalPayloadPlatformBootManagerOverrideProtocolGuid, NULL, (VOID **) &mUniversalPayloadPlatformBootManagerOverrideInstance);\r
+  if (EFI_ERROR (Status)) {\r
+    mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;\r
+  }\r
+  if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){\r
+    mUniversalPayloadPlatformBootManagerOverrideInstance->BeforeConsole();\r
+    return;\r
+  }\r
 \r
   //\r
   // Register ENTER as CONTINUE key\r
@@ -213,6 +226,10 @@ PlatformBootManagerAfterConsole (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Black;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  White;\r
 \r
+  if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){\r
+    mUniversalPayloadPlatformBootManagerOverrideInstance->AfterConsole();\r
+    return;\r
+  }\r
   Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
   White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
 \r
@@ -244,6 +261,9 @@ PlatformBootManagerWaitCallback (
   UINT16          TimeoutRemain\r
 )\r
 {\r
+  if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){\r
+    mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain);\r
+  }\r
   return;\r
 }\r
 \r
@@ -260,6 +280,9 @@ PlatformBootManagerUnableToBoot (
   VOID\r
   )\r
 {\r
+  if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){\r
+    mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot();\r
+  }\r
   return;\r
 }\r
 \r
index 1f5a0bcad0383df748ae09a918dccb9b4ad953f0..600a5352824fa1e1f444d9b609b7b600262c4789 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Include all platform action which can be customized by IBV/OEM.\r
 #\r
-#  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -57,6 +57,7 @@
   gEfiBootLogoProtocolGuid        ## CONSUMES\r
   gEfiDxeSmmReadyToLockProtocolGuid\r
   gEfiSmmAccess2ProtocolGuid\r
+  gUniversalPayloadPlatformBootManagerOverrideProtocolGuid\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
index 99cb3311a68f6b7c04a0369314b62736376711f9..105e1f5a1c0f34553fb383e5b12ff3cef4a06114 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Provides drivers and definitions to create uefi payload for bootloaders.\r
 #\r
-# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -43,6 +43,8 @@
   #\r
   gPlatformGOPPolicyGuid                  = { 0xec2e931b, 0x3281, 0x48a5, { 0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } }\r
 \r
+  gUniversalPayloadPlatformBootManagerOverrideProtocolGuid = { 0xdb3fc2df, 0x7376, 0x4a8d, { 0x82, 0xab, 0x91, 0x54, 0xa1, 0x36, 0xa6, 0x5a } }\r
+\r
 ################################################################################\r
 #\r
 # PCD Declarations section - list of all PCDs Declared by this Package\r