From nobody Wed May 15 12:51:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94537+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664495888356542.3608611954912; Thu, 29 Sep 2022 16:58:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1wz4YY1788612xaSq7dWafnf; Thu, 29 Sep 2022 16:58:08 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.75]) by mx.groups.io with SMTP id smtpd.web12.13968.1664475518077302036 for ; Thu, 29 Sep 2022 11:18:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7hFu6F8v7xJipWDJyZ2nMNT/3pjRtsZAX08+CQmrXgqlKtJCbQHDG1189K/VzS2bnSLZlrhq3IYo4a79V53LMVpClyErJCk4wwY5nBUAI9vGvpTpv78XouPtf6KSn1AUlwb/49JkfpHTJXPFhPzRj30WpvjkVRft1ByeD12CSwNNW47kn7fhDwvgbekNkI1INn7nSsDxCMPjzCOg5Tv4qBXOA7WdUK/ylerOlT972AN2K3jFD5eO/rTovfa+XNOepqVp8by9GxQ/QHOXTWym0Mm1s6/HLjmftrabO6bJWGjLSlg7GRtmdE2FXS5r0s9UlVMBTEXIfpC99ZqXEU3lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0WVWrXiOyXtT/dIpoBxU0yK1IOmDhjfZbXaz8z2ylOI=; b=jQ4EXJ+6OTexBkmc+oJ9I/GTL2Tkvpl0vCzj/cYqLxo/s4t3/9K/4QBQZWs03UT4DeBbAotWC5rqxbSSBoqqlQTtmbh6Eu9ENo8yN7Yo6EnYKrRv2fjtTlv6O9ldcWziJCDjevFD1kx1eX5/RyxkPM1RF9ePL8kgc5xpTsKv/KDyXJf5/jc9Ca3W/AuCiyeV1K8KsjpqXuqbh+0so33yhlN2yp2NKdxIM0DbqzT/c6fjQyB10zmE1h8FAWuxJ2u+aJlseq/bNMfik7ZznhQN1+rHDraNZ7TPyJbXwT1FSk4DYzd6jjRs5TxLMfkLmen7mO8kpL05hkNz2Ve6mCWopw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR03CA0357.namprd03.prod.outlook.com (2603:10b6:303:dc::32) by CH0PR12MB5266.namprd12.prod.outlook.com (2603:10b6:610:d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Thu, 29 Sep 2022 18:18:35 +0000 X-Received: from CO1NAM11FT076.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::46) by MW4PR03CA0357.outlook.office365.com (2603:10b6:303:dc::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26 via Frontend Transport; Thu, 29 Sep 2022 18:18:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94537+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT076.mail.protection.outlook.com (10.13.174.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Thu, 29 Sep 2022 18:18:35 +0000 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 29 Sep 2022 11:18:20 -0700 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 29 Sep 2022 11:18:20 -0700 X-Received: from swatisrik-X299-A.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Thu, 29 Sep 2022 11:18:19 -0700 From: "Name via groups.io" To: , , CC: Swatisri Kantamsetti Subject: [edk2-devel] [PATCH] DynamicTablesPkg:ACPI: SLIT Generator files Date: Thu, 29 Sep 2022 12:18:14 -0600 Message-ID: <9ac0f76bcacc7610b8b22f7a024fe3818bbdd235.1664475116.git.swatisrik@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT076:EE_|CH0PR12MB5266:EE_ X-MS-Office365-Filtering-Correlation-Id: 39f627f2-d107-4af1-2075-08daa24705ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: TgzOv7XSV0Hh7Ak5354yWxPD5A/oTdAv4U568xV5P4CceDJ0IX9dT35yrbxQ95rV0FRIyP1TcBMqqDNsz+vk+iu55eRnZDxKvgU2BEkB1Sj0AJ4qM2eQb2SrvgJQBOIaZFZWZLwaEdQ5kRMih7nL7+2lybGet/Og4LvmIoef7Z2SSOWgY87lSBY3a+wKoWFZxPsDxOjCe371vqJy50ZUaZvjXbvf08EEJj0B9zVK01NssTxEmM9pa1REslSGGqYkqOUp3B7ghf9I2PJe6VR//RYUSvcdM3m8o4SFVZaDdrp9QUinI9bL+LyWYSrQlsCgpbf+45vmtr5p6vJNkQXXOlPlODyFnyAK1EX93KOyJzHp10D4XOBmwqrPvwIaHZRjCSnPZ5FBgKf1D0XNyir8pzhvooNN4LkwYUzgMqfaI9wRBd/WkVG39GvHm2eDNvcxsRV6CSYQCKtIQKiNM2W/mHaVNc/ZPGbBb4++U+ndHnIKmtRg8N33FDJnWzPCuhrjioAlcIlOOLefjime+t0Nzf/ZSSg29hB5KB/zC0wSmOlNTnMlYewYrlQ28jjZBHo1TOpcpn69U9yVMMs3wKCT14/sJMtyS3OvEe9e0Hsb+8fhFNHcMvOGnUqSZC2y2jKuXLjFLRHM0Vlvt49fUtZBB2xNge8d5McXr6YuovuA0fZIqGudVeg+qdN7Y3P5oZpOM3fhltRiA6MZUquUzyPd19BzYfGiYpTe8Q2GTyGz6ng+tzKzMoLteV9r5F44erhrV2Chca6VckLNmTdl7L5MEt7Dva7dfBinioTb9dm9MIE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2022 18:18:35.0678 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39f627f2-d107-4af1-2075-08daa24705ec X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT076.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5266 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,username@nvidia.com X-Gm-Message-State: TOpOXFpwOYzWR40vRWwNgL5yx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664495888; bh=DNd3wOPHIn0stDyxk2dgscnfizerE/SXcHLi69/L9rI=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=mu5cz7ao77PA1Z3d5UKcIWhf/fIlZSJVUEhBSGfxURj0L95FvWWNWFqYMTYUN0Ah8F7 yCVnSPlpQsOqlRG4OUZwq5ACfJXmXlm0Qn1vEys0ZNNsUfZvOZVSwHFpU/xejCny7oW42 Kz7Visizg+JwkciMitgr1219gNYFlupYfjE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664495888987100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Swatisri Kantamsetti Added SLIT Generator and supporting files to generate SLIT ACPI Table Signed-off-by: Swatisri Kantamsetti --- DynamicTablesPkg/DynamicTables.dsc.inc | 2 + DynamicTablesPkg/Include/AcpiTableGenerator.h | 1 + .../Include/ArmNameSpaceObjects.h | 12 + .../Arm/AcpiSlitLibArm/AcpiSlitLibArm.inf | 29 ++ .../Acpi/Arm/AcpiSlitLibArm/SlitGenerator.c | 326 ++++++++++++++++++ MdePkg/Include/IndustryStandard/Slit.h | 39 +++ 6 files changed, 409 insertions(+) create mode 100644 DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSl= itLibArm.inf create mode 100644 DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/SlitGe= nerator.c create mode 100644 MdePkg/Include/IndustryStandard/Slit.h diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dyna= micTables.dsc.inc index 3d4fa0c4c4..c24fc1d719 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -31,6 +31,7 @@ DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/AcpiPpttLibArm.inf DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf + DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSlitLibArm.inf DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/AcpiSratLibArm.inf =20 @@ -56,6 +57,7 @@ NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/AcpiPpttLibArm= .inf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.i= nf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm= .inf + NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSlitLibArm= .inf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/AcpiSratLibArm= .inf =20 # AML Fixup diff --git a/DynamicTablesPkg/Include/AcpiTableGenerator.h b/DynamicTablesP= kg/Include/AcpiTableGenerator.h index f962dbff57..82d0272031 100644 --- a/DynamicTablesPkg/Include/AcpiTableGenerator.h +++ b/DynamicTablesPkg/Include/AcpiTableGenerator.h @@ -93,6 +93,7 @@ typedef enum StdAcpiTableId { EStdAcpiTableIdMcfg, ///< MCFG Generator EStdAcpiTableIdIort, ///< IORT Generator EStdAcpiTableIdPptt, ///< PPTT Generator + EStdAcpiTableIdSlit, ///< SLIT Generator EStdAcpiTableIdSrat, ///< SRAT Generator EStdAcpiTableIdSsdtSerialPort, ///< SSDT Serial-Port Gene= rator EStdAcpiTableIdSsdtCmn600, ///< SSDT Cmn-600 Generator diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTables= Pkg/Include/ArmNameSpaceObjects.h index c66b441d53..aa3f464132 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -65,6 +65,7 @@ typedef enum ArmObjectID { EArmObjRmr, ///< 40 - Reserved Memory Range Node EArmObjMemoryRangeDescriptor, ///< 41 - Memory Range Descriptor EArmObjCpcInfo, ///< 42 - Continuous Performance Co= ntrol Info + EArmObjSystemLocalityInfo, ///< 43 - Relative Distance Info EArmObjMax } EARM_OBJECT_ID; =20 @@ -1095,6 +1096,17 @@ typedef struct CmArmRmrDescriptor { */ typedef AML_CPC_INFO CM_ARM_CPC_INFO; =20 +/** A structure that describes the System Locality Information + + This information is used to optimize the system performance + + ID: EArmObjSystemLocalityInfo +*/ +typedef struct CmArmSystemLocalityInfo { + UINT64 NumSystemLocalities; + UINT8 *Distance; +} CM_ARM_SYSTEM_LOCALITY_INFO; + #pragma pack() =20 #endif // ARM_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSlitLibAr= m.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSlitLibArm.inf new file mode 100644 index 0000000000..ab0ffc9a39 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/AcpiSlitLibArm.inf @@ -0,0 +1,29 @@ +## @file +# SRAT Table Generator +# +# Copyright (c) 2022, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D AcpiSlitLibArm + FILE_GUID =3D 28e3f485-0c24-4376-8982-8e1febd791bc + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D AcpiSlitLibConstructor + DESTRUCTOR =3D AcpiSlitLibDestructor + +[Sources] + SlitGenerator.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/SlitGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/SlitGenerator.c new file mode 100644 index 0000000000..1a232ce95c --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSlitLibArm/SlitGenerator.c @@ -0,0 +1,326 @@ +/** @file + SLIT Table Generator + + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification, January 2019 + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object +**/ + + +#include +#include +#include +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include + +/** + ARM standard SLIT Generator + + Requirements: + The following Configuration Manager Object(s) are used by this Generat= or: + - EArmObjSystemLocalityInfo (Required) +*/ + +/** + This macro expands to a function that retrieves the Relative Distance + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjSystemLocalityInfo, + CM_ARM_SYSTEM_LOCALITY_INFO + ); + +/** Construct the SLIT ACPI table. + + Called by the Dynamic Table Manager, this function invokes the + Configuration Manager protocol interface to get the required hardware + information for generating the ACPI table. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [out] Table Pointer to the constructed ACPI Table. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object was not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for t= he + requested object. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildSlitTable ( + IN CONST ACPI_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table + ) +{ + EFI_STATUS Status; + UINT32 TableSize; + UINT32 SlitObjectCount; + UINT32 SlitObjectOffset; + UINT64 NumSysLocalities; + UINT8 *RelDistInfo; + + CM_ARM_SYSTEM_LOCALITY_INFO *SysLocalityInfo; + EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE *Slit; + + ASSERT ( + (This !=3D NULL) && + (AcpiTableInfo !=3D NULL) && + (CfgMgrProtocol !=3D NULL) && + (Table !=3D NULL) && + (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID) && + (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignature) + ); + + if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) || + (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) + { + DEBUG (( + DEBUG_ERROR, + "ERROR: SLIT: Requested table revision =3D %d is not supported. " + "Supported table revisions: Minimum =3D %d. Maximum =3D %d\n", + AcpiTableInfo->AcpiTableRevision, + This->MinAcpiTableRevision, + This->AcpiTableRevision + )); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + + Status =3D GetEArmObjSystemLocalityInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &SysLocalityInfo, + &SlitObjectCount + ); + if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SLIT: Failed to get Relative Distance Info. Status =3D %r\n", + Status + )); + goto error_handler; + } + + // Calculate the size of the SLIT table + TableSize =3D sizeof (EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE); + + // Number of System Localities + NumSysLocalities =3D SysLocalityInfo->NumSystemLocalities; + + if (SlitObjectCount !=3D 0) { + SlitObjectOffset =3D TableSize; + TableSize +=3D (sizeof (UINT8) * NumSysLocalities * NumSysLocalities= ); + } + + // Allocate the Buffer for SLIT table + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)AllocateZeroPool (TableSize); + if (*Table =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG (( + DEBUG_ERROR, + "ERROR: SLIT: Failed to allocate memory for SLIT Table, Size =3D %d,= " \ + " Status =3D %r\n", + TableSize, + Status + )); + goto error_handler; + } + + Slit =3D (EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE *)*Table; + + DEBUG (( + DEBUG_INFO, + "SLIT: Slit =3D 0x%p TableSize =3D 0x%x\n", + Slit, + TableSize + )); + + Status =3D AddAcpiHeader ( + CfgMgrProtocol, + This, + &Slit->Header, + AcpiTableInfo, + TableSize + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SLIT: Failed to add ACPI header. Status =3D %r\n", + Status + )); + goto error_handler; + } + + // Number of System Localities + Slit->NumLocalities =3D NumSysLocalities; + + // Offset to place the Relative Distance Info + RelDistInfo =3D (UINT8*)((UINT8*)Slit + SlitObjectOffset); + + // Adding Relative distance in SLIT Table + for (UINT64 Index =3D 0; Index < Slit->NumLocalities * Slit->NumLocaliti= es; Index++) { + *RelDistInfo =3D SysLocalityInfo->Distance[Index]; + // Next + RelDistInfo++; + }// while + + return Status; + +error_handler: + + if (*Table !=3D NULL) { + FreePool (*Table); + *Table =3D NULL; + } + + return Status; +} + +/** Free any resources allocated for constructing the SLIT. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in, out] Table Pointer to the ACPI Table. + + @retval EFI_SUCCESS The resources were freed successfully. + @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid. +**/ +STATIC +EFI_STATUS +FreeSlitTableResources ( + IN CONST ACPI_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInf= o, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtoc= ol, + IN OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table + ) +{ + ASSERT ( + (This !=3D NULL) && + (AcpiTableInfo !=3D NULL) && + (CfgMgrProtocol !=3D NULL) && + (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID) && + (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignature) + ); + + if ((Table =3D=3D NULL) || (*Table =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: SLIT: Invalid Table Pointer\n")); + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + FreePool (*Table); + *Table =3D NULL; + return EFI_SUCCESS; +} + +/** The SLIT Table Generator revision. +*/ +#define SLIT_GENERATOR_REVISION CREATE_REVISION (1, 0) + +/** The interface for the SLIT Table Generator. +*/ +STATIC +CONST +ACPI_TABLE_GENERATOR SlitGenerator =3D { + // Generator ID + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSlit), + // Generator Description + L"ACPI.STD.SLIT.GENERATOR", + // ACPI Table Signature + EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE, + // ACPI Table Revision supported by this Generator + EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE_REVISION, + // Minimum supported ACPI Table Revision + EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE_REVISION, + // Creator ID + TABLE_GENERATOR_CREATOR_ID_ARM, + // Creator Revision + SLIT_GENERATOR_REVISION, + // Build Table function + BuildSlitTable, + // Free Resource function + FreeSlitTableResources, + // Extended build function not needed + NULL, + // Extended build function not implemented by the generator. + // Hence extended free resource function is not required. + NULL +}; + +/** Register the Generator with the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +AcpiSlitLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterAcpiTableGenerator (&SlitGenerator); + DEBUG ((DEBUG_INFO, "SLIT: Register Generator. Status =3D %r\n", Status)= ); + ASSERT_EFI_ERROR (Status); + return Status; +} + +/** Deregister the Generator from the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +AcpiSlitLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterAcpiTableGenerator (&SlitGenerator); + DEBUG ((DEBUG_INFO, "SLIT: Deregister Generator. Status =3D %r\n", Statu= s)); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/MdePkg/Include/IndustryStandard/Slit.h b/MdePkg/Include/Indust= ryStandard/Slit.h new file mode 100644 index 0000000000..3413b4046b --- /dev/null +++ b/MdePkg/Include/IndustryStandard/Slit.h @@ -0,0 +1,39 @@ +/** @file + ACPI System Locality Information Table (SLIT) + + https://developer.arm.com/documentation/ddi0598/latest + + Copyright (c) 2022 NVIDIA ???????? + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef __SLIT_H__ +#define __SLIT_H__ + +#pragma pack(1) + +/// +/// System Locality Information Table (SLIT) +/// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 NumLocalities; +} EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE; + +/// +/// SLIT Revision (as defined in ACPI 6.4 spec.) +/// +#define EFI_ACPI_6_4_SYSTEM_LOCALITY_INFORMATION_TABLE_REVISION 0x01 + +/// +/// Relative Distance Info Node Structure +/// +/* +typedef struct { + UINT8 *Distance; +} EFI_ACPI_6_4_REL_DISTANCE_INFO_STRUCTURE; +*/ +#pragma pack() + +#endif --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94537): https://edk2.groups.io/g/devel/message/94537 Mute This Topic: https://groups.io/mt/94007104/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-