public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Girish Mahadevan via groups.io" <gmahadevan=nvidia.com@groups.io>
To: <sami.mujawar@arm.com>, <Alexei.Fedorov@arm.com>,
	<pierre.gondois@arm.com>, <abner.chang@amd.com>,
	<Samer.El-Haj-Mahmoud@arm.com>, <Jose.Marinho@arm.com>
Cc: <gmahadevan@nvidia.com>, <jbrasen@nvidia.com>,
	<ashishsingha@nvidia.com>, <nramirez@nvidia.com>,
	<devel@edk2.groups.io>
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	[thread overview]
Message-ID: <ff8a4869dc4ac7bec0a85b56dec520904a81b34e.1738793024.git.gmahadevan@nvidia.com> (raw)
In-Reply-To: <cover.1738793024.git.gmahadevan@nvidia.com>

Add the Generator library for SMBIOS Table Type 17 - Memory
Device.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Include/SmbiosNameSpaceObjects.h          |  95 ++++
 .../SmbiosType17Lib/SmbiosType17Generator.c   | 491 ++++++++++++++++++
 .../SmbiosType17Lib/SmbiosType17Lib.inf       |  37 ++
 3 files changed, 623 insertions(+)
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf

diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTablesPkg/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_

 

+#include <IndustryStandard/SmBios.h>

+

 #pragma pack(1)

 

 typedef enum SmbiosObjectID {

@@ -37,6 +39,99 @@ typedef enum SmbiosObjectID {
   ESmbiosObjMax

 } ESMBIOS_OBJECT_ID;

 

+/** 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()

 

 #endif // SMBIOS_NAMESPACE_OBJECTS_H_

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.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.<BR>

+  Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <Library/BaseLib.h>

+#include <Library/BaseMemoryLib.h>

+#include <Library/DebugLib.h>

+#include <Library/PrintLib.h>

+#include <Library/MemoryAllocationLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/SmbiosStringTableLib.h>

+#include <Library/JedecJep106Lib.h>

+

+// Module specific include files.

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include <Protocol/Smbios.h>

+#include <IndustryStandard/SmBios.h>

+

+/** 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  TableFactoryProtocol,

+  IN      CONST CM_STD_OBJ_SMBIOS_TABLE_INFO             *CONST  SmbiosTableInfo,

+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL     *CONST  CfgMgrProtocol,

+  IN      SMBIOS_STRUCTURE                             ***CONST  Table,

+  IN      CM_OBJECT_TOKEN                                        **CmObjectToken,

+  IN      CONST UINTN                                            TableCount

+  )

+{

+  UINTN             Index;

+  SMBIOS_STRUCTURE  **TableList;

+

+  TableList = *Table;

+  for (Index = 0; Index < TableCount; Index++) {

+    if (TableList[Index] != NULL) {

+      FreePool (TableList[Index]);

+    }

+  }

+

+  if (*CmObjectToken != NULL) {

+    FreePool (*CmObjectToken);

+  }

+

+  if (TableList != NULL) {

+    FreePool (TableList);

+  }

+

+  return EFI_SUCCESS;

+}

+

+STATIC

+VOID

+AddPhysArrHandle (

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN  CM_OBJECT_TOKEN                                      CmObjToken,

+  OUT SMBIOS_TABLE_TYPE17                                  *SmbiosRecord

+  )

+{

+  EFI_SMBIOS_HANDLE  PhysMemArrHandle;

+  SMBIOS_HANDLE_MAP  *HandleMap;

+

+  HandleMap = TableFactoryProtocol->GetSmbiosHandle (CmObjToken);

+  if (HandleMap == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__));

+    PhysMemArrHandle = 0;

+  } else {

+    PhysMemArrHandle = HandleMap->SmbiosTblHandle;

+  }

+

+  SmbiosRecord->MemoryArrayHandle = PhysMemArrHandle;

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Size (

+  IN  UINT64               Size,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Size < SIZE_GRANULARITY_THRESHOLD) {

+    SmbiosRecord->Size  = Size / SIZE_1KB;

+    SmbiosRecord->Size |= SIZE_GRANULARITY_BITMASK;

+  } else if (Size >= EXTENDED_SIZE_THRESHOLD) {

+    SmbiosRecord->Size         = 0x7FFF;

+    SmbiosRecord->ExtendedSize = (Size / SIZE_1MB);

+  } else {

+    SmbiosRecord->Size = (Size / SIZE_1MB);

+  }

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Speed (

+  IN  UINT32               Speed,

+  IN  UINT32               ConfiguredMemoryClockSpeed,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Speed > -EXTENDED_SPEED_THRESHOLD) {

+    SmbiosRecord->Speed                         = EXTENDED_SPEED_THRESHOLD;

+    SmbiosRecord->ExtendedSpeed                 = Speed;

+    SmbiosRecord->ConfiguredMemoryClockSpeed    = EXTENDED_SPEED_THRESHOLD;

+    SmbiosRecord->ExtendedConfiguredMemorySpeed = ConfiguredMemoryClockSpeed;

+  } else {

+    SmbiosRecord->Speed                      = Speed;

+    SmbiosRecord->ConfiguredMemoryClockSpeed = ConfiguredMemoryClockSpeed;

+  }

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Rank (

+  IN  UINT8                Rank,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Rank > RANK_MASK) {

+    SmbiosRecord->Attributes = 0;

+  } else {

+    SmbiosRecord->Attributes |= (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  TableFactoryProtocol,

+  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 != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (Table != NULL);

+  ASSERT (TableCount != NULL);

+  ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID);

+

+  if ((This == NULL) || (SmbiosTableInfo == NULL) || (CfgMgrProtocol == NULL) ||

+      (Table == NULL) || (TableCount == NULL) ||

+      (SmbiosTableInfo->TableGeneratorId != This->GeneratorID))

+  {

+    DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__));

+    return EFI_INVALID_PARAMETER;

+  }

+

+  *Table = NULL;

+  Status = 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 = (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRUCTURE *) * NumMemDevices);

+  if (TableList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a:Failed to alloc memory for %u devices table\n",

+      __FUNCTION__,

+      NumMemDevices

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exit;

+  }

+

+  CmObjectList = (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_TOKEN *) * NumMemDevices);

+  if (CmObjectList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u CM Objects\n",

+      __FUNCTION__,

+      NumMemDevices

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exit;

+  }

+

+  for (Index = 0; Index < NumMemDevices; Index++) {

+    StringTableInitialize (&StrTable, SMBIOS_TYPE17_MAX_STRINGS);

+

+    SerialNumRef       = 0;

+    AssetTagRef        = 0;

+    DeviceLocatorRef   = 0;

+    BankLocatorRef     = 0;

+    FirmwareVersionRef = 0;

+    ManufacturerNameRef = 0;

+    PartNumRef          = 0;

+    ManufacturerName    = NULL;

+

+    if (MemoryDevicesInfo[Index].DeviceLocator != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].DeviceLocator,

+                 &DeviceLocatorRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add DeviceLocator String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].BankLocator != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].BankLocator,

+                 &BankLocatorRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to BankLocator String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].SerialNum != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].SerialNum,

+                 &SerialNumRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add SerialNum String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].AssetTag != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].AssetTag,

+                 &AssetTagRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add Asset Tag String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].FirmwareVersion != NULL) {

+      Status = 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 != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].PartNum,

+                 &PartNumRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to PartNum String %r \n", Status));

+      }

+    }

+

+    ManufacturerName = (CHAR8 *)Jep106GetManufacturerName (

+                                  (MemoryDevicesInfo[Index].ModuleManufacturerId >> 8) & 0xFF,

+                                  MemoryDevicesInfo[Index].ModuleManufacturerId & 0x7F

+                                  );

+    if (ManufacturerName != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 ManufacturerName,

+                 &ManufacturerNameRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add Manufacturer String %r \n", Status));

+      }

+    }

+

+    SmbiosRecordSize = sizeof (SMBIOS_TABLE_TYPE17) +

+                       StringTableGetStringSetSize (&StrTable);

+    SmbiosRecord = (SMBIOS_TABLE_TYPE17 *)AllocateZeroPool (SmbiosRecordSize);

+    if (SmbiosRecord == NULL) {

+      Status = EFI_OUT_OF_RESOURCES;

+      goto exit;

+    }

+

+    UpdateSmbiosType17Size (MemoryDevicesInfo[Index].Size, SmbiosRecord);

+    UpdateSmbiosType17Speed (MemoryDevicesInfo[Index].Speed, MemoryDevicesInfo[Index].ConfiguredMemorySpeed, SmbiosRecord);

+    UpdateSmbiosType17Rank (MemoryDevicesInfo[Index].Rank, SmbiosRecord);

+

+    SmbiosRecord->VolatileSize         = MemoryDevicesInfo[Index].Size;

+    SmbiosRecord->DeviceSet            = MemoryDevicesInfo[Index].DeviceSet;

+    SmbiosRecord->ModuleManufacturerID =

+      MemoryDevicesInfo[Index].ModuleManufacturerId;

+    SmbiosRecord->ModuleProductID =

+      MemoryDevicesInfo[Index].ModuleProductId;

+    SmbiosRecord->DataWidth                     = MemoryDevicesInfo[Index].DataWidth;

+    SmbiosRecord->TotalWidth                    = MemoryDevicesInfo[Index].TotalWidth;

+    SmbiosRecord->MemoryType                    = MemoryDevicesInfo[Index].DeviceType;

+    SmbiosRecord->FormFactor                    = MemoryDevicesInfo[Index].FormFactor;

+    SmbiosRecord->MinimumVoltage                = MemoryDevicesInfo[Index].MinVolt;

+    SmbiosRecord->MaximumVoltage                = MemoryDevicesInfo[Index].MaxVolt;

+    SmbiosRecord->ConfiguredVoltage             = MemoryDevicesInfo[Index].ConfVolt;

+    SmbiosRecord->MemoryTechnology              = MemoryDevicesInfo[Index].DeviceTechnology;

+    SmbiosRecord->MemoryErrorInformationHandle  = MemoryDevicesInfo[Index].MemoryErrorInformationHandle;

+    SmbiosRecord->TypeDetail                    = MemoryDevicesInfo[Index].TypeDetail;

+    SmbiosRecord->MemoryOperatingModeCapability = MemoryDevicesInfo[Index].MemoryOperatingModeCapability;

+    // Is there a reference to a Physical Array Device.

+    if (MemoryDevicesInfo[Index].PhysicalArrayToken != CM_NULL_TOKEN) {

+      AddPhysArrHandle (

+        TableFactoryProtocol,

+        MemoryDevicesInfo[Index].PhysicalArrayToken,

+        SmbiosRecord

+        );

+    }

+

+    SmbiosRecord->DeviceLocator   = DeviceLocatorRef;

+    SmbiosRecord->BankLocator     = BankLocatorRef;

+    SmbiosRecord->AssetTag        = AssetTagRef;

+    SmbiosRecord->SerialNumber    = SerialNumRef;

+    SmbiosRecord->FirmwareVersion = FirmwareVersionRef;

+    SmbiosRecord->Manufacturer    = ManufacturerNameRef;

+    SmbiosRecord->PartNumber      = PartNumRef;

+    OptionalStrings               = (CHAR8 *)(SmbiosRecord + 1);

+    // publish the string set

+    StringTablePublishStringSet (

+      &StrTable,

+      OptionalStrings,

+      (SmbiosRecordSize - sizeof (SMBIOS_TABLE_TYPE17))

+      );

+    // setup the header

+    SmbiosRecord->Hdr.Type   = EFI_SMBIOS_TYPE_MEMORY_DEVICE;

+    SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE17);

+    TableList[Index]         = (SMBIOS_STRUCTURE *)SmbiosRecord;

+    CmObjectList[Index]      = MemoryDevicesInfo[Index].MemoryDeviceInfoToken;

+    StringTableFree (&StrTable);

+  }

+

+  *Table         = TableList;

+  *CmObjectToken = CmObjectList;

+  *TableCount    = NumMemDevices;

+exit:

+  // free string table

+  return Status;

+}

+

+/** The interface for the SMBIOS Type17 Table Generator.

+*/

+STATIC

+CONST

+SMBIOS_TABLE_GENERATOR  SmbiosType17Generator = {

+  // 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 = RegisterSmbiosTableGenerator (&SmbiosType17Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type 17: Register Generator. Status = %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 = DeregisterSmbiosTableGenerator (&SmbiosType17Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type17: Deregister Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.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.<BR>

+#  Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION    = 0x0001001B

+  BASE_NAME      = SmbiosType17LibArm

+  FILE_GUID      = 1f063bac-f8f1-4e08-8ffd-9aae52c75497

+  VERSION_STRING = 1.0

+  MODULE_TYPE    = DXE_DRIVER

+  LIBRARY_CLASS  = NULL|DXE_DRIVER

+  CONSTRUCTOR    = SmbiosType17LibConstructor

+  DESTRUCTOR     = 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

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2025-02-05 22:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
2025-02-05 22:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 02/12] DynamicTablesPkg: Define a SMBIOS Structure/Table type Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 03/12] DynamicTablesPkg: Add SMBIOS table dispatcher Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 04/12] DynamicTablesPkg: Add extern call to build SMBIOS table Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 05/12] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 06/12] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 07/12] DynamicTablesPkg: Add SMBIOS table generation Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 09/12] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects Girish Mahadevan via groups.io
2025-02-05 22:09 ` Girish Mahadevan via groups.io [this message]
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 11/12] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19) Girish Mahadevan via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff8a4869dc4ac7bec0a85b56dec520904a81b34e.1738793024.git.gmahadevan@nvidia.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox