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 10D4C740039 for ; Wed, 5 Feb 2025 22:09:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wkPukeJdZJITyNNmW/GHOa03MEvz+FU4GZwd31/wev8=; 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=1738793395; v=1; x=1739052594; b=eDG2NirmjBJE6TfooVK76KV1EtvW7dlytFVbHUTpPUMOz40dUIgiUuXejUIqiF4Fdru+73mH eYv6ri6zbhyV/TwE02p3sVa+JTD2ad//FPxhfcDEuSQb2wi0+yz5gkR+AiDumFVIn0aXRjk0hFH 4z6KDZ+WavQhMv5MMzyMdWZM5BfOJGIKXq0e4GwQgct7ZoF7sTI67vxRbczSavE8JX2KZTUUw+t RYk0NVQRO28YvfHbnVE9mDRP8ys+CDn8+RuDETiBX2tMCUN8SbXxt2vwROjjruQDQh8EqsdQhpA nZIy516G7IMbdFZZVAkVnc8UXh2ysniqYgjb/gM1B96ig== X-Received: by 127.0.0.2 with SMTP id IrLuYY7687511x6jEedFNMVE; Wed, 05 Feb 2025 14:09:54 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.77]) by mx.groups.io with SMTP id smtpd.web11.25792.1738793388853136683 for ; Wed, 05 Feb 2025 14:09:49 -0800 X-Received: from DS7PR07CA0008.namprd07.prod.outlook.com (2603:10b6:5:3af::21) by DM4PR12MB8498.namprd12.prod.outlook.com (2603:10b6:8:183::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.11; Wed, 5 Feb 2025 22:09:42 +0000 X-Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:5:3af:cafe::43) by DS7PR07CA0008.outlook.office365.com (2603:10b6:5:3af::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.21 via Frontend Transport; Wed, 5 Feb 2025 22:09:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.14 via Frontend Transport; Wed, 5 Feb 2025 22:09:41 +0000 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) 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:23 -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:22 -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:21 -0800 From: "Girish Mahadevan via groups.io" To: , , , , , CC: , , , , Subject: [edk2-devel] [staging/dynamictables-reorg PATCH v0 10/12] DynamicTablesPkg: Smbios Memory Device (Type 17) Date: Wed, 5 Feb 2025 15:09:08 -0700 Message-ID: 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: DS3PEPF000099E1:EE_|DM4PR12MB8498:EE_ X-MS-Office365-Filtering-Correlation-Id: 486cbd2a-40dc-4803-48d9-08dd4631ca73 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?TosI6q0dvgnGzla71iOW8Upc8aNYswLARadmCxpiGOwf1H3n1XGrGAFIIh42?= =?us-ascii?Q?P7ym3zS2zYhS8vKAjFP9qKCzSel9dlGgkb19qki9IzEFSuVGWauIcG+4d2aQ?= =?us-ascii?Q?Q7wvvO/s/FEfQwm+3vyYCGhQYrEAeT0yAyd7WdzOcIg0fTXi4jLs95wMGOq0?= =?us-ascii?Q?dI1iX5sgG8eKR0eV2yQnMzHO9OJmWgqLuCCGoUA6d8K8V+Pn4dLG+bnZQaVW?= =?us-ascii?Q?44zlsN/N9sLUzRq/J5+N8NCKBcKveNQjejb3gsh8SISjM8f/4WQH8EXyHAJP?= =?us-ascii?Q?BbcsQJTvqFo0hvp3AULeVekgi8PvxsSuSc5EhVLn99z16n6Ym+EOs7lKZh+2?= =?us-ascii?Q?0LTW8hlLVopw/BQsLH98luzCC1T67cdAyu9DfqGHVmOUITIpLkpSks9KOH+9?= =?us-ascii?Q?yuH0I5WX7mRaYDLjd1u/dkg3FOsdpm0eT0Wz7HDUFwCUL4jseOeqUyabP7Bm?= =?us-ascii?Q?d64rAD5wny7r2vrGND+92Ty8FlzdGRjhNN56Ktj0CdZROMFDTIhANorF6g6c?= =?us-ascii?Q?ukWqfRJswAzt2neTmLfwHNX2CsDPI8cMjcqBFWgwHIM/PjumyRbJ0SrQTyTP?= =?us-ascii?Q?FnzcMraezqoZkpleowfZiwKvDinlqmvVnRHFFBW/x1IKg7+LvpojVN5iyMc1?= =?us-ascii?Q?08YZYQidJuKHKrVv3VVmjU3tl5evBRnHLWxSdOfwlkkSCI1YIyhtOu+TNyMl?= =?us-ascii?Q?wvOdm6lqoNEp//fd0hc92xxVYbUvJEtm4a17f3uHIFHbNEw9JsF9flUnEV9C?= =?us-ascii?Q?0mvtNOVa4QXyLPyua+oMArVzYBmqX6O9zRxwuAyxxzk8AEyfRpMX7oilEiip?= =?us-ascii?Q?mha3AUbC4Z3W+cN4j4TQKB+MOuo9/SlN4M+9YPvdtyr7njSBIrhqImDH/tcB?= =?us-ascii?Q?BLKpmif6HvJxZM2o6G0vDKSYebTD6YX9iACa295eLj8wzHpMxfDmaLFIlwOZ?= =?us-ascii?Q?cyadk2le0Bzz3ydLYSpiG0c6bAmzW6rN6Rlv7qy4T9vPnKrgS55RaljKzIzw?= =?us-ascii?Q?UcUTkjhyMXCeNaQSg5mZC5LaLB7vTQ9uxql0Ru0jVR/pwjngF22LaoRhFVQ6?= =?us-ascii?Q?6BYSqR1iZ350R13HIcWQ5iNmXQR+hJzwAlCdadoEfzfJT3IK3eRUuKQ7ndLh?= =?us-ascii?Q?q5FLVv0KB31Dn6GgwRfRR8VhEvRqpkXoZ8kZLdNSZShA5d7x65lBEbHIG3cr?= =?us-ascii?Q?zwIE+jgulVlbbVfAqSabuKR1nCSBqQ5mEJEu4WjgDzxibqHOjMYB3/aAGucB?= =?us-ascii?Q?gamdMjCWsra9gW1ZmpVaV+DC4F93TAWoKu41yRusWPk7z9g7LBZP9MZq+Bzs?= =?us-ascii?Q?2j7N/8xStVNV6GLZa0ojy86lznEKF0tpgUY8vZgulUVLQvAkKCgTfnCDQSl5?= =?us-ascii?Q?eCOm3gNIBM+tKKog9oftxS3tW82HGN+MAXbt5yIkpnzQBiAzu8KiQHyS1NjQ?= =?us-ascii?Q?+y99RMMsiGUx67KUbsKcvsrikwa8v8sQSQDxHRt2syB4yEdL1T+zshLUCapz?= =?us-ascii?Q?FWbBIgJ5Jlrt3OM=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2025 22:09:41.9279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 486cbd2a-40dc-4803-48d9-08dd4631ca73 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8498 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:49 -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: dZoZdydRH9ixH3Nl6I7wENzYx7686176AA= 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=eDG2Nirm; 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 17 - Memory Device. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen --- .../Include/SmbiosNameSpaceObjects.h | 95 ++++ .../SmbiosType17Lib/SmbiosType17Generator.c | 491 ++++++++++++++++++ .../SmbiosType17Lib/SmbiosType17Lib.inf | 37 ++ 3 files changed, 623 insertions(+) create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosT= ype17Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosT= ype17Lib.inf diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h index eeeb94bbb2..e9bde2a712 100644 --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -13,6 +13,8 @@ #ifndef SMBIOS_NAMESPACE_OBJECTS_H_ #define SMBIOS_NAMESPACE_OBJECTS_H_ =20 +#include + #pragma pack(1) =20 typedef enum SmbiosObjectID { @@ -37,6 +39,99 @@ typedef enum SmbiosObjectID { ESmbiosObjMax } ESMBIOS_OBJECT_ID; =20 +/** A structure that describes the physical memory device. + + The physical memory devices on the system are described by this object. + + SMBIOS Specification v3.5.0 Type17 + + ID: ESmbiosObjMemoryDeviceInfo, +*/ +typedef struct CmSmbiosMemoryDeviceInfo { + /** Size of the device. + Size of the device in bytes. + */ + UINT64 Size; + + /** Device Set */ + UINT8 DeviceSet; + + /** Speed of the device + Speed of the device in MegaTransfers/second. + */ + UINT32 Speed; + + /** Configured speed of the memory device + Configured speed of the memory device in MegaTransfers/second. + */ + UINT32 ConfiguredMemorySpeed; + + /** Serial Number of device */ + CHAR8 *SerialNum; + + /** AssetTag identifying the device */ + CHAR8 *AssetTag; + + /** Device Locator String for the device. + String that describes the slot or position of the device on the board. + */ + CHAR8 *DeviceLocator; + + /** Bank locator string for the device. + String that describes the bank where the device is located. + */ + CHAR8 *BankLocator; + + /** Firmware version of the memory device */ + CHAR8 *FirmwareVersion; + + /** Part number of the memory device */ + CHAR8 *PartNum; + + /** Manufacturer Id. + 2 byte Manufacturer Id as per JEDEC Standard JEP106AV + */ + UINT16 ModuleManufacturerId; + + /** Manufacturer Product Id + 2 byte Manufacturer Id as designated by Manufacturer. + */ + UINT16 ModuleProductId; + + /** Minimum voltage + Minimum operating voltage for this device, in millivolts. + */ + UINT16 MinVolt; + + /** Maximum voltage + Maximum operating voltage for this device, in millivolts. + */ + UINT16 MaxVolt; + + /** Configured voltage + Configured voltage for this device, in millivolts. + */ + UINT16 ConfVolt; + + CM_OBJECT_TOKEN MemoryDeviceInfoToken; + CM_OBJECT_TOKEN PhysicalArrayToken; + UINT16 DataWidth; + UINT16 TotalWidth; + UINT8 Rank; + + MEMORY_DEVICE_TYPE DeviceType; + MEMORY_DEVICE_TYPE_DETAIL TypeDetail; + MEMORY_DEVICE_TECHNOLOGY DeviceTechnology; + MEMORY_FORM_FACTOR FormFactor; + MEMORY_DEVICE_OPERATING_MODE_CAPABILITY MemoryOperatingModeCapability= ; + UINT16 MemoryErrorInformationHandle; +} CM_SMBIOS_MEMORY_DEVICE_INFO; + +typedef struct { + CM_OBJECT_TOKEN CmObjToken; + SMBIOS_TABLE_GENERATOR_ID GeneratorId; +} CONTAINED_CM_OBJECTS; + #pragma pack() =20 #endif // SMBIOS_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Ge= nerator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Gen= erator.c new file mode 100644 index 0000000000..2e8bda2aca --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator= .c @@ -0,0 +1,491 @@ +/** @file + SMBIOS Type17 Table Generator. + + Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#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, + ESmbiosObjMemoryDeviceInfo, + CM_SMBIOS_MEMORY_DEVICE_INFO + ) + +#define EXTENDED_SIZE_THRESHOLD (0x7FFF00000LL) +#define SIZE_GRANULARITY_THRESHOLD (0x100000L) +#define SIZE_GRANULARITY_BITMASK (0x8000) +#define EXTENDED_SPEED_THRESHOLD (0xFFFF) +#define SMBIOS_TYPE17_MAX_STRINGS (7) +#define RANK_MASK (0x7) + +STATIC +EFI_STATUS +FreeSmbiosType17TableEx ( + 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; +} + +STATIC +VOID +AddPhysArrHandle ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_OBJECT_TOKEN CmObjToken, + OUT SMBIOS_TABLE_TYPE17 *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; +} + +STATIC +VOID +UpdateSmbiosType17Size ( + IN UINT64 Size, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Size < SIZE_GRANULARITY_THRESHOLD) { + SmbiosRecord->Size =3D Size / SIZE_1KB; + SmbiosRecord->Size |=3D SIZE_GRANULARITY_BITMASK; + } else if (Size >=3D EXTENDED_SIZE_THRESHOLD) { + SmbiosRecord->Size =3D 0x7FFF; + SmbiosRecord->ExtendedSize =3D (Size / SIZE_1MB); + } else { + SmbiosRecord->Size =3D (Size / SIZE_1MB); + } +} + +STATIC +VOID +UpdateSmbiosType17Speed ( + IN UINT32 Speed, + IN UINT32 ConfiguredMemoryClockSpeed, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Speed > -EXTENDED_SPEED_THRESHOLD) { + SmbiosRecord->Speed =3D EXTENDED_SPEED_THRESHO= LD; + SmbiosRecord->ExtendedSpeed =3D Speed; + SmbiosRecord->ConfiguredMemoryClockSpeed =3D EXTENDED_SPEED_THRESHO= LD; + SmbiosRecord->ExtendedConfiguredMemorySpeed =3D ConfiguredMemoryClockS= peed; + } else { + SmbiosRecord->Speed =3D Speed; + SmbiosRecord->ConfiguredMemoryClockSpeed =3D ConfiguredMemoryClockSpee= d; + } +} + +STATIC +VOID +UpdateSmbiosType17Rank ( + IN UINT8 Rank, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Rank > RANK_MASK) { + SmbiosRecord->Attributes =3D 0; + } else { + SmbiosRecord->Attributes |=3D (Rank & RANK_MASK); + } +} + +/** Construct SMBIOS Type17 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. + + @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 +BuildSmbiosType17TableEx ( + 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 NumMemDevices; + SMBIOS_STRUCTURE **TableList; + CM_OBJECT_TOKEN *CmObjectList; + CM_SMBIOS_MEMORY_DEVICE_INFO *MemoryDevicesInfo; + UINTN Index; + UINT8 SerialNumRef; + UINT8 AssetTagRef; + UINT8 DeviceLocatorRef; + UINT8 BankLocatorRef; + UINT8 FirmwareVersionRef; + UINT8 ManufacturerNameRef; + CHAR8 *ManufacturerName; + UINT8 PartNumRef; + CHAR8 *OptionalStrings; + SMBIOS_TABLE_TYPE17 *SmbiosRecord; + UINTN SmbiosRecordSize; + STRING_TABLE StrTable; + + 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 GetESmbiosObjMemoryDeviceInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &MemoryDevicesInfo, + &NumMemDevices + ); + 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 *) * NumMemDevices); + if (TableList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a:Failed to alloc memory for %u devices table\n", + __FUNCTION__, + NumMemDevices + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_= TOKEN *) * NumMemDevices); + if (CmObjectList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u CM Objects\n", + __FUNCTION__, + NumMemDevices + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + for (Index =3D 0; Index < NumMemDevices; Index++) { + StringTableInitialize (&StrTable, SMBIOS_TYPE17_MAX_STRINGS); + + SerialNumRef =3D 0; + AssetTagRef =3D 0; + DeviceLocatorRef =3D 0; + BankLocatorRef =3D 0; + FirmwareVersionRef =3D 0; + ManufacturerNameRef =3D 0; + PartNumRef =3D 0; + ManufacturerName =3D NULL; + + if (MemoryDevicesInfo[Index].DeviceLocator !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].DeviceLocator, + &DeviceLocatorRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add DeviceLocator String %r \n", S= tatus)); + } + } + + if (MemoryDevicesInfo[Index].BankLocator !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].BankLocator, + &BankLocatorRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to BankLocator String %r \n", Status)= ); + } + } + + if (MemoryDevicesInfo[Index].SerialNum !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].SerialNum, + &SerialNumRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add SerialNum String %r \n", Statu= s)); + } + } + + if (MemoryDevicesInfo[Index].AssetTag !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].AssetTag, + &AssetTagRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add Asset Tag String %r \n", Statu= s)); + } + } + + if (MemoryDevicesInfo[Index].FirmwareVersion !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].FirmwareVersion, + &FirmwareVersionRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add Firmware Version String %r \n"= , Status)); + } + } + + if (MemoryDevicesInfo[Index].PartNum !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].PartNum, + &PartNumRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to PartNum String %r \n", Status)); + } + } + + ManufacturerName =3D (CHAR8 *)Jep106GetManufacturerName ( + (MemoryDevicesInfo[Index].ModuleManufact= urerId >> 8) & 0xFF, + MemoryDevicesInfo[Index].ModuleManufactu= rerId & 0x7F + ); + if (ManufacturerName !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + ManufacturerName, + &ManufacturerNameRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add Manufacturer String %r \n", St= atus)); + } + } + + SmbiosRecordSize =3D sizeof (SMBIOS_TABLE_TYPE17) + + StringTableGetStringSetSize (&StrTable); + SmbiosRecord =3D (SMBIOS_TABLE_TYPE17 *)AllocateZeroPool (SmbiosRecord= Size); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + UpdateSmbiosType17Size (MemoryDevicesInfo[Index].Size, SmbiosRecord); + UpdateSmbiosType17Speed (MemoryDevicesInfo[Index].Speed, MemoryDevices= Info[Index].ConfiguredMemorySpeed, SmbiosRecord); + UpdateSmbiosType17Rank (MemoryDevicesInfo[Index].Rank, SmbiosRecord); + + SmbiosRecord->VolatileSize =3D MemoryDevicesInfo[Index].Size; + SmbiosRecord->DeviceSet =3D MemoryDevicesInfo[Index].Device= Set; + SmbiosRecord->ModuleManufacturerID =3D + MemoryDevicesInfo[Index].ModuleManufacturerId; + SmbiosRecord->ModuleProductID =3D + MemoryDevicesInfo[Index].ModuleProductId; + SmbiosRecord->DataWidth =3D MemoryDevicesInfo[Inde= x].DataWidth; + SmbiosRecord->TotalWidth =3D MemoryDevicesInfo[Inde= x].TotalWidth; + SmbiosRecord->MemoryType =3D MemoryDevicesInfo[Inde= x].DeviceType; + SmbiosRecord->FormFactor =3D MemoryDevicesInfo[Inde= x].FormFactor; + SmbiosRecord->MinimumVoltage =3D MemoryDevicesInfo[Inde= x].MinVolt; + SmbiosRecord->MaximumVoltage =3D MemoryDevicesInfo[Inde= x].MaxVolt; + SmbiosRecord->ConfiguredVoltage =3D MemoryDevicesInfo[Inde= x].ConfVolt; + SmbiosRecord->MemoryTechnology =3D MemoryDevicesInfo[Inde= x].DeviceTechnology; + SmbiosRecord->MemoryErrorInformationHandle =3D MemoryDevicesInfo[Inde= x].MemoryErrorInformationHandle; + SmbiosRecord->TypeDetail =3D MemoryDevicesInfo[Inde= x].TypeDetail; + SmbiosRecord->MemoryOperatingModeCapability =3D MemoryDevicesInfo[Inde= x].MemoryOperatingModeCapability; + // Is there a reference to a Physical Array Device. + if (MemoryDevicesInfo[Index].PhysicalArrayToken !=3D CM_NULL_TOKEN) { + AddPhysArrHandle ( + TableFactoryProtocol, + MemoryDevicesInfo[Index].PhysicalArrayToken, + SmbiosRecord + ); + } + + SmbiosRecord->DeviceLocator =3D DeviceLocatorRef; + SmbiosRecord->BankLocator =3D BankLocatorRef; + SmbiosRecord->AssetTag =3D AssetTagRef; + SmbiosRecord->SerialNumber =3D SerialNumRef; + SmbiosRecord->FirmwareVersion =3D FirmwareVersionRef; + SmbiosRecord->Manufacturer =3D ManufacturerNameRef; + SmbiosRecord->PartNumber =3D PartNumRef; + OptionalStrings =3D (CHAR8 *)(SmbiosRecord + 1); + // publish the string set + StringTablePublishStringSet ( + &StrTable, + OptionalStrings, + (SmbiosRecordSize - sizeof (SMBIOS_TABLE_TYPE17)) + ); + // setup the header + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_MEMORY_DEVICE; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE17); + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; + CmObjectList[Index] =3D MemoryDevicesInfo[Index].MemoryDeviceInfo= Token; + StringTableFree (&StrTable); + } + + *Table =3D TableList; + *CmObjectToken =3D CmObjectList; + *TableCount =3D NumMemDevices; +exit: + // free string table + return Status; +} + +/** The interface for the SMBIOS Type17 Table Generator. +*/ +STATIC +CONST +SMBIOS_TABLE_GENERATOR SmbiosType17Generator =3D { + // Generator ID + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType17), + // Generator Description + L"SMBIOS.TYPE17.GENERATOR", + // SMBIOS Table Type + EFI_SMBIOS_TYPE_MEMORY_DEVICE, + NULL, + NULL, + // Build table function Extended. + BuildSmbiosType17TableEx, + // Free function Extended. + FreeSmbiosType17TableEx +}; + +/** 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 +SmbiosType17LibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterSmbiosTableGenerator (&SmbiosType17Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type 17: 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 +SmbiosType17LibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType17Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type17: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Li= b.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf new file mode 100644 index 0000000000..ea8a3310d6 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf @@ -0,0 +1,37 @@ +## @file +# SMBIOS Type17 Table Generator +# +# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbiosType17LibArm + FILE_GUID =3D 1f063bac-f8f1-4e08-8ffd-9aae52c75497 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D SmbiosType17LibConstructor + DESTRUCTOR =3D SmbiosType17LibDestructor + +[Sources] + SmbiosType17Generator.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 + JedecJep106Lib --=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 (#121096): https://edk2.groups.io/g/devel/message/121096 Mute This Topic: https://groups.io/mt/111022016/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-