]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiPayloadPkg: consume the BootManagerMenuFile HOB
authorduntan <dun.tan@intel.com>
Mon, 21 Jun 2021 08:23:28 +0000 (16:23 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 24 Jun 2021 09:16:22 +0000 (09:16 +0000)
Consume the BootManagerMenuFile HOB in PlatformBootManagerLib
This Lib is in UefiPayloadPkg

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: DunTan <dun.tan@intel.com>
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
UefiPayloadPkg/UefiPayloadPkg.dsc

index fce48d26a1a5b55e0fdbdbf1626d0c3f8fa39c63..c4d317fa9e25fa5f746c563baac168071eb40e09 100644 (file)
@@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "PlatformBootManager.h"\r
 #include "PlatformConsole.h"\r
 #include <Protocol/PlatformBootManagerOverride.h>\r
+#include <Guid/BootManagerMenu.h>\r
+#include <Library/HobLib.h>\r
 \r
 UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL  *mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;\r
 \r
@@ -286,3 +288,53 @@ PlatformBootManagerUnableToBoot (
   return;\r
 }\r
 \r
+/**\r
+  Get/update PcdBootManagerMenuFile from GUID HOB which will be assigned in bootloader.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformBootManagerLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+)\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINTN                                Size;\r
+  VOID                                 *GuidHob;\r
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER     *GenericHeader;\r
+  UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU  *BootManagerMenuFile;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEdkiiBootManagerMenuFileGuid);\r
+\r
+  if (GuidHob == NULL) {\r
+    //\r
+    // If the HOB is not create, the default value of PcdBootManagerMenuFile will be used.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
+  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) {\r
+    BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) GET_GUID_HOB_DATA (GuidHob);\r
+    if (BootManagerMenuFile->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, FileName)) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+    Size = sizeof (BootManagerMenuFile->FileName);\r
+    Status = PcdSetPtrS (PcdBootManagerMenuFile, &Size, &BootManagerMenuFile->FileName);\r
+    ASSERT_EFI_ERROR (Status);\r
+  } else {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 600a5352824fa1e1f444d9b609b7b600262c4789..9c4a9da94350da26864355bc0ee6dd5dd1c5a40b 100644 (file)
@@ -13,7 +13,7 @@
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = PlatformBootManagerLib|DXE_DRIVER\r
-\r
+  CONSTRUCTOR                    = PlatformBootManagerLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
   HiiLib\r
   PrintLib\r
   PlatformHookLib\r
+  HobLib\r
 \r
 [Guids]\r
   gEfiEndOfDxeEventGroupGuid\r
+  gEdkiiBootManagerMenuFileGuid\r
 \r
 [Protocols]\r
   gEfiGenericMemTestProtocolGuid  ## CONSUMES\r
@@ -70,3 +72,4 @@
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile\r
index 21b2c8128c71a0920598cb674ecb02b51aebcdf1..5fd2504d7dd67e0e4b3e229583408ae7a8ffcd2b 100644 (file)
 !endif\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }\r
 \r
   gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }\r
 \r
 !endif\r
 \r
 [PcdsPatchableInModule.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }\r
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7\r
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F\r
 !if $(SOURCE_DEBUG_ENABLE)\r