From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web11.39889.1661535509147066052 for ; Fri, 26 Aug 2022 10:38:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=LhYRqnO3; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.236.41, mailfrom: gmahadevan@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZliTXh9bz/8avvME3DSml/ehiW7Pu2ea8YbvYrdjc3nYDNt/q0kubEIVouqpExw8QzaXZOuJQgYNDbLrwqzqXq99VoYZoG+f1TS7Kqr2tx7Ga/nq0cRTeow8vDaEaIYv0FnLsDdC97x5JdftdlF43IPpcxnRrhMSTPoZNEKNZ82YQLX2MulNgz+mdwk8p0qNkfTjy1qeST5jWqDsNlcVww4OjBwG4CTRTJ6bsPVNqbjmI9rz6brqrDek99aChHNTIX8Rn8z6Crw0dYfrnEZA9l3oFWQCbNhxbam+TiNHYALB0UHa7DI9Id0p54l9hBYw+7wxCoPl+AdE39cZovbeCw== 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=RuuwipdUFhGiv/oFHP1dy3z9V1lwRhPog3P3gHLG0Ho=; b=Wz/94gDdbiAB1tPgGVYlHVW1FtyrAbe9NcFwgKQlZ+6Kuv7PpRoR5QOeEMvLZq5jVJh3M+XG33wtIa125ql3qvRJHQ3Ci4TJhH63p1t65qH9lKhQb4pH0GgomZsCL84HXNnttiZaxrDUjklfVtuU2xesSlmdhqi018W9fHdLEGBliBdtMFDc6FWIrttO428ai80Avk3va2TKbevxfaKr75nc7gkw9Uu1FIDERw8pLjMTtjs6haLLdD8EavUSRCIuoGqB4z1bBWCrNrP/ohuTggwUSzrsTNmb8EbI7jZr208jaE/Q0iTqfcHkmSDZr2Nu38GZ8N/PrLtz1MsPEwf4PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=arm.com 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RuuwipdUFhGiv/oFHP1dy3z9V1lwRhPog3P3gHLG0Ho=; b=LhYRqnO3X/un+2+KU1m96B9VfuUhsmIgpKdOWadgydGzs66P6zxc7Pq0/lYRMp26vFtxEiVZMa7bZ24jp22TjYtcNP7k7vykBaHedRI9gjY+gRM78UVZy7NXPLCbpezx0T0cArf8jjjkv0kdyfOLhfK4s9TJTnM2n0BzZGUNww3TWDH4QXy81sapGsBCLHaSjG9j3oRcKWxPYVEuayRZemKJ/QjtNPy3vkOOn5yK5XDiHaLpcijAHYJxJ6gX3bqh6m1+0xGt1HGYf4w9ZMrgqXQhnAqRikmCY/GcGYaiXc2KZEJ92lS3J/nlMzW7BmI+GAA2BnWT/kaiaOrsM7PeIQ== Received: from DM6PR11CA0056.namprd11.prod.outlook.com (2603:10b6:5:14c::33) by DS7PR12MB5959.namprd12.prod.outlook.com (2603:10b6:8:7e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.16; Fri, 26 Aug 2022 17:38:24 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::26) by DM6PR11CA0056.outlook.office365.com (2603:10b6:5:14c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14 via Frontend Transport; Fri, 26 Aug 2022 17:38:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5566.15 via Frontend Transport; Fri, 26 Aug 2022 17:38:23 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Fri, 26 Aug 2022 17:38:23 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Fri, 26 Aug 2022 10:38:22 -0700 Received: from gmahadevan-PRIME-X299-A-II.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Fri, 26 Aug 2022 10:38:22 -0700 From: "Girish Mahadevan" To: , Sami Mujawar , "Alexei Fedorov" CC: Samer El-Haj-Mahmoud , Jeff Brasen , Ashish Singhal , Akanksha Jain , Matteo Carlini , "Hemendra Dassanayake" , Nick Ramirez , William Watson , Girish Mahadevan Subject: [PATCH 2/2] DynamicTablesPkg: Add Smbios Type17 Table generator Date: Fri, 26 Aug 2022 11:37:49 -0600 Message-ID: <90bcdad9b53f1ca184a857da720aac1ab89882f7.1661534045.git.gmahadevan@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-NVConfidentiality: public Return-Path: gmahadevan@nvidia.com MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d422785d-cbd4-44f9-c5af-08da8789c6b4 X-MS-TrafficTypeDiagnostic: DS7PR12MB5959:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eqkmTMuzzX/lL1DanYEcHYDJgharHEtxwcgOBlfzD6B0eqbXRtqHIIl2ToQJ7ilCxD19u647/L0HYiDSs1D0ByhwmfM0RGB6Yi80bXPq2zUJ9hSbkx6Y6VKTY2Fn/i0d6sWLRJrDTenWU9g9vvJXijk2VFaa0v509Mt3WNJIxM+Z4rnBq16O+1QMpCe5IGTusX+WHCC1MurGE6isGwYXzWXaVQloUcuptbzt9jOIr5fSf4WAXnao0+YiUcrUV6plNhyibVeybdRsPR8s/MuX8OGYWXiwPulxMfgMDAmKghQCfvh9WNBOMCV0TFr381ytZ+CxEwoiM74tgBHF98PmCwlK4OVc6eS1uOqUncnAtKMvP0Y5LfkhOxjRO+4yl4+e6aefWiY7JkijXjAf5Vmj1kTmnTLuMETciT+SZaQYFY3yTMVzLvqGa3Sgg33VVt7nMC5keUBl/ILu6O6uEbD9GBwcKrstxPODLqEO+0Tdd4w7uzgImbPGiZ8VANqDOizp1XouYYEhFOgstJmzielXf+xoiIpMaiY2LsrgjDbgaAWjCBWYpH+APQ91Bx//ci2hS7/T7glt0tCBx9+emKA5oRE1W74UNMcN9j/2m2JWRcpQpWlu48KfmBOfsPC1pWikmhZ8zHZbm1Nu1FNfXOEwmARw1svCl5E7MzMvGKTRTsML4/Iyc4BP1UQMR8i7+BzM6lCBAhcGrueHx9S/+yRCPjmAnpM39MlkLDwITrjGNxOomvyCJLlT+9usrprRYKkZud/f1fKYSwlKi5YHXme8KZRtT0JjY5fvet+mBl2X9zY+NiyDMWGdu+xsh0L3WVoE X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(136003)(376002)(39860400002)(40470700004)(36840700001)(46966006)(316002)(19627235002)(70586007)(8676002)(4326008)(54906003)(110136005)(70206006)(36756003)(41300700001)(5660300002)(478600001)(86362001)(8936002)(356005)(81166007)(82310400005)(26005)(186003)(7696005)(2906002)(6666004)(107886003)(82740400003)(336012)(40480700001)(40460700003)(36860700001)(47076005)(30864003)(83380400001)(426003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 17:38:23.8633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d422785d-cbd4-44f9-c5af-08da8789c6b4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5959 Content-Type: text/plain Add a new CM object to describe memory devices and setup a new Generator Library for SMBIOS Type17 table. Signed-off-by: Girish Mahadevan --- .../Include/ArmNameSpaceObjects.h | 59 +++ .../SmbiosType17Lib/SmbiosType17Generator.c | 338 ++++++++++++++++++ .../SmbiosType17Lib/SmbiosType17LibArm.inf | 32 ++ 3 files changed, 429 insertions(+) create mode 100644 DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17LibArm.inf diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h index 102e0f96be..199a19e997 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -63,6 +63,7 @@ typedef enum ArmObjectID { EArmObjPciInterruptMapInfo, ///< 39 - Pci Interrupt Map Info EArmObjRmr, ///< 40 - Reserved Memory Range Node EArmObjMemoryRangeDescriptor, ///< 41 - Memory Range Descriptor + EArmObjMemoryDeviceInfo, ///< 42 - Memory Device Information EArmObjMax } EARM_OBJECT_ID; @@ -1070,6 +1071,64 @@ typedef struct CmArmRmrDescriptor { UINT64 Length; } CM_ARM_MEMORY_RANGE_DESCRIPTOR; +/** 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: EArmObjMemoryDeviceInfo, +*/ +typedef struct CmArmMemoryDeviceInfo { + /** 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; + + /** 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; + + /** 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; + + /** Device Attributes */ + UINT8 Attributes; + + /** Device Configured Voltage in millivolts */ + UINT16 ConfiguredVoltage; +} CM_ARM_MEMORY_DEVICE_INFO; + #pragma pack() #endif // ARM_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17Generator.c b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17Generator.c new file mode 100644 index 0000000000..5683ca570f --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17Generator.c @@ -0,0 +1,338 @@ +/** @file + SMBIOS Type17 Table Generator. + + Copyright (c) 2022, 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 + +// Module specific include files. +#include +#include +#include +#include +#include + +/** This macro expands to a function that retrieves the Memory Device + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjMemoryDeviceInfo, + CM_ARM_MEMORY_DEVICE_INFO + ) + +// Default Values for Memory Device +STATIC SMBIOS_TABLE_TYPE17 MemDeviceInfoTemplate = { + { // Hdr + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type + sizeof (SMBIOS_TABLE_TYPE17), // Length + 0 // Handle + }, + 0, // MemoryArrayHandle + 0, // MemoryErrorInformationHandle + 0xFFFF, // TotalWidth + 0xFFFF, // DataWIdth + 0x7FFF, // Size (always use Extended Size) + MemoryTypeUnknown, // FormFactor + 0xFF, // DeviceSet + 1, // Device Locator + 2, // Bank Locator + MemoryTypeSdram, // MemoryType + { // TypeDetail + 0 + }, + 0xFFFF, // Speed (Use Extended Speed) + 0, // Manufacturer + // (Unused Use ModuleManufactuerId) + 3, // SerialNumber + 4, // AssetTag + 0, // PartNumber + // (Unused Use ModuleProductId) + 0, // Attributes + 0, // ExtendedSize + 2000, // ConfiguredMemoryClockSpeed + 0, // MinimumVoltage + 0, // MaximumVoltage + 0, // ConfiguredVoltage + MemoryTechnologyDram, // MemoryTechnology + { // MemoryOperatingModeCapability + .Uint16 = 0x000 + }, + 5, // FirmwareVersion + 0, // ModuleManufacturerId + 0, // ModuleProductId + 0, // MemorySubsystemContollerManufacturerId + 0, // MemorySybsystemControllerProductId + 0, // NonVolatileSize + 0, // VolatileSize + 0, // CacheSize + 0, // LogicalSize + 0, // ExtendedSpeed + 0, // ExtendedConfiguredMemorySpeed +}; + +STATIC CHAR8 UnknownStr[] = "Unknown\0"; + +STATIC +EFI_STATUS +EFIAPI +FreeSmbiosType17TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN OUT SMBIOS_STRUCTURE ***CONST Table, + IN CONST UINTN TableCount + ) +{ + return EFI_SUCCESS; +} + +/** 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 +EFIAPI +BuildSmbiosType17TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *This, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT SMBIOS_STRUCTURE ***Table, + OUT UINTN *CONST TableCount + ) +{ + EFI_STATUS Status; + UINT32 NumMemDevices; + SMBIOS_STRUCTURE **TableList; + CM_ARM_MEMORY_DEVICE_INFO *MemoryDevicesInfo; + UINTN Index; + UINTN SerialNumLen; + CHAR8 *SerialNum; + UINTN AssetTagLen; + CHAR8 *AssetTag; + UINTN DeviceLocatorLen; + CHAR8 *DeviceLocator; + UINTN BankLocatorLen; + CHAR8 *BankLocator; + UINTN FirmwareVersionLen; + CHAR8 *FirmwareVersion; + CHAR8 *OptionalStrings; + SMBIOS_TABLE_TYPE17 *SmbiosRecord; + + ASSERT (This != NULL); + ASSERT (SmbiosTableInfo != NULL); + ASSERT (CfgMgrProtocol != NULL); + ASSERT (Table != NULL); + ASSERT (TableCount != NULL); + ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID); + + DEBUG ((DEBUG_ERROR, "%a : Start \n", __FUNCTION__)); + *Table = NULL; + Status = GetEArmObjMemoryDeviceInfo ( + 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, "Failed to alloc memory for %u devices table\n")); + Status = EFI_OUT_OF_RESOURCES; + goto exit; + } + + for (Index = 0; Index < NumMemDevices; Index++) { + if (MemoryDevicesInfo[Index].SerialNum != NULL) { + SerialNumLen = AsciiStrLen (MemoryDevicesInfo[Index].SerialNum); + SerialNum = MemoryDevicesInfo[Index].SerialNum; + } else { + SerialNumLen = AsciiStrLen (UnknownStr); + SerialNum = UnknownStr; + } + + if (MemoryDevicesInfo[Index].AssetTag != NULL) { + AssetTagLen = AsciiStrLen (MemoryDevicesInfo[Index].AssetTag); + AssetTag = MemoryDevicesInfo[Index].AssetTag; + } else { + AssetTagLen = AsciiStrLen (UnknownStr); + AssetTag = UnknownStr; + } + + if (MemoryDevicesInfo[Index].DeviceLocator != NULL) { + DeviceLocatorLen = AsciiStrLen (MemoryDevicesInfo[Index].DeviceLocator); + DeviceLocator = MemoryDevicesInfo[Index].DeviceLocator; + } else { + DeviceLocatorLen = AsciiStrLen (UnknownStr); + DeviceLocator = UnknownStr; + } + + if (MemoryDevicesInfo[Index].BankLocator != NULL) { + BankLocatorLen = AsciiStrLen (MemoryDevicesInfo[Index].BankLocator); + BankLocator = MemoryDevicesInfo[Index].BankLocator; + } else { + BankLocatorLen = AsciiStrLen (UnknownStr); + BankLocator = UnknownStr; + } + + if (MemoryDevicesInfo[Index].FirmwareVersion != NULL) { + FirmwareVersionLen = AsciiStrLen (MemoryDevicesInfo[Index].FirmwareVersion); + FirmwareVersion = MemoryDevicesInfo[Index].FirmwareVersion; + } else { + FirmwareVersionLen = AsciiStrLen (UnknownStr); + FirmwareVersion = UnknownStr; + } + + SmbiosRecord = (SMBIOS_TABLE_TYPE17 *)AllocateZeroPool ( + sizeof (SMBIOS_TABLE_TYPE17) + + SerialNumLen + 1 + + AssetTagLen + 1 + DeviceLocatorLen + 1 + + BankLocatorLen + 1 + FirmwareVersionLen + 1 + 1 + ); + if (SmbiosRecord == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto exit; + } + + CopyMem (SmbiosRecord, &MemDeviceInfoTemplate, sizeof (SMBIOS_TABLE_TYPE17)); + SmbiosRecord->ExtendedSize = MemoryDevicesInfo[Index].Size; + SmbiosRecord->DeviceSet = MemoryDevicesInfo[Index].DeviceSet; + SmbiosRecord->ModuleManufacturerID = + MemoryDevicesInfo[Index].ModuleManufacturerId; + SmbiosRecord->ModuleProductID = + MemoryDevicesInfo[Index].ModuleProductId; + SmbiosRecord->Attributes = + MemoryDevicesInfo[Index].Attributes; + SmbiosRecord->ExtendedSpeed = MemoryDevicesInfo[Index].Speed; + OptionalStrings = (CHAR8 *)(SmbiosRecord + 1); + AsciiSPrint (OptionalStrings, DeviceLocatorLen + 1, DeviceLocator); + OptionalStrings = OptionalStrings + DeviceLocatorLen + 1; + AsciiSPrint (OptionalStrings, BankLocatorLen + 1, BankLocator); + OptionalStrings = OptionalStrings + BankLocatorLen + 1; + AsciiSPrint (OptionalStrings, SerialNumLen + 1, SerialNum); + OptionalStrings = OptionalStrings + SerialNumLen + 1; + AsciiSPrint (OptionalStrings, AssetTagLen + 1, AssetTag); + OptionalStrings = OptionalStrings + AssetTagLen + 1; + AsciiSPrint (OptionalStrings, FirmwareVersionLen + 1, FirmwareVersion); + OptionalStrings = OptionalStrings + FirmwareVersionLen + 1; + TableList[Index] = (SMBIOS_STRUCTURE *)SmbiosRecord; + } + + *Table = TableList; + *TableCount = NumMemDevices; + +exit: + DEBUG ((DEBUG_ERROR, "%a : Done \n", __FUNCTION__)); + 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/Arm/SmbiosType17Lib/SmbiosType17LibArm.inf b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17LibArm.inf new file mode 100644 index 0000000000..78a80b75f0 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/Arm/SmbiosType17Lib/SmbiosType17LibArm.inf @@ -0,0 +1,32 @@ +## @file +# SMBIOS Type17 Table Generator +# +# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2019 - 2021, Arm Limited. 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 + +[LibraryClasses] + BaseLib + DebugLib -- 2.17.1