From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web10.44355.1624265224391114153 for ; Mon, 21 Jun 2021 01:47:12 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: dun.tan@intel.com) IronPort-SDR: w01Tj7ZhY/la95KJ2Gjp+KfOB2itnKDhCROSWz+sSLKVOKXodFMjGIdT8+wtjMDQ05TzcrkrgA XBcQUc5Fih+g== X-IronPort-AV: E=McAfee;i="6200,9189,10021"; a="206623643" X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="206623643" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2021 01:47:11 -0700 IronPort-SDR: XkTqYEA1tG7g5VeWPR9qQpNTCT1AWsiidZCXnIDrsZjZseRshs5qPbDD5wV/MBtLLuvCPE0rDm 31u22lZNDQow== X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="453813401" Received: from duntan-mobl.ccr.corp.intel.com ([10.238.1.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2021 01:47:10 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You , DunTan Subject: [PATCH 2/2] UefiPayloadPkg: consume the BootManagerMenuFile HOB Date: Mon, 21 Jun 2021 16:46:33 +0800 Message-Id: <20210621084633.1593-3-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20210621084633.1593-1-dun.tan@intel.com> References: <20210621084633.1593-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Consume the BootManagerMenuFile HOB in PlatformBootManagerLib This Lib is in UefiPayloadPkg Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: DunTan --- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 5 ++++- UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index fce48d26a1..afd9664959 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatformBootManager.h" #include "PlatformConsole.h" #include +#include +#include UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL *mUniversalPayloadPlatformBootManagerOverrideInstance = NULL; @@ -286,3 +288,52 @@ PlatformBootManagerUnableToBoot ( return; } +/** + Get/update PcdBootManagerMenuFile from GUID HOB which will be assigned in bootloader. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs. + +**/ +EFI_STATUS +EFIAPI +PlatformBootManagerLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status; + UINTN Size; + VOID *GuidHob; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *BootManagerMenuFile; + Status = EFI_SUCCESS; + GuidHob = GetFirstGuidHob (&gUniversalPayloadBootManagerMenuFileGuid); + // + // Find the buffer information and update PCDs + // + if (GuidHob == NULL) { + // + // If the HOB is not create, the default value of PcdBootManagerMenuFile will be used. + // + return EFI_SUCCESS; + } + + GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob); + if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { + return EFI_NOT_FOUND; + } + if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) { + BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) GET_GUID_HOB_DATA (GuidHob); + if (BootManagerMenuFile->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, FileName)) { + return EFI_NOT_FOUND; + } + Size = sizeof (BootManagerMenuFile->FileName); + Status = PcdSetPtrS (PcdBootManagerMenuFile, &Size, &BootManagerMenuFile->FileName); + } else { + return EFI_NOT_FOUND; + } + + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; +} diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 600a535282..9c4943a0e0 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -13,7 +13,7 @@ MODULE_TYPE = DXE_DRIVER VERSION_STRING = 1.0 LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER - + CONSTRUCTOR = PlatformBootManagerLibConstructor # # The following information is for reference only and not required by the build tools. @@ -46,9 +46,11 @@ HiiLib PrintLib PlatformHookLib + HobLib [Guids] gEfiEndOfDxeEventGroupGuid + gUniversalPayloadBootManagerMenuFileGuid [Protocols] gEfiGenericMemTestProtocolGuid ## CONSUMES @@ -70,3 +72,4 @@ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 21b360256b..e46b867d30 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -289,7 +289,6 @@ !endif gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } !if $(SOURCE_DEBUG_ENABLE) @@ -297,6 +296,7 @@ !endif [PcdsPatchableInModule.common] + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7 gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F !if $(SOURCE_DEBUG_ENABLE) -- 2.31.1.windows.1