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 C8670AC1B40 for ; Wed, 5 Feb 2025 22:09:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+vkutBbxJi6bSu5lj1cXvotlE2qMuIMgNEpWcxe8T7s=; c=relaxed/simple; d=groups.io; h=Received-SPF: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:Content-Type; s=20240830; t=1738793393; v=1; x=1739052592; b=IPM3JzfgfOYCkw055/8IMF5wjTtaocD4e37a0kqkg4SC2l1II7cQ1f3fto3es37jQ2CyMllu CMDio9Qrgna7s9FS1sBOy7qYF1KsRQJ6OwNixJLXIPmugJtTTWUTye3iDlYICniQB6of3jtkRLo d0YIOXrRxNRnTR/fYrRJxCKXp8t+5+HbIsDnmDyVKGG/ozEy1Z4nwRSbAQJUp0qVc0MHOHU6oMQ fYbpk4AssOE92gjaKbH+muQwqppGl+P/begElfFoHAODAwlPpEEwj/C7b/itedDNkHHnoVv0R+6 lqNCn+uisI9rLX83sa7pU2hpJMzFKsl3YwPbVxP2WEPSQ== X-Received: by 127.0.0.2 with SMTP id 50hXYY7687511x73qixcDrBn; Wed, 05 Feb 2025 14:09:52 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.68]) by mx.groups.io with SMTP id smtpd.web10.25664.1738793388856141536 for ; Wed, 05 Feb 2025 14:09:48 -0800 X-Received: from BN9P223CA0028.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::33) by MW3PR12MB4364.namprd12.prod.outlook.com (2603:10b6:303:5c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.10; Wed, 5 Feb 2025 22:09:44 +0000 X-Received: from BN2PEPF000055DB.namprd21.prod.outlook.com (2603:10b6:408:10b:cafe::40) by BN9P223CA0028.outlook.office365.com (2603:10b6:408:10b::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.27 via Frontend Transport; Wed, 5 Feb 2025 22:09:44 +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 (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 BN2PEPF000055DB.mail.protection.outlook.com (10.167.245.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.0 via Frontend Transport; Wed, 5 Feb 2025 22:09:43 +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.1544.4; Wed, 5 Feb 2025 14:09:25 -0800 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.1544.14; Wed, 5 Feb 2025 14:09:24 -0800 X-Received: from NV-PF4WDED0.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.1544.14 via Frontend Transport; Wed, 5 Feb 2025 14:09:24 -0800 From: "Girish Mahadevan via groups.io" To: , , , , , CC: , , , , Subject: [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19) Date: Wed, 5 Feb 2025 15:09:10 -0700 Message-ID: <58f8eb29f9f98dd6674510557f6543a9250681d2.1738793024.git.gmahadevan@nvidia.com> In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DB:EE_|MW3PR12MB4364:EE_ X-MS-Office365-Filtering-Correlation-Id: 1186236d-d51b-4dd0-e071-08dd4631cbaa X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nR2vKJVOeWmrJwe4zW7FHl/eKaj0dMoKldzW7yESyJyXhR48PeonPfiEb1il?= =?us-ascii?Q?g3OPcEBi6Z2t53NjCLGeSOLMykrrgMsJcoBmsK0CgNYbgMV1SsxE11a41FIl?= =?us-ascii?Q?YoXFclViXpdyixeTxrGdw90kHIA6tJxlqacbsVJDrbVhI5KJT26ta6gdiStl?= =?us-ascii?Q?JBf8UtVevUYM2XZNysnLrnZ9Rt+Kxk3WOYTJknmqxnfgXd4c/+5HmFb/bWQm?= =?us-ascii?Q?Uvm/rs6+xQbuDqKbHlHq07SzGHN6OI/YthK80xwh0+xVZBviS8BNpKv3L2sW?= =?us-ascii?Q?roy72u7DnU+/w9jyEzTEA11h+X2vn7DnYQiQkagCXIeKpAtK3VQVgEMcYudQ?= =?us-ascii?Q?BvsUVNRiVwHMLYH4mt1bh/hSeYu4lCeGyUeDpG93Bps19pzHbx2HNNirtJht?= =?us-ascii?Q?oSsjBpoMOWbDocgmIkItRWS1b8Qu9SebynD2oQ8MF8q0gcuxb5ZPDYk2JLas?= =?us-ascii?Q?SXmfFTaD/NJo0uVS8tNuJf0koMmcohFeJdFLhunA+VbQO624UxWynXPl/4We?= =?us-ascii?Q?VFENziO0NQDMeiKc76h+Iy3NXFaQU00hHmyLQqPfRhk/GdX7u/o+VlwLQmGB?= =?us-ascii?Q?eqQGN4Nv+b6xORwjpfWb6hDnjNsbxS0J07oqgFRkmDiBKFG9PaftJlxFA9ct?= =?us-ascii?Q?nsxKjMnWI9IbSJTXAZLqRuVKJyRGn6gYpVl0rG16lW7veno1eTStnSoGvVMf?= =?us-ascii?Q?Qz8fk04/2CDG1fNThI01Qa/8oRjgAOIg8bKi5Si+XM1qdWkdXFjng2bbzd62?= =?us-ascii?Q?iBw+C9FG8VqDVLcHsHumtwkN1C5LaaUIJiglXNfPsYL8WQnIw8FpH6H4rd06?= =?us-ascii?Q?JCrWfBO6mij84DkRe+fC1BrjZCHEO/mTH503Y7BZYOqICFgX4KYoqM1gqi/Q?= =?us-ascii?Q?NmPSZQgFFCr/BOmmvnYHLYs642W0NHfzhZV2ZxfGcqlkMW1H3Q+TzB4IerHQ?= =?us-ascii?Q?JJ6FBvJFlivdzv/LZGawmtxJlN8LLH5VAm1n2w+4ixL53/NiRhBYAvrvd23m?= =?us-ascii?Q?pFa33BGe5L7ByG4HXoWcZj7bKEcWYna/kMqC06wc/wa8xiJytZrhUJQLLq8y?= =?us-ascii?Q?ariUHIELA9CxOJilXet5MV4CtRm6VQ27y1aYz3yvpo1R0ExLKyGxpShMbtr2?= =?us-ascii?Q?7iLnI8+EGDDBw8398lpvNt/7NWcO0Djsi4ZAsKyva6W3UxPQRdIK12Bb+Xjh?= =?us-ascii?Q?qp8QL5jmRisaTU/A127/UGrhUrpdChfNiXTpv19dt9yZ2BV2KxBHmp4+qz14?= =?us-ascii?Q?Mju2xUHbDr623KV5/0Ocd496YG+VXj5inKPix3IR1IjK67/mRKocIkQO1T2X?= =?us-ascii?Q?FUk61UxsUwtem6yEu4IzD2k54AU7N0sxjA0MBc06cQSJm3Ux0C7OJVuEjID8?= =?us-ascii?Q?F6N3ffZStgvWnNE1HGXtmlKaPbmNKdISM84Qz2H6o8ePcVfo0B30TuMCmbHW?= =?us-ascii?Q?HzJPy7rWgbsjwh6nwzxn+txtPSoI+Gme0ln5LbPmyWTMCKf2foZ+EHQ8Lm2b?= =?us-ascii?Q?CJzVrgwA8DpTPvQ=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2025 22:09:43.8762 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1186236d-d51b-4dd0-e071-08dd4631cbaa 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: BN2PEPF000055DB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4364 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, 05 Feb 2025 14:09:48 -0800 Resent-From: gmahadevan@nvidia.com Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ytC8cJjqnoqIi1EcmiaPGL4Ex7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=IPM3Jzfg; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Add the Generator library for SMBIOS Table Type 19 - Memory Array Mapped Address. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen --- .../Include/SmbiosNameSpaceObjects.h | 14 + .../SmbiosType19Lib/SmbiosType19Generator.c | 364 ++++++++++++++++++ .../SmbiosType19Lib/SmbiosType19Lib.inf | 36 ++ 3 files changed, 414 insertions(+) create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosT= ype19Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosT= ype19Lib.inf diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h index 7e883e1b89..e6c35f1ffd 100644 --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -151,6 +151,20 @@ typedef struct CmSmbiosPhysicalMemoryArray { CM_OBJECT_TOKEN PhysMemArrayToken; } CM_SMBIOS_PHYSICAL_MEMORY_ARRAY; =20 +/** A structure that describes the Memory Array Mapped Address. + + SMBIOS Specification v3.6.0 Type 19 + + ID: ESmbiosObjPhysicalMemoryArray +**/ +typedef struct CmSmbiosMemArrayMappedAddress { + EFI_PHYSICAL_ADDRESS StartingAddress; + EFI_PHYSICAL_ADDRESS EndingAddress; + CM_OBJECT_TOKEN MemoryArrayMappedAddressToken; + UINT8 NumMemDevices; + CM_OBJECT_TOKEN PhysMemArrayToken; +} CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS; + #pragma pack() =20 #endif // SMBIOS_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Ge= nerator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Gen= erator.c new file mode 100644 index 0000000000..0ca16cb300 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator= .c @@ -0,0 +1,364 @@ +/** @file + SMBIOS Type19 Table Generator. + + Copyright (c) 2024, 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, + ESmbiosObjMemoryArrayMappedAddress, + CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS + ) + +#define EXTENDED_ADDRESS_THRESHOLD (0xFFFFFFFFL) + +/** + * Free any resources allocated when installing SMBIOS Type19 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 +FreeSmbiosType19TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFact= oryProtocol, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTab= leInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrPro= tocol, + IN SMBIOS_STRUCTURE ***CONST Table, + IN CM_OBJECT_TOKEN **CmObjec= tToken, + IN CONST UINTN TableCoun= t + ) +{ + 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; +} + +/** + * Add the SMBIOS table handle reference to the Physical Array Table. + * + * @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 +AddPhysArrHandle ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_OBJECT_TOKEN CmObjToken, + OUT SMBIOS_TABLE_TYPE19 *SmbiosRecord + ) +{ + EFI_SMBIOS_HANDLE PhysMemArrHandle; + 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__)= ); + PhysMemArrHandle =3D 0; + } else { + PhysMemArrHandle =3D HandleMap->SmbiosTblHandle; + } + + SmbiosRecord->MemoryArrayHandle =3D PhysMemArrHandle; +} + +/** + * Update the Address encoding for Type 19. + * + * @param [in] StartAddress Starting memory address covered by the d= evice. + * @param [in] EndAddress Ending memory address covered by the dev= ice. + * @param [out] SmbiosRecord SMBIOS record to update. +**/ +STATIC +VOID +UpdateSmbiosType19Address ( + IN UINT64 StartAddress, + IN UINT64 EndAddress, + OUT SMBIOS_TABLE_TYPE19 *SmbiosRecord + ) +{ + UINT64 StartingAddressKb =3D StartAddress / SIZE_1KB; + UINT64 EndingAddressKb =3D EndAddress / SIZE_1KB; + + if (StartingAddressKb >=3D EXTENDED_ADDRESS_THRESHOLD) { + SmbiosRecord->StartingAddress =3D EXTENDED_ADDRESS_THRESHOLD; + SmbiosRecord->EndingAddress =3D EXTENDED_ADDRESS_THRESHOLD; + SmbiosRecord->ExtendedStartingAddress =3D StartAddress; + SmbiosRecord->ExtendedEndingAddress =3D EndAddress; + } else { + SmbiosRecord->StartingAddress =3D StartingAddressKb; + SmbiosRecord->EndingAddress =3D EndingAddressKb; + } +} + +/** Construct SMBIOS Type19 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] SmbiosTableInfo Pointer to the SMBIOS table information. + @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 +BuildSmbiosType19TableEx ( + 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; + UINT32 NumMemMap; + SMBIOS_STRUCTURE **TableList; + CM_OBJECT_TOKEN *CmObjectList; + CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS *MemoryMapInfo; + SMBIOS_TABLE_TYPE19 *SmbiosRecord; + 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 GetESmbiosObjMemoryArrayMappedAddress ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &MemoryMapInfo, + &NumMemMap + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to get Memory Devices CM Object %r\n", + Status + )); + return Status; + } + + TableList =3D (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRU= CTURE *) * NumMemMap); + if (TableList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u devices table\n", + __FUNCTION__, + NumMemMap + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType19TableEx; + } + + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_= TOKEN *) * NumMemMap); + if (CmObjectList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u CMObjects\n", + __FUNCTION__, + NumMemMap + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType19TableEx; + } + + for (Index =3D 0; Index < NumMemMap; Index++) { + /** + * Per Spec each structure is terminated by a double-NULL if there are= no + * strings. + */ + SmbiosRecord =3D (SMBIOS_TABLE_TYPE19 *)AllocateZeroPool (sizeof (SMBI= OS_TABLE_TYPE19) + 1 + 1); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType19TableEx; + } + + UpdateSmbiosType19Address ( + MemoryMapInfo[Index].StartingAddress, + MemoryMapInfo[Index].EndingAddress, + SmbiosRecord + ); + SmbiosRecord->PartitionWidth =3D MemoryMapInfo[Index].NumMemDevices; + // Is there a reference to a Physical Array Device. + if (MemoryMapInfo[Index].PhysMemArrayToken !=3D CM_NULL_TOKEN) { + AddPhysArrHandle ( + TableFactoryProtocol, + MemoryMapInfo[Index].PhysMemArrayToken, + SmbiosRecord + ); + } + + // setup the header + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRE= SS; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE19); + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; + CmObjectList[Index] =3D MemoryMapInfo[Index].MemoryArrayMappedAdd= ressToken; + } + + *Table =3D TableList; + *CmObjectToken =3D CmObjectList; + *TableCount =3D NumMemMap; + +exitBuildSmbiosType19TableEx: + return Status; +} + +/** The interface for the SMBIOS Type17 Table Generator. +*/ +STATIC +CONST +SMBIOS_TABLE_GENERATOR SmbiosType19Generator =3D { + // Generator ID + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType19), + // Generator Description + L"SMBIOS.TYPE19.GENERATOR", + // SMBIOS Table Type + EFI_SMBIOS_TYPE_MEMORY_DEVICE, + NULL, + NULL, + // Build table function Extended. + BuildSmbiosType19TableEx, + // Free function Extended. + FreeSmbiosType19TableEx +}; + +/** 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 +SmbiosType19LibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterSmbiosTableGenerator (&SmbiosType19Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type 19: 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 +SmbiosType19LibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType19Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type19: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Li= b.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf new file mode 100644 index 0000000000..0043e71d1c --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf @@ -0,0 +1,36 @@ +## @file +# SMBIOS Type19 Table Generator +# +# Copyright (c) 2024, 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 SmbiosType19LibArm + FILE_GUID =3D 36da84ff-2c7d-4983-99a0-c9e1a8675fb4 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D SmbiosType19LibConstructor + DESTRUCTOR =3D SmbiosType19LibDestructor + +[Sources] + SmbiosType19Generator.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 + SmbiosStringTableLib --=20 2.25.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 (#121095): https://edk2.groups.io/g/devel/message/121095 Mute This Topic: https://groups.io/mt/111022015/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-