* [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg
@ 2021-06-23 2:52 Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
` (12 more replies)
0 siblings, 13 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel
This whole patch set will enable some basic feature of Universal Payload
in UefiPayloadPkg.
V2:
Modify the 1st, 7th, 10th patch according to the comments.
Zhiguang Liu (12):
UefiPayloadPkg: Add HobLib for UniversalPayload
MdeModulePkg: Add new structure for the Universal Payload Serial Port
Info
UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload
UefiPayloadPkg: Update the function definition of HobConstructor
UefiPayloadPkg: Create separate Payload Entry for UniversalPayload
UefiPayloadPkg: Get and enter DxeCore for Universal Payload
UefiPayloadPkg: Fix up UPL Pcd database
UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc
UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for
devices
UefiPayloadPkg: Add macro to disable some drivers
UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in
UefiPayloadPkg
UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in
UefiPayloadPkg
MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h | 30 ++++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 +++
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 20 +++++++++++---------
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 => PayloadEntryHobLib}/Hob.c | 28 ++++++++++++++--------------
UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf | 2 +-
UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf | 41 +++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 5 +----
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 408 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c | 4 ++--
UefiPayloadPkg/UefiPayloadPkg.dec | 2 ++
UefiPayloadPkg/UefiPayloadPkg.dsc | 52 +++++++++++++++++++++++++++++++++++++++++++---------
UefiPayloadPkg/UefiPayloadPkg.fdf | 10 +++++++++-
24 files changed, 1694 insertions(+), 54 deletions(-)
create mode 100644 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
create mode 100644 UefiPayloadPkg/Include/Library/DxeHobListLib.h
create mode 100644 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
create mode 100644 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
create mode 100644 UefiPayloadPkg/Library/DxeHobLib/HobLib.c
create mode 100644 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
create mode 100644 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
create mode 100644 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c
create mode 100644 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf
rename UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c (92%)
rename UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf (87%)
create mode 100644 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
create mode 100644 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
create mode 100644 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
create mode 100644 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
--
2.30.0.windows.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 23:45 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info Zhiguang Liu
` (11 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You, Ray Ni
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 <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
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 => PayloadEntryHobLib}/Hob.c | 2 +-
UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf | 2 +-
UefiPayloadPkg/UefiPayloadPkg.dsc | 15 +++++++++++----
11 files changed, 838 insertions(+), 6 deletions(-)
diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
new file mode 100644
index 0000000000..7e9b23f6d7
--- /dev/null
+++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
@@ -0,0 +1,27 @@
+/** @file
+ Provides a service to retrieve a pointer to the start of HOB list.
+ Only available to DXE module types.
+
+ This library does not contain any functions or macros. It simply exports a global
+ pointer to the start of HOB list as defined in the Platform Initialization Driver
+ Execution Environment Core Interface Specification. The library constructor must
+ initialize this global pointer to the start of HOB list, so it is available at the
+ module's entry point. Since there is overhead in looking up the pointer to the start
+ of HOB list, only those modules that actually require access to the HOB list
+ should use this library.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __DXE_HOB_LIST_LIB_H__
+#define __DXE_HOB_LIST_LIB_H__
+
+///
+/// Cache copy of the start of HOB list
+///
+extern VOID *gHobList;
+
+#endif
+
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
new file mode 100644
index 0000000000..ff334a0d41
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
@@ -0,0 +1,36 @@
+## @file
+# HOB Library implementation for Payload Phase.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeHobLib
+ MODULE_UNI_FILE = DxeHobLib.uni
+ FILE_GUID = 1a15b8b3-3e8a-4698-87b9-65aad9993b52
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = HobLib|DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ HobLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiPayloadPkg/UefiPayloadPkg.dec
+
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ DxeHobListLib
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
new file mode 100644
index 0000000000..4e02e9c2ae
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
@@ -0,0 +1,16 @@
+// /** @file
+// HOB Library implementation for Payload Phase.
+//
+// The Hoblist will be set by DxeHobListLib or other modules.
+//
+// Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "HOB Library implementation for Payload Phase."
+
+#string STR_MODULE_DESCRIPTION #language en-US "The HOB Library implementation for Payload Phase that doesn't contain HobLibConstructor"
+
diff --git a/UefiPayloadPkg/Library/DxeHobLib/HobLib.c b/UefiPayloadPkg/Library/DxeHobLib/HobLib.c
new file mode 100644
index 0000000000..5d5ede0c17
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/HobLib.c
@@ -0,0 +1,597 @@
+/** @file
+ HOB Library implementation for Payload Phase.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DxeHobListLib.h>
+
+/**
+ Returns the pointer to the HOB list.
+
+ This function returns the pointer to first HOB in the list.
+ For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
+ to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
+ the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
+ Since the System Configuration Table does not exist that the time the DXE Core is
+ launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
+ to manage the pointer to the HOB list.
+
+ If the pointer to the HOB list is NULL, then ASSERT().
+
+ @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+ VOID
+ )
+{
+ ASSERT (gHobList != NULL);
+ return gHobList;
+}
+
+/**
+ Returns the next instance of a HOB type from the starting HOB.
+
+ This function searches the first instance of a HOB type from the starting HOB pointer.
+ If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+
+ If HobStart is NULL, then ASSERT().
+
+ @param Type The HOB type to return.
+ @param HobStart The starting HOB pointer to search from.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ ASSERT (HobStart != NULL);
+
+ Hob.Raw = (UINT8 *) HobStart;
+ //
+ // Parse the HOB list until end of list or matching type is found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+ if (Hob.Header->HobType == Type) {
+ return Hob.Raw;
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+ return NULL;
+}
+
+/**
+ Returns the first instance of a HOB type among the whole HOB list.
+
+ This function searches the first instance of a HOB type among the whole HOB list.
+ If there does not exist such HOB type in the HOB list, it will return NULL.
+
+ If the pointer to the HOB list is NULL, then ASSERT().
+
+ @param Type The HOB type to return.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetFirstHob (
+ IN UINT16 Type
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextHob (Type, HobList);
+}
+
+/**
+ Returns the next instance of the matched GUID HOB from the starting HOB.
+
+ This function searches the first instance of a HOB from the starting HOB pointer.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size information, respectively.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+
+ If Guid is NULL, then ASSERT().
+ If HobStart is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+ @param HobStart A pointer to a Guid.
+
+ @return The next instance of the matched GUID HOB from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ GuidHob.Raw = (UINT8 *) HobStart;
+ while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
+ if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
+ break;
+ }
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+ return GuidHob.Raw;
+}
+
+/**
+ Returns the first instance of the matched GUID HOB among the whole HOB list.
+
+ This function searches the first instance of a HOB among the whole HOB list.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size information, respectively.
+
+ If the pointer to the HOB list is NULL, then ASSERT().
+ If Guid is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+
+ @return The first instance of the matched GUID HOB among the whole HOB list.
+
+**/
+VOID *
+EFIAPI
+GetFirstGuidHob (
+ IN CONST EFI_GUID *Guid
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextGuidHob (Guid, HobList);
+}
+
+/**
+ Get the system boot mode from the HOB list.
+
+ This function returns the system boot mode information from the
+ PHIT HOB in HOB list.
+
+ If the pointer to the HOB list is NULL, then ASSERT().
+
+ @param VOID
+
+ @return The Boot Mode.
+
+**/
+EFI_BOOT_MODE
+EFIAPI
+GetBootModeHob (
+ VOID
+ )
+{
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
+
+ HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
+
+ return HandOffHob->BootMode;
+}
+
+/**
+ Builds a HOB for a loaded PE32 module.
+
+ This function builds a HOB for a loaded PE32 module.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If ModuleName is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ModuleName The GUID File Name of the module.
+ @param MemoryAllocationModule The 64 bit physical address of the module.
+ @param ModuleLength The length of the module in bytes.
+ @param EntryPoint The 64 bit physical address of the module entry point.
+
+**/
+VOID
+EFIAPI
+BuildModuleHob (
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB that describes a chunk of system memory with Owner GUID.
+
+ This function builds a HOB that describes a chunk of system memory.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ResourceType The type of resource described by this HOB.
+ @param ResourceAttribute The resource attributes of the memory described by this HOB.
+ @param PhysicalStart The 64 bit physical address of memory described by this HOB.
+ @param NumberOfBytes The length of the memory described by this HOB in bytes.
+ @param OwnerGUID GUID for the owner of this resource.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorWithOwnerHob (
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes,
+ IN EFI_GUID *OwnerGUID
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB that describes a chunk of system memory.
+
+ This function builds a HOB that describes a chunk of system memory.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ResourceType The type of resource described by this HOB.
+ @param ResourceAttribute The resource attributes of the memory described by this HOB.
+ @param PhysicalStart The 64 bit physical address of memory described by this HOB.
+ @param NumberOfBytes The length of the memory described by this HOB in bytes.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorHob (
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a customized HOB tagged with a GUID for identification and returns
+ the start address of GUID HOB data.
+
+ This function builds a customized HOB tagged with a GUID for identification
+ and returns the start address of GUID HOB data so that caller can fill the customized data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If Guid is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+ HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+
+ @param Guid The GUID to tag the customized HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @retval NULL The GUID HOB could not be allocated.
+ @retval others The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+ return NULL;
+}
+
+/**
+ Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
+ data field, and returns the start address of the GUID HOB data.
+
+ This function builds a customized HOB tagged with a GUID for identification and copies the input
+ data to the HOB data field and returns the start address of the GUID HOB data. It can only be
+ invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If Guid is NULL, then ASSERT().
+ If Data is NULL and DataLength > 0, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+ HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+
+ @param Guid The GUID to tag the customized HOB.
+ @param Data The data to be copied into the data field of the GUID HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @retval NULL The GUID HOB could not be allocated.
+ @retval others The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidDataHob (
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+ return NULL;
+}
+
+/**
+ Builds a Firmware Volume HOB.
+
+ This function builds a Firmware Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+ If the FvImage buffer is not at its required alignment, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a EFI_HOB_TYPE_FV2 HOB.
+
+ This function builds a EFI_HOB_TYPE_FV2 HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+ If the FvImage buffer is not at its required alignment, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+ @param FvName The name of the Firmware Volume.
+ @param FileName The name of the file.
+
+**/
+VOID
+EFIAPI
+BuildFv2Hob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN CONST EFI_GUID *FvName,
+ IN CONST EFI_GUID *FileName
+ )
+{
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a EFI_HOB_TYPE_FV3 HOB.
+
+ This function builds a EFI_HOB_TYPE_FV3 HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+ If the FvImage buffer is not at its required alignment, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+ @param AuthenticationStatus The authentication status.
+ @param ExtractedFv TRUE if the FV was extracted as a file within
+ another firmware volume. FALSE otherwise.
+ @param FvName The name of the Firmware Volume.
+ Valid only if IsExtractedFv is TRUE.
+ @param FileName The name of the file.
+ Valid only if IsExtractedFv is TRUE.
+
+**/
+VOID
+EFIAPI
+BuildFv3Hob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT32 AuthenticationStatus,
+ IN BOOLEAN ExtractedFv,
+ IN CONST EFI_GUID *FvName, OPTIONAL
+ IN CONST EFI_GUID *FileName OPTIONAL
+ )
+{
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a Capsule Volume HOB.
+
+ This function builds a Capsule Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If the platform does not support Capsule Volume HOBs, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Capsule Volume.
+ @param Length The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the CPU.
+
+ This function builds a HOB for the CPU.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
+ @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
+
+**/
+VOID
+EFIAPI
+BuildCpuHob (
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the Stack.
+
+ This function builds a HOB for the stack.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the Stack.
+ @param Length The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the BSP store.
+
+ This function builds a HOB for BSP store.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the BSP.
+ @param Length The length of the BSP store in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the memory allocation.
+
+ This function builds a HOB for the memory allocation.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the memory.
+ @param Length The length of the memory allocation in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildMemoryAllocationHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
new file mode 100644
index 0000000000..8bb31b3f9c
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
@@ -0,0 +1,66 @@
+/** @file
+ This library retrieve the EFI_BOOT_SERVICES pointer from EFI system table in
+ library's constructor.
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <Uefi.h>
+
+VOID *gHobList = NULL;
+
+/**
+ Local implementation of GUID comparasion that doesn't depend on DebugLib::ASSERT().
+
+ This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
+ If there are any bit differences in the two GUIDs, then FALSE is returned.
+
+ @param Guid1 A pointer to a 128 bit GUID.
+ @param Guid2 A pointer to a 128 bit GUID.
+
+ @retval TRUE Guid1 and Guid2 are identical.
+ @retval FALSE Guid1 and Guid2 are not identical.
+**/
+BOOLEAN
+LocalCompareGuid (
+ IN CONST GUID *Guid1,
+ IN CONST GUID *Guid2
+ )
+{
+ UINT64 *Left;
+ UINT64 *Right;
+
+ Left = (UINT64 *) Guid1;
+ Right = (UINT64 *) Guid2;
+
+ return (BOOLEAN) (Left[0] == Right[0] && Left[1] == Right[1]);
+}
+
+/**
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeHobListLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
+ if (LocalCompareGuid (&gEfiHobListGuid, &SystemTable->ConfigurationTable[Index].VendorGuid)) {
+ gHobList = SystemTable->ConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
new file mode 100644
index 0000000000..1115949556
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
@@ -0,0 +1,35 @@
+## @file
+# UEFI Boot Services Table Library implementation.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = UefiPayloadInitHobLib
+ FILE_GUID = ff5c7a21-ab7a-4366-8616-11c6e53247b6
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DxeHobListLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeHobListLibConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ DxeHobListLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiPayloadPkg/UefiPayloadPkg.dec
+
+[Guids]
+ gEfiHobListGuid ## CONSUMES
+
+
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
+ This library retrieve the EFI_BOOT_SERVICES pointer from EFI system table in
+ library's constructor.
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <Uefi.h>
+
+EFI_STATUS
+EFIAPI
+DxeHobListLibNullConstructor (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
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
+# UEFI Boot Services Table Library implementation.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeHobListLibNull
+ MODULE_TYPE = BASE
+ FILE_GUID = 060876c2-0e4e-4c63-8996-6af3710cfa64
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DxeHobListLib
+ CONSTRUCTOR = DxeHobListLibNullConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Sources]
+ DxeHobListLibNull.c
diff --git a/UefiPayloadPkg/Library/HobLib/Hob.c b/UefiPayloadPkg/Library/PayloadEntryHobLib/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
Copyright (c) 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/UefiPayloadPkg/Library/HobLib/HobLib.inf b/UefiPayloadPkg/Library/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
#
-# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 21b360256b..d8277efccd 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -27,6 +27,7 @@
DEFINE SOURCE_DEBUG_ENABLE = FALSE
DEFINE PS2_KEYBOARD_ENABLE = FALSE
+ DEFINE UNIVERSAL_PAYLOAD = FALSE
#
# SBL: UEFI payload for Slim Bootloader
@@ -146,6 +147,13 @@
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+ DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
+
+!if $(UNIVERSAL_PAYLOAD) == TRUE
+ HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
+!else
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+!endif
#
# UEFI & PI
@@ -221,10 +229,12 @@
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
[LibraryClasses.common.SEC]
- HobLib|UefiPayloadPkg/Library/HobLib/HobLib.inf
+ HobLib|UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf
[LibraryClasses.common.DXE_CORE]
+ DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
@@ -238,7 +248,6 @@
[LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -251,7 +260,6 @@
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
@@ -260,7 +268,6 @@
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
################################################################################
#
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload Zhiguang Liu
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Jian J Wang, Hao A Wu, Ray Ni
Add Universal Payload Serial Port Info definition header file according to
Universal Payload's documentation as below:
https://universalpayload.github.io/documentation/
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h | 30 ++++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 +++
2 files changed, 33 insertions(+)
diff --git a/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
new file mode 100644
index 0000000000..87181f7634
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
@@ -0,0 +1,30 @@
+/** @file
+ This file defines the structure for serial port info.
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ - Universal Payload Specification 0.75 (https://universalpayload.github.io/documentation/)
+**/
+
+#ifndef UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+
+#include <UniversalPayload/UniversalPayload.h>
+
+#pragma pack(1)
+typedef struct {
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;
+ BOOLEAN UseMmio;
+ UINT8 RegisterStride;
+ UINT32 BaudRate;
+ EFI_PHYSICAL_ADDRESS RegisterBase;
+} UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO;
+#pragma pack()
+
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION 1
+
+extern GUID gUniversalPayloadSerialPortInfoGuid;
+
+#endif // UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 10602a8f79..ad84421cf3 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -422,6 +422,9 @@
## Include/UniversalPayload/ExtraData.h
gUniversalPayloadExtraDataGuid = {0x15a5baf6, 0x1c91, 0x467d, {0x9d, 0xfb, 0x31, 0x9d, 0x17, 0x8d, 0x4b, 0xb4}}
+ ## Include/UniversalPayload/SerialPortInfo.h
+ gUniversalPayloadSerialPortInfoGuid = { 0xaa7e190d, 0xbe21, 0x4409, { 0x8e, 0x67, 0xa2, 0xcd, 0xf, 0x61, 0xe1, 0x70 } }
+
[Ppis]
## Include/Ppi/AtaController.h
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 04/12] UefiPayloadPkg: Update the function definition of HobConstructor Zhiguang Liu
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
Add a new separate PlatformHookLib for Universal Payload to consume Guid
Hob gUniversalPayloadSerialPortInfoGuid to get serial port information
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/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+)
diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
new file mode 100644
index 0000000000..6705f29505
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
@@ -0,0 +1,82 @@
+/** @file
+ Platform Hook Library instance for UART device.
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <PiDxe.h>
+#include <UniversalPayload/SerialPortInfo.h>
+#include <Library/PlatformHookLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+
+/**
+ Performs platform specific initialization required for the CPU to access
+ the hardware associated with a SerialPortLib instance. This function does
+ not initialize the serial port hardware itself. Instead, it initializes
+ hardware devices that are required for the CPU to access the serial port
+ hardware. This function may be called more than once.
+
+ @retval RETURN_SUCCESS The platform specific initialization succeeded.
+ @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+ VOID
+ )
+{
+ RETURN_STATUS Status;
+ UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;
+ UINT8 *GuidHob;
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
+
+ GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
+ if (GuidHob == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ 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_SERIAL_PORT_INFO_REVISION) {
+ SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (GuidHob);
+ if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
+ //
+ // Return if can't find the Serial Port Info Hob with enough length
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet64S (PcdUartDefaultBaudRate, SerialPortInfo->BaudRate);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ return RETURN_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
+}
diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
new file mode 100644
index 0000000000..41e05ddf54
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
@@ -0,0 +1,41 @@
+## @file
+# Platform Hook Library instance for UART device for Universal Payload.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PlatformHookLib
+ FILE_GUID = 807E05AB-9411-429F-97F0-FE425BF6B094
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformHookLib
+ CONSTRUCTOR = PlatformHookSerialPortInitialize
+
+[Sources]
+ PlatformHookLib.c
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+ HobLib
+ DxeHobListLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UefiPayloadPkg/UefiPayloadPkg.dec
+
+[Guids]
+ gUniversalPayloadSerialPortInfoGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## PRODUCES
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## PRODUCES
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 04/12] UefiPayloadPkg: Update the function definition of HobConstructor
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (2 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload Zhiguang Liu
` (8 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
Update the function defination of HobConstructor to align the Phit Hob
structure.
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/Library/PayloadEntryHobLib/Hob.c | 26 +++++++++++++-------------
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 5 +----
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 16 ++++++++--------
3 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
index 23a749edf1..768c3db770 100644
--- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
+++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
@@ -39,14 +39,14 @@ GetHobList (
/**
Build a Handoff Information Table HOB
- This function initialize a HOB region from EfiMemoryBegin with length
- EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+ This function initialize a HOB region from EfiMemoryBegin to
+ EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
be inside the HOB region.
- @param[in] EfiMemoryBegin Total memory start address
- @param[in] EfiMemoryLength Total memory length reported in handoff HOB.
- @param[in] EfiFreeMemoryBottom Free memory start address
- @param[in] EfiFreeMemoryTop Free memory end address.
+ @param[in] EfiMemoryBottom Total memory start address
+ @param[in] EfiMemoryTop Total memory end address.
+ @param[in] EfiFreeMemoryBottom Free memory start address
+ @param[in] EfiFreeMemoryTop Free memory end address.
@return The pointer to the handoff HOB table.
@@ -54,8 +54,8 @@ GetHobList (
EFI_HOB_HANDOFF_INFO_TABLE*
EFIAPI
HobConstructor (
- IN VOID *EfiMemoryBegin,
- IN UINTN EfiMemoryLength,
+ IN VOID *EfiMemoryBottom,
+ IN VOID *EfiMemoryTop,
IN VOID *EfiFreeMemoryBottom,
IN VOID *EfiFreeMemoryTop
)
@@ -77,11 +77,11 @@ HobConstructor (
Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
- Hob->EfiMemoryTop = (UINTN)EfiMemoryBegin + EfiMemoryLength;
- Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
- Hob->EfiFreeMemoryTop = (UINTN)EfiFreeMemoryTop;
- Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
- Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
+ Hob->EfiMemoryTop = (EFI_PHYSICAL_ADDRESS) EfiMemoryTop;
+ Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS) EfiMemoryBottom;
+ Hob->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS) EfiFreeMemoryTop;
+ Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1);
+ Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
mHobList = Hob;
return Hob;
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 19d2a8d3bd..ed956c447c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -561,7 +561,6 @@ PayloadEntry (
PHYSICAL_ADDRESS DxeCoreEntryPoint;
EFI_HOB_HANDOFF_INFO_TABLE *HandoffHobTable;
UINTN MemBase;
- UINTN MemSize;
UINTN HobMemBase;
UINTN HobMemTop;
EFI_PEI_HOB_POINTERS Hob;
@@ -580,9 +579,7 @@ PayloadEntry (
HobMemBase = ALIGN_VALUE (MemBase + PcdGet32 (PcdPayloadFdMemSize), SIZE_1MB);
HobMemTop = HobMemBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
- // DXE core assumes the memory below HOB region could be used, so include the FV region memory into HOB range.
- MemSize = HobMemTop - MemBase;
- HandoffHobTable = HobConstructor ((VOID *)MemBase, MemSize, (VOID *)HobMemBase, (VOID *)HobMemTop);
+ HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID *)HobMemBase, (VOID *)HobMemTop);
// Build HOB based on information from Bootloader
Status = BuildHobFromBl ();
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 5a1b37be16..1ad7a37023 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -93,14 +93,14 @@ UpdateStackHob (
/**
Build a Handoff Information Table HOB
- This function initialize a HOB region from EfiMemoryBegin with length
- EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+ This function initialize a HOB region from EfiMemoryBegin to
+ EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
be inside the HOB region.
- @param[in] EfiMemoryBegin Total memory start address
- @param[in] EfiMemoryLength Total memory length reported in handoff HOB.
- @param[in] EfiFreeMemoryBottom Free memory start address
- @param[in] EfiFreeMemoryTop Free memory end address.
+ @param[in] EfiMemoryBottom Total memory start address
+ @param[in] EfiMemoryTop Total memory end address.
+ @param[in] EfiFreeMemoryBottom Free memory start address
+ @param[in] EfiFreeMemoryTop Free memory end address.
@return The pointer to the handoff HOB table.
@@ -108,8 +108,8 @@ UpdateStackHob (
EFI_HOB_HANDOFF_INFO_TABLE*
EFIAPI
HobConstructor (
- IN VOID *EfiMemoryBegin,
- IN UINTN EfiMemoryLength,
+ IN VOID *EfiMemoryBottom,
+ IN VOID *EfiMemoryTop,
IN VOID *EfiFreeMemoryBottom,
IN VOID *EfiFreeMemoryTop
);
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (3 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 04/12] UefiPayloadPkg: Update the function definition of HobConstructor Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload Zhiguang Liu
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
This patch create the UniversalPayload Entry based on the UefiPayload
Entry. It implements the logic to find a proper memory range to create the
new Hob and migrate the Hobs from Bootloader.
To make the change history clear, the logic to get the DxeCore will be in
the next patch.
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/UefiPayloadEntry/UniversalPayloadEntry.c | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 402 insertions(+)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
new file mode 100644
index 0000000000..66e87bcb9b
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -0,0 +1,311 @@
+/** @file
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "UefiPayloadEntry.h"
+
+#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+ EFI_RESOURCE_ATTRIBUTE_TESTED | \
+ EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_64_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_PERSISTENT )
+
+#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+ EFI_RESOURCE_ATTRIBUTE_TESTED )
+
+extern VOID *mHobList;
+
+/**
+ Add HOB into HOB list
+
+ @param[in] Hob The HOB to be added into the HOB list.
+**/
+VOID
+AddNewHob (
+ IN EFI_PEI_HOB_POINTERS *Hob
+ )
+{
+ EFI_PEI_HOB_POINTERS NewHob;
+
+ if (Hob->Raw == NULL) {
+ return;
+ }
+ NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
+
+ if (NewHob.Header != NULL) {
+ CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - sizeof (EFI_HOB_GENERIC_HEADER));
+ }
+}
+
+/**
+ Found the Resource Descriptor HOB that contains a range
+
+ @param[in] Base Memory start address
+ @param[in] Top Memory Top.
+
+ @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindResourceDescriptorByRange (
+ VOID *HobList,
+ EFI_PHYSICAL_ADDRESS Base,
+ EFI_PHYSICAL_ADDRESS Top
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+
+ for (Hob.Raw = (UINT8 *) HobList; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+ //
+ // Skip all HOBs except Resource Descriptor HOBs
+ //
+ if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+ continue;
+ }
+
+ //
+ // Skip Resource Descriptor HOBs that do not describe tested system memory
+ //
+ ResourceHob = Hob.ResourceDescriptor;
+ if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
+ continue;
+ }
+ if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
+ continue;
+ }
+
+ //
+ // Skip Resource Descriptor HOBs that do not contain the PHIT range EfiFreeMemoryBottom..EfiFreeMemoryTop
+ //
+ if (Base < ResourceHob->PhysicalStart) {
+ continue;
+ }
+ if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
+ continue;
+ }
+ return ResourceHob;
+ }
+ return NULL;
+}
+
+/**
+ Find the highest below 4G memory resource descriptor, except the input Resource Descriptor.
+
+ @param[in] HobList Hob start address
+ @param[in] MinimalNeededSize Minimal needed size.
+ @param[in] ExceptResourceHob Ignore this Resource Descriptor.
+
+ @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindAnotherHighestBelow4GResourceDescriptor (
+ IN VOID *HobList,
+ IN UINTN MinimalNeededSize,
+ IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob;
+ ReturnResourceHob = NULL;
+
+ for (Hob.Raw = (UINT8 *) HobList; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+ //
+ // Skip all HOBs except Resource Descriptor HOBs
+ //
+ if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+ continue;
+ }
+
+ //
+ // Skip Resource Descriptor HOBs that do not describe tested system memory
+ //
+ ResourceHob = Hob.ResourceDescriptor;
+ if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
+ continue;
+ }
+ if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
+ continue;
+ }
+
+ //
+ // Skip if the Resource Descriptor HOB equals to ExceptResourceHob
+ //
+ if (ResourceHob == ExceptResourceHob) {
+ continue;
+ }
+ //
+ // Skip Resource Descriptor HOBs that are beyond 4G
+ //
+ if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_4GB) {
+ continue;
+ }
+ //
+ // Skip Resource Descriptor HOBs that are too small
+ //
+ if (ResourceHob->ResourceLength < MinimalNeededSize) {
+ continue;
+ }
+
+ //
+ // Return the topest Resource Descriptor
+ //
+ if (ReturnResourceHob == NULL) {
+ ReturnResourceHob = ResourceHob;
+ } else {
+ if (ReturnResourceHob->PhysicalStart < ResourceHob->PhysicalStart) {
+ ReturnResourceHob = ResourceHob;
+ }
+ }
+ }
+ return ReturnResourceHob;
+}
+
+/**
+ It will build HOBs based on information from bootloaders.
+
+ @retval EFI_SUCCESS If it completed successfully.
+ @retval Others If it failed to build required HOBs.
+**/
+EFI_STATUS
+BuildHobs (
+ IN UINTN BootloaderParameter
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ UINTN MinimalNeededSize;
+ EFI_PHYSICAL_ADDRESS FreeMemoryBottom;
+ EFI_PHYSICAL_ADDRESS FreeMemoryTop;
+ EFI_PHYSICAL_ADDRESS MemoryBottom;
+ EFI_PHYSICAL_ADDRESS MemoryTop;
+ EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+
+ Hob.Raw = (UINT8 *) BootloaderParameter;
+ MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+
+ ASSERT (Hob.Raw != NULL);
+ ASSERT ((UINTN) Hob.HandoffInformationTable->EfiFreeMemoryTop == Hob.HandoffInformationTable->EfiFreeMemoryTop);
+ ASSERT ((UINTN) Hob.HandoffInformationTable->EfiMemoryTop == Hob.HandoffInformationTable->EfiMemoryTop);
+ ASSERT ((UINTN) Hob.HandoffInformationTable->EfiFreeMemoryBottom == Hob.HandoffInformationTable->EfiFreeMemoryBottom);
+ ASSERT ((UINTN) Hob.HandoffInformationTable->EfiMemoryBottom == Hob.HandoffInformationTable->EfiMemoryBottom);
+
+
+ //
+ // Try to find Resource Descriptor HOB that contains Hob range EfiMemoryBottom..EfiMemoryTop
+ //
+ PhitResourceHob = FindResourceDescriptorByRange(Hob.Raw, Hob.HandoffInformationTable->EfiMemoryBottom, Hob.HandoffInformationTable->EfiMemoryTop);
+ if (PhitResourceHob == NULL) {
+ //
+ // Boot loader's Phit Hob is not in an available Resource Descriptor, find another Resource Descriptor for new Phit Hob
+ //
+ ResourceHob = FindAnotherHighestBelow4GResourceDescriptor(Hob.Raw, MinimalNeededSize, NULL);
+ if (ResourceHob == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ MemoryBottom = ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
+ FreeMemoryBottom = MemoryBottom;
+ FreeMemoryTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength;
+ MemoryTop = FreeMemoryTop;
+ } else if (PhitResourceHob->PhysicalStart + PhitResourceHob->ResourceLength - Hob.HandoffInformationTable->EfiMemoryTop >= MinimalNeededSize) {
+ //
+ // New availiable Memory range in new hob is right above memory top in old hob.
+ //
+ MemoryBottom = Hob.HandoffInformationTable->EfiFreeMemoryTop;
+ FreeMemoryBottom = Hob.HandoffInformationTable->EfiMemoryTop;
+ FreeMemoryTop = FreeMemoryBottom + MinimalNeededSize;
+ MemoryTop = FreeMemoryTop;
+ } else if (Hob.HandoffInformationTable->EfiMemoryBottom - PhitResourceHob->PhysicalStart >= MinimalNeededSize) {
+ //
+ // New availiable Memory range in new hob is right below memory bottom in old hob.
+ //
+ MemoryBottom = Hob.HandoffInformationTable->EfiMemoryBottom - MinimalNeededSize;
+ FreeMemoryBottom = MemoryBottom;
+ FreeMemoryTop = Hob.HandoffInformationTable->EfiMemoryBottom;
+ MemoryTop = Hob.HandoffInformationTable->EfiMemoryTop;
+ } else {
+ //
+ // In the Resource Descriptor HOB contains boot loader Hob, there is no enough free memory size for payload hob
+ // Find another Resource Descriptor Hob
+ //
+ ResourceHob = FindAnotherHighestBelow4GResourceDescriptor(Hob.Raw, MinimalNeededSize, PhitResourceHob);
+ if (ResourceHob == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ MemoryBottom = ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
+ FreeMemoryBottom = MemoryBottom;
+ FreeMemoryTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength;
+ MemoryTop = FreeMemoryTop;
+ }
+ HobConstructor ((VOID *) (UINTN) MemoryBottom, (VOID *) (UINTN) MemoryTop, (VOID *) (UINTN) FreeMemoryBottom, (VOID *) (UINTN) FreeMemoryTop);
+ //
+ // From now on, mHobList will point to the new Hob range.
+ //
+
+ //
+ // Since payload created new Hob, move all hobs except PHIT from boot loader hob list.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+ if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
+ // Add this hob to payload HOB
+ AddNewHob (&Hob);
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Entry point to the C language phase of UEFI payload.
+
+ @retval It will not return if SUCCESS, and return error when passing bootloader parameter.
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN UINTN BootloaderParameter
+ )
+{
+ EFI_STATUS Status;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandoffHobTable;
+ EFI_PEI_HOB_POINTERS Hob;
+
+ mHobList = (VOID *) BootloaderParameter;
+ // Call constructor for all libraries
+ ProcessLibraryConstructorList ();
+
+ DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n"));
+ DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof(UINTN)));
+
+ // Initialize floating point operating environment to be compliant with UEFI spec.
+ InitializeFloatingPointUnits ();
+
+ // Build HOB based on information from Bootloader
+ Status = BuildHobs (BootloaderParameter);
+
+ //
+ // Mask off all legacy 8259 interrupt sources
+ //
+ IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+ IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
+ HandoffHobTable = (EFI_HOB_HANDOFF_INFO_TABLE *) GetFirstHob(EFI_HOB_TYPE_HANDOFF);
+ Hob.HandoffInformationTable = HandoffHobTable;
+
+ // Should not get here
+ CpuDeadLoop ();
+ return EFI_SUCCESS;
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
new file mode 100644
index 0000000000..58ff87d969
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -0,0 +1,91 @@
+## @file
+# This is the first module for UEFI payload.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = UniversalPayloadEntry
+ FILE_GUID = D4F0F269-1209-4A66-8039-C4D5A700EA4E
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ UniversalPayloadEntry.c
+ LoadDxeCore.c
+ MemoryAllocation.c
+
+[Sources.Ia32]
+ X64/VirtualMemory.h
+ X64/VirtualMemory.c
+ Ia32/DxeLoadFunc.c
+ Ia32/IdtVectorAsm.nasm
+
+[Sources.X64]
+ X64/VirtualMemory.h
+ X64/VirtualMemory.c
+ X64/DxeLoadFunc.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+ UefiPayloadPkg/UefiPayloadPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ BaseLib
+ SerialPortLib
+ IoLib
+ HobLib
+ PeCoffLib
+ UefiCpuLib
+
+[Guids]
+ gEfiMemoryTypeInformationGuid
+ gEfiFirmwareFileSystem2Guid
+ gUefiSystemTableInfoGuid
+ gEfiGraphicsInfoHobGuid
+ gEfiGraphicsDeviceInfoHobGuid
+ gUefiAcpiBoardInfoGuid
+ gEfiSmbiosTableGuid
+ gEfiAcpiTableGuid
+ gUefiSerialPortInfoGuid
+
+[FeaturePcd.IA32]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
+
+[FeaturePcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES
+
+
+[Pcd.IA32,Pcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ## CONSUMES
+
+ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase
+ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize
+ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop
+ gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (4 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database Zhiguang Liu
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
>From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information,
and get the Dxe Core from the FV.
Also, make sure if there are muliple FV hob, the FV hob pointing to this FV
will be the first in the hob list.
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/UefiPayloadEntry/LoadDxeCore.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 17 +++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 1 +
UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c | 4 ++--
5 files changed, 109 insertions(+), 4 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index de9dbb0b0e..f5d70c59f8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -305,3 +305,50 @@ LoadDxeCore (
return EFI_SUCCESS;
}
+
+/**
+ Find DXE core from FV and build DXE core HOBs.
+
+ @param[in] DxeFv The FV where to find the DXE core.
+ @param[out] DxeCoreEntryPoint DXE core entry point
+
+ @retval EFI_SUCCESS If it completed successfully.
+ @retval EFI_NOT_FOUND If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+ IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+ OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
+ )
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER *FileHeader;
+ VOID *PeCoffImage;
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+
+ //
+ // Find DXE core file from DXE FV
+ //
+ Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID **)&PeCoffImage);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get DXE core info
+ //
+ Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, DxeCoreEntryPoint);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
+
+ return EFI_SUCCESS;
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 1ad7a37023..dff7b6b87f 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -33,6 +33,8 @@
#include <Guid/GraphicsInfoHob.h>
#include <UniversalPayload/SmbiosTable.h>
#include <UniversalPayload/AcpiTable.h>
+#include <UniversalPayload/UniversalPayload.h>
+#include <UniversalPayload/ExtraData.h>
#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
@@ -127,6 +129,21 @@ LoadDxeCore (
OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
);
+/**
+ Find DXE core from FV and build DXE core HOBs.
+
+ @param[in] DxeFv The FV where to find the DXE core.
+ @param[out] DxeCoreEntryPoint DXE core entry point
+
+ @retval EFI_SUCCESS If it completed successfully.
+ @retval EFI_NOT_FOUND If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+ IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+ OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
+ );
+
/**
Transfers control to DxeCore.
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 66e87bcb9b..9d59454486 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -179,7 +179,8 @@ FindAnotherHighestBelow4GResourceDescriptor (
**/
EFI_STATUS
BuildHobs (
- IN UINTN BootloaderParameter
+ IN UINTN BootloaderParameter,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv
)
{
EFI_PEI_HOB_POINTERS Hob;
@@ -190,6 +191,10 @@ BuildHobs (
EFI_PHYSICAL_ADDRESS MemoryTop;
EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
+ UINT8 *GuidHob;
+ EFI_HOB_FIRMWARE_VOLUME *FvHob;
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
Hob.Raw = (UINT8 *) BootloaderParameter;
MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
@@ -254,6 +259,10 @@ BuildHobs (
// From now on, mHobList will point to the new Hob range.
//
+ //
+ // Create an empty FvHob for the DXE FV that contains DXE core.
+ //
+ BuildFvHob ((EFI_PHYSICAL_ADDRESS) 0, 0);
//
// Since payload created new Hob, move all hobs except PHIT from boot loader hob list.
//
@@ -265,6 +274,29 @@ BuildHobs (
Hob.Raw = GET_NEXT_HOB (Hob);
}
+ //
+ // Get DXE FV location
+ //
+ GuidHob = GetFirstGuidHob(&gUniversalPayloadExtraDataGuid);
+ ASSERT (GuidHob != NULL);
+ GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ ASSERT (sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob));
+ ASSERT (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob));
+ ASSERT (GenericHeader->Length >= (sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY)));
+ ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (GuidHob);
+ ASSERT (ExtraData->Count == 1);
+ ASSERT (AsciiStrCmp (ExtraData->Entry[0].Identifier, "uefi_fv") == 0);
+
+ *DxeFv = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) ExtraData->Entry[0].Base;
+ ASSERT ((*DxeFv)->FvLength == ExtraData->Entry[0].Size);
+
+ //
+ // Update DXE FV information to first fv hob in the hob list, which
+ // is the empty FvHob created before.
+ //
+ FvHob = GetFirstHob (EFI_HOB_TYPE_FV);
+ FvHob->BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) *DxeFv;
+ FvHob->Length = (*DxeFv)->FvLength;
return EFI_SUCCESS;
}
@@ -280,10 +312,13 @@ _ModuleEntryPoint (
)
{
EFI_STATUS Status;
+ PHYSICAL_ADDRESS DxeCoreEntryPoint;
EFI_HOB_HANDOFF_INFO_TABLE *HandoffHobTable;
EFI_PEI_HOB_POINTERS Hob;
+ EFI_FIRMWARE_VOLUME_HEADER *DxeFv;
mHobList = (VOID *) BootloaderParameter;
+ DxeFv = NULL;
// Call constructor for all libraries
ProcessLibraryConstructorList ();
@@ -294,7 +329,11 @@ _ModuleEntryPoint (
InitializeFloatingPointUnits ();
// Build HOB based on information from Bootloader
- Status = BuildHobs (BootloaderParameter);
+ Status = BuildHobs (BootloaderParameter, &DxeFv);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);
+ ASSERT_EFI_ERROR (Status);
//
// Mask off all legacy 8259 interrupt sources
@@ -304,6 +343,7 @@ _ModuleEntryPoint (
HandoffHobTable = (EFI_HOB_HANDOFF_INFO_TABLE *) GetFirstHob(EFI_HOB_TYPE_HANDOFF);
Hob.HandoffInformationTable = HandoffHobTable;
+ HandOffToDxeCore (DxeCoreEntryPoint, Hob);
// Should not get here
CpuDeadLoop ();
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 58ff87d969..77cd25aafd 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -62,6 +62,7 @@
gEfiSmbiosTableGuid
gEfiAcpiTableGuid
gUefiSerialPortInfoGuid
+ gUniversalPayloadExtraDataGuid
[FeaturePcd.IA32]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 73ea30e7a2..dec87ee1ef 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -66,8 +66,8 @@ HandOffToDxeCore (
//
// Get the address and size of the GHCB pages
//
- GhcbBase = (VOID *) PcdGet64 (PcdGhcbBase);
- GhcbSize = PcdGet64 (PcdGhcbSize);
+ GhcbBase = 0;
+ GhcbSize = 0;
PageTables = 0;
if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (5 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 23:45 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc Zhiguang Liu
` (5 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
V1:
Edk2 bootloader will pass the pei pcd database, and UPL also contain a
PCD database.
Dxe PCD driver has the assumption that the two PCD database can be
catenated and the local token number should be successive。
This patch will manually fix up the UPL PCD database to meet that
assumption.
V2:
Update the function comments
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 19 ++++++++++++-------
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 2 ++
UefiPayloadPkg/UefiPayloadPkg.dec | 2 ++
UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
6 files changed, 119 insertions(+), 7 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index f5d70c59f8..0b6cb47cd0 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -114,20 +114,23 @@ LoadPeCoffImage (
}
/**
- This function searchs a given file type within a valid FV.
+ This function searchs a given file type with a given Guid within a valid FV.
+ If input Guid is NULL, will locate the first section having the given file type
@param FvHeader A pointer to firmware volume header that contains the set of files
to be searched.
@param FileType File type to be searched.
+ @param Guid Will ignore if it is NULL.
@param FileHeader A pointer to the discovered file, if successful.
@retval EFI_SUCCESS Successfully found FileType
@retval EFI_NOT_FOUND File type can't be found.
**/
EFI_STATUS
-FvFindFile (
+FvFindFileByTypeGuid (
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
IN EFI_FV_FILETYPE FileType,
+ IN EFI_GUID *Guid OPTIONAL,
OUT EFI_FFS_FILE_HEADER **FileHeader
)
{
@@ -171,8 +174,10 @@ FvFindFile (
// Look for file type
//
if (File->Type == FileType) {
- *FileHeader = File;
- return EFI_SUCCESS;
+ if (Guid == NULL || CompareGuid(&File->Name, Guid)) {
+ *FileHeader = File;
+ return EFI_SUCCESS;
+ }
}
}
@@ -266,7 +271,7 @@ LoadDxeCore (
//
// DXE FV is inside Payload FV. Here find DXE FV from Payload FV
//
- Status = FvFindFile (PayloadFv, EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &FileHeader);
+ Status = FvFindFileByTypeGuid (PayloadFv, EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, NULL, &FileHeader);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -283,7 +288,7 @@ LoadDxeCore (
//
// Find DXE core file from DXE FV
//
- Status = FvFindFile (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
+ Status = FvFindFileByTypeGuid (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, NULL, &FileHeader);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -330,7 +335,7 @@ UniversalLoadDxeCore (
//
// Find DXE core file from DXE FV
//
- Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
+ Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL, &FileHeader);
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index dff7b6b87f..331724c687 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -35,6 +35,7 @@
#include <UniversalPayload/AcpiTable.h>
#include <UniversalPayload/UniversalPayload.h>
#include <UniversalPayload/ExtraData.h>
+#include <Guid/PcdDataBaseSignatureGuid.h>
#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
@@ -159,4 +160,48 @@ HandOffToDxeCore (
IN EFI_PEI_HOB_POINTERS HobList
);
+EFI_STATUS
+FixUpPcdDatabase (
+ IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
+ );
+
+/**
+ This function searchs a given section type within a valid FFS file.
+
+ @param FileHeader A pointer to the file header that contains the set of sections to
+ be searched.
+ @param SearchType The value of the section type to search.
+ @param SectionData A pointer to the discovered section, if successful.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+FileFindSection (
+ IN EFI_FFS_FILE_HEADER *FileHeader,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **SectionData
+ );
+
+/**
+ This function searchs a given file type with a given Guid within a valid FV.
+ If input Guid is NULL, will locate the first section having the given file type
+
+ @param FvHeader A pointer to firmware volume header that contains the set of files
+ to be searched.
+ @param FileType File type to be searched.
+ @param Guid Will ignore if it is NULL.
+ @param FileHeader A pointer to the discovered file, if successful.
+
+ @retval EFI_SUCCESS Successfully found FileType
+ @retval EFI_NOT_FOUND File type can't be found.
+**/
+EFI_STATUS
+FvFindFileByTypeGuid (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
+ IN EFI_FV_FILETYPE FileType,
+ IN EFI_GUID *Guid OPTIONAL,
+ OUT EFI_FFS_FILE_HEADER **FileHeader
+ );
#endif
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 9d59454486..b8c1317df0 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -25,6 +25,62 @@
extern VOID *mHobList;
+/**
+ Some bootloader may pass a pcd database, and UPL also contain a PCD database.
+ Dxe PCD driver has the assumption that the two PCD database can be catenated and
+ the local token number should be successive。
+ This function will fix up the UPL PCD database to meet that assumption.
+
+ @param[in] DxeFv The FV where to find the Universal PCD database.
+
+ @retval EFI_SUCCESS If it completed successfully.
+ @retval other Failed to fix up.
+**/
+EFI_STATUS
+FixUpPcdDatabase (
+ IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
+ )
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER *FileHeader;
+ VOID *PcdRawData;
+ PEI_PCD_DATABASE *PeiDatabase;
+ PEI_PCD_DATABASE *UplDatabase;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ DYNAMICEX_MAPPING *ExMapTable;
+ UINTN Index;
+
+ GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
+ if (GuidHob == NULL) {
+ //
+ // No fix-up is needed.
+ //
+ return EFI_SUCCESS;
+ }
+ PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
+ DEBUG ((DEBUG_INFO, "Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount));
+
+ Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DRIVER, PcdGetPtr (PcdPcdDriverFile), &FileHeader);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ UplDatabase = (PEI_PCD_DATABASE *) PcdRawData;
+ ExMapTable = (DYNAMICEX_MAPPING *) (UINTN) ((UINTN) PcdRawData + UplDatabase->ExMapTableOffset);
+
+ for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
+ ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
+ }
+ DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n"));
+ return EFI_SUCCESS;
+}
+
/**
Add HOB into HOB list
@@ -332,6 +388,7 @@ _ModuleEntryPoint (
Status = BuildHobs (BootloaderParameter, &DxeFv);
ASSERT_EFI_ERROR (Status);
+ FixUpPcdDatabase (DxeFv);
Status = UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);
ASSERT_EFI_ERROR (Status);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 77cd25aafd..76d7e4791c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -63,6 +63,7 @@
gEfiAcpiTableGuid
gUefiSerialPortInfoGuid
gUniversalPayloadExtraDataGuid
+ gPcdDataBaseHobGuid
[FeaturePcd.IA32]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
@@ -72,6 +73,7 @@
[Pcd.IA32,Pcd.X64]
+ gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec
index 105e1f5a1c..d84f560995 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -72,3 +72,5 @@ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x
# Size of the region used by UEFI in permanent memory
gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x02000000|UINT32|0x00000017
+
+gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index d8277efccd..e3d669a6d6 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -298,6 +298,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
+ gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }
!if $(SOURCE_DEBUG_ENABLE)
gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (6 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices Zhiguang Liu
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
Add a new macro "UNIVERSAL_PAYLOAD" to build Universal Payload.
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/UefiPayloadPkg.dsc | 22 ++++++++++++++++++----
UefiPayloadPkg/UefiPayloadPkg.fdf | 3 ++-
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index e3d669a6d6..155aea4bc4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -196,7 +196,11 @@
TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+!if $(UNIVERSAL_PAYLOAD) == TRUE
+ PlatformHookLib|UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
+!else
PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
+!endif
PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
@@ -213,10 +217,12 @@
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
!endif
PlatformSupportLib|UefiPayloadPkg/Library/PlatformSupportLibNull/PlatformSupportLibNull.inf
-!if $(BOOTLOADER) == "COREBOOT"
- BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
-!else
- BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+!if $(UNIVERSAL_PAYLOAD) == FALSE
+ !if $(BOOTLOADER) == "COREBOOT"
+ BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
+ !else
+ BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+ !endif
!endif
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -383,10 +389,18 @@
!if "IA32" in $(ARCH)
[Components.IA32]
+ !if $(UNIVERSAL_PAYLOAD) == TRUE
+ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+ !else
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+ !endif
!else
[Components.X64]
+ !if $(UNIVERSAL_PAYLOAD) == TRUE
+ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+ !else
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+ !endif
!endif
[Components.X64]
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index ed7fbcaddb..6073f9c1b4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -52,8 +52,9 @@ READ_STATUS = TRUE
READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE
+!if $(UNIVERSAL_PAYLOAD) == FALSE
INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
-
+!endif
FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
SECTION FV_IMAGE = DXEFV
}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (7 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
` (3 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
Some boot loader may already reserve MMIO/IO resource for IOAPIC and HPET,
so remove the assert when reserve MMIO/IO resource for IOAPIC and HPET
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/BlSupportDxe/BlSupportDxe.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index ffd3427fb3..04e968a232 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -41,13 +41,12 @@ ReserveResourceInGcd (
);
if (EFI_ERROR (Status)) {
DEBUG ((
- DEBUG_ERROR,
+ DEBUG_WARN,
"Failed to add memory space :0x%lx 0x%lx\n",
BaseAddress,
Length
));
}
- ASSERT_EFI_ERROR (Status);
Status = gDS->AllocateMemorySpace (
EfiGcdAllocateAddress,
GcdType,
@@ -57,14 +56,20 @@ ReserveResourceInGcd (
ImageHandle,
NULL
);
- ASSERT_EFI_ERROR (Status);
} else {
Status = gDS->AddIoSpace (
GcdType,
BaseAddress,
Length
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_WARN,
+ "Failed to add IO space :0x%lx 0x%lx\n",
+ BaseAddress,
+ Length
+ ));
+ }
Status = gDS->AllocateIoSpace (
EfiGcdAllocateAddress,
GcdType,
@@ -74,7 +79,6 @@ ReserveResourceInGcd (
ImageHandle,
NULL
);
- ASSERT_EFI_ERROR (Status);
}
return Status;
}
@@ -106,11 +110,9 @@ BlDxeEntryPoint (
//
// Report MMIO/IO Resources
//
- Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC
- ASSERT_EFI_ERROR (Status);
+ ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC
- Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET
- ASSERT_EFI_ERROR (Status);
+ ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET
//
// Find the frame buffer information and update PCDs
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (8 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 23:48 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg Zhiguang Liu
` (2 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
V2:
Change DISABLE_VARIABLE to EMU_VARIABLE_ENABLE
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++++++++++-
UefiPayloadPkg/UefiPayloadPkg.fdf | 7 +++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 155aea4bc4..85055e9091 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -87,6 +87,12 @@
#
DEFINE SHELL_TYPE = BUILD_SHELL
+ #
+ # Disable features
+ #
+ DEFINE EMU_VARIABLE_ENABLE = FALSE
+ DEFINE DISABLE_RESET_SYSTEM = FALSE
+
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -431,10 +437,13 @@
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+!if $(DISABLE_RESET_SYSTEM) == FALSE
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+!if $(EMU_VARIABLE_ENABLE) == FALSE
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-
+!endif
#
# Following are the DXE drivers
#
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 6073f9c1b4..4d186692da 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -105,9 +105,16 @@ INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+
+!if $(DISABLE_RESET_SYSTEM) == FALSE
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
+
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+
+!if $(EMU_VARIABLE_ENABLE) == FALSE
INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!endif
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (9 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange " Zhiguang Liu
[not found] ` <168B167444E9F647.3239@groups.io>
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
To install ACPI SDT protocol, define PcdInstallAcpiSdtProtocol as TRUE.
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/UefiPayloadPkg.dsc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 85055e9091..c0de7fc734 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -290,6 +290,8 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+ ## This PCD specified whether ACPI SDT protocol is installed.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
[PcdsFixedAtBuild]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch V2 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in UefiPayloadPkg
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
` (10 preceding siblings ...)
2021-06-23 2:52 ` [Patch V2 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg Zhiguang Liu
@ 2021-06-23 2:52 ` Zhiguang Liu
[not found] ` <168B167444E9F647.3239@groups.io>
12 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 2:52 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
This PCD will be consumed by Universal Payload
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/UefiPayloadPkg.dsc | 1 +
1 file changed, 1 insertion(+)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index c0de7fc734..35d714a6f9 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -362,6 +362,7 @@
################################################################################
[PcdsDynamicExDefault]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers
[not found] ` <168B167444E9F647.3239@groups.io>
@ 2021-06-23 8:50 ` Zhiguang Liu
0 siblings, 0 replies; 17+ messages in thread
From: Zhiguang Liu @ 2021-06-23 8:50 UTC (permalink / raw)
To: devel@edk2.groups.io, Liu, Zhiguang; +Cc: Ma, Maurice, Dong, Guo, You, Benjamin
[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]
Sorry, the two if condition statements about EMU_VARIABLE_ENABLE should be
!if $(EMU_VARIABLE_ENABLE) == TRUE
When the EMU_VARIABLE_ENABLE Macro is true, will include the VariableRuntimeDxe.inf driver.
Thanks
Zhiguang
________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Zhiguang Liu <zhiguang.liu@intel.com>
Sent: Wednesday, June 23, 2021 10:52
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo <guo.dong@intel.com>; You, Benjamin <benjamin.you@intel.com>
Subject: [edk2-devel] [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers
V2:
Change DISABLE_VARIABLE to EMU_VARIABLE_ENABLE
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++++++++++-
UefiPayloadPkg/UefiPayloadPkg.fdf | 7 +++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 155aea4bc4..85055e9091 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -87,6 +87,12 @@
#
DEFINE SHELL_TYPE = BUILD_SHELL
+ #
+ # Disable features
+ #
+ DEFINE EMU_VARIABLE_ENABLE = FALSE
+ DEFINE DISABLE_RESET_SYSTEM = FALSE
+
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -431,10 +437,13 @@
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+!if $(DISABLE_RESET_SYSTEM) == FALSE
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+!if $(EMU_VARIABLE_ENABLE) == FALSE
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-
+!endif
#
# Following are the DXE drivers
#
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 6073f9c1b4..4d186692da 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -105,9 +105,16 @@ INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+
+!if $(DISABLE_RESET_SYSTEM) == FALSE
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
+
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+
+!if $(EMU_VARIABLE_ENABLE) == FALSE
INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!endif
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
--
2.30.0.windows.2
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76897): https://edk2.groups.io/g/devel/message/76897
Mute This Topic: https://groups.io/mt/83730189/1779286
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [zhiguang.liu@intel.com]
-=-=-=-=-=-=
[-- Attachment #2: Type: text/html, Size: 8656 bytes --]
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database
2021-06-23 2:52 ` [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database Zhiguang Liu
@ 2021-06-23 23:45 ` Guo Dong
0 siblings, 0 replies; 17+ messages in thread
From: Guo Dong @ 2021-06-23 23:45 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Ma, Maurice, You, Benjamin
Reviewed-by: Guo Dong <guo.dong@intel.com>
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Tuesday, June 22, 2021 7:53 PM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> <guo.dong@intel.com>; You, Benjamin <benjamin.you@intel.com>
> Subject: [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database
>
> V1:
> Edk2 bootloader will pass the pei pcd database, and UPL also contain a
> PCD database.
> Dxe PCD driver has the assumption that the two PCD database can be
> catenated and the local token number should be successive。
> This patch will manually fix up the UPL PCD database to meet that
> assumption.
> V2:
> Update the function comments
>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 19
> ++++++++++++-------
> UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 45
> +++++++++++++++++++++++++++++++++++++++++++++
> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 57
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 2 ++
> UefiPayloadPkg/UefiPayloadPkg.dec | 2 ++
> UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
> 6 files changed, 119 insertions(+), 7 deletions(-)
>
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> index f5d70c59f8..0b6cb47cd0 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> @@ -114,20 +114,23 @@ LoadPeCoffImage (
> }
>
>
>
> /**
>
> - This function searchs a given file type within a valid FV.
>
> + This function searchs a given file type with a given Guid within a valid FV.
>
> + If input Guid is NULL, will locate the first section having the given file type
>
>
>
> @param FvHeader A pointer to firmware volume header that contains
> the set of files
>
> to be searched.
>
> @param FileType File type to be searched.
>
> + @param Guid Will ignore if it is NULL.
>
> @param FileHeader A pointer to the discovered file, if successful.
>
>
>
> @retval EFI_SUCCESS Successfully found FileType
>
> @retval EFI_NOT_FOUND File type can't be found.
>
> **/
>
> EFI_STATUS
>
> -FvFindFile (
>
> +FvFindFileByTypeGuid (
>
> IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
>
> IN EFI_FV_FILETYPE FileType,
>
> + IN EFI_GUID *Guid OPTIONAL,
>
> OUT EFI_FFS_FILE_HEADER **FileHeader
>
> )
>
> {
>
> @@ -171,8 +174,10 @@ FvFindFile (
> // Look for file type
>
> //
>
> if (File->Type == FileType) {
>
> - *FileHeader = File;
>
> - return EFI_SUCCESS;
>
> + if (Guid == NULL || CompareGuid(&File->Name, Guid)) {
>
> + *FileHeader = File;
>
> + return EFI_SUCCESS;
>
> + }
>
> }
>
> }
>
>
>
> @@ -266,7 +271,7 @@ LoadDxeCore (
> //
>
> // DXE FV is inside Payload FV. Here find DXE FV from Payload FV
>
> //
>
> - Status = FvFindFile (PayloadFv,
> EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &FileHeader);
>
> + Status = FvFindFileByTypeGuid (PayloadFv,
> EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, NULL, &FileHeader);
>
> if (EFI_ERROR (Status)) {
>
> return Status;
>
> }
>
> @@ -283,7 +288,7 @@ LoadDxeCore (
> //
>
> // Find DXE core file from DXE FV
>
> //
>
> - Status = FvFindFile (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
>
> + Status = FvFindFileByTypeGuid (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE,
> NULL, &FileHeader);
>
> if (EFI_ERROR (Status)) {
>
> return Status;
>
> }
>
> @@ -330,7 +335,7 @@ UniversalLoadDxeCore (
> //
>
> // Find DXE core file from DXE FV
>
> //
>
> - Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
>
> + Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL,
> &FileHeader);
>
> if (EFI_ERROR (Status)) {
>
> return Status;
>
> }
>
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> index dff7b6b87f..331724c687 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> @@ -35,6 +35,7 @@
> #include <UniversalPayload/AcpiTable.h>
>
> #include <UniversalPayload/UniversalPayload.h>
>
> #include <UniversalPayload/ExtraData.h>
>
> +#include <Guid/PcdDataBaseSignatureGuid.h>
>
>
>
> #define LEGACY_8259_MASK_REGISTER_MASTER 0x21
>
> #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
>
> @@ -159,4 +160,48 @@ HandOffToDxeCore (
> IN EFI_PEI_HOB_POINTERS HobList
>
> );
>
>
>
> +EFI_STATUS
>
> +FixUpPcdDatabase (
>
> + IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
>
> + );
>
> +
>
> +/**
>
> + This function searchs a given section type within a valid FFS file.
>
> +
>
> + @param FileHeader A pointer to the file header that contains the set
> of sections to
>
> + be searched.
>
> + @param SearchType The value of the section type to search.
>
> + @param SectionData A pointer to the discovered section, if
> successful.
>
> +
>
> + @retval EFI_SUCCESS The section was found.
>
> + @retval EFI_NOT_FOUND The section was not found.
>
> +
>
> +**/
>
> +EFI_STATUS
>
> +FileFindSection (
>
> + IN EFI_FFS_FILE_HEADER *FileHeader,
>
> + IN EFI_SECTION_TYPE SectionType,
>
> + OUT VOID **SectionData
>
> + );
>
> +
>
> +/**
>
> + This function searchs a given file type with a given Guid within a valid FV.
>
> + If input Guid is NULL, will locate the first section having the given file type
>
> +
>
> + @param FvHeader A pointer to firmware volume header that contains
> the set of files
>
> + to be searched.
>
> + @param FileType File type to be searched.
>
> + @param Guid Will ignore if it is NULL.
>
> + @param FileHeader A pointer to the discovered file, if successful.
>
> +
>
> + @retval EFI_SUCCESS Successfully found FileType
>
> + @retval EFI_NOT_FOUND File type can't be found.
>
> +**/
>
> +EFI_STATUS
>
> +FvFindFileByTypeGuid (
>
> + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
>
> + IN EFI_FV_FILETYPE FileType,
>
> + IN EFI_GUID *Guid OPTIONAL,
>
> + OUT EFI_FFS_FILE_HEADER **FileHeader
>
> + );
>
> #endif
>
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> index 9d59454486..b8c1317df0 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> @@ -25,6 +25,62 @@
>
>
> extern VOID *mHobList;
>
>
>
> +/**
>
> + Some bootloader may pass a pcd database, and UPL also contain a PCD
> database.
>
> + Dxe PCD driver has the assumption that the two PCD database can be
> catenated and
>
> + the local token number should be successive。
>
> + This function will fix up the UPL PCD database to meet that assumption.
>
> +
>
> + @param[in] DxeFv The FV where to find the Universal PCD database.
>
> +
>
> + @retval EFI_SUCCESS If it completed successfully.
>
> + @retval other Failed to fix up.
>
> +**/
>
> +EFI_STATUS
>
> +FixUpPcdDatabase (
>
> + IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
>
> + )
>
> +{
>
> + EFI_STATUS Status;
>
> + EFI_FFS_FILE_HEADER *FileHeader;
>
> + VOID *PcdRawData;
>
> + PEI_PCD_DATABASE *PeiDatabase;
>
> + PEI_PCD_DATABASE *UplDatabase;
>
> + EFI_HOB_GUID_TYPE *GuidHob;
>
> + DYNAMICEX_MAPPING *ExMapTable;
>
> + UINTN Index;
>
> +
>
> + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
>
> + if (GuidHob == NULL) {
>
> + //
>
> + // No fix-up is needed.
>
> + //
>
> + return EFI_SUCCESS;
>
> + }
>
> + PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
>
> + DEBUG ((DEBUG_INFO, "Find the Pei PCD data base, the total local token
> number is %d\n", PeiDatabase->LocalTokenCount));
>
> +
>
> + Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DRIVER,
> PcdGetPtr (PcdPcdDriverFile), &FileHeader);
>
> + ASSERT_EFI_ERROR (Status);
>
> + if (EFI_ERROR (Status)) {
>
> + return Status;
>
> + }
>
> + Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData);
>
> + ASSERT_EFI_ERROR (Status);
>
> + if (EFI_ERROR (Status)) {
>
> + return Status;
>
> + }
>
> +
>
> + UplDatabase = (PEI_PCD_DATABASE *) PcdRawData;
>
> + ExMapTable = (DYNAMICEX_MAPPING *) (UINTN) ((UINTN) PcdRawData
> + UplDatabase->ExMapTableOffset);
>
> +
>
> + for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
>
> + ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
>
> + }
>
> + DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n"));
>
> + return EFI_SUCCESS;
>
> +}
>
> +
>
> /**
>
> Add HOB into HOB list
>
>
>
> @@ -332,6 +388,7 @@ _ModuleEntryPoint (
> Status = BuildHobs (BootloaderParameter, &DxeFv);
>
> ASSERT_EFI_ERROR (Status);
>
>
>
> + FixUpPcdDatabase (DxeFv);
>
> Status = UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);
>
> ASSERT_EFI_ERROR (Status);
>
>
>
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> index 77cd25aafd..76d7e4791c 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> @@ -63,6 +63,7 @@
> gEfiAcpiTableGuid
>
> gUefiSerialPortInfoGuid
>
> gUniversalPayloadExtraDataGuid
>
> + gPcdDataBaseHobGuid
>
>
>
> [FeaturePcd.IA32]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ##
> CONSUMES
>
> @@ -72,6 +73,7 @@
>
>
>
>
> [Pcd.IA32,Pcd.X64]
>
> + gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ##
> SOMETIMES_CONSUMES
>
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM
> ask ## CONSUMES
>
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> ## CONSUMES
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
> b/UefiPayloadPkg/UefiPayloadPkg.dec
> index 105e1f5a1c..d84f560995 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
> @@ -72,3 +72,5 @@
> gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
> |0x80|UINT32|0x
>
>
> # Size of the region used by UEFI in permanent memory
>
>
> gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x020
> 00000|UINT32|0x00000017
>
> +
>
> +gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80,
> 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95,
> 0x41 }|VOID*|0x00000018
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index d8277efccd..e3d669a6d6 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -298,6 +298,7 @@
> gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21,
> 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66,
> 0x23, 0x31 }
>
>
>
> + gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf,
> 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }
>
>
>
> !if $(SOURCE_DEBUG_ENABLE)
>
>
> gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x
> 2
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload
2021-06-23 2:52 ` [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
@ 2021-06-23 23:45 ` Guo Dong
0 siblings, 0 replies; 17+ messages in thread
From: Guo Dong @ 2021-06-23 23:45 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Ma, Maurice, You, Benjamin, Ni, Ray
Reviewed-by: Guo Dong <guo.dong@intel.com>
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Tuesday, June 22, 2021 7:52 PM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> <guo.dong@intel.com>; You, Benjamin <benjamin.you@intel.com>; Ni, Ray
> <ray.ni@intel.com>
> Subject: [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload
>
> 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 <maurice.ma@intel.com>
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> 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 => PayloadEntryHobLib}/Hob.c | 2 +-
> UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf | 2 +-
> UefiPayloadPkg/UefiPayloadPkg.dsc | 15 +++++++++++----
> 11 files changed, 838 insertions(+), 6 deletions(-)
>
> diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> new file mode 100644
> index 0000000000..7e9b23f6d7
> --- /dev/null
> +++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> @@ -0,0 +1,27 @@
> +/** @file
>
> + Provides a service to retrieve a pointer to the start of HOB list.
>
> + Only available to DXE module types.
>
> +
>
> + This library does not contain any functions or macros. It simply exports a
> global
>
> + pointer to the start of HOB list as defined in the Platform Initialization
> Driver
>
> + Execution Environment Core Interface Specification. The library
> constructor must
>
> + initialize this global pointer to the start of HOB list, so it is available at the
>
> + module's entry point. Since there is overhead in looking up the pointer to
> the start
>
> + of HOB list, only those modules that actually require access to the HOB list
>
> + should use this library.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +#ifndef __DXE_HOB_LIST_LIB_H__
>
> +#define __DXE_HOB_LIST_LIB_H__
>
> +
>
> +///
>
> +/// Cache copy of the start of HOB list
>
> +///
>
> +extern VOID *gHobList;
>
> +
>
> +#endif
>
> +
>
> diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> new file mode 100644
> index 0000000000..ff334a0d41
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> @@ -0,0 +1,36 @@
> +## @file
>
> +# HOB Library implementation for Payload Phase.
>
> +#
>
> +# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +#
>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +#
>
> +#
>
> +##
>
> +
>
> +[Defines]
>
> + INF_VERSION = 0x00010005
>
> + BASE_NAME = DxeHobLib
>
> + MODULE_UNI_FILE = DxeHobLib.uni
>
> + FILE_GUID = 1a15b8b3-3e8a-4698-87b9-65aad9993b52
>
> + MODULE_TYPE = DXE_DRIVER
>
> + VERSION_STRING = 1.0
>
> + LIBRARY_CLASS = HobLib|DXE_DRIVER DXE_RUNTIME_DRIVER
> SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
>
> +
>
> +#
>
> +# VALID_ARCHITECTURES = IA32 X64 EBC
>
> +#
>
> +
>
> +[Sources]
>
> + HobLib.c
>
> +
>
> +
>
> +[Packages]
>
> + MdePkg/MdePkg.dec
>
> + UefiPayloadPkg/UefiPayloadPkg.dec
>
> +
>
> +
>
> +[LibraryClasses]
>
> + BaseMemoryLib
>
> + DebugLib
>
> + DxeHobListLib
>
> diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
> b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
> new file mode 100644
> index 0000000000..4e02e9c2ae
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
> @@ -0,0 +1,16 @@
> +// /** @file
>
> +// HOB Library implementation for Payload Phase.
>
> +//
>
> +// The Hoblist will be set by DxeHobListLib or other modules.
>
> +//
>
> +// Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +//
>
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +//
>
> +// **/
>
> +
>
> +
>
> +#string STR_MODULE_ABSTRACT #language en-US "HOB Library
> implementation for Payload Phase."
>
> +
>
> +#string STR_MODULE_DESCRIPTION #language en-US "The HOB Library
> implementation for Payload Phase that doesn't contain HobLibConstructor"
>
> +
>
> diff --git a/UefiPayloadPkg/Library/DxeHobLib/HobLib.c
> b/UefiPayloadPkg/Library/DxeHobLib/HobLib.c
> new file mode 100644
> index 0000000000..5d5ede0c17
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobLib/HobLib.c
> @@ -0,0 +1,597 @@
> +/** @file
>
> + HOB Library implementation for Payload Phase.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +#include <PiDxe.h>
>
> +
>
> +#include <Library/HobLib.h>
>
> +#include <Library/DebugLib.h>
>
> +#include <Library/BaseMemoryLib.h>
>
> +#include <Library/DxeHobListLib.h>
>
> +
>
> +/**
>
> + Returns the pointer to the HOB list.
>
> +
>
> + This function returns the pointer to first HOB in the list.
>
> + For PEI phase, the PEI service GetHobList() can be used to retrieve the
> pointer
>
> + to the HOB list. For the DXE phase, the HOB list pointer can be retrieved
> through
>
> + the EFI System Table by looking up theHOB list GUID in the System
> Configuration Table.
>
> + Since the System Configuration Table does not exist that the time the DXE
> Core is
>
> + launched, the DXE Core uses a global variable from the DXE Core Entry
> Point Library
>
> + to manage the pointer to the HOB list.
>
> +
>
> + If the pointer to the HOB list is NULL, then ASSERT().
>
> +
>
> + @return The pointer to the HOB list.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +GetHobList (
>
> + VOID
>
> + )
>
> +{
>
> + ASSERT (gHobList != NULL);
>
> + return gHobList;
>
> +}
>
> +
>
> +/**
>
> + Returns the next instance of a HOB type from the starting HOB.
>
> +
>
> + This function searches the first instance of a HOB type from the starting
> HOB pointer.
>
> + If there does not exist such HOB type from the starting HOB pointer, it will
> return NULL.
>
> + In contrast with macro GET_NEXT_HOB(), this function does not skip the
> starting HOB pointer
>
> + unconditionally: it returns HobStart back if HobStart itself meets the
> requirement;
>
> + caller is required to use GET_NEXT_HOB() if it wishes to skip current
> HobStart.
>
> +
>
> + If HobStart is NULL, then ASSERT().
>
> +
>
> + @param Type The HOB type to return.
>
> + @param HobStart The starting HOB pointer to search from.
>
> +
>
> + @return The next instance of a HOB type from the starting HOB.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +GetNextHob (
>
> + IN UINT16 Type,
>
> + IN CONST VOID *HobStart
>
> + )
>
> +{
>
> + EFI_PEI_HOB_POINTERS Hob;
>
> +
>
> + ASSERT (HobStart != NULL);
>
> +
>
> + Hob.Raw = (UINT8 *) HobStart;
>
> + //
>
> + // Parse the HOB list until end of list or matching type is found.
>
> + //
>
> + while (!END_OF_HOB_LIST (Hob)) {
>
> + if (Hob.Header->HobType == Type) {
>
> + return Hob.Raw;
>
> + }
>
> + Hob.Raw = GET_NEXT_HOB (Hob);
>
> + }
>
> + return NULL;
>
> +}
>
> +
>
> +/**
>
> + Returns the first instance of a HOB type among the whole HOB list.
>
> +
>
> + This function searches the first instance of a HOB type among the whole
> HOB list.
>
> + If there does not exist such HOB type in the HOB list, it will return NULL.
>
> +
>
> + If the pointer to the HOB list is NULL, then ASSERT().
>
> +
>
> + @param Type The HOB type to return.
>
> +
>
> + @return The next instance of a HOB type from the starting HOB.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +GetFirstHob (
>
> + IN UINT16 Type
>
> + )
>
> +{
>
> + VOID *HobList;
>
> +
>
> + HobList = GetHobList ();
>
> + return GetNextHob (Type, HobList);
>
> +}
>
> +
>
> +/**
>
> + Returns the next instance of the matched GUID HOB from the starting HOB.
>
> +
>
> + This function searches the first instance of a HOB from the starting HOB
> pointer.
>
> + Such HOB should satisfy two conditions:
>
> + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name
> equals to the input Guid.
>
> + If there does not exist such HOB from the starting HOB pointer, it will
> return NULL.
>
> + Caller is required to apply GET_GUID_HOB_DATA () and
> GET_GUID_HOB_DATA_SIZE ()
>
> + to extract the data section and its size information, respectively.
>
> + In contrast with macro GET_NEXT_HOB(), this function does not skip the
> starting HOB pointer
>
> + unconditionally: it returns HobStart back if HobStart itself meets the
> requirement;
>
> + caller is required to use GET_NEXT_HOB() if it wishes to skip current
> HobStart.
>
> +
>
> + If Guid is NULL, then ASSERT().
>
> + If HobStart is NULL, then ASSERT().
>
> +
>
> + @param Guid The GUID to match with in the HOB list.
>
> + @param HobStart A pointer to a Guid.
>
> +
>
> + @return The next instance of the matched GUID HOB from the starting
> HOB.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +GetNextGuidHob (
>
> + IN CONST EFI_GUID *Guid,
>
> + IN CONST VOID *HobStart
>
> + )
>
> +{
>
> + EFI_PEI_HOB_POINTERS GuidHob;
>
> +
>
> + GuidHob.Raw = (UINT8 *) HobStart;
>
> + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION,
> GuidHob.Raw)) != NULL) {
>
> + if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
>
> + break;
>
> + }
>
> + GuidHob.Raw = GET_NEXT_HOB (GuidHob);
>
> + }
>
> + return GuidHob.Raw;
>
> +}
>
> +
>
> +/**
>
> + Returns the first instance of the matched GUID HOB among the whole HOB
> list.
>
> +
>
> + This function searches the first instance of a HOB among the whole HOB list.
>
> + Such HOB should satisfy two conditions:
>
> + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name
> equals to the input Guid.
>
> + If there does not exist such HOB from the starting HOB pointer, it will
> return NULL.
>
> + Caller is required to apply GET_GUID_HOB_DATA () and
> GET_GUID_HOB_DATA_SIZE ()
>
> + to extract the data section and its size information, respectively.
>
> +
>
> + If the pointer to the HOB list is NULL, then ASSERT().
>
> + If Guid is NULL, then ASSERT().
>
> +
>
> + @param Guid The GUID to match with in the HOB list.
>
> +
>
> + @return The first instance of the matched GUID HOB among the whole
> HOB list.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +GetFirstGuidHob (
>
> + IN CONST EFI_GUID *Guid
>
> + )
>
> +{
>
> + VOID *HobList;
>
> +
>
> + HobList = GetHobList ();
>
> + return GetNextGuidHob (Guid, HobList);
>
> +}
>
> +
>
> +/**
>
> + Get the system boot mode from the HOB list.
>
> +
>
> + This function returns the system boot mode information from the
>
> + PHIT HOB in HOB list.
>
> +
>
> + If the pointer to the HOB list is NULL, then ASSERT().
>
> +
>
> + @param VOID
>
> +
>
> + @return The Boot Mode.
>
> +
>
> +**/
>
> +EFI_BOOT_MODE
>
> +EFIAPI
>
> +GetBootModeHob (
>
> + VOID
>
> + )
>
> +{
>
> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
>
> +
>
> + HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
>
> +
>
> + return HandOffHob->BootMode;
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB for a loaded PE32 module.
>
> +
>
> + This function builds a HOB for a loaded PE32 module.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If ModuleName is NULL, then ASSERT().
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param ModuleName The GUID File Name of the module.
>
> + @param MemoryAllocationModule The 64 bit physical address of the
> module.
>
> + @param ModuleLength The length of the module in bytes.
>
> + @param EntryPoint The 64 bit physical address of the module entry
> point.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildModuleHob (
>
> + IN CONST EFI_GUID *ModuleName,
>
> + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
>
> + IN UINT64 ModuleLength,
>
> + IN EFI_PHYSICAL_ADDRESS EntryPoint
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB that describes a chunk of system memory with Owner GUID.
>
> +
>
> + This function builds a HOB that describes a chunk of system memory.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param ResourceType The type of resource described by this HOB.
>
> + @param ResourceAttribute The resource attributes of the memory
> described by this HOB.
>
> + @param PhysicalStart The 64 bit physical address of memory described
> by this HOB.
>
> + @param NumberOfBytes The length of the memory described by this
> HOB in bytes.
>
> + @param OwnerGUID GUID for the owner of this resource.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildResourceDescriptorWithOwnerHob (
>
> + IN EFI_RESOURCE_TYPE ResourceType,
>
> + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
>
> + IN EFI_PHYSICAL_ADDRESS PhysicalStart,
>
> + IN UINT64 NumberOfBytes,
>
> + IN EFI_GUID *OwnerGUID
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB that describes a chunk of system memory.
>
> +
>
> + This function builds a HOB that describes a chunk of system memory.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param ResourceType The type of resource described by this HOB.
>
> + @param ResourceAttribute The resource attributes of the memory
> described by this HOB.
>
> + @param PhysicalStart The 64 bit physical address of memory described
> by this HOB.
>
> + @param NumberOfBytes The length of the memory described by this
> HOB in bytes.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildResourceDescriptorHob (
>
> + IN EFI_RESOURCE_TYPE ResourceType,
>
> + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
>
> + IN EFI_PHYSICAL_ADDRESS PhysicalStart,
>
> + IN UINT64 NumberOfBytes
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a customized HOB tagged with a GUID for identification and returns
>
> + the start address of GUID HOB data.
>
> +
>
> + This function builds a customized HOB tagged with a GUID for identification
>
> + and returns the start address of GUID HOB data so that caller can fill the
> customized data.
>
> + The HOB Header and Name field is already stripped.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If Guid is NULL, then ASSERT().
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
>
> + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is
> 0xFFF8.
>
> +
>
> + @param Guid The GUID to tag the customized HOB.
>
> + @param DataLength The size of the data payload for the GUID HOB.
>
> +
>
> + @retval NULL The GUID HOB could not be allocated.
>
> + @retval others The start address of GUID HOB data.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +BuildGuidHob (
>
> + IN CONST EFI_GUID *Guid,
>
> + IN UINTN DataLength
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> + return NULL;
>
> +}
>
> +
>
> +/**
>
> + Builds a customized HOB tagged with a GUID for identification, copies the
> input data to the HOB
>
> + data field, and returns the start address of the GUID HOB data.
>
> +
>
> + This function builds a customized HOB tagged with a GUID for identification
> and copies the input
>
> + data to the HOB data field and returns the start address of the GUID HOB
> data. It can only be
>
> + invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is
> read-only for DXE phase.
>
> + The HOB Header and Name field is already stripped.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If Guid is NULL, then ASSERT().
>
> + If Data is NULL and DataLength > 0, then ASSERT().
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
>
> + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is
> 0xFFF8.
>
> +
>
> + @param Guid The GUID to tag the customized HOB.
>
> + @param Data The data to be copied into the data field of the GUID
> HOB.
>
> + @param DataLength The size of the data payload for the GUID HOB.
>
> +
>
> + @retval NULL The GUID HOB could not be allocated.
>
> + @retval others The start address of GUID HOB data.
>
> +
>
> +**/
>
> +VOID *
>
> +EFIAPI
>
> +BuildGuidDataHob (
>
> + IN CONST EFI_GUID *Guid,
>
> + IN VOID *Data,
>
> + IN UINTN DataLength
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> + return NULL;
>
> +}
>
> +
>
> +/**
>
> + Builds a Firmware Volume HOB.
>
> +
>
> + This function builds a Firmware Volume HOB.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> + If the FvImage buffer is not at its required alignment, then ASSERT().
>
> +
>
> + @param BaseAddress The base address of the Firmware Volume.
>
> + @param Length The size of the Firmware Volume in bytes.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildFvHob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a EFI_HOB_TYPE_FV2 HOB.
>
> +
>
> + This function builds a EFI_HOB_TYPE_FV2 HOB.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> + If the FvImage buffer is not at its required alignment, then ASSERT().
>
> +
>
> + @param BaseAddress The base address of the Firmware Volume.
>
> + @param Length The size of the Firmware Volume in bytes.
>
> + @param FvName The name of the Firmware Volume.
>
> + @param FileName The name of the file.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildFv2Hob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length,
>
> + IN CONST EFI_GUID *FvName,
>
> + IN CONST EFI_GUID *FileName
>
> + )
>
> +{
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a EFI_HOB_TYPE_FV3 HOB.
>
> +
>
> + This function builds a EFI_HOB_TYPE_FV3 HOB.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> + If the FvImage buffer is not at its required alignment, then ASSERT().
>
> +
>
> + @param BaseAddress The base address of the Firmware Volume.
>
> + @param Length The size of the Firmware Volume in bytes.
>
> + @param AuthenticationStatus The authentication status.
>
> + @param ExtractedFv TRUE if the FV was extracted as a file within
>
> + another firmware volume. FALSE otherwise.
>
> + @param FvName The name of the Firmware Volume.
>
> + Valid only if IsExtractedFv is TRUE.
>
> + @param FileName The name of the file.
>
> + Valid only if IsExtractedFv is TRUE.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildFv3Hob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length,
>
> + IN UINT32 AuthenticationStatus,
>
> + IN BOOLEAN ExtractedFv,
>
> + IN CONST EFI_GUID *FvName, OPTIONAL
>
> + IN CONST EFI_GUID *FileName OPTIONAL
>
> + )
>
> +{
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a Capsule Volume HOB.
>
> +
>
> + This function builds a Capsule Volume HOB.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If the platform does not support Capsule Volume HOBs, then ASSERT().
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param BaseAddress The base address of the Capsule Volume.
>
> + @param Length The size of the Capsule Volume in bytes.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildCvHob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB for the CPU.
>
> +
>
> + This function builds a HOB for the CPU.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param SizeOfMemorySpace The maximum physical memory
> addressability of the processor.
>
> + @param SizeOfIoSpace The maximum physical I/O addressability of the
> processor.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildCpuHob (
>
> + IN UINT8 SizeOfMemorySpace,
>
> + IN UINT8 SizeOfIoSpace
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB for the Stack.
>
> +
>
> + This function builds a HOB for the stack.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param BaseAddress The 64 bit physical address of the Stack.
>
> + @param Length The length of the stack in bytes.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildStackHob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB for the BSP store.
>
> +
>
> + This function builds a HOB for BSP store.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param BaseAddress The 64 bit physical address of the BSP.
>
> + @param Length The length of the BSP store in bytes.
>
> + @param MemoryType Type of memory allocated by this HOB.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildBspStoreHob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length,
>
> + IN EFI_MEMORY_TYPE MemoryType
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> +
>
> +/**
>
> + Builds a HOB for the memory allocation.
>
> +
>
> + This function builds a HOB for the memory allocation.
>
> + It can only be invoked during PEI phase;
>
> + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
>
> +
>
> + If there is no additional space for HOB creation, then ASSERT().
>
> +
>
> + @param BaseAddress The 64 bit physical address of the memory.
>
> + @param Length The length of the memory allocation in bytes.
>
> + @param MemoryType Type of memory allocated by this HOB.
>
> +
>
> +**/
>
> +VOID
>
> +EFIAPI
>
> +BuildMemoryAllocationHob (
>
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
>
> + IN UINT64 Length,
>
> + IN EFI_MEMORY_TYPE MemoryType
>
> + )
>
> +{
>
> + //
>
> + // PEI HOB is read only for DXE phase
>
> + //
>
> + ASSERT (FALSE);
>
> +}
>
> diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
> b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
> new file mode 100644
> index 0000000000..8bb31b3f9c
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
> @@ -0,0 +1,66 @@
> +/** @file
>
> + This library retrieve the EFI_BOOT_SERVICES pointer from EFI system table
> in
>
> + library's constructor.
>
> +
>
> + Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +
>
> +#include <Uefi.h>
>
> +
>
> +VOID *gHobList = NULL;
>
> +
>
> +/**
>
> + Local implementation of GUID comparasion that doesn't depend on
> DebugLib::ASSERT().
>
> +
>
> + This function compares Guid1 to Guid2. If the GUIDs are identical then
> TRUE is returned.
>
> + If there are any bit differences in the two GUIDs, then FALSE is returned.
>
> +
>
> + @param Guid1 A pointer to a 128 bit GUID.
>
> + @param Guid2 A pointer to a 128 bit GUID.
>
> +
>
> + @retval TRUE Guid1 and Guid2 are identical.
>
> + @retval FALSE Guid1 and Guid2 are not identical.
>
> +**/
>
> +BOOLEAN
>
> +LocalCompareGuid (
>
> + IN CONST GUID *Guid1,
>
> + IN CONST GUID *Guid2
>
> + )
>
> +{
>
> + UINT64 *Left;
>
> + UINT64 *Right;
>
> +
>
> + Left = (UINT64 *) Guid1;
>
> + Right = (UINT64 *) Guid2;
>
> +
>
> + return (BOOLEAN) (Left[0] == Right[0] && Left[1] == Right[1]);
>
> +}
>
> +
>
> +/**
>
> + @param ImageHandle The firmware allocated handle for the EFI image.
>
> + @param SystemTable A pointer to the EFI System Table.
>
> +
>
> + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
>
> +
>
> +**/
>
> +EFI_STATUS
>
> +EFIAPI
>
> +DxeHobListLibConstructor (
>
> + IN EFI_HANDLE ImageHandle,
>
> + IN EFI_SYSTEM_TABLE *SystemTable
>
> + )
>
> +{
>
> + UINTN Index;
>
> +
>
> + for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
>
> + if (LocalCompareGuid (&gEfiHobListGuid, &SystemTable-
> >ConfigurationTable[Index].VendorGuid)) {
>
> + gHobList = SystemTable->ConfigurationTable[Index].VendorTable;
>
> + return EFI_SUCCESS;
>
> + }
>
> + }
>
> +
>
> + return EFI_NOT_FOUND;
>
> +}
>
> diff --git a/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
> b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
> new file mode 100644
> index 0000000000..1115949556
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
> @@ -0,0 +1,35 @@
> +## @file
>
> +# UEFI Boot Services Table Library implementation.
>
> +#
>
> +# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +#
>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +#
>
> +#
>
> +##
>
> +
>
> +[Defines]
>
> + INF_VERSION = 0x00010005
>
> + BASE_NAME = UefiPayloadInitHobLib
>
> + FILE_GUID = ff5c7a21-ab7a-4366-8616-11c6e53247b6
>
> + MODULE_TYPE = UEFI_DRIVER
>
> + VERSION_STRING = 1.0
>
> + LIBRARY_CLASS = DxeHobListLib|DXE_DRIVER
> DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION
> UEFI_DRIVER SMM_CORE
>
> +
>
> + CONSTRUCTOR = DxeHobListLibConstructor
>
> +
>
> +#
>
> +# VALID_ARCHITECTURES = IA32 X64 EBC
>
> +#
>
> +
>
> +[Sources]
>
> + DxeHobListLib.c
>
> +
>
> +[Packages]
>
> + MdePkg/MdePkg.dec
>
> + UefiPayloadPkg/UefiPayloadPkg.dec
>
> +
>
> +[Guids]
>
> + gEfiHobListGuid ## CONSUMES
>
> +
>
> +
>
> 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
>
> + This library retrieve the EFI_BOOT_SERVICES pointer from EFI system table
> in
>
> + library's constructor.
>
> +
>
> + Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +
>
> +#include <Uefi.h>
>
> +
>
> +EFI_STATUS
>
> +EFIAPI
>
> +DxeHobListLibNullConstructor (
>
> + VOID
>
> + )
>
> +{
>
> + return EFI_SUCCESS;
>
> +}
>
> 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
>
> +# UEFI Boot Services Table Library implementation.
>
> +#
>
> +# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +#
>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +#
>
> +#
>
> +##
>
> +
>
> +[Defines]
>
> + INF_VERSION = 0x00010005
>
> + BASE_NAME = DxeHobListLibNull
>
> + MODULE_TYPE = BASE
>
> + FILE_GUID = 060876c2-0e4e-4c63-8996-6af3710cfa64
>
> + VERSION_STRING = 1.0
>
> + LIBRARY_CLASS = DxeHobListLib
>
> + CONSTRUCTOR = DxeHobListLibNullConstructor
>
> +
>
> +#
>
> +# VALID_ARCHITECTURES = IA32 X64 EBC
>
> +#
>
> +
>
> +[Packages]
>
> + MdePkg/MdePkg.dec
>
> +
>
> +[Sources]
>
> + DxeHobListLibNull.c
>
> diff --git a/UefiPayloadPkg/Library/HobLib/Hob.c
> b/UefiPayloadPkg/Library/PayloadEntryHobLib/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
>
>
>
> Copyright (c) 2010, Apple Inc. All rights reserved.<BR>
>
> - Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>
>
> + Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
>
>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> diff --git a/UefiPayloadPkg/Library/HobLib/HobLib.inf
> b/UefiPayloadPkg/Library/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
>
> #
>
> -# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
>
> # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
>
> #
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 21b360256b..d8277efccd 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -27,6 +27,7 @@
>
>
> DEFINE SOURCE_DEBUG_ENABLE = FALSE
>
> DEFINE PS2_KEYBOARD_ENABLE = FALSE
>
> + DEFINE UNIVERSAL_PAYLOAD = FALSE
>
>
>
> #
>
> # SBL: UEFI payload for Slim Bootloader
>
> @@ -146,6 +147,13 @@
>
> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
> PeCoffGetEntryPointLib.inf
>
>
> CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCac
> heMaintenanceLib.inf
>
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
>
> + DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf
>
> +
>
> +!if $(UNIVERSAL_PAYLOAD) == TRUE
>
> + HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
>
> +!else
>
> + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>
> +!endif
>
>
>
> #
>
> # UEFI & PI
>
> @@ -221,10 +229,12 @@
>
> VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Va
> riablePolicyHelperLib.inf
>
>
>
> [LibraryClasses.common.SEC]
>
> - HobLib|UefiPayloadPkg/Library/HobLib/HobLib.inf
>
> + HobLib|UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf
>
> PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>
> +
> DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull
> .inf
>
>
>
> [LibraryClasses.common.DXE_CORE]
>
> +
> DxeHobListLib|UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull
> .inf
>
> PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>
> HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
>
>
> MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLi
> b/DxeCoreMemoryAllocationLib.inf
>
> @@ -238,7 +248,6 @@
>
>
> [LibraryClasses.common.DXE_DRIVER]
>
> PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>
> - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>
>
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
> ryAllocationLib.inf
>
>
> ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
> xtractGuidedSectionLib.inf
>
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/Dx
> eReportStatusCodeLib.inf
>
> @@ -251,7 +260,6 @@
>
>
> [LibraryClasses.common.DXE_RUNTIME_DRIVER]
>
> PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>
> - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>
>
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
> ryAllocationLib.inf
>
>
> ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCod
> eLib/RuntimeDxeReportStatusCodeLib.inf
>
>
> VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLi
> bRuntimeDxe.inf
>
> @@ -260,7 +268,6 @@
> PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>
>
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
> ryAllocationLib.inf
>
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/Dx
> eReportStatusCodeLib.inf
>
> - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>
>
>
>
> ##########################################################
> ######################
>
> #
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers
2021-06-23 2:52 ` [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
@ 2021-06-23 23:48 ` Guo Dong
0 siblings, 0 replies; 17+ messages in thread
From: Guo Dong @ 2021-06-23 23:48 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Ma, Maurice, You, Benjamin
Please update the MACRO as below.
> + DEFINE EMU_VARIABLE_ENABLE = FALSE
Change to:
DEFINE EMU_VARIABLE_ENABLE = TRUE
> +!if $(EMU_VARIABLE_ENABLE) == FALSE
Change to
+!if $(EMU_VARIABLE_ENABLE) == TRUE
With that:
Reviewed-by: Guo Dong <guo.dong@intel.com>
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Tuesday, June 22, 2021 7:53 PM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> <guo.dong@intel.com>; You, Benjamin <benjamin.you@intel.com>
> Subject: [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers
>
> V2:
> Change DISABLE_VARIABLE to EMU_VARIABLE_ENABLE
>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++++++++++-
> UefiPayloadPkg/UefiPayloadPkg.fdf | 7 +++++++
> 2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 155aea4bc4..85055e9091 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -87,6 +87,12 @@
> #
>
> DEFINE SHELL_TYPE = BUILD_SHELL
>
>
>
> + #
>
> + # Disable features
>
> + #
>
> + DEFINE EMU_VARIABLE_ENABLE = FALSE
>
> + DEFINE DISABLE_RESET_SYSTEM = FALSE
>
> +
>
> [BuildOptions]
>
> *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
>
> @@ -431,10 +437,13 @@
> MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>
> MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>
>
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
> terRuntimeDxe.inf
>
> +!if $(DISABLE_RESET_SYSTEM) == FALSE
>
>
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
> Dxe.inf
>
> +!endif
>
>
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntime
> Dxe.inf
>
> +!if $(EMU_VARIABLE_ENABLE) == FALSE
>
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>
> -
>
> +!endif
>
> #
>
> # Following are the DXE drivers
>
> #
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf
> b/UefiPayloadPkg/UefiPayloadPkg.fdf
> index 6073f9c1b4..4d186692da 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.fdf
> +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
> @@ -105,9 +105,16 @@ INF
> MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
> INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>
> INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>
> INF
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
> terRuntimeDxe.inf
>
> +
>
> +!if $(DISABLE_RESET_SYSTEM) == FALSE
>
> INF
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
> Dxe.inf
>
> +!endif
>
> +
>
> INF
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntime
> Dxe.inf
>
> +
>
> +!if $(EMU_VARIABLE_ENABLE) == FALSE
>
> INF
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>
> +!endif
>
>
>
> INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
>
> INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2021-06-23 23:48 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-23 2:52 [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
2021-06-23 23:45 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 04/12] UefiPayloadPkg: Update the function definition of HobConstructor Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database Zhiguang Liu
2021-06-23 23:45 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
2021-06-23 23:48 ` Guo Dong
2021-06-23 2:52 ` [Patch V2 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg Zhiguang Liu
2021-06-23 2:52 ` [Patch V2 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange " Zhiguang Liu
[not found] ` <168B167444E9F647.3239@groups.io>
2021-06-23 8:50 ` [edk2-devel] [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox