From nobody Mon Feb 9 12:15:16 2026 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+107259+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 169032832662492.36993768279899; Tue, 25 Jul 2023 16:38:46 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=I9pDsqOTTN92ARjgh3wHLMMSpDSaEg25VtOwW4A/9w8=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:X-NVConfidentiality:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type; s=20140610; t=1690328326; v=1; b=PPB3suWDFycn96ksMbtNl1TG+ZptyysjT0HY/4x8dMAk1O+1FX/OFPDmv1Gb8YE4hHWjZlsV Ok1pN6N7gH2au85d67psVwF+rVcFqKsU/YrNPB+gMxo0h+VI6/Gb8XRG1naFMV/mUf4qd4aSdMn 3RUOroNyG3WA8W+r4tZ9dr4E= X-Received: by 127.0.0.2 with SMTP id 7Pq2YY1788612x603t3EcF8N; Tue, 25 Jul 2023 16:38:46 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.49]) by mx.groups.io with SMTP id smtpd.web11.111.1690328325633186739 for ; Tue, 25 Jul 2023 16:38:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SaQEppTf0veQZtVpZVtw6mB5D6SLO+Zso/7q3ZpNc6B4mf/4BaS4LN36WObUuOlv1BLuLy4Y+E6qo2NHmi20FZPSdSiOGuqm9B4O22cJiSvLBfhWCp77phKPbgGXa1OJiEXpZv9QTuFYdsMaktj+DQ9T1soFuuQpBuIRly8vjNczg3p8in9bV6VsG9RK4I1KZNm+PY/+AGmY7+frGprQXgn5NAmvMmD+hWUT9huLwVynHvhjeQL2HS55GVddXux7DXopkXF0LfF4XPd0FKHPStak9C7Y3Q5YI3So24WGJhJrRu4dypC4qcaExOY90SD+kBON4gNwPTR2AhzAXxmHtg== 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=QLiVkqgCXu9vjtFluhxO5VcSSxqVNzgZW4XPrhTL97g=; b=P+MYHxWi1hOnlcixkTj38rKpHQXdtELVTMf37n7vZ9HaPJbJQFhEJjgEIFiwZnGaH8dsVTbVt3WbC2a/5pPOvqGZwWLfz7C6XodFIAY4G9NNo3oLGfGMRSxsH06NOBnAL2q+rYm32dKMgJMEl9N5tnqyF16o711LGC8aBuyWD6TsaGg4C33QXWhj50EvX97GwADHL3WfSt9G+MkKExiDV0oE5reQzwnUr9sIV4karEcTg22pR0MbdB5h6hQoThr45GHsr3niegT4FqsuRwio2ODU83W8iXYiGD32yt/YHg7rBB0uk6A+4WwnpqMHvgzWsgBKzpOuVVfxWdQywgywUg== 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 MW4P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::24) by IA1PR12MB6483.namprd12.prod.outlook.com (2603:10b6:208:3a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 23:38:41 +0000 X-Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::9f) by MW4P222CA0019.outlook.office365.com (2603:10b6:303:114::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:41 +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+107259+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 CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:41 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.5; Tue, 25 Jul 2023 16:38:25 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:25 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:24 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Date: Tue, 25 Jul 2023 23:38:05 +0000 Message-ID: <20230725233805.646668-6-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT011:EE_|IA1PR12MB6483:EE_ X-MS-Office365-Filtering-Correlation-Id: 41b90e01-81e4-434b-e5d3-08db8d684710 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: jYWrXX8WMOrp4KOCrdZRy/UfQUS491IdlL+kosD/5ggkAx9uUAtTh1SZXYjhmMAq4DwSynrIE8Zp+QJ11VN+M08k2dUZzMEWviBAT0Zw6NVEFq00x2N7Kub4WyXcpo3mFOaaPKH17u7/97mwMaQzsTxzhl3Cim35wlM0xGVHIO4xlV2Avcch1CypDzz4JE3+1NIpoOFZwP6XMqiOtw6TpxOXHhEh7XfE8Xe2u/0y30q4cxzetPY7lsv+uaE6NzpS03ZoEWTnUf0Z/S/5phcpbde5gocTklMAqKXsEJg1yIRkXy4wz4eEA8VLZmbNblahMPJNPqmBz0qLBbaX814946mwebsC8psRbw9BG4MVU+VXfxCcL4Xk40kcO1G61vBNnpSGH20cZEcgswGIZdn+FhjxUgXs9ulhEG3xlMIMzQgewX0MY2UKteqrQtA35VtkR9JPmL5rcdZrhCHiPtcWktIXQ1BT/DdZ2K0jm1ke6lWMRTG29HuaVDPQrtIqR/e2HS460IBH0a97OKqddtWfISUZC8iNejfLo8S8gFWI/DoRBohxPu/GrYu4gEOmX0dn062aFLV26bmLKlantsfw3sr3VpBYuYT19Xqni6g3N+XgdyvnTa/IJXyWjQlZLanNCUfM8+Gqu0K6kmx4g/zt3xYgpt/m008FkbaRHZv99N1U7Ud27eRjcDgKnlhz7sHWN0xlMcXu+MFe2y5qPal3EVbWy4XeNHqEyFnP5IGdZSPrdelb6TOhFZ84yy+uRRKU X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:41.0055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41b90e01-81e4-434b-e5d3-08db8d684710 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: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6483 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: oWJbxtgKqQSQP8vSzvUSDF2Mx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328327437100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the Generator library for SMBIOS Table Type 16 - Physical Memory Array. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen Reviewed-by: Nick Ramirez --- .../SmbiosTableBuilder.c | 3 - .../Include/SmbiosNameSpaceObjects.h | 19 + .../SmbiosType16Lib/SmbiosType16Generator.c | 361 ++++++++++++++++++ .../SmbiosType16Lib/SmbiosType16Lib.inf | 35 ++ 4 files changed, 415 insertions(+), 3 deletions(-) create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosT= ype16Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosT= ype16Lib.inf diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBui= lder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder= .c index bfddaac3aa..5feafcac66 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c @@ -312,7 +312,6 @@ exit_handler: } } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 @@ -432,7 +431,6 @@ BuildAndInstallSmbiosTable ( )); } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 @@ -516,7 +514,6 @@ ProcessSmbiosTables ( )); } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h index e44d703fac..760b082021 100644 --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -107,6 +107,25 @@ typedef struct { SMBIOS_TABLE_GENERATOR_ID GeneratorId; } CONTAINED_CM_OBJECTS; =20 +/** A structure that describes the Physical Memory Array. + + SMBIOS Specification v3.6.0 Type 16 + + ID: ESmbiosObjPhysicalMemoryArray +**/ +typedef struct CmSmbiosPhysicalMemoryArray { + UINT8 Use; + UINT8 Location; + UINT16 MemoryErrorCorrection; + UINT16 MemoryErrorInformationHandle; + UINT16 NumberOfMemoryDevices; + UINT8 MemoryErrorCorrectionType; + UINT64 Size; + UINT8 NumMemDevices; + CM_OBJECT_TOKEN MemoryErrInfoToken; + CM_OBJECT_TOKEN PhysMemArrayToken; +} CM_SMBIOS_PHYSICAL_MEMORY_ARRAY; + #pragma pack() =20 #endif // SMBIOS_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Ge= nerator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Gen= erator.c new file mode 100644 index 0000000000..dad7588ed5 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator= .c @@ -0,0 +1,361 @@ +/** @file + SMBIOS Type16 Table Generator. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include +#include + +/** This macro expands to a function that retrieves the Memory Device + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceSmbios, + ESmbiosObjPhysicalMemoryArray, + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY + ) + +#define EXTENDED_SIZE_THRESHOLD (SIZE_2TB) + +/** + * Free any resources allocated when installing SMBIOS Type16 table. + * + * @param [in] This Pointer to the SMBIOS table generator. + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory + Protocol interface. + + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table informati= on. + * @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + * @param [in] Table Pointer to the SMBIOS table. + * @param [in] CmObjectToken Pointer to the CM ObjectToken Array. + * @param [in] TableCount Number of SMBIOS tables. + + * @retval EFI_SUCCESS Table generated successfully. + * @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for + the requested object. + * @retval EFI_INVALID_PARAMETER A parameter is invalid. + * @retval EFI_NOT_FOUND Could not find information. + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + * @retval EFI_UNSUPPORTED Unsupported configuration. +**/ +STATIC +EFI_STATUS +FreeSmbiosType16TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFa= ctoryProtocol, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosT= ableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrP= rotocol, + IN SMBIOS_STRUCTURE ***CONST Table, + IN CM_OBJECT_TOKEN **CmObj= ectToken, + IN CONST UINTN TableCo= unt + ) +{ + UINTN Index; + SMBIOS_STRUCTURE **TableList; + + TableList =3D *Table; + for (Index =3D 0; Index < TableCount; Index++) { + if (TableList[Index] !=3D NULL) { + FreePool (TableList[Index]); + } + } + + if (*CmObjectToken !=3D NULL) { + FreePool (*CmObjectToken); + } + + if (TableList !=3D NULL) { + FreePool (TableList); + } + + return EFI_SUCCESS; +} + +/** + * Update the Size encoding for Type 16. + * + * @param [in] SizeBytes Size of the Memory device. + * @param [out] SmbiosRecord SMBIOS record to update. +**/ +STATIC +VOID +UpdateSmbiosType16Size ( + IN UINT64 SizeBytes, + IN OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord + ) +{ + UINT64 SizeKb =3D SizeBytes / SIZE_1KB; + + if (SizeBytes < EXTENDED_SIZE_THRESHOLD) { + SmbiosRecord->MaximumCapacity =3D SizeKb; + } else { + SmbiosRecord->MaximumCapacity =3D 0x80000000; + SmbiosRecord->ExtendedMaximumCapacity =3D SizeKb; + } +} + +/** + * Add the SMBIOS table handle reference to the Error Tables. + * + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Fac= tory. + * @param [in] CmObjToken CM Token to lookup.. + * @param [out] SmbiosRecord SMBIOS record to update. +**/ +STATIC +VOID +AddMemErrDeviceHandle ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_OBJECT_TOKEN CmObjToken, + OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord + ) +{ + EFI_SMBIOS_HANDLE Handle; + SMBIOS_HANDLE_MAP *HandleMap; + + HandleMap =3D TableFactoryProtocol->GetSmbiosHandle (CmObjToken); + if (HandleMap =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__)= ); + Handle =3D 0xFFFF; + } else { + Handle =3D HandleMap->SmbiosTblHandle; + } + + SmbiosRecord->MemoryErrorInformationHandle =3D Handle; +} + +/** Construct SMBIOS Type16 Table describing memory devices. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + * @param [in] This Pointer to the SMBIOS table generator. + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory + * Protocol interface. + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table informati= on. + * @param [in] CfgMgrProtocol Pointer to the Configuration Manager + * Protocol interface. + * @param [out] Table Pointer to the SMBIOS table. + * @param [out] CmObjectToken Pointer to the CM Object Token Array. + * @param [out] TableCount Number of tables installed. + + * @retval EFI_SUCCESS Table generated successfully. + * @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + * Manager is less than the Object size for + * the requested object. + * @retval EFI_INVALID_PARAMETER A parameter is invalid. + * @retval EFI_NOT_FOUND Could not find information. + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + * @retval EFI_UNSUPPORTED Unsupported configuration. +**/ +STATIC +EFI_STATUS +BuildSmbiosType16TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT SMBIOS_STRUCTURE ***Table, + OUT CM_OBJECT_TOKEN **CmObjectToken, + OUT UINTN *CONST TableCount + ) +{ + EFI_STATUS Status; + SMBIOS_STRUCTURE **TableList; + SMBIOS_TABLE_TYPE16 *SmbiosRecord; + CM_OBJECT_TOKEN *CmObjectList; + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY *PhysMemoryArray; + UINT32 NumObj; + UINTN Index; + + ASSERT (This !=3D NULL); + ASSERT (SmbiosTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (TableCount !=3D NULL); + ASSERT (SmbiosTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + + if ((This =3D=3D NULL) || (SmbiosTableInfo =3D=3D NULL) || (CfgMgrProtoc= ol =3D=3D NULL) || + (Table =3D=3D NULL) || (TableCount =3D=3D NULL) || + (SmbiosTableInfo->TableGeneratorId !=3D This->GeneratorID)) + { + DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + Status =3D GetESmbiosObjPhysicalMemoryArray ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &PhysMemoryArray, + &NumObj + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to get Memory Devices CM Object %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + TableList =3D (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRU= CTURE *) * NumObj); + if (TableList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u devices table\n", + __FUNCTION__, + NumObj + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_= TOKEN *) * NumObj); + if (CmObjectList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u CM Objects.\n", + __FUNCTION__, + NumObj + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + for (Index =3D 0; Index < NumObj; Index++) { + /** + * Per Spec each structure is terminated by a double-NULL if there are= no + * strings. + */ + SmbiosRecord =3D (SMBIOS_TABLE_TYPE16 *)AllocateZeroPool (sizeof (SMBI= OS_TABLE_TYPE16) + 1 + 1); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + UpdateSmbiosType16Size (PhysMemoryArray->Size, SmbiosRecord); + SmbiosRecord->Location =3D PhysMemoryArray[Index].Locatio= n; + SmbiosRecord->Use =3D PhysMemoryArray[Index].Use; + SmbiosRecord->MemoryErrorCorrection =3D PhysMemoryArray[Index].MemoryE= rrorCorrectionType; + SmbiosRecord->NumberOfMemoryDevices =3D PhysMemoryArray->NumMemDevices; + if (PhysMemoryArray[Index].MemoryErrInfoToken !=3D CM_NULL_TOKEN) { + AddMemErrDeviceHandle ( + TableFactoryProtocol, + PhysMemoryArray[Index].MemoryErrInfoToken, + SmbiosRecord + ); + } else { + SmbiosRecord->MemoryErrorInformationHandle =3D 0xFFFF; + } + + // Setup the header + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE16); + + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; + CmObjectList[Index] =3D PhysMemoryArray[Index].PhysMemArrayToken; + } + + *Table =3D TableList; + *CmObjectToken =3D CmObjectList; + *TableCount =3D NumObj; +exitBuildSmbiosType16Table: + return Status; +} + +/** The interface for the SMBIOS Type16 Table Generator. +*/ +STATIC +CONST +SMBIOS_TABLE_GENERATOR SmbiosType16Generator =3D { + // Generator ID + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType16), + // Generator Description + L"SMBIOS.TYPE16.GENERATOR", + // SMBIOS Table Type + EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, + NULL, + NULL, + // Build table function. + BuildSmbiosType16TableEx, + // Free function. + FreeSmbiosType16TableEx, +}; + +/** Register the Generator with the SMBIOS 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 +SmbiosType16LibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterSmbiosTableGenerator (&SmbiosType16Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type 16: Register Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** Deregister the Generator from the SMBIOS 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 +SmbiosType16LibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType16Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type16: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Li= b.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf new file mode 100644 index 0000000000..5bb40db21c --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf @@ -0,0 +1,35 @@ +## @file +# SMBIOS Type17 Table Generator +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. +# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbiosType16LibArm + FILE_GUID =3D a256956a-de0b-4aa7-8eac-5ce13bbfbb1f + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D SmbiosType16LibConstructor + DESTRUCTOR =3D SmbiosType16LibDestructor + +[Sources] + SmbiosType16Generator.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED + +[LibraryClasses] + BaseLib + DebugLib --=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 (#107259): https://edk2.groups.io/g/devel/message/107259 Mute This Topic: https://groups.io/mt/100361564/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-