From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.2350.1624416764304600337 for ; Tue, 22 Jun 2021 19:52:44 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: Y346ySDnGdMptqsSQf95IEa3dtQWWBK68g8yK3f1G8FdKbIgCXIM5K3sLv0bO3Fqeah7sZ2QHM 7TVFv1hzvpvw== X-IronPort-AV: E=McAfee;i="6200,9189,10023"; a="204175477" X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="204175477" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 19:52:42 -0700 IronPort-SDR: Tbi0RQDhnGaxLqc0g9w4oTdiyfGXsll3mFj/HiSZioci+BUerTTAwJuedfH6dGBXIde8XmFkOX b+GgLzz4VL2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="487138245" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga001.jf.intel.com with ESMTP; 22 Jun 2021 19:52:40 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You , Ray Ni Subject: [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Date: Wed, 23 Jun 2021 10:52:24 +0800 Message-Id: <20210623025235.3311-2-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <20210623025235.3311-1-zhiguang.liu@intel.com> References: <20210623025235.3311-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable V1: For payload entry, use PayloadEntryHobLib as HobLib and payload entry should initialize hob base. For DxeCore, use new added DxeHobLib as HobLib, and DxeCore will initialize hob base. For Dxe Driver, use new added DxeHobLib as HobLib, and use DxeHobListLib to initialize hob base. V2: Remove the UefiLib since it won't be needed. Adding a new library DxeHobLib + DxeHobListLib instead of using the DxeHobLib.inf in MdePkg is because the constructor needed be separated from DxeHobLib. If not, when building UefiPayloadPkg, the dependency chain is as below: DebugLib -> SerialPortLib -> PlatformHookLib -> HobLib -> DebugLib Each library has a constructor, and this becomes a constructor circle. To break the circle, separate the constructor from the HobLib as a new DxeHobListLib, which won't depend on DebugLib. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: Ray Ni Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/Include/Library/DxeHobListLib.h | 27 +++= ++++++++++++++++++++++++ UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf | 36 +++= +++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni | 16 +++= +++++++++++++ UefiPayloadPkg/Library/DxeHobLib/HobLib.c | 597 +++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c | 66 +++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf | 35 +++= ++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c | 20 +++= +++++++++++++++++ UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf | 28 +++= +++++++++++++++++++++++++ UefiPayloadPkg/Library/{HobLib =3D> PayloadEntryHobLib}/Hob.c | 2 +- UefiPayloadPkg/Library/{HobLib =3D> PayloadEntryHobLib}/HobLib.inf | 2 +- UefiPayloadPkg/UefiPayloadPkg.dsc | 15 +++= ++++++++---- 11 files changed, 838 insertions(+), 6 deletions(-) diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h b/UefiPayloadPk= g/Include/Library/DxeHobListLib.h new file mode 100644 index 0000000000..7e9b23f6d7 --- /dev/null +++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h @@ -0,0 +1,27 @@ +/** @file=0D + Provides a service to retrieve a pointer to the start of HOB list.=0D + Only available to DXE module types.=0D +=0D + This library does not contain any functions or macros. It simply export= s a global=0D + pointer to the start of HOB list as defined in the Platform Initializati= on Driver=0D + Execution Environment Core Interface Specification. The library constru= ctor must=0D + initialize this global pointer to the start of HOB list, so it is availa= ble at the=0D + module's entry point. Since there is overhead in looking up the pointer= to the start=0D + of HOB list, only those modules that actually require access to the HOB = list=0D + should use this library.=0D +=0D +Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef __DXE_HOB_LIST_LIB_H__=0D +#define __DXE_HOB_LIST_LIB_H__=0D +=0D +///=0D +/// Cache copy of the start of HOB list=0D +///=0D +extern VOID *gHobList;=0D +=0D +#endif=0D +=0D diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf b/UefiPayloadPk= g/Library/DxeHobLib/DxeHobLib.inf new file mode 100644 index 0000000000..ff334a0d41 --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf @@ -0,0 +1,36 @@ +## @file=0D +# HOB Library implementation for Payload Phase.=0D +#=0D +# Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D DxeHobLib=0D + MODULE_UNI_FILE =3D DxeHobLib.uni=0D + FILE_GUID =3D 1a15b8b3-3e8a-4698-87b9-65aad9993b52= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D HobLib|DXE_DRIVER DXE_RUNTIME_DRIVER = SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + HobLib.c=0D +=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +=0D +[LibraryClasses]=0D + BaseMemoryLib=0D + DebugLib=0D + DxeHobListLib=0D diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni b/UefiPayloadPk= g/Library/DxeHobLib/DxeHobLib.uni new file mode 100644 index 0000000000..4e02e9c2ae --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni @@ -0,0 +1,16 @@ +// /** @file=0D +// HOB Library implementation for Payload Phase.=0D +//=0D +// The Hoblist will be set by DxeHobListLib or other modules.=0D +//=0D +// Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +//=0D +// SPDX-License-Identifier: BSD-2-Clause-Patent=0D +//=0D +// **/=0D +=0D +=0D +#string STR_MODULE_ABSTRACT #language en-US "HOB Library imple= mentation for Payload Phase."=0D +=0D +#string STR_MODULE_DESCRIPTION #language en-US "The HOB Library i= mplementation for Payload Phase that doesn't contain HobLibConstructor"=0D +=0D diff --git a/UefiPayloadPkg/Library/DxeHobLib/HobLib.c b/UefiPayloadPkg/Lib= rary/DxeHobLib/HobLib.c new file mode 100644 index 0000000000..5d5ede0c17 --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobLib/HobLib.c @@ -0,0 +1,597 @@ +/** @file=0D + HOB Library implementation for Payload Phase.=0D +=0D +Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Returns the pointer to the HOB list.=0D +=0D + This function returns the pointer to first HOB in the list.=0D + For PEI phase, the PEI service GetHobList() can be used to retrieve the = pointer=0D + to the HOB list. For the DXE phase, the HOB list pointer can be retriev= ed through=0D + the EFI System Table by looking up theHOB list GUID in the System Config= uration Table.=0D + Since the System Configuration Table does not exist that the time the DX= E Core is=0D + launched, the DXE Core uses a global variable from the DXE Core Entry Po= int Library=0D + to manage the pointer to the HOB list.=0D +=0D + If the pointer to the HOB list is NULL, then ASSERT().=0D +=0D + @return The pointer to the HOB list.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +GetHobList (=0D + VOID=0D + )=0D +{=0D + ASSERT (gHobList !=3D NULL);=0D + return gHobList;=0D +}=0D +=0D +/**=0D + Returns the next instance of a HOB type from the starting HOB.=0D +=0D + This function searches the first instance of a HOB type from the startin= g HOB pointer.=0D + If there does not exist such HOB type from the starting HOB pointer, it = will return NULL.=0D + In contrast with macro GET_NEXT_HOB(), this function does not skip the s= tarting HOB pointer=0D + unconditionally: it returns HobStart back if HobStart itself meets the r= equirement;=0D + caller is required to use GET_NEXT_HOB() if it wishes to skip current Ho= bStart.=0D +=0D + If HobStart is NULL, then ASSERT().=0D +=0D + @param Type The HOB type to return.=0D + @param HobStart The starting HOB pointer to search from.=0D +=0D + @return The next instance of a HOB type from the starting HOB.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +GetNextHob (=0D + IN UINT16 Type,=0D + IN CONST VOID *HobStart=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS Hob;=0D +=0D + ASSERT (HobStart !=3D NULL);=0D +=0D + Hob.Raw =3D (UINT8 *) HobStart;=0D + //=0D + // Parse the HOB list until end of list or matching type is found.=0D + //=0D + while (!END_OF_HOB_LIST (Hob)) {=0D + if (Hob.Header->HobType =3D=3D Type) {=0D + return Hob.Raw;=0D + }=0D + Hob.Raw =3D GET_NEXT_HOB (Hob);=0D + }=0D + return NULL;=0D +}=0D +=0D +/**=0D + Returns the first instance of a HOB type among the whole HOB list.=0D +=0D + This function searches the first instance of a HOB type among the whole = HOB list.=0D + If there does not exist such HOB type in the HOB list, it will return NU= LL.=0D +=0D + If the pointer to the HOB list is NULL, then ASSERT().=0D +=0D + @param Type The HOB type to return.=0D +=0D + @return The next instance of a HOB type from the starting HOB.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +GetFirstHob (=0D + IN UINT16 Type=0D + )=0D +{=0D + VOID *HobList;=0D +=0D + HobList =3D GetHobList ();=0D + return GetNextHob (Type, HobList);=0D +}=0D +=0D +/**=0D + Returns the next instance of the matched GUID HOB from the starting HOB.= =0D +=0D + This function searches the first instance of a HOB from the starting HOB= pointer.=0D + Such HOB should satisfy two conditions:=0D + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to = the input Guid.=0D + If there does not exist such HOB from the starting HOB pointer, it will = return NULL.=0D + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_S= IZE ()=0D + to extract the data section and its size information, respectively.=0D + In contrast with macro GET_NEXT_HOB(), this function does not skip the s= tarting HOB pointer=0D + unconditionally: it returns HobStart back if HobStart itself meets the r= equirement;=0D + caller is required to use GET_NEXT_HOB() if it wishes to skip current Ho= bStart.=0D +=0D + If Guid is NULL, then ASSERT().=0D + If HobStart is NULL, then ASSERT().=0D +=0D + @param Guid The GUID to match with in the HOB list.=0D + @param HobStart A pointer to a Guid.=0D +=0D + @return The next instance of the matched GUID HOB from the starting HOB.= =0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +GetNextGuidHob (=0D + IN CONST EFI_GUID *Guid,=0D + IN CONST VOID *HobStart=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS GuidHob;=0D +=0D + GuidHob.Raw =3D (UINT8 *) HobStart;=0D + while ((GuidHob.Raw =3D GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob= .Raw)) !=3D NULL) {=0D + if (CompareGuid (Guid, &GuidHob.Guid->Name)) {=0D + break;=0D + }=0D + GuidHob.Raw =3D GET_NEXT_HOB (GuidHob);=0D + }=0D + return GuidHob.Raw;=0D +}=0D +=0D +/**=0D + Returns the first instance of the matched GUID HOB among the whole HOB l= ist.=0D +=0D + This function searches the first instance of a HOB among the whole HOB l= ist.=0D + Such HOB should satisfy two conditions:=0D + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to = the input Guid.=0D + If there does not exist such HOB from the starting HOB pointer, it will = return NULL.=0D + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_S= IZE ()=0D + to extract the data section and its size information, respectively.=0D +=0D + If the pointer to the HOB list is NULL, then ASSERT().=0D + If Guid is NULL, then ASSERT().=0D +=0D + @param Guid The GUID to match with in the HOB list.=0D +=0D + @return The first instance of the matched GUID HOB among the whole HOB l= ist.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +GetFirstGuidHob (=0D + IN CONST EFI_GUID *Guid=0D + )=0D +{=0D + VOID *HobList;=0D +=0D + HobList =3D GetHobList ();=0D + return GetNextGuidHob (Guid, HobList);=0D +}=0D +=0D +/**=0D + Get the system boot mode from the HOB list.=0D +=0D + This function returns the system boot mode information from the=0D + PHIT HOB in HOB list.=0D +=0D + If the pointer to the HOB list is NULL, then ASSERT().=0D +=0D + @param VOID=0D +=0D + @return The Boot Mode.=0D +=0D +**/=0D +EFI_BOOT_MODE=0D +EFIAPI=0D +GetBootModeHob (=0D + VOID=0D + )=0D +{=0D + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;=0D +=0D + HandOffHob =3D (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();=0D +=0D + return HandOffHob->BootMode;=0D +}=0D +=0D +/**=0D + Builds a HOB for a loaded PE32 module.=0D +=0D + This function builds a HOB for a loaded PE32 module.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If ModuleName is NULL, then ASSERT().=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param ModuleName The GUID File Name of the module.=0D + @param MemoryAllocationModule The 64 bit physical address of the modul= e.=0D + @param ModuleLength The length of the module in bytes.=0D + @param EntryPoint The 64 bit physical address of the modul= e entry point.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildModuleHob (=0D + IN CONST EFI_GUID *ModuleName,=0D + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,=0D + IN UINT64 ModuleLength,=0D + IN EFI_PHYSICAL_ADDRESS EntryPoint=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB that describes a chunk of system memory with Owner GUID.=0D +=0D + This function builds a HOB that describes a chunk of system memory.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param ResourceType The type of resource described by this HOB.= =0D + @param ResourceAttribute The resource attributes of the memory descri= bed by this HOB.=0D + @param PhysicalStart The 64 bit physical address of memory descri= bed by this HOB.=0D + @param NumberOfBytes The length of the memory described by this H= OB in bytes.=0D + @param OwnerGUID GUID for the owner of this resource.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildResourceDescriptorWithOwnerHob (=0D + IN EFI_RESOURCE_TYPE ResourceType,=0D + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,=0D + IN EFI_PHYSICAL_ADDRESS PhysicalStart,=0D + IN UINT64 NumberOfBytes,=0D + IN EFI_GUID *OwnerGUID=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB that describes a chunk of system memory.=0D +=0D + This function builds a HOB that describes a chunk of system memory.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param ResourceType The type of resource described by this HOB.= =0D + @param ResourceAttribute The resource attributes of the memory descri= bed by this HOB.=0D + @param PhysicalStart The 64 bit physical address of memory descri= bed by this HOB.=0D + @param NumberOfBytes The length of the memory described by this H= OB in bytes.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildResourceDescriptorHob (=0D + IN EFI_RESOURCE_TYPE ResourceType,=0D + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,=0D + IN EFI_PHYSICAL_ADDRESS PhysicalStart,=0D + IN UINT64 NumberOfBytes=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a customized HOB tagged with a GUID for identification and return= s=0D + the start address of GUID HOB data.=0D +=0D + This function builds a customized HOB tagged with a GUID for identificat= ion=0D + and returns the start address of GUID HOB data so that caller can fill t= he customized data.=0D + The HOB Header and Name field is already stripped.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If Guid is NULL, then ASSERT().=0D + If there is no additional space for HOB creation, then ASSERT().=0D + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().=0D + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0x= FFF8.=0D +=0D + @param Guid The GUID to tag the customized HOB.=0D + @param DataLength The size of the data payload for the GUID HOB.=0D +=0D + @retval NULL The GUID HOB could not be allocated.=0D + @retval others The start address of GUID HOB data.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +BuildGuidHob (=0D + IN CONST EFI_GUID *Guid,=0D + IN UINTN DataLength=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D + return NULL;=0D +}=0D +=0D +/**=0D + Builds a customized HOB tagged with a GUID for identification, copies th= e input data to the HOB=0D + data field, and returns the start address of the GUID HOB data.=0D +=0D + This function builds a customized HOB tagged with a GUID for identificat= ion and copies the input=0D + data to the HOB data field and returns the start address of the GUID HOB= data. It can only be=0D + invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB = is read-only for DXE phase.=0D + The HOB Header and Name field is already stripped.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If Guid is NULL, then ASSERT().=0D + If Data is NULL and DataLength > 0, then ASSERT().=0D + If there is no additional space for HOB creation, then ASSERT().=0D + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().=0D + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0x= FFF8.=0D +=0D + @param Guid The GUID to tag the customized HOB.=0D + @param Data The data to be copied into the data field of the G= UID HOB.=0D + @param DataLength The size of the data payload for the GUID HOB.=0D +=0D + @retval NULL The GUID HOB could not be allocated.=0D + @retval others The start address of GUID HOB data.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +BuildGuidDataHob (=0D + IN CONST EFI_GUID *Guid,=0D + IN VOID *Data,=0D + IN UINTN DataLength=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D + return NULL;=0D +}=0D +=0D +/**=0D + Builds a Firmware Volume HOB.=0D +=0D + This function builds a Firmware Volume HOB.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D + If the FvImage buffer is not at its required alignment, then ASSERT().=0D +=0D + @param BaseAddress The base address of the Firmware Volume.=0D + @param Length The size of the Firmware Volume in bytes.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildFvHob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a EFI_HOB_TYPE_FV2 HOB.=0D +=0D + This function builds a EFI_HOB_TYPE_FV2 HOB.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D + If the FvImage buffer is not at its required alignment, then ASSERT().=0D +=0D + @param BaseAddress The base address of the Firmware Volume.=0D + @param Length The size of the Firmware Volume in bytes.=0D + @param FvName The name of the Firmware Volume.=0D + @param FileName The name of the file.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildFv2Hob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN CONST EFI_GUID *FvName,=0D + IN CONST EFI_GUID *FileName=0D + )=0D +{=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a EFI_HOB_TYPE_FV3 HOB.=0D +=0D + This function builds a EFI_HOB_TYPE_FV3 HOB.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D + If the FvImage buffer is not at its required alignment, then ASSERT().=0D +=0D + @param BaseAddress The base address of the Firmware Volume.=0D + @param Length The size of the Firmware Volume in bytes.= =0D + @param AuthenticationStatus The authentication status.=0D + @param ExtractedFv TRUE if the FV was extracted as a file wit= hin=0D + another firmware volume. FALSE otherwise.= =0D + @param FvName The name of the Firmware Volume.=0D + Valid only if IsExtractedFv is TRUE.=0D + @param FileName The name of the file.=0D + Valid only if IsExtractedFv is TRUE.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildFv3Hob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN UINT32 AuthenticationStatus,=0D + IN BOOLEAN ExtractedFv,=0D + IN CONST EFI_GUID *FvName, OPTIONAL=0D + IN CONST EFI_GUID *FileName OPTIONAL=0D + )=0D +{=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a Capsule Volume HOB.=0D +=0D + This function builds a Capsule Volume HOB.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If the platform does not support Capsule Volume HOBs, then ASSERT().=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param BaseAddress The base address of the Capsule Volume.=0D + @param Length The size of the Capsule Volume in bytes.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildCvHob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB for the CPU.=0D +=0D + This function builds a HOB for the CPU.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param SizeOfMemorySpace The maximum physical memory addressability o= f the processor.=0D + @param SizeOfIoSpace The maximum physical I/O addressability of t= he processor.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildCpuHob (=0D + IN UINT8 SizeOfMemorySpace,=0D + IN UINT8 SizeOfIoSpace=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB for the Stack.=0D +=0D + This function builds a HOB for the stack.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param BaseAddress The 64 bit physical address of the Stack.=0D + @param Length The length of the stack in bytes.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildStackHob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB for the BSP store.=0D +=0D + This function builds a HOB for BSP store.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param BaseAddress The 64 bit physical address of the BSP.=0D + @param Length The length of the BSP store in bytes.=0D + @param MemoryType Type of memory allocated by this HOB.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildBspStoreHob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN EFI_MEMORY_TYPE MemoryType=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D +=0D +/**=0D + Builds a HOB for the memory allocation.=0D +=0D + This function builds a HOB for the memory allocation.=0D + It can only be invoked during PEI phase;=0D + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase= .=0D +=0D + If there is no additional space for HOB creation, then ASSERT().=0D +=0D + @param BaseAddress The 64 bit physical address of the memory.=0D + @param Length The length of the memory allocation in bytes.=0D + @param MemoryType Type of memory allocated by this HOB.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +BuildMemoryAllocationHob (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN EFI_MEMORY_TYPE MemoryType=0D + )=0D +{=0D + //=0D + // PEI HOB is read only for DXE phase=0D + //=0D + ASSERT (FALSE);=0D +}=0D diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c b/UefiPay= loadPkg/Library/DxeHobListLib/DxeHobListLib.c new file mode 100644 index 0000000000..8bb31b3f9c --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c @@ -0,0 +1,66 @@ +/** @file=0D + This library retrieve the EFI_BOOT_SERVICES pointer from EFI system tabl= e in=0D + library's constructor.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +=0D +#include =0D +=0D +VOID *gHobList =3D NULL;=0D +=0D +/**=0D + Local implementation of GUID comparasion that doesn't depend on DebugLib= ::ASSERT().=0D +=0D + This function compares Guid1 to Guid2. If the GUIDs are identical then = TRUE is returned.=0D + If there are any bit differences in the two GUIDs, then FALSE is returne= d.=0D +=0D + @param Guid1 A pointer to a 128 bit GUID.=0D + @param Guid2 A pointer to a 128 bit GUID.=0D +=0D + @retval TRUE Guid1 and Guid2 are identical.=0D + @retval FALSE Guid1 and Guid2 are not identical.=0D +**/=0D +BOOLEAN=0D +LocalCompareGuid (=0D + IN CONST GUID *Guid1,=0D + IN CONST GUID *Guid2=0D + )=0D +{=0D + UINT64 *Left;=0D + UINT64 *Right;=0D +=0D + Left =3D (UINT64 *) Guid1;=0D + Right =3D (UINT64 *) Guid2;=0D +=0D + return (BOOLEAN) (Left[0] =3D=3D Right[0] && Left[1] =3D=3D Right[1]);=0D +}=0D +=0D +/**=0D + @param ImageHandle The firmware allocated handle for the EFI image.=0D + @param SystemTable A pointer to the EFI System Table.=0D +=0D + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +DxeHobListLibConstructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + UINTN Index;=0D +=0D + for (Index =3D 0; Index < SystemTable->NumberOfTableEntries; Index++) {= =0D + if (LocalCompareGuid (&gEfiHobListGuid, &SystemTable->ConfigurationTab= le[Index].VendorGuid)) {=0D + gHobList =3D SystemTable->ConfigurationTable[Index].VendorTable;=0D + return EFI_SUCCESS;=0D + }=0D + }=0D +=0D + return EFI_NOT_FOUND;=0D +}=0D diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf b/UefiP= ayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf new file mode 100644 index 0000000000..1115949556 --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf @@ -0,0 +1,35 @@ +## @file=0D +# UEFI Boot Services Table Library implementation.=0D +#=0D +# Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D UefiPayloadInitHobLib=0D + FILE_GUID =3D ff5c7a21-ab7a-4366-8616-11c6e53247b6= =0D + MODULE_TYPE =3D UEFI_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D DxeHobListLib|DXE_DRIVER DXE_RUNTIME= _DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE=0D +=0D + CONSTRUCTOR =3D DxeHobListLibConstructor=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + DxeHobListLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[Guids]=0D + gEfiHobListGuid ## CONSUMES=0D +=0D +=0D diff --git a/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c b= /UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c new file mode 100644 index 0000000000..92d3e17ef0 --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c @@ -0,0 +1,20 @@ +/** @file=0D + This library retrieve the EFI_BOOT_SERVICES pointer from EFI system tabl= e in=0D + library's constructor.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +=0D +#include =0D +=0D +EFI_STATUS=0D +EFIAPI=0D +DxeHobListLibNullConstructor (=0D + VOID=0D + )=0D +{=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf= b/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf new file mode 100644 index 0000000000..f17e5ebdbd --- /dev/null +++ b/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf @@ -0,0 +1,28 @@ +## @file=0D +# UEFI Boot Services Table Library implementation.=0D +#=0D +# Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D DxeHobListLibNull=0D + MODULE_TYPE =3D BASE=0D + FILE_GUID =3D 060876c2-0e4e-4c63-8996-6af3710cfa64= =0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D DxeHobListLib=0D + CONSTRUCTOR =3D DxeHobListLibNullConstructor=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D +=0D +[Sources]=0D + DxeHobListLibNull.c=0D diff --git a/UefiPayloadPkg/Library/HobLib/Hob.c b/UefiPayloadPkg/Library/P= ayloadEntryHobLib/Hob.c similarity index 96% rename from UefiPayloadPkg/Library/HobLib/Hob.c rename to UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c index c0b4cc0b0f..23a749edf1 100644 --- a/UefiPayloadPkg/Library/HobLib/Hob.c +++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c @@ -1,7 +1,7 @@ /** @file=0D =0D Copyright (c) 2010, Apple Inc. All rights reserved.
=0D - Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D diff --git a/UefiPayloadPkg/Library/HobLib/HobLib.inf b/UefiPayloadPkg/Libr= ary/PayloadEntryHobLib/HobLib.inf similarity index 87% rename from UefiPayloadPkg/Library/HobLib/HobLib.inf rename to UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf index 030e22a810..cbb4f02efc 100644 --- a/UefiPayloadPkg/Library/HobLib/HobLib.inf +++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf @@ -1,6 +1,6 @@ #/** @file=0D #=0D -# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
= =0D # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 21b360256b..d8277efccd 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -27,6 +27,7 @@ =0D DEFINE SOURCE_DEBUG_ENABLE =3D FALSE=0D DEFINE PS2_KEYBOARD_ENABLE =3D FALSE=0D + DEFINE UNIVERSAL_PAYLOAD =3D FALSE=0D =0D #=0D # SBL: UEFI payload for Slim Bootloader=0D @@ -146,6 +147,13 @@ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeC= offGetEntryPointLib.inf=0D CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMain= tenanceLib.inf=0D SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf=0D + DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf=0D +=0D +!if $(UNIVERSAL_PAYLOAD) =3D=3D TRUE=0D + HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf=0D +!else=0D + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D +!endif=0D =0D #=0D # UEFI & PI=0D @@ -221,10 +229,12 @@ VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf=0D =0D [LibraryClasses.common.SEC]=0D - HobLib|UefiPayloadPkg/Library/HobLib/HobLib.inf=0D + HobLib|UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf=0D PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D + DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull= .inf=0D =0D [LibraryClasses.common.DXE_CORE]=0D + DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull= .inf=0D PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf=0D MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeC= oreMemoryAllocationLib.inf=0D @@ -238,7 +248,6 @@ =0D [LibraryClasses.common.DXE_DRIVER]=0D PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExt= ractGuidedSectionLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeRepor= tStatusCodeLib.inf=0D @@ -251,7 +260,6 @@ =0D [LibraryClasses.common.DXE_RUNTIME_DRIVER]=0D PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf=0D VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ibRuntimeDxe.inf=0D @@ -260,7 +268,6 @@ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeRepor= tStatusCodeLib.inf=0D - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D =0D ##########################################################################= ######=0D #=0D --=20 2.30.0.windows.2