From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1563AD80F81 for ; Wed, 19 Jun 2024 22:07:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lNPAfkKqavwXxB3UH0GtEbC1fH9+2HusBH3SYo4WX8c=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1718834824; v=1; b=rscQdQjlmLu8/8hWWke1ymqlTTCi1Mszd3UZpLamgcJjcv5sX/eEgYxGT3+4g/Nn/rdmjOFs xVlLN1MXg1ynJs6dr/0/bU0wTm461LmzEtWd7Iz7XG+EPv5X/ideg+FtYwP03prAZxWoLm3IOZ2 hiS9iOozGkRtypWCsEVb81U/0yA2hp8mN3xhiNYKCAE6A25YLsF4DjA+w5X0cxmYcgHxrq7UaIl x0/M/zPOLLUBd/zn2foVjbkdgCgpCz4XMl50wNCRAdBvJxF4RfVamIdim80XBRhdEToDloBg2+b +edqasqPzS5d8VtF0iQgiBMbcVvqAUMQdA8T7sOfd9fDg== X-Received: by 127.0.0.2 with SMTP id 9NBUYY7687511xirnBamXoEf; Wed, 19 Jun 2024 15:07:03 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.34047.1718834823023131762 for ; Wed, 19 Jun 2024 15:07:03 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 744761042; Wed, 19 Jun 2024 15:07:27 -0700 (PDT) X-Received: from e126645.home (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D1E23F64C; Wed, 19 Jun 2024 15:07:00 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , AbdulLateef Attar , Girish Mahadevan , Jeff Brasen , Jeshua Smith , Leif Lindholm , Meenakshi Aggarwal , Sami Mujawar , Sunil V L , Yeo Reum Yun , Pierre Gondois Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 06/15] DynamicTablesPkg: AcpiSratLib: Prepare to support other archs Date: Thu, 20 Jun 2024 00:06:20 +0200 Message-Id: <20240619220629.1994362-7-pierre.gondois@arm.com> In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com> References: <20240619220629.1994362-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 19 Jun 2024 15:07:03 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: FqPUalDatAxxklesX9Wbp56Mx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=rscQdQjl; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Allow other architectures to reuse the AcpiSratLib by extracting the Arm specific part of the table generation. Signed-off-by: Pierre Gondois --- .../Acpi/Common/AcpiSratLib/AcpiSratLib.inf | 7 + .../Common/AcpiSratLib/Arm/ArmSratGenerator.c | 262 ++++++++++++++++++ .../AcpiSratLib/Common/CommonSratGenerator.c | 77 +++++ .../Acpi/Common/AcpiSratLib/SratGenerator.c | 214 ++------------ .../Acpi/Common/AcpiSratLib/SratGenerator.h | 59 ++++ 5 files changed, 422 insertions(+), 197 deletions(-) create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/Ar= mSratGenerator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Common= /CommonSratGenerator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGe= nerator.h diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.i= nf b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf index 2f23f4e668e5..c2f24a23ccd8 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf @@ -18,6 +18,13 @@ [Defines] =0D [Sources]=0D SratGenerator.c=0D + SratGenerator.h=0D +=0D +[Sources.ARM, Sources.AARCH64]=0D + Arm/ArmSratGenerator.c=0D +=0D +[Sources.IA32, Sources.X64]=0D + Common/CommonSratGenerator.c=0D =0D [Packages]=0D EmbeddedPkg/EmbeddedPkg.dec=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGe= nerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGen= erator.c new file mode 100644 index 000000000000..3d36b25e1840 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGenerator= .c @@ -0,0 +1,262 @@ +/** @file=0D + Arm SRAT Table Generator=0D +=0D + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.3 Specification, January 2019=0D +=0D + @par Glossary:=0D + - Cm or CM - Configuration Manager=0D + - Obj or OBJ - Object=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include "SratGenerator.h"=0D +=0D +/**=0D + ARM standard SRAT Generator=0D +=0D + Requirements:=0D + The following Configuration Manager Object(s) are used by this Generat= or:=0D + - EArmObjGicCInfo (REQUIRED)=0D + - EArmObjGicItsInfo (OPTIONAL)=0D +*/=0D +=0D +/** This macro expands to a function that retrieves the GIC=0D + CPU interface Information from the Configuration Manager.=0D +*/=0D +GET_OBJECT_LIST (=0D + EObjNameSpaceArm,=0D + EArmObjGicCInfo,=0D + CM_ARM_GICC_INFO=0D + );=0D +=0D +/** This macro expands to a function that retrieves the GIC=0D + Interrupt Translation Service Information from the=0D + Configuration Manager.=0D +*/=0D +GET_OBJECT_LIST (=0D + EObjNameSpaceArm,=0D + EArmObjGicItsInfo,=0D + CM_ARM_GIC_ITS_INFO=0D + );=0D +=0D +/** Enum of the Arm specific CM objects required to=0D + build the arch specific information of the SRAT table.=0D +*/=0D +typedef enum ArmSratSubTableType {=0D + EArmGicCSubTableType,=0D + EArmGicItsSubTableType,=0D + EArmSubTableTypeMax,=0D +} EARM_SRAT_SUB_TABLE_TYPE;=0D +=0D +typedef struct SratSubTable {=0D + /// Start offset of the arch specific sub-table.=0D + UINT32 Offset;=0D +=0D + /// Count=0D + UINT32 Count;=0D +=0D + /// Array of CmInfo objects of the relevant type.=0D + VOID *CmInfo;=0D +} SRAT_SUB_TABLE;=0D +=0D +STATIC SRAT_SUB_TABLE mSratSubTable[EArmSubTableTypeMax];=0D +=0D +/** Reserve arch sub-tables space.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + @param [in, out] ArchOffset On input, contains the offset where arch sp= ecific=0D + sub-tables can be written. It is expected t= hat=0D + there enough space to write all the arch sp= ecific=0D + sub-tables from this offset onward.=0D + On ouput, contains the ending offset of the= arch=0D + specific sub-tables.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object information is not fou= nd.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +ArchReserveOffsets (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT UINT32 *ArchOffset=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + ASSERT (CfgMgrProtocol !=3D NULL);=0D + ASSERT (ArchOffset !=3D NULL);=0D +=0D + Status =3D GetEArmObjGicCInfo (=0D + CfgMgrProtocol,=0D + CM_NULL_TOKEN,=0D + (CM_ARM_GICC_INFO **)&mSratSubTable[EArmGicCSubTableType].CmI= nfo,=0D + &mSratSubTable[EArmGicCSubTableType].Count=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: SRAT: Failed to get GICC Info. Status =3D %r\n",=0D + Status=0D + ));=0D + return Status;=0D + }=0D +=0D + if (mSratSubTable[EArmGicCSubTableType].Count =3D=3D 0) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: SRAT: GIC CPU Interface information not provided.\n"=0D + ));=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D GetEArmObjGicItsInfo (=0D + CfgMgrProtocol,=0D + CM_NULL_TOKEN,=0D + (CM_ARM_GIC_ITS_INFO **)&mSratSubTable[EArmGicItsSubTableType= ].CmInfo,=0D + &mSratSubTable[EArmGicItsSubTableType].Count=0D + );=0D + if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: SRAT: Failed to get GIC ITS Info. Status =3D %r\n",=0D + Status=0D + ));=0D + return Status;=0D + }=0D +=0D + mSratSubTable[EArmGicCSubTableType].Offset =3D *ArchOffset;=0D + *ArchOffset +=3D (sizeof (EFI_ACPI_6_3_GIC= C_AFFINITY_STRUCTURE) *=0D + mSratSubTable[EArmGicCSubT= ableType].Count);=0D +=0D + if (mSratSubTable[EArmGicItsSubTableType].Count !=3D 0) {=0D + mSratSubTable[EArmGicItsSubTableType].Offset =3D *ArchOffset;=0D + *ArchOffset +=3D (sizeof (EFI_ACPI_6_3= _GIC_ITS_AFFINITY_STRUCTURE) *=0D + mSratSubTable[EArmGicI= tsSubTableType].Count);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/** Add the GICC Affinity Structures in the SRAT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in] Srat Pointer to the SRAT Table.=0D +**/=0D +STATIC=0D +VOID=0D +EFIAPI=0D +AddGICCAffinity (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D + IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat=0D + )=0D +{=0D + EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff;=0D + CM_ARM_GICC_INFO *GicCInfo;=0D +=0D + GicCInfo =3D mSratSubTable[EArmGicCSubTableType].CmInfo;=0D + GicCAff =3D (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8 *)Srat +=0D + mSratSubTable[EArmGi= cCSubTableType].Offset);=0D +=0D + while (mSratSubTable[EArmGicCSubTableType].Count-- !=3D 0) {=0D + DEBUG ((DEBUG_INFO, "SRAT: GicCAff =3D 0x%p\n", GicCAff));=0D +=0D + GicCAff->Type =3D EFI_ACPI_6_3_GICC_AFFINITY;=0D + GicCAff->Length =3D sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUC= TURE);=0D + GicCAff->ProximityDomain =3D GicCInfo->ProximityDomain;=0D + GicCAff->AcpiProcessorUid =3D GicCInfo->AcpiProcessorUid;=0D + GicCAff->Flags =3D GicCInfo->AffinityFlags;=0D + GicCAff->ClockDomain =3D GicCInfo->ClockDomain;=0D +=0D + // Next=0D + GicCAff++;=0D + GicCInfo++;=0D + }// while=0D +}=0D +=0D +/** Add the GIC ITS Affinity Structures in the SRAT Table.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in] Srat Pointer to the SRAT Table.=0D +**/=0D +STATIC=0D +VOID=0D +EFIAPI=0D +AddGICItsAffinity (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D + IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat=0D + )=0D +{=0D + EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff;=0D + CM_ARM_GIC_ITS_INFO *GicItsInfo;=0D +=0D + GicItsInfo =3D mSratSubTable[EArmGicItsSubTableType].CmInfo;=0D + GicItsAff =3D (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8 *)Srat= +=0D + mSratSubTable[E= ArmGicItsSubTableType].Offset);=0D +=0D + while (mSratSubTable[EArmGicItsSubTableType].Count-- !=3D 0) {=0D + DEBUG ((DEBUG_INFO, "SRAT: GicItsAff =3D 0x%p\n", GicItsAff));=0D +=0D + GicItsAff->Type =3D EFI_ACPI_6_3_GIC_ITS_AFFINITY;=0D + GicItsAff->Length =3D sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_S= TRUCTURE);=0D + GicItsAff->ProximityDomain =3D GicItsInfo->ProximityDomain;=0D + GicItsAff->Reserved[0] =3D EFI_ACPI_RESERVED_BYTE;=0D + GicItsAff->Reserved[1] =3D EFI_ACPI_RESERVED_BYTE;=0D + GicItsAff->ItsId =3D GicItsInfo->GicItsId;=0D +=0D + // Next=0D + GicItsAff++;=0D + GicItsInfo++;=0D + }// while=0D +}=0D +=0D +/** Add the arch specific sub-tables to the SRAT table.=0D +=0D + These sub-tables are written in the space reserved beforehand.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in] Srat Pointer to the SRAT Table.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AddArchObjects (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D + IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat=0D + )=0D +{=0D + ASSERT (CfgMgrProtocol !=3D NULL);=0D + ASSERT (Srat !=3D NULL);=0D +=0D + AddGICCAffinity (CfgMgrProtocol, Srat);=0D +=0D + if (mSratSubTable[EArmGicCSubTableType].Count !=3D 0) {=0D + AddGICItsAffinity (CfgMgrProtocol, Srat);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Common/Common= SratGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Common/C= ommonSratGenerator.c new file mode 100644 index 000000000000..bc69fbf7f3bb --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Common/CommonSratGen= erator.c @@ -0,0 +1,77 @@ +/** @file=0D + Common SRAT Table Generator=0D +=0D + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.3 Specification, January 2019=0D +=0D + @par Glossary:=0D + - Cm or CM - Configuration Manager=0D + - Obj or OBJ - Object=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +// Module specific include files.=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include "SratGenerator.h"=0D +=0D +/** Reserve arch sub-tables space.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + @param [in, out] ArchOffset On input, contains the offset where arch sp= ecific=0D + sub-tables can be written. It is expected t= hat=0D + there enough space to write all the arch sp= ecific=0D + sub-tables from this offset onward.=0D + On ouput, contains the ending offset of the= arch=0D + specific sub-tables.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object information is not fou= nd.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +ArchReserveOffsets (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT UINT32 *ArchOffset=0D + )=0D +{=0D + // Nothing to do.=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/** Add the arch specific sub-tables to the SRAT table.=0D +=0D + These sub-tables are written in the space reserved beforehand.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in] Srat Pointer to the SRAT Table.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AddArchObjects (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D + IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat=0D + )=0D +{=0D + // Nothing to do.=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator= .c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c index 48c9970a7151..dcdacc4e966e 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c @@ -25,38 +25,19 @@ #include =0D #include =0D =0D +#include "SratGenerator.h"=0D +=0D /**=0D - ARM standard SRAT Generator=0D + Standard SRAT Generator=0D =0D Requirements:=0D The following Configuration Manager Object(s) are used by this Generat= or:=0D - - EArmObjGicCInfo (REQUIRED)=0D - - EArmObjGicItsInfo (OPTIONAL)=0D - EArchCommonObjMemoryAffinityInfo (OPTIONAL)=0D - EArchCommonObjGenericInitiatorAffinityInfo (OPTIONAL)=0D - EArchCommonObjDeviceHandleAcpi (OPTIONAL)=0D - EArchCommonObjDeviceHandlePci (OPTIONAL)=0D */=0D =0D -/** This macro expands to a function that retrieves the GIC=0D - CPU interface Information from the Configuration Manager.=0D -*/=0D -GET_OBJECT_LIST (=0D - EObjNameSpaceArm,=0D - EArmObjGicCInfo,=0D - CM_ARM_GICC_INFO=0D - );=0D -=0D -/** This macro expands to a function that retrieves the GIC=0D - Interrupt Translation Service Information from the=0D - Configuration Manager.=0D -*/=0D -GET_OBJECT_LIST (=0D - EObjNameSpaceArm,=0D - EArmObjGicItsInfo,=0D - CM_ARM_GIC_ITS_INFO=0D - );=0D -=0D /**=0D This macro expands to a function that retrieves the Memory Affinity=0D information from the Configuration Manager.=0D @@ -121,102 +102,6 @@ GetBdf ( return Bdf;=0D }=0D =0D -/** Add the GICC Affinity Structures in the SRAT Table.=0D -=0D - @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D - Protocol Interface.=0D - @param [in] Srat Pointer to the SRAT Table.=0D - @param [in] GicCAffOffset Offset of the GICC Affinity=0D - information in the SRAT Table.=0D - @param [in] GicCInfo Pointer to the GIC CPU Information list.=0D - @param [in] GicCCount Count of GIC CPU Interfaces.=0D -=0D - @retval EFI_SUCCESS Table generated successfully.=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -AddGICCAffinity (=0D - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D - IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat,=0D - IN CONST UINT32 GicCAffOff= set,=0D - IN CONST CM_ARM_GICC_INFO *GicCInfo,= =0D - IN UINT32 GicCCount= =0D - )=0D -{=0D - EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff;=0D -=0D - ASSERT (Srat !=3D NULL);=0D - ASSERT (GicCInfo !=3D NULL);=0D -=0D - GicCAff =3D (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8 *)Srat +=0D - GicCAffOffset);=0D -=0D - while (GicCCount-- !=3D 0) {=0D - DEBUG ((DEBUG_INFO, "SRAT: GicCAff =3D 0x%p\n", GicCAff));=0D -=0D - GicCAff->Type =3D EFI_ACPI_6_3_GICC_AFFINITY;=0D - GicCAff->Length =3D sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUC= TURE);=0D - GicCAff->ProximityDomain =3D GicCInfo->ProximityDomain;=0D - GicCAff->AcpiProcessorUid =3D GicCInfo->AcpiProcessorUid;=0D - GicCAff->Flags =3D GicCInfo->AffinityFlags;=0D - GicCAff->ClockDomain =3D GicCInfo->ClockDomain;=0D -=0D - // Next=0D - GicCAff++;=0D - GicCInfo++;=0D - }// while=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D -/** Add the GIC ITS Affinity Structures in the SRAT Table.=0D -=0D - @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D - Protocol Interface.=0D - @param [in] Srat Pointer to the SRAT Table.=0D - @param [in] GicItsAffOffset Offset of the GIC ITS Affinity=0D - information in the SRAT Table.=0D - @param [in] GicItsInfo Pointer to the GIC ITS Information list.=0D - @param [in] GicItsCount Count of GIC ITS.=0D -=0D - @retval EFI_SUCCESS Table generated successfully.=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -AddGICItsAffinity (=0D - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D - IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat,=0D - IN CONST UINT32 GicItsAffO= ffset,=0D - IN CONST CM_ARM_GIC_ITS_INFO *GicItsInf= o,=0D - IN UINT32 GicItsCoun= t=0D - )=0D -{=0D - EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff;=0D -=0D - ASSERT (Srat !=3D NULL);=0D - ASSERT (GicItsInfo !=3D NULL);=0D -=0D - GicItsAff =3D (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8 *)Srat = +=0D - GicItsAffOffset)= ;=0D -=0D - while (GicItsCount-- !=3D 0) {=0D - DEBUG ((DEBUG_INFO, "SRAT: GicItsAff =3D 0x%p\n", GicItsAff));=0D -=0D - GicItsAff->Type =3D EFI_ACPI_6_3_GIC_ITS_AFFINITY;=0D - GicItsAff->Length =3D sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_S= TRUCTURE);=0D - GicItsAff->ProximityDomain =3D GicItsInfo->ProximityDomain;=0D - GicItsAff->Reserved[0] =3D EFI_ACPI_RESERVED_BYTE;=0D - GicItsAff->Reserved[1] =3D EFI_ACPI_RESERVED_BYTE;=0D - GicItsAff->ItsId =3D GicItsInfo->GicItsId;=0D -=0D - // Next=0D - GicItsAff++;=0D - GicItsInfo++;=0D - }// while=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D /** Add the Memory Affinity Structures in the SRAT Table.=0D =0D @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D @@ -455,18 +340,12 @@ BuildSratTable ( {=0D EFI_STATUS Status;=0D UINT32 TableSize;=0D - UINT32 GicCCount;=0D - UINT32 GicItsCount;=0D UINT32 MemAffCount;=0D UINT32 GenInitiatorAffCount;=0D =0D - UINT32 GicCAffOffset;=0D - UINT32 GicItsAffOffset;=0D UINT32 MemAffOffset;=0D UINT32 GenInitiatorAffOffset;=0D =0D - CM_ARM_GICC_INFO *GicCInfo;=0D - CM_ARM_GIC_ITS_INFO *GicItsInfo;=0D CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemAffInfo;=0D CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *GenInitiatorAffInfo;=0D =0D @@ -497,46 +376,6 @@ BuildSratTable ( =0D *Table =3D NULL;=0D =0D - Status =3D GetEArmObjGicCInfo (=0D - CfgMgrProtocol,=0D - CM_NULL_TOKEN,=0D - &GicCInfo,=0D - &GicCCount=0D - );=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((=0D - DEBUG_ERROR,=0D - "ERROR: SRAT: Failed to get GICC Info. Status =3D %r\n",=0D - Status=0D - ));=0D - goto error_handler;=0D - }=0D -=0D - if (GicCCount =3D=3D 0) {=0D - DEBUG ((=0D - DEBUG_ERROR,=0D - "ERROR: SRAT: GIC CPU Interface information not provided.\n"=0D - ));=0D - ASSERT (0);=0D - Status =3D EFI_INVALID_PARAMETER;=0D - goto error_handler;=0D - }=0D -=0D - Status =3D GetEArmObjGicItsInfo (=0D - CfgMgrProtocol,=0D - CM_NULL_TOKEN,=0D - &GicItsInfo,=0D - &GicItsCount=0D - );=0D - if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) {=0D - DEBUG ((=0D - DEBUG_ERROR,=0D - "ERROR: SRAT: Failed to get GIC ITS Info. Status =3D %r\n",=0D - Status=0D - ));=0D - goto error_handler;=0D - }=0D -=0D Status =3D GetEArchCommonObjMemoryAffinityInfo (=0D CfgMgrProtocol,=0D CM_NULL_TOKEN,=0D @@ -571,13 +410,18 @@ BuildSratTable ( // Calculate the size of the SRAT table=0D TableSize =3D sizeof (EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER= );=0D =0D - GicCAffOffset =3D TableSize;=0D - TableSize +=3D (sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE) * GicCC= ount);=0D -=0D - if (GicItsCount !=3D 0) {=0D - GicItsAffOffset =3D TableSize;=0D - TableSize +=3D (sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE) = *=0D - GicItsCount);=0D + // Place the Arch specific subtables/structures first and=0D + // reserve the offsets. The common subtables/structures=0D + // are placed next.=0D + Status =3D ArchReserveOffsets (CfgMgrProtocol, &TableSize);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: SRAT: Failed to reserve arch offsets."=0D + " Status =3D %r\n",=0D + Status=0D + ));=0D + goto error_handler;=0D }=0D =0D if (MemAffCount !=3D 0) {=0D @@ -636,40 +480,16 @@ BuildSratTable ( Srat->Reserved1 =3D 1;=0D Srat->Reserved2 =3D EFI_ACPI_RESERVED_QWORD;=0D =0D - Status =3D AddGICCAffinity (=0D - CfgMgrProtocol,=0D - Srat,=0D - GicCAffOffset,=0D - GicCInfo,=0D - GicCCount=0D - );=0D + Status =3D AddArchObjects (CfgMgrProtocol, Srat);=0D if (EFI_ERROR (Status)) {=0D DEBUG ((=0D DEBUG_ERROR,=0D - "ERROR: SRAT: Failed to add GICC Affinity structures. Status =3D %r\= n",=0D + "ERROR: SRAT: Failed to add arch objects header. Status =3D %r\n",=0D Status=0D ));=0D goto error_handler;=0D }=0D =0D - if (GicItsCount !=3D 0) {=0D - Status =3D AddGICItsAffinity (=0D - CfgMgrProtocol,=0D - Srat,=0D - GicItsAffOffset,=0D - GicItsInfo,=0D - GicItsCount=0D - );=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((=0D - DEBUG_ERROR,=0D - "ERROR: SRAT: Failed to add GIC ITS Affinity structures. Status = =3D %r\n",=0D - Status=0D - ));=0D - goto error_handler;=0D - }=0D - }=0D -=0D if (MemAffCount !=3D 0) {=0D Status =3D AddMemoryAffinity (=0D CfgMgrProtocol,=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator= .h b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.h new file mode 100644 index 000000000000..106d0084947e --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.h @@ -0,0 +1,59 @@ +/** @file=0D + SRAT Table Generator=0D +=0D + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - ACPI 6.3 Specification, January 2019=0D +=0D + @par Glossary:=0D + - Cm or CM - Configuration Manager=0D + - Obj or OBJ - Object=0D +**/=0D +=0D +#ifndef SRAT_GENERATOR_H_=0D +#define SRAT_GENERATOR_H_=0D +=0D +/** Reserve arch sub-tables space.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + @param [in, out] ArchOffset On input, contains the offset where arch sp= ecific=0D + sub-tables can be written. It is expected t= hat=0D + there enough space to write all the arch sp= ecific=0D + sub-tables from this offset onward.=0D + On ouput, contains the ending offset of the= arch=0D + specific sub-tables.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D + @retval EFI_INVALID_PARAMETER A parameter is invalid.=0D + @retval EFI_NOT_FOUND The required object information is not fou= nd.=0D + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration=0D + Manager is less than the Object size for t= he=0D + requested object.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +ArchReserveOffsets (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,= =0D + IN OUT UINT32 *ArchOffset=0D + );=0D +=0D +/** Add the arch specific sub-tables to the SRAT table.=0D +=0D + These sub-tables are written in the space reserved beforehand.=0D +=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol Interface.=0D + @param [in] Srat Pointer to the SRAT Table.=0D +=0D + @retval EFI_SUCCESS Table generated successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AddArchObjects (=0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol,=0D + IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat=0D + );=0D +=0D +#endif // SRAT_GENERATOR_H_=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119638): https://edk2.groups.io/g/devel/message/119638 Mute This Topic: https://groups.io/mt/106770159/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-