Date   

[Patch V5 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB.

Zhiguang Liu
 

If HOB contains APCI table information, entry point of AcpiTableDxe.inf
should parse the APCI table from HOB, and install these tables.
We assume the whole ACPI table
(starting with EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
is contained by a single gEfiAcpiTableGuid HOB.

If error happens when installing ACPI table, stop installing and removing
all the tables that are already added.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Dandan Bi <dandan.bi@...>
Cc: Liming Gao <gaoliming@...>
Cc: Ray Ni <ray.ni@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92 +++++++=
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------=
----------
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38 +++++++=
++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8 +++++---
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171 +++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++-------
4 files changed, 271 insertions(+), 38 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c b/MdeModule=
Pkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
index 14ced68e64..d98573d613 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
@@ -1,7 +1,7 @@
/** @file=0D
ACPI Sdt Protocol Driver=0D
=0D
- Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>=
=0D
+ Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. <BR>=
=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -191,8 +191,7 @@ SdtNotifyAcpiList (
/**=0D
Returns a requested ACPI table.=0D
=0D
- The GetAcpiTable() function returns a pointer to a buffer containing the=
ACPI table associated=0D
- with the Index that was input. The following structures are not consider=
ed elements in the list of=0D
+ The following structures are not considered elements in the list of=0D
ACPI tables:=0D
- Root System Description Pointer (RSD_PTR)=0D
- Root System Description Table (RSDT)=0D
@@ -201,42 +200,32 @@ SdtNotifyAcpiList (
member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi=
Table() interface,=0D
the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.=0D
=0D
- @param[in] Index The zero-based index of the table to retrieve.=
=0D
- @param[out] Table Pointer for returning the table buffer.=0D
- @param[out] Version On return, updated with the ACPI versions to w=
hich this table belongs. Type=0D
- EFI_ACPI_TABLE_VERSION is defined in "Related =
Definitions" in the=0D
- EFI_ACPI_SDT_PROTOCOL.=0D
- @param[out] TableKey On return, points to the table key for the spe=
cified ACPI system definition table.=0D
- This is identical to the table key used in the=
EFI_ACPI_TABLE_PROTOCOL.=0D
- The TableKey can be passed to EFI_ACPI_TABLE_P=
ROTOCOL.UninstallAcpiTable()=0D
- to uninstall the table.=0D
- @retval EFI_SUCCESS The function completed successfully.=0D
- @retval EFI_NOT_FOUND The requested index is too large and a table w=
as not found.=0D
+ @param[in] AcpiTableInstance ACPI table Instance.=0D
+ @param[in] Index The zero-based index of the table to re=
trieve.=0D
+ @param[out] Table Pointer for returning the table buffer.=
=0D
+ @param[out] Version On return, updated with the ACPI versio=
ns to which this table belongs. Type=0D
+ EFI_ACPI_TABLE_VERSION is defined in "R=
elated Definitions" in the=0D
+ EFI_ACPI_SDT_PROTOCOL.=0D
+ @param[out] TableKey On return, points to the table key for =
the specified ACPI system definition table.=0D
+ This is identical to the table key used=
in the EFI_ACPI_TABLE_PROTOCOL.=0D
+ The TableKey can be passed to EFI_ACPI_=
TABLE_PROTOCOL.UninstallAcpiTable()=0D
+ to uninstall the table.=0D
+ @retval EFI_SUCCESS The function completed successfully.=0D
+ @retval EFI_NOT_FOUND The requested index is too large and a =
table was not found.=0D
**/=0D
EFI_STATUS=0D
-EFIAPI=0D
-GetAcpiTable2 (=0D
+SdtGetAcpiTable (=0D
+ IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,=0D
IN UINTN Index,=0D
OUT EFI_ACPI_SDT_HEADER **Table,=0D
OUT EFI_ACPI_TABLE_VERSION *Version,=0D
OUT UINTN *TableKey=0D
)=0D
{=0D
- EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;=0D
UINTN TableIndex;=0D
LIST_ENTRY *CurrentLink;=0D
LIST_ENTRY *StartLink;=0D
EFI_ACPI_TABLE_LIST *CurrentTable;=0D
-=0D
- ASSERT (Table !=3D NULL);=0D
- ASSERT (Version !=3D NULL);=0D
- ASSERT (TableKey !=3D NULL);=0D
-=0D
- //=0D
- // Get the instance of the ACPI Table=0D
- //=0D
- AcpiTableInstance =3D SdtGetAcpiTableInstance ();=0D
-=0D
//=0D
// Find the table=0D
//=0D
@@ -270,6 +259,55 @@ GetAcpiTable2 (
return EFI_SUCCESS;=0D
}=0D
=0D
+/**=0D
+ Returns a requested ACPI table.=0D
+=0D
+ The GetAcpiTable() function returns a pointer to a buffer containing the=
ACPI table associated=0D
+ with the Index that was input. The following structures are not consider=
ed elements in the list of=0D
+ ACPI tables:=0D
+ - Root System Description Pointer (RSD_PTR)=0D
+ - Root System Description Table (RSDT)=0D
+ - Extended System Description Table (XSDT)=0D
+ Version is updated with a bit map containing all the versions of ACPI of=
which the table is a=0D
+ member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi=
Table() interface,=0D
+ the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.=0D
+=0D
+ @param[in] Index The zero-based index of the table to retrieve.=
=0D
+ @param[out] Table Pointer for returning the table buffer.=0D
+ @param[out] Version On return, updated with the ACPI versions to w=
hich this table belongs. Type=0D
+ EFI_ACPI_TABLE_VERSION is defined in "Related =
Definitions" in the=0D
+ EFI_ACPI_SDT_PROTOCOL.=0D
+ @param[out] TableKey On return, points to the table key for the spe=
cified ACPI system definition table.=0D
+ This is identical to the table key used in the=
EFI_ACPI_TABLE_PROTOCOL.=0D
+ The TableKey can be passed to EFI_ACPI_TABLE_P=
ROTOCOL.UninstallAcpiTable()=0D
+ to uninstall the table.=0D
+ @retval EFI_SUCCESS The function completed successfully.=0D
+ @retval EFI_NOT_FOUND The requested index is too large and a table w=
as not found.=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+GetAcpiTable2 (=0D
+ IN UINTN Index,=0D
+ OUT EFI_ACPI_SDT_HEADER **Table,=0D
+ OUT EFI_ACPI_TABLE_VERSION *Version,=0D
+ OUT UINTN *TableKey=0D
+ )=0D
+{=0D
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;=0D
+=0D
+ ASSERT (Table !=3D NULL);=0D
+ ASSERT (Version !=3D NULL);=0D
+ ASSERT (TableKey !=3D NULL);=0D
+=0D
+ //=0D
+ // Get the instance of the ACPI Table=0D
+ //=0D
+ AcpiTableInstance =3D SdtGetAcpiTableInstance ();=0D
+=0D
+ return SdtGetAcpiTable (AcpiTableInstance, Index, Table, Version, TableK=
ey);=0D
+}=0D
+=0D
+=0D
/**=0D
Register a callback when an ACPI table is installed.=0D
=0D
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h b/MdeModu=
lePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
index 9d7cf7ccfc..0af2d11a1a 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
@@ -1,7 +1,7 @@
/** @file=0D
ACPI Table Protocol Driver=0D
=0D
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -24,6 +24,8 @@
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/UefiBootServicesTableLib.h>=0D
#include <Library/PcdLib.h>=0D
+#include <Library/HobLib.h>=0D
+#include <UniversalPayload/AcpiTable.h>=0D
=0D
//=0D
// Statements that include other files=0D
@@ -228,6 +230,40 @@ SdtAcpiTableAcpiSdtConstructor (
IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance=0D
);=0D
=0D
+/**=0D
+ Returns a requested ACPI table.=0D
+=0D
+ The following structures are not considered elements in the list of=0D
+ ACPI tables:=0D
+ - Root System Description Pointer (RSD_PTR)=0D
+ - Root System Description Table (RSDT)=0D
+ - Extended System Description Table (XSDT)=0D
+ Version is updated with a bit map containing all the versions of ACPI of=
which the table is a=0D
+ member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpi=
Table() interface,=0D
+ the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.=0D
+=0D
+ @param[in] AcpiTableInstance ACPI table Instance.=0D
+ @param[in] Index The zero-based index of the table to re=
trieve.=0D
+ @param[out] Table Pointer for returning the table buffer.=
=0D
+ @param[out] Version On return, updated with the ACPI versio=
ns to which this table belongs. Type=0D
+ EFI_ACPI_TABLE_VERSION is defined in "R=
elated Definitions" in the=0D
+ EFI_ACPI_SDT_PROTOCOL.=0D
+ @param[out] TableKey On return, points to the table key for =
the specified ACPI system definition table.=0D
+ This is identical to the table key used=
in the EFI_ACPI_TABLE_PROTOCOL.=0D
+ The TableKey can be passed to EFI_ACPI_=
TABLE_PROTOCOL.UninstallAcpiTable()=0D
+ to uninstall the table.=0D
+ @retval EFI_SUCCESS The function completed successfully.=0D
+ @retval EFI_NOT_FOUND The requested index is too large and a =
table was not found.=0D
+**/=0D
+EFI_STATUS=0D
+SdtGetAcpiTable (=0D
+ IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,=0D
+ IN UINTN Index,=0D
+ OUT EFI_ACPI_SDT_HEADER **Table,=0D
+ OUT EFI_ACPI_TABLE_VERSION *Version,=0D
+ OUT UINTN *TableKey=0D
+ );=0D
+=0D
//=0D
// export PrivateData symbol, because we need that in AcpiSdtProtol implem=
entation=0D
//=0D
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/Md=
eModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
index d341df439e..86dea43e27 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
@@ -4,7 +4,7 @@
# This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produces =
UEFI/PI=0D
# services to install/uninstall/manage ACPI tables.=0D
#=0D
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=
=0D
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -51,10 +51,12 @@
DebugLib=0D
BaseLib=0D
PcdLib=0D
+ HobLib=0D
=0D
[Guids]=0D
- gEfiAcpi10TableGuid ## PRODUCES ## SystemTable=
=0D
- gEfiAcpiTableGuid ## PRODUCES ## SystemTable=
=0D
+ gEfiAcpi10TableGuid ## PRODUCES ## S=
ystemTable=0D
+ gEfiAcpiTableGuid ## PRODUCES ## S=
ystemTable=0D
+ gUniversalPayloadAcpiTableGuid ## SOMETIMES_CONSUMES ## H=
OB=0D
=0D
[FeaturePcd]=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ## CONSUMES=0D
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b=
/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 5a2afdff27..34d4a1cec0 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -1,7 +1,7 @@
/** @file=0D
ACPI Table Protocol Implementation=0D
=0D
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>=0D
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
@@ -30,6 +30,7 @@ STATIC EFI_ALLOCATE_TYPE mAcpiTableAllocType;
@param Table Table to add.=0D
@param Checksum Does the table require checksumming.=0D
@param Version The version of the list to add the tab=
le to.=0D
+ @param IsFromHob True, if add Apci Table from Hob List.=
=0D
@param Handle Pointer for returning the handle.=0D
=0D
@return EFI_SUCCESS The function completed successfully.=0D
@@ -44,6 +45,7 @@ AddTableToList (
IN VOID *Table,=0D
IN BOOLEAN Checksum,=0D
IN EFI_ACPI_TABLE_VERSION Version,=0D
+ IN BOOLEAN IsFromHob,=0D
OUT UINTN *Handle=0D
);=0D
=0D
@@ -238,6 +240,7 @@ InstallAcpiTable (
AcpiTableBufferConst,=0D
TRUE,=0D
Version,=0D
+ FALSE,=0D
TableKey=0D
);=0D
if (!EFI_ERROR (Status)) {=0D
@@ -472,6 +475,7 @@ FreeTableMemory (
@param Table Table to add.=0D
@param Checksum Does the table require checksumming.=0D
@param Version The version of the list to add the tab=
le to.=0D
+ @param IsFromHob True, if add Apci Table from Hob List.=
=0D
@param Handle Pointer for returning the handle.=0D
=0D
@return EFI_SUCCESS The function completed successfully.=0D
@@ -487,6 +491,7 @@ AddTableToList (
IN VOID *Table,=0D
IN BOOLEAN Checksum,=0D
IN EFI_ACPI_TABLE_VERSION Version,=0D
+ IN BOOLEAN IsFromHob,=0D
OUT UINTN *Handle=0D
)=0D
{=0D
@@ -553,12 +558,17 @@ AddTableToList (
// SMM communication ACPI table.=0D
//=0D
ASSERT ((EFI_PAGE_SIZE % 64) =3D=3D 0);=0D
- Status =3D gBS->AllocatePages (=0D
- AllocateMaxAddress,=0D
- EfiACPIMemoryNVS,=0D
- EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),=0D
- &AllocPhysAddress=0D
- );=0D
+ if (IsFromHob){=0D
+ AllocPhysAddress =3D (UINTN)Table;=0D
+ Status =3D EFI_SUCCESS;=0D
+ } else {=0D
+ Status =3D gBS->AllocatePages (=0D
+ AllocateMaxAddress,=0D
+ EfiACPIMemoryNVS,=0D
+ EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),=0D
+ &AllocPhysAddress=0D
+ );=0D
+ }=0D
} else if (mAcpiTableAllocType =3D=3D AllocateAnyPages) {=0D
//=0D
// If there is no allocation limit, there is also no need to use page=
=0D
@@ -1689,6 +1699,151 @@ ChecksumCommonTables (
return EFI_SUCCESS;=0D
}=0D
=0D
+/**=0D
+ This function will find gUniversalPayloadAcpiTableGuid Guid Hob, and ins=
tall Acpi table from it.=0D
+=0D
+ @param AcpiTableInstance Protocol instance private data.=0D
+=0D
+ @return EFI_SUCCESS The function completed successfully.=0D
+ @return EFI_NOT_FOUND The function doesn't find the gEfiAcpiTableGu=
id Guid Hob.=0D
+ @return EFI_ABORTED The function could not complete successfully.=
=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+InstallAcpiTableFromHob (=0D
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance=0D
+ )=0D
+{=0D
+ EFI_HOB_GUID_TYPE *GuidHob;=0D
+ EFI_ACPI_TABLE_VERSION Version;=0D
+ EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;=0D
+ EFI_ACPI_DESCRIPTION_HEADER *Rsdt;=0D
+ EFI_ACPI_DESCRIPTION_HEADER *ChildTable;=0D
+ UINT64 ChildTableAddress;=0D
+ UINTN Count;=0D
+ UINTN Index;=0D
+ UINTN TableKey;=0D
+ EFI_STATUS Status;=0D
+ UINTN EntrySize;=0D
+ UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableAdress;=0D
+ VOID *TableToInstall;=0D
+ EFI_ACPI_SDT_HEADER *Table;=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;=0D
+=0D
+ TableKey =3D 0;=0D
+ Version =3D PcdGet32 (PcdAcpiExposedTableVersions);=0D
+ Status =3D EFI_SUCCESS;=0D
+ //=0D
+ // HOB only contains the ACPI table in 2.0+ format.=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gUniversalPayloadAcpiTableGuid);=0D
+ if (GuidHob =3D=3D NULL) {=0D
+ return EFI_NOT_FOUND;=0D
+ }=0D
+=0D
+ GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA=
(GuidHob);=0D
+ if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE =
(GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {=
=0D
+ return EFI_NOT_FOUND;=0D
+ }=0D
+ if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION=
) {=0D
+ //=0D
+ // UNIVERSAL_PAYLOAD_ACPI_TABLE structure is used when Revision equals=
to UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION=0D
+ //=0D
+ AcpiTableAdress =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA=
(GuidHob);=0D
+ if (AcpiTableAdress->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_=
FIELD (UNIVERSAL_PAYLOAD_ACPI_TABLE, Rsdp)) {=0D
+ //=0D
+ // Retrun if can't find the ACPI Info Hob with enough length=0D
+ //=0D
+ return EFI_NOT_FOUND;=0D
+ }=0D
+ Rsdp =3D (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) (UINTN) (Acp=
iTableAdress->Rsdp);=0D
+=0D
+ //=0D
+ // An ACPI-compatible OS must use the XSDT if present.=0D
+ // It shouldn't happen that XsdtAddress points beyond 4G range in 32-b=
it environment.=0D
+ //=0D
+ ASSERT ((UINTN) Rsdp->XsdtAddress =3D=3D Rsdp->XsdtAddress);=0D
+=0D
+ EntrySize =3D sizeof (UINT64);=0D
+ Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;=0D
+ if (Rsdt =3D=3D NULL) {=0D
+ //=0D
+ // XsdtAddress is zero, then we use Rsdt which has 32 bit entry=0D
+ //=0D
+ Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;=
=0D
+ EntrySize =3D sizeof (UINT32);=0D
+ }=0D
+=0D
+ if (Rsdt->Length <=3D sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {=0D
+ return EFI_ABORTED;=0D
+ }=0D
+=0D
+ Count =3D (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / Entr=
ySize;=0D
+=0D
+ for (Index =3D 0; Index < Count; Index++){=0D
+ ChildTableAddress =3D 0;=0D
+ CopyMem (&ChildTableAddress, (UINT8 *) (Rsdt + 1) + EntrySize * Inde=
x, EntrySize);=0D
+ //=0D
+ // If the address is of UINT64 while this module runs at 32 bits,=0D
+ // make sure the upper bits are all-zeros.=0D
+ //=0D
+ ASSERT (ChildTableAddress =3D=3D (UINTN) ChildTableAddress);=0D
+ if (ChildTableAddress !=3D (UINTN) ChildTableAddress) {=0D
+ Status =3D EFI_ABORTED;=0D
+ break;=0D
+ }=0D
+=0D
+ ChildTable =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) ChildTableAdd=
ress;=0D
+ Status =3D AddTableToList (AcpiTableInstance, ChildTable, TRUE, Vers=
ion, TRUE, &TableKey);=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI ta=
ble at 0x%p\n", ChildTable));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ break;=0D
+ }=0D
+ if (ChildTable->Signature =3D=3D EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION=
_TABLE_SIGNATURE){=0D
+ //=0D
+ // Add the FACS and DSDT tables if it is not NULL.=0D
+ //=0D
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Fi=
rmwareCtrl !=3D 0) {=0D
+ TableToInstall =3D (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DE=
SCRIPTION_TABLE *) ChildTable)->FirmwareCtrl;=0D
+ Status =3D AddTableToList (AcpiTableInstance, TableToInstall, TR=
UE, Version, TRUE, &TableKey);=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACP=
I table FACS\n"));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ break;=0D
+ }=0D
+ }=0D
+=0D
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Ds=
dt !=3D 0) {=0D
+ TableToInstall =3D (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DE=
SCRIPTION_TABLE *) ChildTable)->Dsdt;=0D
+ Status =3D AddTableToList (AcpiTableInstance, TableToInstall, TR=
UE, Version, TRUE, &TableKey);=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACP=
I table DSDT\n"));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ break;=0D
+ }=0D
+ }=0D
+ }=0D
+ }=0D
+ } else {=0D
+ return EFI_NOT_FOUND;=0D
+ }=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ //=0D
+ // Error happens when trying to add ACPI table to the list.=0D
+ // Remove all of them from list because at this time, no other tables =
except from HOB are in the list=0D
+ //=0D
+ while (SdtGetAcpiTable (AcpiTableInstance, 0, &Table, &Version, &Table=
Key) =3D=3D EFI_SUCCESS) {=0D
+ RemoveTableFromList (AcpiTableInstance, Version, TableKey);=0D
+ }=0D
+ } else {=0D
+ Status =3D PublishTables (AcpiTableInstance, Version);=0D
+ }=0D
+=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ return Status;=0D
+}=0D
=0D
/**=0D
Constructor for the ACPI table protocol. Initializes instance=0D
@@ -1918,6 +2073,8 @@ AcpiTableAcpiTableConstructor (
=0D
ChecksumCommonTables (AcpiTableInstance);=0D
=0D
+ InstallAcpiTableFromHob (AcpiTableInstance);=0D
+=0D
//=0D
// Completed successfully=0D
//=0D
--=20
2.30.0.windows.2


[Patch V5 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Hob

Zhiguang Liu
 

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Include/UniversalPayload/AcpiTable.h | 30 +++++++++++++++++++=
+++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 +++
2 files changed, 33 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/AcpiTable.h b/MdeModuleP=
kg/Include/UniversalPayload/AcpiTable.h
new file mode 100644
index 0000000000..33ef72637e
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
@@ -0,0 +1,30 @@
+/** @file=0D
+ Define the structure for the Universal Payload APCI table.=0D
+=0D
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+ @par Revision Reference:=0D
+ - Universal Payload Specification 0.75 (https://universalpayload.githu=
b.io/documentation/)=0D
+**/=0D
+=0D
+#ifndef UNIVERSAL_PAYLOAD_ACPI_TABLE_H_=0D
+#define UNIVERSAL_PAYLOAD_ACPI_TABLE_H_=0D
+=0D
+#include <Uefi.h>=0D
+#include <UniversalPayload/UniversalPayload.h>=0D
+=0D
+#pragma pack(1)=0D
+=0D
+typedef struct {=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;=0D
+ EFI_PHYSICAL_ADDRESS Rsdp;=0D
+} UNIVERSAL_PAYLOAD_ACPI_TABLE;=0D
+=0D
+#pragma pack()=0D
+=0D
+#define UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION 1=0D
+=0D
+extern GUID gUniversalPayloadAcpiTableGuid;=0D
+=0D
+#endif // UNIVERSAL_PAYLOAD_ACPI_TABLE_H_=0D
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 377e868e7c..8c0885955b 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -416,6 +416,9 @@
## Include/UniversalPayload/SmbiosTable.h=0D
gUniversalPayloadSmbiosTableGuid =3D { 0x590a0d26, 0x06e5, 0x4d20, { 0x8=
a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } }=0D
=0D
+ ## Include/UniversalPayload/AcpiTable.h=0D
+ gUniversalPayloadAcpiTableGuid =3D { 0x9f9a9506, 0x5597, 0x4515, { 0xba,=
0xb6, 0x8b, 0xcd, 0xe7, 0x84, 0xba, 0x87 } }=0D
+=0D
[Ppis]=0D
## Include/Ppi/AtaController.h=0D
gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,=
0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}=0D
--=20
2.30.0.windows.2


[Patch V5 6/9] UefiPayloadPkg: Create gUniversalPayloadSmbiosTableGuid Hob

Zhiguang Liu
 

From SysTableInfo Hob, get Smbios table address, and create
gUniversalPayloadSmbiosTableGuid Hob to store it. Remove directly adding
smbios table to ConfigurationTable.
Dxe module SmbiosDxe will parse it and install smbios table from it.

Cc: Maurice Ma <maurice.ma@...>
Cc: Guo Dong <guo.dong@...>
Cc: Benjamin You <benjamin.you@...>
Reviewed-by: Guo Dong <guo.dong@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 11 +----------
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 3 +--
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 12 +++++++++++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 3 ++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 3 ++-
5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/Bl=
SupportDxe/BlSupportDxe.c
index a746d0581e..56b85b8e6d 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -2,7 +2,7 @@
This driver will report some MMIO/IO resources to dxe core, extract smbi=
os and acpi=0D
tables from bootloader.=0D
=0D
- Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -129,15 +129,6 @@ BlDxeEntryPoint (
ASSERT_EFI_ERROR (Status);=0D
}=0D
=0D
- //=0D
- // Install Smbios Table=0D
- //=0D
- if (SystemTableInfo->SmbiosTableBase !=3D 0 && SystemTableInfo->SmbiosTa=
bleSize !=3D 0) {=0D
- DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", S=
ystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));=0D
- Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID=
*)(UINTN)SystemTableInfo->SmbiosTableBase);=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
-=0D
//=0D
// Find the frame buffer information and update PCDs=0D
//=0D
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/=
BlSupportDxe/BlSupportDxe.inf
index cebc811355..30f41f8c39 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -3,7 +3,7 @@
#=0D
# Report some MMIO/IO resources to dxe core, extract smbios and acpi table=
s=0D
#=0D
-# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>=
=0D
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -43,7 +43,6 @@
=0D
[Guids]=0D
gEfiAcpiTableGuid=0D
- gEfiSmbiosTableGuid=0D
gUefiSystemTableInfoGuid=0D
gUefiAcpiBoardInfoGuid=0D
gEfiGraphicsInfoHobGuid=0D
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo=
adPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 805f5448d9..80f66a3fd5 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -1,6 +1,6 @@
/** @file=0D
=0D
- Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -234,6 +234,7 @@ BuildHobFromBl (
EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo;=0D
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo;=0D
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo;=0D
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableHob;=0D
=0D
//=0D
// Parse memory info and build memory HOBs=0D
@@ -276,6 +277,15 @@ BuildHobFromBl (
DEBUG ((DEBUG_INFO, "Detected Acpi Table at 0x%lx, length 0x%x\n", Sys=
TableInfo.AcpiTableBase, SysTableInfo.AcpiTableSize));=0D
DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx, length 0x%x\n", S=
ysTableInfo.SmbiosTableBase, SysTableInfo.SmbiosTableSize));=0D
}=0D
+ //=0D
+ // Creat SmBios table Hob=0D
+ //=0D
+ SmBiosTableHob =3D BuildGuidHob (&gUniversalPayloadSmbiosTableGuid, size=
of (UNIVERSAL_PAYLOAD_SMBIOS_TABLE));=0D
+ ASSERT (SmBiosTableHob !=3D NULL);=0D
+ SmBiosTableHob->Header.Revision =3D UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVIS=
ION;=0D
+ SmBiosTableHob->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE=
);=0D
+ SmBiosTableHob->SmBiosEntryPoint =3D SysTableInfo.SmbiosTableBase;=0D
+ DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGui=
d guid hob\n"));=0D
=0D
//=0D
// Create guid hob for acpi board information=0D
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPaylo=
adPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 2c84d6ed53..e7d0d15118 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -1,6 +1,6 @@
/** @file=0D
*=0D
-* Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+* Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>=0D
*=0D
* SPDX-License-Identifier: BSD-2-Clause-Patent=0D
*=0D
@@ -31,6 +31,7 @@
#include <Guid/MemoryMapInfoGuid.h>=0D
#include <Guid/AcpiBoardInfoGuid.h>=0D
#include <Guid/GraphicsInfoHob.h>=0D
+#include <UniversalPayload/SmbiosTable.h>=0D
=0D
=0D
#define LEGACY_8259_MASK_REGISTER_MASTER 0x21=0D
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay=
loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index cc59f1903b..fc5b5ce9d4 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -1,7 +1,7 @@
## @file=0D
# This is the first module for UEFI payload.=0D
#=0D
-# Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>=
=0D
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
@@ -64,6 +64,7 @@
gEfiGraphicsInfoHobGuid=0D
gEfiGraphicsDeviceInfoHobGuid=0D
gUefiAcpiBoardInfoGuid=0D
+ gUniversalPayloadSmbiosTableGuid=0D
=0D
[FeaturePcd.IA32]=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUME=
S=0D
--=20
2.30.0.windows.2


[Patch V5 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables

Zhiguang Liu
 

The default EfiSmbiosProtocol operates on an empty SMBIOS table.
The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
Scan for existing tables in SmbiosDxe and load them if they seem valid.
This fixes the settings menu not showing any hardware information, instead
only "0 MB RAM" was displayed.
Tests showed that the OS can still see the SMBIOS tables.

SmbiosDxe will get the SMBIOS from a guid Hob.
Also will keep the SmbiosHandle if it is available.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Dandan Bi <dandan.bi@...>
Cc: Star Zeng <star.zeng@...>
Cc: Zhichao Gao <zhichao.gao@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Patrick Rudolph <patrick.rudolph@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 293 +++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
++++++++++++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 65 +++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
3 files changed, 360 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un=
iversal/SmbiosDxe/SmbiosDxe.c
index 3cdb0b1ed7..400b0fa578 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -2,7 +2,7 @@
This code produces the Smbios protocol. It also responsible for construc=
ting=0D
SMBIOS table into system table.=0D
=0D
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -148,6 +148,12 @@ SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructu=
reData =3D {
//=0D
0=0D
};=0D
+=0D
+IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] =3D {=0D
+ {&gUniversalPayloadSmbios3TableGuid, IsValidSmbios30Table },=0D
+ {&gUniversalPayloadSmbiosTableGuid, IsValidSmbios20Table }=0D
+};=0D
+=0D
/**=0D
=0D
Get the full size of SMBIOS structure including optional strings that fo=
llow the formatted structure.=0D
@@ -1408,6 +1414,290 @@ SmbiosTableConstruction (
}=0D
}=0D
=0D
+/**=0D
+ Validates a SMBIOS 2.0 table entry point.=0D
+=0D
+ @param TableEntry The SmBios table entry to validate.=0D
+ @param TableAddress On exit, point to the smbios table addres.=0D
+ @param TableMaximumSize On exit, point to the maximum size of the table=
.=0D
+=0D
+ @retval TRUE SMBIOS table entry point is valid.=0D
+ @retval FALSE SMBIOS table entry point is malformed.=0D
+=0D
+**/=0D
+STATIC=0D
+BOOLEAN=0D
+IsValidSmbios20Table (=0D
+ IN VOID *TableEntry,=0D
+ OUT VOID **TableAddress,=0D
+ OUT UINTN *TableMaximumSize=0D
+ )=0D
+{=0D
+ UINT8 Checksum;=0D
+ SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;=0D
+ SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;=0D
+=0D
+ if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) !=3D 0) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_", 5) !=3D =
0) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // The actual value of the EntryPointLength should be 1Fh.=0D
+ // However, it was incorrectly stated in version 2.1 of smbios specifica=
tion.=0D
+ // Therefore, 0x1F and 0x1E are both accepted.=0D
+ //=0D
+ if (SmbiosTable->EntryPointLength !=3D 0x1E && SmbiosTable->EntryPointLe=
ngth !=3D sizeof (SMBIOS_TABLE_ENTRY_POINT)) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // MajorVersion should not be less than 2.=0D
+ //=0D
+ if (SmbiosTable->MajorVersion < 2) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // The whole struct check sum should be zero=0D
+ //=0D
+ Checksum =3D CalculateSum8 (=0D
+ (UINT8 *) SmbiosTable,=0D
+ SmbiosTable->EntryPointLength=0D
+ );=0D
+ if (Checksum !=3D 0) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // The Intermediate Entry Point Structure check sum should be zero.=0D
+ //=0D
+ Checksum =3D CalculateSum8 (=0D
+ (UINT8 *) SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT=
, IntermediateAnchorString),=0D
+ SmbiosTable->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENT=
RY_POINT, IntermediateAnchorString)=0D
+ );=0D
+ if (Checksum !=3D 0) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ *TableAddress =3D (VOID *) (UINTN) SmbiosTable->TableAddress;=0D
+ *TableMaximumSize =3D SmbiosTable->TableLength;=0D
+ return TRUE;=0D
+}=0D
+=0D
+/**=0D
+ Validates a SMBIOS 3.0 table entry point.=0D
+=0D
+ @param TableEntry The SmBios table entry to validate.=0D
+ @param TableAddress On exit, point to the smbios table addres.=0D
+ @param TableMaximumSize On exit, point to the maximum size of the table=
.=0D
+=0D
+ @retval TRUE SMBIOS table entry point is valid.=0D
+ @retval FALSE SMBIOS table entry point is malformed.=0D
+=0D
+**/=0D
+STATIC=0D
+BOOLEAN=0D
+IsValidSmbios30Table (=0D
+ IN VOID *TableEntry,=0D
+ OUT VOID **TableAddress,=0D
+ OUT UINTN *TableMaximumSize=0D
+ )=0D
+{=0D
+ UINT8 Checksum;=0D
+ SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;=0D
+ SmbiosTable =3D (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;=0D
+=0D
+ if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) !=3D 0) {=0D
+ return FALSE;=0D
+ }=0D
+ if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT=
)) {=0D
+ return FALSE;=0D
+ }=0D
+ if (SmbiosTable->MajorVersion < 3) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // The whole struct check sum should be zero=0D
+ //=0D
+ Checksum =3D CalculateSum8 (=0D
+ (UINT8 *) SmbiosTable,=0D
+ SmbiosTable->EntryPointLength=0D
+ );=0D
+ if (Checksum !=3D 0) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ *TableAddress =3D (VOID *) (UINTN) SmbiosTable->TableAddress;=0D
+ *TableMaximumSize =3D SmbiosTable->TableMaximumSize;=0D
+ return TRUE;=0D
+}=0D
+=0D
+/**=0D
+ Parse an existing SMBIOS table and insert it using SmbiosAdd.=0D
+=0D
+ @param ImageHandle The EFI_HANDLE to this driver.=0D
+ @param Smbios The SMBIOS table to parse.=0D
+ @param Length The length of the SMBIOS table.=0D
+=0D
+ @retval EFI_SUCCESS SMBIOS table was parsed and installed.=0D
+ @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system=
resources.=0D
+ @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table=0D
+=0D
+**/=0D
+STATIC=0D
+EFI_STATUS=0D
+ParseAndAddExistingSmbiosTable (=0D
+ IN EFI_HANDLE ImageHandle,=0D
+ IN SMBIOS_STRUCTURE_POINTER Smbios,=0D
+ IN UINTN Length=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ CHAR8 *String;=0D
+ EFI_SMBIOS_HANDLE SmbiosHandle;=0D
+ SMBIOS_STRUCTURE_POINTER SmbiosEnd;=0D
+=0D
+ SmbiosEnd.Raw =3D Smbios.Raw + Length;=0D
+=0D
+ if (Smbios.Raw >=3D SmbiosEnd.Raw || Smbios.Raw =3D=3D NULL) {=0D
+ return EFI_INVALID_PARAMETER;=0D
+ }=0D
+=0D
+ do {=0D
+ //=0D
+ // Make sure not to access memory beyond SmbiosEnd=0D
+ //=0D
+ if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||=0D
+ Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {=0D
+ return EFI_INVALID_PARAMETER;=0D
+ }=0D
+ //=0D
+ // Check for end marker=0D
+ //=0D
+ if (Smbios.Hdr->Type =3D=3D SMBIOS_TYPE_END_OF_TABLE) {=0D
+ break;=0D
+ }=0D
+ //=0D
+ // Make sure not to access memory beyond SmbiosEnd=0D
+ // Each structure shall be terminated by a double-null (0000h).=0D
+ //=0D
+ if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.R=
aw ||=0D
+ Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) {=
=0D
+ return EFI_INVALID_PARAMETER;=0D
+ }=0D
+ //=0D
+ // Install the table=0D
+ //=0D
+ SmbiosHandle =3D Smbios.Hdr->Handle;=0D
+ Status =3D SmbiosAdd (=0D
+ &mPrivateData.Smbios,=0D
+ ImageHandle,=0D
+ &SmbiosHandle,=0D
+ Smbios.Hdr=0D
+ );=0D
+=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return Status;=0D
+ }=0D
+ //=0D
+ // Go to the next SMBIOS structure. Each SMBIOS structure may include =
2 parts:=0D
+ // 1. Formatted section; 2. Unformatted string section. So, 2 steps ar=
e needed=0D
+ // to skip one SMBIOS structure.=0D
+ //=0D
+=0D
+ //=0D
+ // Step 1: Skip over formatted section.=0D
+ //=0D
+ String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);=0D
+=0D
+ //=0D
+ // Step 2: Skip over unformatted string section.=0D
+ //=0D
+ do {=0D
+ //=0D
+ // Each string is terminated with a NULL(00h) BYTE and the sets of s=
trings=0D
+ // is terminated with an additional NULL(00h) BYTE.=0D
+ //=0D
+ for ( ; *String !=3D 0; String++) {=0D
+ if ((UINTN) String >=3D (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {=
=0D
+ return EFI_INVALID_PARAMETER;=0D
+ }=0D
+ }=0D
+=0D
+ if (*(UINT8 *) ++String =3D=3D 0) {=0D
+ //=0D
+ // Pointer to the next SMBIOS structure.=0D
+ //=0D
+ Smbios.Raw =3D (UINT8 *) ++String;=0D
+ break;=0D
+ }=0D
+ } while (TRUE);=0D
+ } while (Smbios.Raw < SmbiosEnd.Raw);=0D
+=0D
+ return EFI_SUCCESS;=0D
+}=0D
+=0D
+/**=0D
+ Retrieve SMBIOS from Hob.=0D
+ @param ImageHandle Module's image handle=0D
+=0D
+ @retval EFI_SUCCESS Smbios from Hob is installed.=0D
+ @return EFI_NOT_FOUND Not found Smbios from Hob.=0D
+ @retval Other No Smbios from Hob is installed.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+RetrieveSmbiosFromHob (=0D
+ IN EFI_HANDLE ImageHandle=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ UINTN Index;=0D
+ SMBIOS_STRUCTURE_POINTER Smbios;=0D
+ EFI_HOB_GUID_TYPE *GuidHob;=0D
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableAdress;=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;=0D
+ VOID *TableAddress;=0D
+ UINTN TableMaximumSize;=0D
+=0D
+ Status =3D EFI_NOT_FOUND;=0D
+=0D
+ for (Index =3D 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) {=0D
+ GuidHob =3D GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid);=0D
+ if (GuidHob =3D=3D NULL) {=0D
+ continue;=0D
+ }=0D
+ GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DA=
TA (GuidHob);=0D
+ if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_=
SIZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (Guid=
Hob))) {=0D
+ if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_SMBIOS_TABLE_RE=
VISION) {=0D
+ //=0D
+ // UNIVERSAL_PAYLOAD_SMBIOS_TABLE structure is used when Revision =
equals to UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION=0D
+ //=0D
+ SmBiosTableAdress =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_=
HOB_DATA (GuidHob);=0D
+ if (GenericHeader->Length >=3D UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FI=
ELD (UNIVERSAL_PAYLOAD_SMBIOS_TABLE, SmBiosEntryPoint)) {=0D
+ if (mIsSmbiosTableValid[Index].IsValid ((VOID *) (UINTN )SmBiosT=
ableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) {=0D
+ Smbios.Raw =3D TableAddress;=0D
+ Status =3D ParseAndAddExistingSmbiosTable (ImageHandle, Smbios=
, TableMaximumSize);=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse=
preinstalled tables from Guid Hob\n"));=0D
+ Status =3D EFI_UNSUPPORTED;=0D
+ } else {=0D
+ return EFI_SUCCESS;=0D
+ }=0D
+ }=0D
+ }=0D
+ }=0D
+ }=0D
+ }=0D
+ return Status;=0D
+}=0D
+=0D
/**=0D
=0D
Driver to produce Smbios protocol and pre-allocate 1 page for the final =
SMBIOS table.=0D
@@ -1451,5 +1741,6 @@ SmbiosDriverEntryPoint (
&mPrivateData.Smbios=0D
);=0D
=0D
+ RetrieveSmbiosFromHob (ImageHandle);=0D
return Status;=0D
}=0D
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h b/MdeModulePkg/Un=
iversal/SmbiosDxe/SmbiosDxe.h
index f97c85ae40..a131bdabec 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
@@ -1,7 +1,7 @@
/** @file=0D
This code supports the implementation of the Smbios protocol=0D
=0D
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/UefiBootServicesTableLib.h>=0D
#include <Library/PcdLib.h>=0D
+#include <Library/HobLib.h>=0D
+#include <UniversalPayload/SmbiosTable.h>=0D
=0D
#define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')=0D
typedef struct {=0D
@@ -121,4 +123,65 @@ SmbiosTableConstruction (
BOOLEAN Smbios64BitTable=0D
);=0D
=0D
+/**=0D
+ Validates a SMBIOS 3.0 table entry point.=0D
+=0D
+ @param TableEntry The SmBios table entry to validate.=0D
+ @param TableAddress On exit, point to the smbios table addres.=0D
+ @param TableMaximumSize On exit, point to the maximum size of the table=
.=0D
+=0D
+ @retval TRUE SMBIOS table entry point is valid.=0D
+ @retval FALSE SMBIOS table entry point is malformed.=0D
+=0D
+**/=0D
+STATIC=0D
+BOOLEAN=0D
+IsValidSmbios30Table (=0D
+ IN VOID *TableEntry,=0D
+ OUT VOID **TableAddress,=0D
+ OUT UINTN *TableMaximumSize=0D
+ );=0D
+=0D
+/**=0D
+ Validates a SMBIOS 2.0 table entry point.=0D
+=0D
+ @param TableEntry The SmBios table entry to validate.=0D
+ @param TableAddress On exit, point to the smbios table addres.=0D
+ @param TableMaximumSize On exit, point to the maximum size of the table=
.=0D
+=0D
+ @retval TRUE SMBIOS table entry point is valid.=0D
+ @retval FALSE SMBIOS table entry point is malformed.=0D
+=0D
+**/=0D
+STATIC=0D
+BOOLEAN=0D
+IsValidSmbios20Table (=0D
+ IN VOID *TableEntry,=0D
+ OUT VOID **TableAddress,=0D
+ OUT UINTN *TableMaximumSize=0D
+ );=0D
+=0D
+/**=0D
+ Validates a SMBIOS table entry point.=0D
+=0D
+ @param TableEntry The SmBios table entry to validate.=0D
+ @param TableAddress On exit, point to the smbios table addres.=0D
+ @param TableMaximumSize On exit, point to the maximum size of the table=
.=0D
+=0D
+ @retval TRUE SMBIOS table entry point is valid.=0D
+ @retval FALSE SMBIOS table entry point is malformed.=0D
+=0D
+**/=0D
+typedef=0D
+BOOLEAN=0D
+(* IS_SMBIOS_TABLE_VALID) (=0D
+ IN VOID *TableEntry,=0D
+ OUT VOID **TableAddress,=0D
+ OUT UINTN *TableMaximumSize=0D
+ );=0D
+typedef struct {=0D
+ EFI_GUID *Guid;=0D
+ IS_SMBIOS_TABLE_VALID IsValid;=0D
+} IS_SMBIOS_TABLE_VALID_ENTRY;=0D
+=0D
#endif=0D
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/=
Universal/SmbiosDxe/SmbiosDxe.inf
index f6c036e1dc..c03915a692 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
@@ -1,7 +1,7 @@
## @file=0D
# This driver initializes and installs the SMBIOS protocol, constructs SMB=
IOS table into system configuration table.=0D
#=0D
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -41,6 +41,7 @@
UefiDriverEntryPoint=0D
DebugLib=0D
PcdLib=0D
+ HobLib=0D
=0D
[Protocols]=0D
gEfiSmbiosProtocolGuid ## PRODUCES=0D
@@ -48,6 +49,8 @@
[Guids]=0D
gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES =
## SystemTable=0D
gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES =
## SystemTable=0D
+ gUniversalPayloadSmbios3TableGuid ## CONSUMES =
## HOB=0D
+ gUniversalPayloadSmbiosTableGuid ## SOMETIMES_CONSUMES =
## HOB=0D
=0D
[Pcd]=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES=0D
--=20
2.30.0.windows.2


[Patch V5 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Hob

Zhiguang Liu
 

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Include/UniversalPayload/SmbiosTable.h | 30 +++++++++++++++++=
+++++++++++++
MdeModulePkg/MdeModulePkg.dec | 6 ++++++
2 files changed, 36 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h b/MdeModul=
ePkg/Include/UniversalPayload/SmbiosTable.h
new file mode 100644
index 0000000000..94c4aaf7ee
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
@@ -0,0 +1,30 @@
+/** @file=0D
+ Define the structure for the Universal Payload SmBios.=0D
+=0D
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+ @par Revision Reference:=0D
+ - Universal Payload Specification 0.75 (https://universalpayload.githu=
b.io/documentation/)=0D
+**/=0D
+=0D
+#ifndef UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_=0D
+#define UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_=0D
+=0D
+#include <Uefi.h>=0D
+#include <UniversalPayload/UniversalPayload.h>=0D
+=0D
+#pragma pack (1)=0D
+=0D
+typedef struct {=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;=0D
+ EFI_PHYSICAL_ADDRESS SmBiosEntryPoint;=0D
+} UNIVERSAL_PAYLOAD_SMBIOS_TABLE;=0D
+=0D
+#pragma pack()=0D
+=0D
+#define UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION 1=0D
+=0D
+extern GUID gUniversalPayloadSmbios3TableGuid;=0D
+extern GUID gUniversalPayloadSmbiosTableGuid;=0D
+#endif // UNIVERSAL_PAYLOAD_SMBIOS_TABLE_H_=0D
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 5cee4e159a..377e868e7c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -410,6 +410,12 @@
## Include/UniversalPayload/PciRootBridges.h=0D
gUniversalPayloadPciRootBridgeInfoGuid =3D { 0xec4ebacb, 0x2638, 0x416e,=
{ 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}=0D
=0D
+ ## Include/UniversalPayload/SmbiosTable.h=0D
+ gUniversalPayloadSmbios3TableGuid =3D { 0x92b7896c, 0x3362, 0x46ce, { 0x=
99, 0xb3, 0x4f, 0x5e, 0x3c, 0x34, 0xeb, 0x42 } }=0D
+=0D
+ ## Include/UniversalPayload/SmbiosTable.h=0D
+ gUniversalPayloadSmbiosTableGuid =3D { 0x590a0d26, 0x06e5, 0x4d20, { 0x8=
a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } }=0D
+=0D
[Ppis]=0D
## Include/Ppi/AtaController.h=0D
gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,=
0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}=0D
--=20
2.30.0.windows.2


[Patch V5 3/9] UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob

Zhiguang Liu
 

UefiPayload parse gUniversalPayloadPciRootBridgeInfoGuid Guid Hob to
retrieve PCI root bridges information.
gUniversalPayloadPciRootBridgeInfoGuid Guid Hob should be created by
Bootloader.

Cc: Maurice Ma <maurice.ma@...>
Cc: Guo Dong <guo.dong@...>
Cc: Benjamin You <benjamin.you@...>
Reviewed-by: Guo Dong <guo.dong@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h | 40 ++++++=
++++++++++++++++++++++++++++++++--
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 47 ++++++=
++++++++++++++++++++++++++++++++++++++---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 8 ++++++=
+-
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c | 73 ++++++=
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +-
5 files changed, 162 insertions(+), 8 deletions(-)

diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h b/Uefi=
PayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
index c2961b3bee..3eee1fbeac 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
@@ -2,7 +2,7 @@
Header file of PciHostBridgeLib.=0D
=0D
Copyright (C) 2016, Red Hat, Inc.=0D
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>=0D
=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
@@ -11,14 +11,38 @@
#ifndef _PCI_HOST_BRIDGE_H=0D
#define _PCI_HOST_BRIDGE_H=0D
=0D
+#include <UniversalPayload/PciRootBridges.h>=0D
+=0D
typedef struct {=0D
ACPI_HID_DEVICE_PATH AcpiDevicePath;=0D
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;=0D
} CB_PCI_ROOT_BRIDGE_DEVICE_PATH;=0D
=0D
+/**=0D
+ Scan for all root bridges in platform.=0D
+=0D
+ @param[out] NumberOfRootBridges Number of root bridges detected=0D
+=0D
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.=0D
+**/=0D
PCI_ROOT_BRIDGE *=0D
ScanForRootBridges (=0D
- UINTN *NumberOfRootBridges=0D
+ OUT UINTN *NumberOfRootBridges=0D
+);=0D
+=0D
+/**=0D
+ Scan for all root bridges from Universal Payload PciRootBridgeInfoHob=0D
+=0D
+ @param[in] PciRootBridgeInfo Pointer of Universal Payload PCI Root B=
ridge Info Hob=0D
+ @param[out] NumberOfRootBridges Number of root bridges detected=0D
+=0D
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.=0D
+=0D
+**/=0D
+PCI_ROOT_BRIDGE *=0D
+RetrieveRootBridgeInfoFromHob (=0D
+ IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,=0D
+ OUT UINTN *NumberOfRootBridges=0D
);=0D
=0D
/**=0D
@@ -77,4 +101,16 @@ InitRootBridge (
OUT PCI_ROOT_BRIDGE *RootBus=0D
);=0D
=0D
+/**=0D
+ Initialize DevicePath for a PCI_ROOT_BRIDGE.=0D
+ @param[in] HID HID for device path=0D
+ @param[in] UID UID for device path=0D
+=0D
+ @retval A pointer to the new created device patch.=0D
+**/=0D
+EFI_DEVICE_PATH_PROTOCOL *=0D
+CreateRootBridgeDevicePath (=0D
+ IN UINT32 HID,=0D
+ IN UINT32 UID=0D
+);=0D
#endif=0D
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/U=
efiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 512c3127cc..a0d7cdc306 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -2,7 +2,7 @@
Library instance of PciHostBridgeLib library class for coreboot.=0D
=0D
Copyright (C) 2016, Red Hat, Inc.=0D
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>=0D
=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
@@ -19,6 +19,7 @@
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/PciHostBridgeLib.h>=0D
#include <Library/PciLib.h>=0D
+#include <Library/HobLib.h>=0D
=0D
#include "PciHostBridge.h"=0D
=0D
@@ -48,7 +49,6 @@ CB_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTempl=
ate =3D {
}=0D
};=0D
=0D
-=0D
/**=0D
Initialize a PCI_ROOT_BRIDGE structure.=0D
=0D
@@ -145,6 +145,27 @@ InitRootBridge (
return EFI_SUCCESS;=0D
}=0D
=0D
+/**=0D
+ Initialize DevicePath for a PCI_ROOT_BRIDGE.=0D
+ @param[in] HID HID for device path=0D
+ @param[in] UID UID for device path=0D
+=0D
+ @retval A pointer to the new created device patch.=0D
+**/=0D
+EFI_DEVICE_PATH_PROTOCOL *=0D
+CreateRootBridgeDevicePath (=0D
+ IN UINT32 HID,=0D
+ IN UINT32 UID=0D
+)=0D
+{=0D
+ CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;=0D
+ DevicePath =3D AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate),=
=0D
+ &mRootBridgeDevicePathTemplate);=0D
+ ASSERT (DevicePath !=3D NULL);=0D
+ DevicePath->AcpiDevicePath.HID =3D HID;=0D
+ DevicePath->AcpiDevicePath.UID =3D UID;=0D
+ return (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;=0D
+}=0D
=0D
/**=0D
Return all the root bridge instances in an array.=0D
@@ -161,10 +182,30 @@ PciHostBridgeGetRootBridges (
UINTN *Count=0D
)=0D
{=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo;=0D
+ EFI_HOB_GUID_TYPE *GuidHob;=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;=0D
+ //=0D
+ // Find Universal Payload PCI Root Bridge Info hob=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gUniversalPayloadPciRootBridgeInfoGuid);=0D
+ if (GuidHob !=3D NULL) {=0D
+ GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DA=
TA (GuidHob);=0D
+ if ((sizeof(UNIVERSAL_PAYLOAD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_S=
IZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (GuidH=
ob))) {=0D
+ if ((GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDG=
ES_REVISION) && (GenericHeader->Length >=3D sizeof (UNIVERSAL_PAYLOAD_PCI_R=
OOT_BRIDGES))) {=0D
+ //=0D
+ // UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES structure is used when Revis=
ion equals to UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION=0D
+ //=0D
+ PciRootBridgeInfo =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_G=
UID_HOB_DATA (GuidHob);=0D
+ if (PciRootBridgeInfo->Count <=3D (GET_GUID_HOB_DATA_SIZE (GuidHob=
) - sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES)) / sizeof(UNIVERSAL_PAYLOAD_=
PCI_ROOT_BRIDGE)) {=0D
+ return RetrieveRootBridgeInfoFromHob (PciRootBridgeInfo, Count);=
=0D
+ }=0D
+ }=0D
+ }=0D
+ }=0D
return ScanForRootBridges (Count);=0D
}=0D
=0D
-=0D
/**=0D
Free the root bridge instances array returned from=0D
PciHostBridgeGetRootBridges().=0D
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b=
/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
index 7896df2416..6069dcc0ef 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -2,7 +2,7 @@
# Library instance of PciHostBridgeLib library class for coreboot.=0D
#=0D
# Copyright (C) 2016, Red Hat, Inc.=0D
-# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>=
=0D
+# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -39,3 +39,9 @@
DevicePathLib=0D
MemoryAllocationLib=0D
PciLib=0D
+=0D
+[Guids]=0D
+ gUniversalPayloadPciRootBridgeInfoGuid=0D
+=0D
+[Pcd]=0D
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration=0D
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c=
b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
index fffbf04cad..b0268f0506 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
@@ -1,7 +1,7 @@
/** @file=0D
Scan the entire PCI bus for root bridges to support coreboot UEFI payloa=
d.=0D
=0D
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>=0D
=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
@@ -582,3 +582,74 @@ ScanForRootBridges (
=0D
return RootBridges;=0D
}=0D
+=0D
+/**=0D
+ Scan for all root bridges from Universal Payload PciRootBridgeInfoHob=0D
+=0D
+ @param[in] PciRootBridgeInfo Pointer of Universal Payload PCI Root B=
ridge Info Hob=0D
+ @param[out] NumberOfRootBridges Number of root bridges detected=0D
+=0D
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.=0D
+=0D
+**/=0D
+PCI_ROOT_BRIDGE *=0D
+RetrieveRootBridgeInfoFromHob (=0D
+ IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,=0D
+ OUT UINTN *NumberOfRootBridges=0D
+)=0D
+{=0D
+ PCI_ROOT_BRIDGE *PciRootBridges;=0D
+ UINTN Size;=0D
+ UINT8 Index;=0D
+=0D
+ ASSERT (PciRootBridgeInfo !=3D NULL);=0D
+ ASSERT (NumberOfRootBridges !=3D NULL);=0D
+ if (PciRootBridgeInfo =3D=3D NULL) {=0D
+ return NULL;=0D
+ }=0D
+ if (PciRootBridgeInfo->Count =3D=3D 0) {=0D
+ return NULL;=0D
+ }=0D
+ Size =3D PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE);=0D
+ PciRootBridges =3D (PCI_ROOT_BRIDGE *) AllocatePool (Size);=0D
+ ASSERT (PciRootBridges !=3D NULL);=0D
+ if (PciRootBridges =3D=3D NULL) {=0D
+ return NULL;=0D
+ }=0D
+ ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRI=
DGE));=0D
+=0D
+ //=0D
+ // Create all root bridges with PciRootBridgeInfoHob=0D
+ //=0D
+ for (Index =3D 0; Index < PciRootBridgeInfo->Count; Index++) {=0D
+ PciRootBridges[Index].Segment =3D PciRootBridgeInfo->Roo=
tBridge[Index].Segment;=0D
+ PciRootBridges[Index].Supports =3D PciRootBridgeInfo->Roo=
tBridge[Index].Supports;=0D
+ PciRootBridges[Index].Attributes =3D PciRootBridgeInfo->Roo=
tBridge[Index].Attributes;=0D
+ PciRootBridges[Index].DmaAbove4G =3D PciRootBridgeInfo->Roo=
tBridge[Index].DmaAbove4G;=0D
+ PciRootBridges[Index].NoExtendedConfigSpace =3D PciRootBridgeInfo->Roo=
tBridge[Index].NoExtendedConfigSpace;=0D
+ PciRootBridges[Index].ResourceAssigned =3D PciRootBridgeInfo->Res=
ourceAssigned;=0D
+ PciRootBridges[Index].AllocationAttributes =3D PciRootBridgeInfo->Roo=
tBridge[Index].AllocationAttributes;=0D
+ PciRootBridges[Index].DevicePath =3D CreateRootBridgeDevice=
Path(PciRootBridgeInfo->RootBridge[Index].HID, PciRootBridgeInfo->RootBridg=
e[Index].UID);=0D
+ CopyMem(&PciRootBridges[Index].Bus, &PciRootBridgeInfo->RootBr=
idge[Index].Bus, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ CopyMem(&PciRootBridges[Index].Io, &PciRootBridgeInfo->RootBr=
idge[Index].Io, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ CopyMem(&PciRootBridges[Index].Mem, &PciRootBridgeInfo->RootBr=
idge[Index].Mem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ CopyMem(&PciRootBridges[Index].MemAbove4G, &PciRootBridgeInfo->RootBr=
idge[Index].MemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ CopyMem(&PciRootBridges[Index].PMem, &PciRootBridgeInfo->RootBr=
idge[Index].PMem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ CopyMem(&PciRootBridges[Index].PMemAbove4G, &PciRootBridgeInfo->RootBr=
idge[Index].PMemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE)=
);=0D
+ }=0D
+=0D
+ *NumberOfRootBridges =3D PciRootBridgeInfo->Count;=0D
+=0D
+ //=0D
+ // Now, this library only supports RootBridge that ResourceAssigned is T=
rue=0D
+ //=0D
+ if (PciRootBridgeInfo->ResourceAssigned) {=0D
+ PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);=0D
+ } else {=0D
+ DEBUG ((DEBUG_ERROR, "There is root bridge whose ResourceAssigned is F=
ALSE\n"));=0D
+ PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE);=0D
+ return NULL;=0D
+ }=0D
+=0D
+ return PciRootBridges;=0D
+}=0D
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload=
Pkg.dsc
index 37ad5a0ae7..e9211adf86 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -323,7 +323,6 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|$(SERIAL_FIFO_CONTRO=
L)=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|$(SERIAL_EXTE=
NDED_TX_FIFO_SIZE)=0D
=0D
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE=0D
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|$(UART_DEFAULT_BAUD_RATE=
)=0D
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|$(UART_DEFAULT_DATA_BITS=
)=0D
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|$(UART_DEFAULT_PARITY)=0D
@@ -363,6 +362,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|100=0D
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0=0D
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0=0D
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE=0D
=0D
##########################################################################=
######=0D
#=0D
--=20
2.30.0.windows.2


[Patch V5 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob

Zhiguang Liu
 

V5:
Add ExceptionList in MdeModulePkg\MdeModulePkg.ci.yaml, to avoid open CI
issue, because UID and HID are terms which are already used in current
source code.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Include/UniversalPayload/PciRootBridges.h | 91 ++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
++
MdeModulePkg/MdeModulePkg.ci.yaml | 2 ++
MdeModulePkg/MdeModulePkg.dec | 6 ++++++
3 files changed, 99 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h b/MdeMo=
dulePkg/Include/UniversalPayload/PciRootBridges.h
new file mode 100644
index 0000000000..3a7aae82d4
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
@@ -0,0 +1,91 @@
+/** @file=0D
+ This file defines the structure for the PCI Root Bridges.=0D
+=0D
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+ @par Revision Reference:=0D
+ - Universal Payload Specification 0.75 (https://universalpayload.githu=
b.io/documentation/)=0D
+**/=0D
+=0D
+#ifndef UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H_=0D
+#define UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H_=0D
+=0D
+#include <UniversalPayload/UniversalPayload.h>=0D
+=0D
+#pragma pack(1)=0D
+=0D
+//=0D
+// (Base > Limit) indicates an aperture is not available.=0D
+//=0D
+typedef struct {=0D
+ //=0D
+ // Base and Limit are the device address instead of host address when=0D
+ // Translation is not zero=0D
+ //=0D
+ UINT64 Base;=0D
+ UINT64 Limit;=0D
+ //=0D
+ // According to UEFI 2.7, Device Address =3D Host Address + Translation,=
=0D
+ // so Translation =3D Device Address - Host Address.=0D
+ // On platforms where Translation is not zero, the subtraction is probab=
ly to=0D
+ // be performed with UINT64 wrap-around semantics, for we may translate =
an=0D
+ // above-4G host address into a below-4G device address for legacy PCIe =
device=0D
+ // compatibility.=0D
+ //=0D
+ // NOTE: The alignment of Translation is required to be larger than any =
BAR=0D
+ // alignment in the same root bridge, so that the same alignment can be=
=0D
+ // applied to both device address and host address, which simplifies the=
=0D
+ // situation and makes the current resource allocation code in generic P=
CI=0D
+ // host bridge driver still work.=0D
+ //=0D
+ UINT64 Translation;=0D
+} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE;=0D
+=0D
+///=0D
+/// Payload PCI Root Bridge Information HOB=0D
+///=0D
+typedef struct {=0D
+ UINT32 Segment; ///< S=
egment number.=0D
+ UINT64 Supports; ///< S=
upported attributes.=0D
+ ///< R=
efer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes()=0D
+ ///< a=
nd SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.=0D
+ UINT64 Attributes; ///< I=
nitial attributes.=0D
+ ///< R=
efer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes()=0D
+ ///< a=
nd SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.=0D
+ BOOLEAN DmaAbove4G; ///< D=
MA above 4GB memory.=0D
+ ///< S=
et to TRUE when root bridge supports DMA above 4GB memory.=0D
+ BOOLEAN NoExtendedConfigSpace; ///< W=
hen FALSE, the root bridge supports=0D
+ ///< E=
xtended (4096-byte) Configuration Space.=0D
+ ///< W=
hen TRUE, the root bridge supports=0D
+ ///< 2=
56-byte Configuration Space only.=0D
+ UINT64 AllocationAttributes; ///< A=
llocation attributes.=0D
+ ///< R=
efer to EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM and=0D
+ ///< E=
FI_PCI_HOST_BRIDGE_MEM64_DECODE used by GetAllocAttributes()=0D
+ ///< i=
n EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Bus; ///< B=
us aperture which can be used by the root bridge.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Io; ///< I=
O aperture which can be used by the root bridge.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE Mem; ///< M=
MIO aperture below 4GB which can be used by the root bridge.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE MemAbove4G; ///< M=
MIO aperture above 4GB which can be used by the root bridge.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE PMem; ///< P=
refetchable MMIO aperture below 4GB which can be used by the root bridge.=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; ///< P=
refetchable MMIO aperture above 4GB which can be used by the root bridge.=0D
+ UINT32 HID; ///< P=
nP hardware ID of the root bridge. This value must match the corresponding=
=0D
+ ///< _=
HID in the ACPI name space.=0D
+ UINT32 UID; ///< U=
nique ID that is required by ACPI if two devices have the same _HID.=0D
+ ///< T=
his value must also match the corresponding _UID/_HID pair in the ACPI name=
space.=0D
+} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE;=0D
+=0D
+typedef struct {=0D
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;=0D
+ BOOLEAN ResourceAssigned;=0D
+ UINT8 Count;=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE RootBridge[0];=0D
+} UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES;=0D
+=0D
+#pragma pack()=0D
+=0D
+#define UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION 1=0D
+=0D
+extern GUID gUniversalPayloadPciRootBridgeInfoGuid;=0D
+=0D
+#endif // UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_H_=0D
diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml b/MdeModulePkg/MdeModulePkg.=
ci.yaml
index 45783f12c1..4c71468bd3 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -16,6 +16,8 @@
## "<ErrorID>", "<KeyWord>"=0D
## ]=0D
"ExceptionList": [=0D
+ "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID",=0D
+ "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID",=0D
],=0D
## Both file path and directory path are accepted.=0D
"IgnoreFiles": [=0D
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 8d38383915..5cee4e159a 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -404,6 +404,12 @@
## Include/Guid/MigratedFvInfo.h=0D
gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,=
0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }=0D
=0D
+ #=0D
+ # GUID defined in UniversalPayload=0D
+ #=0D
+ ## Include/UniversalPayload/PciRootBridges.h=0D
+ gUniversalPayloadPciRootBridgeInfoGuid =3D { 0xec4ebacb, 0x2638, 0x416e,=
{ 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}=0D
+=0D
[Ppis]=0D
## Include/Ppi/AtaController.h=0D
gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,=
0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}=0D
--=20
2.30.0.windows.2


[Patch V5 1/9] MdeModulePkg: Add Universal Payload general definition header file

Zhiguang Liu
 

Add Universal Payload general definition header file according to
Universal Payload's documentation as below:
https://universalpayload.github.io/documentation/

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Reviewed-by: Hao A Wu <hao.a.wu@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 35 ++++++++++++=
+++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h b/Mde=
ModulePkg/Include/UniversalPayload/UniversalPayload.h
new file mode 100644
index 0000000000..e661306a9b
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
@@ -0,0 +1,35 @@
+/** @file=0D
+ Universal Payload general definitions.=0D
+=0D
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+ @par Revision Reference:=0D
+ - Universal Payload Specification 0.75 (https://universalpayload.githu=
b.io/documentation/)=0D
+**/=0D
+=0D
+#ifndef UNIVERSAL_PAYLOAD_H_=0D
+#define UNIVERSAL_PAYLOAD_H_=0D
+=0D
+#pragma pack(1)=0D
+=0D
+typedef struct {=0D
+ UINT8 Revision;=0D
+ UINT8 Reserved;=0D
+ UINT16 Length;=0D
+} UNIVERSAL_PAYLOAD_GENERIC_HEADER;=0D
+=0D
+#pragma pack()=0D
+=0D
+/**=0D
+ Returns the size of a structure of known type, up through and including =
a specified field.=0D
+=0D
+ @param TYPE The name of the data structure that contains the field=
specified by Field.=0D
+ @param Field The name of the field in the data structure.=0D
+=0D
+ @return size, in bytes.=0D
+=0D
+**/=0D
+#define UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYP=
E, Field) + sizeof (((TYPE *) 0)->Field))=0D
+=0D
+#endif // UNIVERSAL_PAYLOAD_H_=0D
--=20
2.30.0.windows.2


[Patch V5 0/9] Create multiple Hobs for Universal Payload

Zhiguang Liu
 

V1:
This patch set is based on Universal Payload on https://universalpayload.github.io/documentation/payload-interfaces/index.html
This patch set introduce one general header, three different hob types and how Universal Payload consume these hobs.

V2:
Move all the header files and Guid define to MdeModulePkg
Fix code bug when parsing SmbiosDxe.
Enhance error handling in AcpiTableProtocol.c.
Add AcpiTableDxe.inf in UefiPayload.fdf

V3:
Avoid duplicated code in SmBiosDxe.c

V4:
Add link to spec in header files' file comments
Avoid using PLD, because it may be confusing

V5:
Add ExceptionList in MdeModulePkg\MdeModulePkg.ci.yaml, in MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob

Zhiguang Liu (9):
MdeModulePkg: Add Universal Payload general definition header file
MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob
UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob
MdeModulePkg: Add new structure for the Universal Payload SMBios Table
Hob
MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables
UefiPayloadPkg: Create gUniversalPayloadSmbiosTableGuid Hob
MdeModulePkg: Add new structure for the Universal Payload ACPI Table
Hob
MdeModulePkg/ACPI: Install ACPI table from HOB.
UefiPayloadPkg: Create gUniversalPayloadAcpiTableGuid Hob

MdeModulePkg/Include/UniversalPayload/AcpiTable.h | 30 ++++++++++++++++++++++++++++++
MdeModulePkg/Include/UniversalPayload/PciRootBridges.h | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MdeModulePkg/Include/UniversalPayload/SmbiosTable.h | 30 ++++++++++++++++++++++++++++++
MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 35 +++++++++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.ci.yaml | 2 ++
MdeModulePkg/MdeModulePkg.dec | 15 +++++++++++++++
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38 +++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8 +++++---
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 28 +---------------------------
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 5 +----
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 4 +---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h | 40 ++++++++++++++++++++++++++++++++++++++--
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 8 +++++++-
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 23 ++++++++++++++++++++++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 5 +++--
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 4 +++-
UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +-
UefiPayloadPkg/UefiPayloadPkg.fdf | 4 ++++
25 files changed, 1031 insertions(+), 87 deletions(-)
create mode 100644 MdeModulePkg/Include/UniversalPayload/AcpiTable.h
create mode 100644 MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
create mode 100644 MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
create mode 100644 MdeModulePkg/Include/UniversalPayload/UniversalPayload.h

--
2.30.0.windows.2


Re: [PATCH] SecurityPkg: TcgStorageOpalLib: Initialize SupportedAttributes parameter.

Wang, Jian J
 

Acked-by: Jian J Wang <jian.j.wang@...>

-----Original Message-----
From: Kuo, Scottie <scottie.kuo@...>
Sent: Tuesday, June 01, 2021 5:26 PM
To: Yao, Jiewen <jiewen.yao@...>; devel@edk2.groups.io; Wang, Jian J
<jian.j.wang@...>
Cc: Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1
<rahul1.kumar@...>; Chu, Maggie <maggie.chu@...>
Subject: RE: [PATCH] SecurityPkg: TcgStorageOpalLib: Initialize
SupportedAttributes parameter.

Hi, @Wang, Jian J
Please help to review the patch. Thanks😊

Best regards,
Scottie

-----Original Message-----
From: Yao, Jiewen <jiewen.yao@...>
Sent: Thursday, May 27, 2021 6:32 PM
To: Kuo, Scottie <scottie.kuo@...>; devel@edk2.groups.io
Cc: Zhang, Qi1 <qi1.zhang@...>; Kumar, Rahul1
<rahul1.kumar@...>; Chu, Maggie <maggie.chu@...>; Wang, Jian
J <jian.j.wang@...>
Subject: RE: [PATCH] SecurityPkg: TcgStorageOpalLib: Initialize
SupportedAttributes parameter.

Reviewed-by: Jiewen Yao <Jiewen.yao@...>

Hi Scottie
Please remember to add Wang, Jian J as reviewer too.

Thank you
Yao Jiewen

-----Original Message-----
From: Kuo, Scottie <scottie.kuo@...>
Sent: Monday, May 24, 2021 2:41 PM
To: devel@edk2.groups.io
Cc: Kuo, Scottie <scottie.kuo@...>; Zhang, Qi1
<qi1.zhang@...>; Kumar, Rahul1 <rahul1.kumar@...>; Yao,
Jiewen <jiewen.yao@...>; Chu, Maggie <maggie.chu@...>
Subject: [PATCH] SecurityPkg: TcgStorageOpalLib: Initialize
SupportedAttributes parameter.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3408

The value of SupportedAttributes in OpalGetSupportedAttributesInfo ()
is left undetermined, if the caller doesn't initialize it.
Initialize it in the function entry.

Signed-off-by: Scottie Kuo <scottie.kuo@...>
Cc: Qi Zhang <qi1.zhang@...>
Cc: Rahul Kumar <rahul1.kumar@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Maggie Chu <maggie.chu@...>
---
SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalCore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git
a/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalCore.c
b/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalCore.c
index b58597e61f..c840590e8e 100644
--- a/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalCore.c
+++ b/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalCore.c
@@ -1,7 +1,7 @@
/** @file
Public API for Opal Core library.

-Copyright (c) 2016 - 2018, Intel Corporation. All rights
reserved.<BR>
+Copyright (c) 2016 - 2021, Intel Corporation. All rights
+reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -1647,6 +1647,7 @@ OpalGetSupportedAttributesInfo(
NULL_CHECK(OpalBaseComId);

ZeroMem(Buffer, BUFFER_SIZE);
+ ZeroMem(SupportedAttributes, sizeof(OPAL_DISK_SUPPORT_ATTRIBUTE));
ASSERT(sizeof(Buffer) >= sizeof(TCG_SUPPORTED_SECURITY_PROTOCOLS));

//
--
2.26.2.windows.1


回复: 回复: [edk2-devel] [PATCH v1 1/1] Pytool: SpellCheck: Fix incorrect file mask across package matrices

gaoliming
 

Create PR https://github.com/tianocore/edk2/pull/1713

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Kun Qin
发送时间: 2021年6月12日 11:50
收件人: gaoliming <gaoliming@...>; devel@edk2.groups.io
抄送: 'Sean Brogan' <sean.brogan@...>; 'Bret Barkelew'
<Bret.Barkelew@...>; 'Michael D Kinney'
<michael.d.kinney@...>
主题: Re: 回复: [edk2-devel] [PATCH v1 1/1] Pytool: SpellCheck: Fix
incorrect
file mask across package matrices

Thanks for the review, Liming. Could you please help merging this patch
to the master when you have a chance?

Thanks in advance!
Kun

On 06/10/2021 20:23, gaoliming wrote:
Reviewed-by: Liming Gao <gaoliming@...>

-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Kun Qin
发送时间: 2021年6月10日 9:48
收件人: devel@edk2.groups.io
抄送: Sean Brogan <sean.brogan@...>; Bret Barkelew
<Bret.Barkelew@...>; Michael D Kinney
<michael.d.kinney@...>; Liming Gao <gaoliming@...>
主题: [edk2-devel] [PATCH v1 1/1] Pytool: SpellCheck: Fix incorrect
file
mask
across package matrices

From: Sean Brogan <spbrogan@...>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3443

Existing implementation could modify class global data that causes
potential incorrect file mask to be used for execution of plugin.

This change switches class variable to be tuple so that it cannot be
accidently modified. Local usage of STANDARD_PLUGIN_DEFINED_PATHS
is
also
changed to copy to new list before modification.

Cc: Sean Brogan <sean.brogan@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>

Signed-off-by: Sean Brogan <sean.brogan@...>
---
.pytool/Plugin/SpellCheck/SpellCheck.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.pytool/Plugin/SpellCheck/SpellCheck.py
b/.pytool/Plugin/SpellCheck/SpellCheck.py
index 43365441b91c..9ad57632a6e8 100644
--- a/.pytool/Plugin/SpellCheck/SpellCheck.py
+++ b/.pytool/Plugin/SpellCheck/SpellCheck.py
@@ -37,12 +37,12 @@ class SpellCheck(ICiBuildPlugin):
#
# A package can remove any of these using IgnoreStandardPaths
#
- STANDARD_PLUGIN_DEFINED_PATHS = ["*.c", "*.h",
+ STANDARD_PLUGIN_DEFINED_PATHS = ("*.c", "*.h",
"*.nasm", "*.asm",
"*.masm",
"*.s",
"*.asl",
"*.dsc", "*.dec", "*.fdf",
"*.inf",
"*.md", "*.txt"
- ]
+ )

def GetTestName(self, packagename: str, environment: VarDict) ->
tuple:
""" Provide the testcase name and classname for use in
reporting
@@ -107,7 +107,8 @@ class SpellCheck(ICiBuildPlugin):
version_aggregator.GetVersionAggregator().ReportVersion(
"CSpell", cspell_version,
version_aggregator.VersionTypes.INFO)

- package_relative_paths_to_spell_check =
SpellCheck.STANDARD_PLUGIN_DEFINED_PATHS
+ # copy the default as a list
+ package_relative_paths_to_spell_check =
list(SpellCheck.STANDARD_PLUGIN_DEFINED_PATHS)

#
# Allow the ci.yaml to remove any of the above standard
paths
--
2.31.1.windows.1








Re: [PATCH 1/1] BaseTools GenFw: Keep read only alloc section as text section when convert ELF

Bob Feng
 

Reviewed-by: Bob Feng <bob.c.feng@...>

-----Original Message-----
From: Liming Gao <gaoliming@...>
Sent: Wednesday, June 9, 2021 6:06 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@...>; Ni, Ray <ray.ni@...>
Subject: [PATCH 1/1] BaseTools GenFw: Keep read only alloc section as text section when convert ELF

This is the fix of the regression issue at c6b872c6.
Based on ELF spec, readonly alloc section is .rodata section. It is requried.
This fix is to add back original check logic for ELF section. Now, the readonly alloc section and execute alloc section are regarded as .text section.

Signed-off-by: Liming Gao <gaoliming@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Ray Ni <ray.ni@...>
---
With this fix, previous fix commit ec1cffd9 is not required. But, the checker added by commit ec1cffd9 is correct for ACPI data conversion. So, I don't plan to revert it.

BaseTools/Source/C/GenFw/Elf32Convert.c | 3 ++- BaseTools/Source/C/GenFw/Elf64Convert.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 314f8233234d..d917a444c82d 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -238,7 +238,8 @@ IsTextShdr (
Elf_Shdr *Shdr
)
{
- return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
+ return (BOOLEAN) (((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC)) ||
+ ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) ==
+ SHF_ALLOC));
}

STATIC
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 8b09db7b690b..33031ec8f6e7 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -246,7 +246,8 @@ IsTextShdr (
Elf_Shdr *Shdr
)
{
- return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
+ return (BOOLEAN) (((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC)) ||
+ ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) ==
+ SHF_ALLOC));
}

STATIC
--
2.27.0.windows.1


回复: [edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 06/15/2021 #cal-reminder

gaoliming
 

Hi, all

 The following issues will be discussed in this week TianoCore Bug Triage meeting.

 

3458

EDK2

Code

unassigned@...

UNCO

Add support IORT Rev E.b specification updates

16:28:58

sami.mujawar@...

3457

EDK2

Code

unassigned@...

UNCO

Support measured AMD SEV boot with kernel/initrd/cmdline

Mon 03:31

dovmurik@...

3456

EDK2 Pla

BoardMod

unassigned@...

UNCO

RngLib not found error when the CAPSULE_ENABLE defined.

Sun 09:19

jiaoxf95@...

3315

EDK2

Code

mhaeuser@...

UNCO

DxeCore: Unloading image pre-CpuDxe may dereference NULL

Sat 09:30

mhaeuser@...

3455

EDK2

Code

sachin.agrawal@...

UNCO

RSA PSS API had better enforce SaltSize to be same as DigestSize

Sat 07:35

jiewen.yao@...

3454

EDK2

Code

unassigned@...

UNCO

Spellcheck plugin finds fewer files when run on Linux

Sat 01:06

sean.brogan@...

3445

EDK2

Code

unassigned@...

UNCO

Update node to at least 12 to support cspell

Fri 23:58

kun.qin@...

3453

EDK2

Code

unassigned@...

UNCO

ipxe Boot throws exception when accessing SNP Interfaces

Fri 08:35

sivaramann@...

3447

Tianocor

Code

zhiguang.liu@...

UNCO

Create header files and multiple Hobs for Universal Payload

Thu 22:05

zhiguang.liu@...

3449

EDK2

Code

unassigned@...

UNCO

VariablePolicy needs to replace VariableLock.

Thu 17:33

klautner@...

3448

Tianocor

Code

unassigned@...

UNCO

EDK II platform for Cherry Trail

Thu 13:22

nicklas.frahm@...

3446

Tianocor

Code

unassigned@...

UNCO

TianoCore missing support for Specification 2.8 Items

Thu 12:44

kevin.davis@...

3444

EDK2 Pla

OptionRo

unassigned@...

UNCO

FtdiUsbSerialDriverDxe doesn't properly initialize

Wed 14:38

jack.tay.little@...

3442

EDK2

Code

unassigned@...

UNCO

The value of TPM_RC_BAD_TAG is wrong

Wed 06:21

nicolas.iooss.2010_tianocor...

3441

EDK2

Code

zhiguang.liu@...

UNCO

Device path has wrong FV path if the boot manager menu is from different FV

2021-06-09

zhiguang.liu@...

3402

EDK2

Code

unassigned@...

UNCO

it will take too long time(about 40s) to save IIO Configuration SETUP value on EGS CRB board.

2021-06-09

shengfengx.xue@...

3440

EDK2

Code

unassigned@...

UNCO

Add MM Configuration PPI definition to MdePkg

2021-06-09

kun.qin@...

 

Thanks

Liming

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 devel@edk2.groups.io Calendar
发送时间: 2021615 9:30
收件人: devel@edk2.groups.io
主题: [edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 06/15/2021 #cal-reminder

 

Reminder: TianoCore Bug Triage - APAC / NAMO

When:
06/15/2021
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Liming Gao gaoliming@...

View Event

Description:

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,77463821#   United States, Sacramento

Phone Conference ID: 774 638 21#

Find a local number | Reset PIN

Learn More | Meeting options


Re: [PATCH 0/4] Prepare bhyve's OVMF for GPU-Passthrough

Peter Grehan
 

Hi Corvin,

GPU-Passthrough for bhyve requires a few patches to work properly.
These patches will allow GPU-Passthrough for bhyve.
It will work for dedicated AMD GPUs and integrated Intel GPUs.
I have no issue with adding USB support or fixing the PCI32 base: that either codifies existing behaviour or adds functionality.

However, flipping the switch over to bus enumeration being in EFI is a policy change in how bhyve has always worked - can that be discussed on the freebsd-virtualization first ?

later,

Peter.


Re: [edk2-platforms PATCH 0/4] ACPI MDIO support for Marvell SoCs

Jon Nettleton
 

On Mon, Jun 14, 2021 at 11:55 PM Leif Lindholm <leif@...> wrote:

Hi Marcin,

On Sun, Jun 13, 2021 at 20:16:27 +0200, Marcin Wojtas wrote:
Hi,

The MDIO ACPI binding has been established and merged to the
Linux tree,
Congratulations! :)

Is FreeBSD expected to follow suit?

hence it is now possible to update the ACPI
description of the platforms that base on the Marvell SoCs.

For convenience, the code is exposed in the public github branch:
https://github.com/semihalf-wojtas-marcin/edk2-platforms/commits/acpi-mdio-r20210613
There is also MacchiatoBin firmware binary avaialable for testing:
https://drive.google.com/file/d/1eigP_aeM4wYQpEaLAlQzs3IN_w1-kQr0

I'm looking forward to the comments or remarks.
The patches themselves look straightforward enough.
I *would* prefer some tested-by, for these sources rather than the
binary, before merging though.
I will get the ACPI changes from Marcin and put a Tested-By on
from SolidRun's side.

Jon


Best Regards,

Leif

Best regards,
Marcin

Marcin Wojtas (4):
SolidRun/Armada80x0McBin: Add ACPI MDIO description
Marvell/Cn913xDb: Add ACPI MDIO description
Marvell/Armada70x0Db: Add ACPI MDIO description
Marvell/Armada80x0Db: Add ACPI MDIO description

Silicon/Marvell/Armada7k8k/AcpiTables/Armada70x0Db/Dsdt.asl | 24 +++++++++
Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0Db/Dsdt.asl | 38 ++++++++++++++
Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0McBin/Dsdt.asl | 53 ++++++++++++++++++++
Silicon/Marvell/OcteonTx/AcpiTables/T91/Cn9131DbA/Ssdt.asl | 1 +
Silicon/Marvell/OcteonTx/AcpiTables/T91/Cn913xDbA/Dsdt.asl | 24 +++++++++
5 files changed, 140 insertions(+)

--
2.29.0


Re: [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV

Wu, Hao A
 

-----Original Message-----
From: Liu, Zhiguang <zhiguang.liu@...>
Sent: Wednesday, June 9, 2021 5:37 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@...>; Wu, Hao A <hao.a.wu@...>;
Gao, Zhichao <zhichao.gao@...>; Ni, Ray <ray.ni@...>
Subject: [PATCH] MdeModulePkg: Fix device path when the boot manager
menu is from different FV

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3441

When the boot manager menu is from different FV, the current logic still use
the
device path of the FV as the module links to this library

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Zhichao Gao <zhichao.gao@...>
Cc: Ray Ni <ray.ni@...>
Signed-off-by: Zhiguang Liu <zhiguang.liu@...>
---
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 28 +++-------------
------------
1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index bef41ae102..95d185b639 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -2405,13 +2405,9 @@ BmRegisterBootManagerMenu (
CHAR16 *Description;

UINTN DescriptionLength;

EFI_DEVICE_PATH_PROTOCOL *DevicePath;

- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;

- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;

UINTN HandleCount;

EFI_HANDLE *Handles;

UINTN Index;

- VOID *Data;

- UINTN DataSize;



DevicePath = NULL;

Description = NULL;

@@ -2437,22 +2433,17 @@ BmRegisterBootManagerMenu (
}



if (DevicePath == NULL) {

- Data = NULL;

- Status = GetSectionFromAnyFv (

+ Status = GetFileDevicePathFromAnyFv (

PcdGetPtr (PcdBootManagerMenuFile),

EFI_SECTION_PE32,

0,

- (VOID **) &Data,

- &DataSize

+ &DevicePath

);

- if (Data != NULL) {

- FreePool (Data);

- }

if (EFI_ERROR (Status)) {

DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be
found, skip its boot option registration\n"));

return EFI_NOT_FOUND;

}

-

+ ASSERT (DevicePath != NULL);

//

// Get BootManagerMenu application's description from EFI User
Interface Section.

//

@@ -2466,19 +2457,6 @@ BmRegisterBootManagerMenu (
if (EFI_ERROR (Status)) {

Description = NULL;

}

-

- EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr
(PcdBootManagerMenuFile));

- Status = gBS->HandleProtocol (

- gImageHandle,

- &gEfiLoadedImageProtocolGuid,

- (VOID **) &LoadedImage

- );

- ASSERT_EFI_ERROR (Status);

- DevicePath = AppendDevicePathNode (

- DevicePathFromHandle (LoadedImage->DeviceHandle),

- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode

- );

- ASSERT (DevicePath != NULL);

}

Acked-by: Hao A Wu <hao.a.wu@...>

Best Regards,
Hao Wu





Status = EfiBootManagerInitializeLoadOption (

--
2.30.0.windows.2


Re: [RESEND PATCH v2] BaseTools: Add support for RISCV GOT/PLT relocations

Daniel Schaefer
 

Great commit message, thanks Sunil!
Maintainers, please take a look and let us know if there's any other concern.
This patch lets us build the RISC-V platforms using modern toolchains that are provided directly by the distributions, rather than building your own from source.

Thanks,
Daniel


From: Sunil V L <sunilvl@...>
Sent: Friday, June 11, 2021 22:08
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>; Schaefer, Daniel <daniel.schaefer@...>; Bob Feng <bob.c.feng@...>; Liming Gao <gaoliming@...>; Yuwei Chen <yuwei.chen@...>; Heinrich Schuchardt <xypron.glpk@...>
Subject: Re: [RESEND PATCH v2] BaseTools: Add support for RISCV GOT/PLT relocations
 
Hi,
    I just edited the commit message to indicate the module and CC the
    maintainers. Could I get the feedback please?
Thanks
Sunil

On Fri, Jun 11, 2021 at 07:35:03PM +0530, Sunil V L wrote:
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3096
>
> This patch adds support for R_RISCV_CALL_PLT and R_RISCV_GOT_HI20
> relocations generated by PIE enabled compiler. This also needed
> changes to R_RISCV_32 and R_RISCV_64 relocations as explained in
> https://github.com/riscv/riscv-gnu-toolchain/issues/905#issuecomment-846682710
>
> Changes in v2:
>   - Addressed Daniel's comment on formatting
>
> Testing:
> 1) Debian GCC 8.3.0 and booted sifive_u and QMEU virt models.
> 2) Debian 10.2.0 and booted QEMU virt model.
> 3) riscv-gnu-tool chain 9.2 and booted QEMU virt model.
>
> Signed-off-by: Sunil V L <sunilvl@...>
>
> Acked-by: Abner Chang <abner.chang@...>
> Reviewed-by: Daniel Schaefer <daniel.schaefer@...>
> Tested-by: <daniel.schaefer@...>
>
> Cc: Bob Feng <bob.c.feng@...>
> Cc: Liming Gao <gaoliming@...>
> Cc: Yuwei Chen <yuwei.chen@...>
> Cc: Heinrich Schuchardt <xypron.glpk@...>
> ---
>  BaseTools/Source/C/GenFw/Elf64Convert.c | 44 +++++++++++++++++++++----
>  1 file changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
> index d097db8632..d684318269 100644
> --- a/BaseTools/Source/C/GenFw/Elf64Convert.c
> +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
> @@ -129,6 +129,8 @@ STATIC UINT32 mDebugOffset;
>  STATIC UINT8       *mRiscVPass1Targ = NULL;
>  STATIC Elf_Shdr    *mRiscVPass1Sym = NULL;
>  STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
> +STATIC INT32       mRiscVPass1Offset;
> +STATIC INT32       mRiscVPass1GotFixup;

>  //
>  // Initialization Function
> @@ -479,11 +481,11 @@ WriteSectionRiscV64 (
>      break;

>    case R_RISCV_32:
> -    *(UINT32 *)Targ = (UINT32)((UINT64)(*(UINT32 *)Targ) - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);
> +    *(UINT64 *)Targ = Sym->st_value + Rel->r_addend;
>      break;

>    case R_RISCV_64:
> -    *(UINT64 *)Targ = *(UINT64 *)Targ - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx];
> +    *(UINT64 *)Targ = Sym->st_value + Rel->r_addend;
>      break;

>    case R_RISCV_HI20:
> @@ -533,6 +535,18 @@ WriteSectionRiscV64 (
>      mRiscVPass1SymSecIndex = 0;
>      break;

> +  case R_RISCV_GOT_HI20:
> +    Value = (Sym->st_value - Rel->r_offset);
> +    mRiscVPass1Offset = RV_X(Value, 0, 12);
> +    Value = RV_X(Value, 12, 20);
> +    *(UINT32 *)Targ = (Value << 12) | (RV_X(*(UINT32*)Targ, 0, 12));
> +
> +    mRiscVPass1Targ = Targ;
> +    mRiscVPass1Sym = SymShdr;
> +    mRiscVPass1SymSecIndex = Sym->st_shndx;
> +    mRiscVPass1GotFixup = 1;
> +    break;
> +
>    case R_RISCV_PCREL_HI20:
>      mRiscVPass1Targ = Targ;
>      mRiscVPass1Sym = SymShdr;
> @@ -545,11 +559,17 @@ WriteSectionRiscV64 (
>      if (mRiscVPass1Targ != NULL && mRiscVPass1Sym != NULL && mRiscVPass1SymSecIndex != 0) {
>        int i;
>        Value2 = (UINT32)(RV_X(*(UINT32 *)mRiscVPass1Targ, 12, 20));
> -      Value = (UINT32)(RV_X(*(UINT32 *)Targ, 20, 12));
> -      if(Value & (RISCV_IMM_REACH/2)) {
> -        Value |= ~(RISCV_IMM_REACH-1);
> +
> +      if(mRiscVPass1GotFixup) {
> +        Value = (UINT32)(mRiscVPass1Offset);
> +      } else {
> +        Value = (UINT32)(RV_X(*(UINT32 *)Targ, 20, 12));
> +        if(Value & (RISCV_IMM_REACH/2)) {
> +          Value |= ~(RISCV_IMM_REACH-1);
> +        }
>        }
>        Value = Value - (UINT32)mRiscVPass1Sym->sh_addr + mCoffSectionsOffset[mRiscVPass1SymSecIndex];
> +
>        if(-2048 > (INT32)Value) {
>          i = (((INT32)Value * -1) / 4096);
>          Value2 -= i;
> @@ -569,12 +589,21 @@ WriteSectionRiscV64 (
>          }
>        }

> -      *(UINT32 *)Targ = (RV_X(Value, 0, 12) << 20) | (RV_X(*(UINT32*)Targ, 0, 20));
> +      if(mRiscVPass1GotFixup) {
> +        *(UINT32 *)Targ = (RV_X((UINT32)Value, 0, 12) << 20)
> +                            | (RV_X(*(UINT32*)Targ, 0, 20));
> +        /* Convert LD instruction to ADDI */
> +        *(UINT32 *)Targ = ((*(UINT32 *)Targ & ~0x707f) | 0x13);
> +      } else {
> +        *(UINT32 *)Targ = (RV_X(Value, 0, 12) << 20) | (RV_X(*(UINT32*)Targ, 0, 20));
> +      }
>        *(UINT32 *)mRiscVPass1Targ = (RV_X(Value2, 0, 20)<<12) | (RV_X(*(UINT32 *)mRiscVPass1Targ, 0, 12));
>      }
>      mRiscVPass1Sym = NULL;
>      mRiscVPass1Targ = NULL;
>      mRiscVPass1SymSecIndex = 0;
> +    mRiscVPass1Offset = 0;
> +    mRiscVPass1GotFixup = 0;
>      break;

>    case R_RISCV_ADD64:
> @@ -586,6 +615,7 @@ WriteSectionRiscV64 (
>    case R_RISCV_GPREL_I:
>    case R_RISCV_GPREL_S:
>    case R_RISCV_CALL:
> +  case R_RISCV_CALL_PLT:
>    case R_RISCV_RVC_BRANCH:
>    case R_RISCV_RVC_JUMP:
>    case R_RISCV_RELAX:
> @@ -1528,6 +1558,7 @@ WriteRelocations64 (
>              case R_RISCV_GPREL_I:
>              case R_RISCV_GPREL_S:
>              case R_RISCV_CALL:
> +            case R_RISCV_CALL_PLT:
>              case R_RISCV_RVC_BRANCH:
>              case R_RISCV_RVC_JUMP:
>              case R_RISCV_RELAX:
> @@ -1537,6 +1568,7 @@ WriteRelocations64 (
>              case R_RISCV_SET16:
>              case R_RISCV_SET32:
>              case R_RISCV_PCREL_HI20:
> +            case R_RISCV_GOT_HI20:
>              case R_RISCV_PCREL_LO12_I:
>                break;

> --
> 2.25.1
>


Event: TianoCore Bug Triage - APAC / NAMO - 06/15/2021 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Bug Triage - APAC / NAMO

When:
06/15/2021
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Liming Gao gaoliming@...

View Event

Description:

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,77463821#   United States, Sacramento

Phone Conference ID: 774 638 21#

Find a local number | Reset PIN

Learn More | Meeting options


Re: [PATCH v3 3/8] SecurityPkg: Create include file for default key content.

Yao, Jiewen
 

Hi
I am not sure why we hardcode 3 items for each.

Can we move this fdf to platform pkg, instead of security pkg ?

Thank you
Yao Jiewen

-----Original Message-----
From: Grzegorz Bernacki <gjb@...>
Sent: Monday, June 14, 2021 5:43 PM
To: devel@edk2.groups.io
Cc: leif@...; ardb+tianocore@...; Samer.El-Haj-
Mahmoud@...; sunny.Wang@...; mw@...;
upstream@...; Yao, Jiewen <jiewen.yao@...>; Wang, Jian J
<jian.j.wang@...>; Xu, Min M <min.m.xu@...>;
lersek@...; sami.mujawar@...; afish@...; Ni, Ray
<ray.ni@...>; Justen, Jordan L <jordan.l.justen@...>;
rebecca@...; grehan@...; thomas.abraham@...; Chiu,
Chasel <chasel.chiu@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; gaoliming@...; Dong, Eric
<eric.dong@...>; Kinney, Michael D <michael.d.kinney@...>; Sun,
Zailiang <zailiang.sun@...>; Qian, Yi <yi.qian@...>;
graeme@...; rad@...; pete@...; Grzegorz Bernacki
<gjb@...>
Subject: [PATCH v3 3/8] SecurityPkg: Create include file for default key content.

This commits add file which can be included by platform Flash
Description File. It allows to specify certificate files, which
will be embedded into binary file. The content of these files
can be used to initialize Secure Boot default keys and databases.

Signed-off-by: Grzegorz Bernacki <gjb@...>
---
SecurityPkg/SecureBootDefaultKeys.fdf.inc | 70 ++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 SecurityPkg/SecureBootDefaultKeys.fdf.inc

diff --git a/SecurityPkg/SecureBootDefaultKeys.fdf.inc
b/SecurityPkg/SecureBootDefaultKeys.fdf.inc
new file mode 100644
index 0000000000..bf4f2d42de
--- /dev/null
+++ b/SecurityPkg/SecureBootDefaultKeys.fdf.inc
@@ -0,0 +1,70 @@
+## @file
+# FDF include file which allows to embed Secure Boot keys
+#
+# Copyright (c) 2021, ARM Limited. All rights reserved.
+# Copyright (c) 2021, Semihalf. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+!if $(DEFAULT_KEYS) == TRUE
+ FILE FREEFORM = 85254ea7-4759-4fc4-82d4-5eed5fb0a4a0 {
+ !ifdef $(PK_DEFAULT_FILE)
+ SECTION RAW = $(PK_DEFAULT_FILE)
+ !endif
+ SECTION UI = "PK Default"
+ }
+
+ FILE FREEFORM = 6f64916e-9f7a-4c35-b952-cd041efb05a3 {
+ !ifdef $(KEK_DEFAULT_FILE1)
+ SECTION RAW = $(KEK_DEFAULT_FILE1)
+ !endif
+ !ifdef $(KEK_DEFAULT_FILE2)
+ SECTION RAW = $(KEK_DEFAULT_FILE2)
+ !endif
+ !ifdef $(KEK_DEFAULT_FILE3)
+ SECTION RAW = $(KEK_DEFAULT_FILE3)
+ !endif
+ SECTION UI = "KEK Default"
+ }
+
+ FILE FREEFORM = c491d352-7623-4843-accc-2791a7574421 {
+ !ifdef $(DB_DEFAULT_FILE1)
+ SECTION RAW = $(DB_DEFAULT_FILE1)
+ !endif
+ !ifdef $(DB_DEFAULT_FILE2)
+ SECTION RAW = $(DB_DEFAULT_FILE2)
+ !endif
+ !ifdef $(DB_DEFAULT_FILE3)
+ SECTION RAW = $(DB_DEFAULT_FILE3)
+ !endif
+ SECTION UI = "DB Default"
+ }
+
+ FILE FREEFORM = 36c513ee-a338-4976-a0fb-6ddba3dafe87 {
+ !ifdef $(DBT_DEFAULT_FILE1)
+ SECTION RAW = $(DBT_DEFAULT_FILE1)
+ !endif
+ !ifdef $(DBT_DEFAULT_FILE2)
+ SECTION RAW = $(DBT_DEFAULT_FILE2)
+ !endif
+ !ifdef $(DBT_DEFAULT_FILE3)
+ SECTION RAW = $(DBT_DEFAULT_FILE3)
+ !endif
+ SECTION UI = "DBT Default"
+ }
+
+ FILE FREEFORM = 5740766a-718e-4dc0-9935-c36f7d3f884f {
+ !ifdef $(DBX_DEFAULT_FILE1)
+ SECTION RAW = $(DBX_DEFAULT_FILE1)
+ !endif
+ !ifdef $(DBX_DEFAULT_FILE2)
+ SECTION RAW = $(DBX_DEFAULT_FILE2)
+ !endif
+ !ifdef $(DBX_DEFAULT_FILE3)
+ SECTION RAW = $(DBX_DEFAULT_FILE3)
+ !endif
+ SECTION UI = "DBX Default"
+ }
+
+!endif
--
2.25.1


Re: [Patch V2] BaseTools: Enable the flag to treat dynamic pcd as dynamicEx

Bob Feng
 

Add Mike Turner for review.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bob Feng
Sent: Tuesday, June 8, 2021 10:50 AM
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Kinney, Michael D <michael.d.kinney@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>
Subject: [edk2-devel] [Patch V2] BaseTools: Enable the flag to treat dynamic pcd as dynamicEx

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1688

In order to support binary build, build tool add a flag to convert type of Dynamic Pcd to DynamicEx Pcd

User can append -D PCD_DYNAMIC_AS_DYNAMICEX to build command to enable this function.
Also, user can add "PCD_DYNAMIC_AS_DYNAMICEX = TRUE/FALSE"
to the defines section of Dsc file to enable this function.

PCD_DYNAMIC_AS_DYNAMICEX is a new reserved key word for this function.

Signed-off-by: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...> ---Correct Liming's email address.
BaseTools/Source/Python/Common/DataType.py | 1 +
.../Python/Workspace/BuildClassObject.py | 153 ++++++++----------
.../Source/Python/Workspace/DecBuildData.py | 15 +-
.../Source/Python/Workspace/DscBuildData.py | 19 +--
.../Source/Python/Workspace/InfBuildData.py | 15 +-
5 files changed, 73 insertions(+), 130 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index fb88f20cc4..4e9c9e34af 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -402,10 +402,11 @@ TAB_DSC_DEFINES_DSC_SPECIFICATION = 'DSC_SPECIFICATION'
TAB_DSC_DEFINES_OUTPUT_DIRECTORY = 'OUTPUT_DIRECTORY' TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES = 'SUPPORTED_ARCHITECTURES' TAB_DSC_DEFINES_BUILD_TARGETS = 'BUILD_TARGETS' TAB_DSC_DEFINES_SKUID_IDENTIFIER = 'SKUID_IDENTIFIER' TAB_DSC_DEFINES_PCD_INFO_GENERATION = 'PCD_INFO_GENERATION'+TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX = 'PCD_DYNAMIC_AS_DYNAMICEX' TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION = 'PCD_VAR_CHECK_GENERATION' TAB_DSC_DEFINES_FLASH_DEFINITION = 'FLASH_DEFINITION' TAB_DSC_DEFINES_BUILD_NUMBER = 'BUILD_NUMBER' TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME' TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index ebb65fc2fe..88a1d1582c 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -10,11 +10,13 @@ from Common.DataType import * import collections import re from collections import OrderedDict from Common.Misc import CopyDict,ArrayIndex import copy+from CommonDataClass.DataClass import * import Common.EdkLogger as EdkLogger+import Common.GlobalData as GlobalData from Common.BuildToolError import OPTION_VALUE_INVALID from Common.caching import cached_property StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') ## PcdClassObject@@ -396,10 +398,71 @@ class StructurePcd(PcdClassObject):
new_pcd.ValueChain = {item for item in self.ValueChain} return new_pcd LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModList']) +class BuildData(object):+ # dict used to convert PCD type in database to string used by build tool++ _PCD_TYPE_STRING_ = {+ MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,+ MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,+ MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,+ MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,+ MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,+ MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,+ MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,+ MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ }++ def UpdatePcdTypeDict(self):+ if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX,"FALSE").upper() == "TRUE":+ self._PCD_TYPE_STRING_ = {+ MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,+ MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,+ MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,+ MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ }++ ## Convert the class to a string+ #+ # Convert member MetaFile of the class to a string+ #+ # @retval string Formatted String+ #+ def __str__(self):+ return str(self.MetaFile)++ ## Override __eq__ function+ #+ # Check whether ModuleBuildClassObjects are the same+ #+ # @retval False The two ModuleBuildClassObjects are different+ # @retval True The two ModuleBuildClassObjects are the same+ #+ def __eq__(self, Other):+ return self.MetaFile == Other++ ## Override __hash__ function+ #+ # Use MetaFile as key in hash table+ #+ # @retval string Key for hash table+ #+ def __hash__(self):+ return hash(self.MetaFile)+ ## ModuleBuildClassObject # # This Class defines ModuleBuildClass # # @param object: Inherited from object class@@ -440,11 +503,11 @@ LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModLis
# { [(PcdCName, PcdGuidCName)] : PcdClassObject} # @var BuildOptions: To store value for BuildOptions, it is a set structure as # { [BuildOptionKey] : BuildOptionValue} # @var Depex: To store value for Depex #-class ModuleBuildClassObject(object):+class ModuleBuildClassObject(BuildData): def __init__(self): self.AutoGenVersion = 0 self.MetaFile = '' self.BaseName = '' self.ModuleType = ''@@ -474,38 +537,10 @@ class ModuleBuildClassObject(object):
self.BuildOptions = {} self.Depex = {} self.StrPcdSet = [] self.StrPcdOverallValue = {} - ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether ModuleBuildClassObjects are the same- #- # @retval False The two ModuleBuildClassObjects are different- # @retval True The two ModuleBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)- ## PackageBuildClassObject # # This Class defines PackageBuildClass # # @param object: Inherited from object class@@ -525,11 +560,11 @@ class ModuleBuildClassObject(object):
# @var LibraryClasses: To store value for LibraryClasses, it is a set structure as # { [LibraryClassName] : LibraryClassInfFile } # @var Pcds: To store value for Pcds, it is a set structure as # { [(PcdCName, PcdGuidCName)] : PcdClassObject} #-class PackageBuildClassObject(object):+class PackageBuildClassObject(BuildData): def __init__(self): self.MetaFile = '' self.PackageName = '' self.Guid = '' self.Version = ''@@ -539,38 +574,10 @@ class PackageBuildClassObject(object):
self.Guids = {} self.Includes = [] self.LibraryClasses = {} self.Pcds = {} - ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether PackageBuildClassObjects are the same- #- # @retval False The two PackageBuildClassObjects are different- # @retval True The two PackageBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)- ## PlatformBuildClassObject # # This Class defines PlatformBuildClass # # @param object: Inherited from object class@@ -595,11 +602,11 @@ class PackageBuildClassObject(object):
# @var Pcds: To store value for Pcds, it is a set structure as # { [(PcdCName, PcdGuidCName)] : PcdClassObject } # @var BuildOptions: To store value for BuildOptions, it is a set structure as # { [BuildOptionKey] : BuildOptionValue } #-class PlatformBuildClassObject(object):+class PlatformBuildClassObject(BuildData): def __init__(self): self.MetaFile = '' self.PlatformName = '' self.Guid = '' self.Version = ''@@ -614,33 +621,5 @@ class PlatformBuildClassObject(object):
self.LibraryInstances = [] self.LibraryClasses = {} self.Libraries = {} self.Pcds = {} self.BuildOptions = {}-- ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether PlatformBuildClassObjects are the same- #- # @retval False The two PlatformBuildClassObjects are different- # @retval True The two PlatformBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 30826a3cea..da7a52c5d0 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -19,24 +19,10 @@ from re import compile
# # This class is used to retrieve information stored in database and convert them # into PackageBuildClassObject form for easier use for AutoGen. # class DecBuildData(PackageBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of DecBuildData directly _PROPERTY_ = { # # Required Fields@@ -66,10 +52,11 @@ class DecBuildData(PackageBuildClassObject):
self._Bdb = BuildDataBase self._Arch = Arch self._Target = Target self._Toolchain = Toolchain self._Clear()+ self.UpdatePcdTypeDict() ## XXX[key] = value def __setitem__(self, key, value): self.__dict__[self._PROPERTY_[key]] = value diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 5f07d3e75c..4d5b1ad4d9 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -177,24 +177,10 @@ def GetDependencyList(FileStack, SearchPathList):
DependencyList = list(DependencySet) # remove duplicate ones return DependencyList class DscBuildData(PlatformBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of DscBuildData directly _PROPERTY_ = { # # Required Fields@@ -240,11 +226,11 @@ class DscBuildData(PlatformBuildClassObject):
self._ToolChainFamily = None self._Clear() self.WorkspaceDir = os.getenv("WORKSPACE") if os.getenv("WORKSPACE") else "" self.DefaultStores = None self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds)-+ self.UpdatePcdTypeDict() @property def OutputPath(self): if os.getenv("WORKSPACE"): return os.path.join(os.getenv("WORKSPACE"), self.OutputDirectory, self._Target + "_" + self._Toolchain, PcdValueInitName) else:@@ -409,10 +395,13 @@ class DscBuildData(PlatformBuildClassObject):
try: uuid.UUID(Record[2]) except: EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile) self._VpdToolGuid = Record[2]+ elif Name == TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX:+ if TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX not in gCommandLineDefines:+ gCommandLineDefines[TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX] = Record[2].strip() elif Name in self: self[Name] = Record[2] # set _Header to non-None in order to avoid database re-querying self._Header = 'DUMMY' diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 7675b0ea00..45b8ef4716 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -57,24 +57,10 @@ def _PpiValue(CName, PackageList, Inffile = None):
# # This class is used to retrieve information stored in database and convert them # into ModuleBuildClassObject form for easier use for AutoGen. # class InfBuildData(ModuleBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of InfBuildData directly _PROPERTY_ = { # # Required Fields@@ -152,10 +138,11 @@ class InfBuildData(ModuleBuildClassObject):
self._GuidsUsedByPcd = OrderedDict() self._GuidComments = None self._PcdComments = None self._BuildOptions = None self._DependencyFileList = None+ self.UpdatePcdTypeDict() self.LibInstances = [] self.ReferenceModules = set() def SetReferenceModule(self,Module): self.ReferenceModules.add(Module)--
2.29.1.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76176): https://edk2.groups.io/g/devel/message/76176
Mute This Topic: https://groups.io/mt/83388055/1768742
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [bob.c.feng@...] -=-=-=-=-=-=

15781 - 15800 of 92218