From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5DC8C74003A for ; Thu, 24 Aug 2023 19:36:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=IS8wuXRtT9XNWGjCyWILlO9VDtR1oFCGnp7yeJNUmHo=; c=relaxed/simple; d=groups.io; h=Received-SPF:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:Authentication-Results-Original:nodisclaimer:MIME-Version:Original-Authentication-Results:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1692905812; v=1; b=Jpdw9yhxsfKI8FMdbYsPCXFLkanwhqcYQ9lHwwPySsX2A1aKzVfD482WqT3rjlgV6xEu9YCC BljCfVokN9G2J74txgIOyxwBikZ0WcF5VgUsF3BrFH39e5Nl0x1J6OrkIp+/nQVGv3Me5GW7SH+ +811cvx8PlDT/jEgtQ3tJa7I= X-Received: by 127.0.0.2 with SMTP id sbWIYY7687511xBrucB5Xcbl; Thu, 24 Aug 2023 12:36:52 -0700 X-Received: from EUR02-VI1-obe.outbound.protection.outlook.com (EUR02-VI1-obe.outbound.protection.outlook.com [40.107.241.82]) by mx.groups.io with SMTP id smtpd.web11.782.1692905811578597995 for ; Thu, 24 Aug 2023 12:36:52 -0700 X-Received: from DU2PR04CA0152.eurprd04.prod.outlook.com (2603:10a6:10:2b0::7) by AS8PR08MB6021.eurprd08.prod.outlook.com (2603:10a6:20b:23c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 19:36:44 +0000 X-Received: from DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b0:cafe::d3) by DU2PR04CA0152.outlook.office365.com (2603:10a6:10:2b0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Thu, 24 Aug 2023 19:36:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT028.mail.protection.outlook.com (100.127.142.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 19:36:44 +0000 X-Received: ("Tessian outbound 5c548696a0e7:v175"); Thu, 24 Aug 2023 19:36:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 562b85677e08bc6e X-CR-MTA-TID: 64aa7808 X-Received: from b24326212d1a.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5491F657-B465-4DF4-8DE9-2AD271D5050D.1; Thu, 24 Aug 2023 19:36:33 +0000 X-Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b24326212d1a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 24 Aug 2023 19:36:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELo5tp9oJcSWMIYgrYVgfSPfggwC/leCiZDOdPcQWf40YYU4Juh3B922nCtW+tMnjXd517XaTvc9xTexZ/17V+UrnQNwd+KF6vhE/fwgs+c7cdWi8aPxYnnuPh6RPqA4tz0X0C4iW7IncLz6iQSOrygHayZQmjraWJBNAxQucWRNeWKMLBu3CbCEx8IttZ5ksdI62000mvko9WvNCkfPRite0U1gfuW9MQ+loZ9rscu10NTOPp04XyTs8DNdo+VcblJCD8k8BSt4LD0qQH6I9vwVFJTr5x129v0XqhXiH3MeXUTSdjZCLuzQHKnmZqd+7Ddaui+/h7xzH+cxqmuUAw== 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=znGiY5coECYEEPZ7+B5hcL70l7EJtS8JxpoOyLeIS/k=; b=JQovR4c9i88h42AVltGrIaDzTwewNeNtl959EK4EBujUt0sh8bGf8DrWvA48EbRCZZ/31h4RENQUWCGOkTMYY17gbWDyoXbCF+GO+tcAsdkqNSqNJ4urdKBVkcTXkrinXTcuAH8JlcwmdUrfjkGyw5JWlXwOpG2DAVP+TE2GI1jGkBmWptmVDb2Lkd6+kwhcnE+LlWcDmF22VDxVAQOqWUoGxpRv5OQf3B/mV8jvyPBZ5G1tr4AjR90VDQh0TOHsb2IG8jdSxbK0m3PybEMPSmfuuqYGBLrLU2MqAkU69K5raqkJdnFajJ0NTTG4GtC8TYk+Xcduh6TEj9eBo/IDLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none X-Received: from DBBPR08MB6012.eurprd08.prod.outlook.com (2603:10a6:10:205::9) by DU0PR08MB8496.eurprd08.prod.outlook.com (2603:10a6:10:403::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 19:36:29 +0000 X-Received: from DBBPR08MB6012.eurprd08.prod.outlook.com ([fe80::c7de:7a71:8ff6:7e25]) by DBBPR08MB6012.eurprd08.prod.outlook.com ([fe80::c7de:7a71:8ff6:7e25%5]) with mapi id 15.20.6699.027; Thu, 24 Aug 2023 19:36:29 +0000 From: "Jose Marinho" To: "devel@edk2.groups.io" , "gmahadevan@nvidia.com" , Sami Mujawar CC: Alexei Fedorov , Pierre Gondois , "Jeff Brasen (jbrasen@nvidia.com)" , "ashishsingha@nvidia.com" , "nramirez@nvidia.com" , nd Subject: Re: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Thread-Topic: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Thread-Index: AQHZv1HQV3cdkixkeEiizF4EfpQLXa/6BK+A Date: Thu, 24 Aug 2023 19:36:29 +0000 Message-ID: References: <20230725233805.646668-1-gmahadevan@nvidia.com> <20230725233805.646668-6-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-6-gmahadevan@nvidia.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: DBBPR08MB6012:EE_|DU0PR08MB8496:EE_|DBAEUR03FT028:EE_|AS8PR08MB6021:EE_ X-MS-Office365-Filtering-Correlation-Id: eb4d1540-6758-412b-959e-08dba4d972ff x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HZ/MxC0JnmqPG7RoBRkHAgr0+VfsJq02FM4Vw6MZbephQtih6eLHXMAGPA9RydjWSSlkRChHq9OcwPPNN91+199D/tTWPDIAm9WUW46Xt3XCyWLMmvnsFiNJC6QaY30SA087MA1Znd7SX4ikKZcvgjY/xhIq6dezqpN7uYiJV+kHAxV/UCjEcZJ1C0UjhK1yqmKbMGkoEon90TuQhfwwJVQpVRmPoru4fTW1xApzCuZtY0XRF5zl27Q7UqGb9IK+YwmNHLcwiVzyeCP09fOc3hRwTCQeSe9ZmitYMo5H7QylUGFm1lXN1DOkg//W4EaIVqqOyHIG8n5gTQ9n7+lGROXrSpF9keyERpGHL6JWj2F2UMv1Dus5zVoWZx6LliZzs8lUHXXkz4fLS1+2xA+43WE38wOCfR+e4lrC2rXZ6mURCLuhIoZnIxoaddkncAbZ7B5DqdR3Vl8F62uqlcTNf6W7+Ir7OL1Oqp1yQrrqqeudLJbCl2LbCnQf3wCorOQrUfjmMP+JPSmsjQNnTiZx+xHmfl/+hQ5DYwJ4xkqlzQRlMdIy6SWTSuZ3dXF5x/WXs1jCzy50LoocRL0Az7Ww1KgS9T13COgs6JH6jTGfQpg= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR08MB6012.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(346002)(366004)(376002)(39860400002)(1800799009)(186009)(451199024)(52536014)(4326008)(8676002)(8936002)(83380400001)(66899024)(5660300002)(30864003)(26005)(55016003)(33656002)(71200400001)(38100700002)(38070700005)(19627235002)(122000001)(66946007)(66556008)(76116006)(64756008)(66446008)(54906003)(66476007)(6636002)(316002)(110136005)(478600001)(966005)(41300700001)(2906002)(9686003)(53546011)(86362001)(6506007)(7696005);DIR:OUT;SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8496 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6304c44a-2553-4439-28aa-08dba4d969d8 X-Microsoft-Antispam-Message-Info: vutKSc05zdLFrePMYr2Pwmi7Z0E05G+oOyds/Naiit9QUPzFbQ0HEZDsudADgtGQMlAr9Jbf+a387nImwoFsVoFHcGK65HiLKpeNLjoMZvD+QkltgwLNymQoWqFnXtJ9AGtwXFhKtkbOtgPi5Kj5cGMBp0A1pCDuIaSWsWk4mi8CYGJfZXLgC7tzsyBUcBKa4y+ZBdSB0kOvfMcoboAgd8oJzlNm3HJIFTnbCh11HZtu5IxG+Qyv9FU1KLyyvZ6tOg7/BVbN4ERJWEgGnWFDUhLVsFLcmNU9eS46nQRvwbB1NYnv6sFyGrFDVa0Dw0fH9AlHBgZwz4/tc/6IwU+aZVL6a+uGp95K4EH9O8ar+AV1bBk41VRLCVySNHd5cJGeXImnJiENEjjv564MtQ04iY63g9wF/iNvGD/iJAu4AVQGvGDIgu0eXaP7dkHrw+jEHXUqEcjABgZQku7aY1JO7nROeJLee9LbRgXkxFEPeHCSZmFO0yQW5IafxsLSOCtZYFWB3W0xBhcVA046WaE/xwGyKBnbJl2FYI9unw7S1g5vVqPU5wSMrd3/v9Bor25s2yzueBAy4F55k1usd3rUNiM6/ftZyd7vwCZbBAmeZPZ5NQh0KrmcaKv9uhhxmHs9t9OG8lpeys1GAW1d4K8VdSFIBQXedqqdWlCZqeMjOYVBRWKHFFXFsvV4xrwrD6QqPEbBl3TVGFQZwmtQDvcjSx8z8PSzzoSKPlzgExw92Ms= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 19:36:44.7112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb4d1540-6758-412b-959e-08dba4d972ff X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6021 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jose.marinho@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: HkZIRjhHLzxw1QebfhlNJioGx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Jpdw9yhx; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Girish > Mahadevan via groups.io > Sent: Wednesday, July 26, 2023 12:38 AM > To: devel@edk2.groups.io; Sami Mujawar > Cc: gmahadevan@nvidia.com; Alexei Fedorov ; > Pierre Gondois ; Jeff Brasen (jbrasen@nvidia.com) > ; ashishsingha@nvidia.com; nramirez@nvidia.com > Subject: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Smbios Physical > Memory Array (Type 16) >=20 > Add the Generator library for SMBIOS Table Type 16 - Physical Memory Arra= y. >=20 > Signed-off-by: Girish Mahadevan > Reviewed-by: Jeff Brasen > Reviewed-by: Nick Ramirez > --- > .../SmbiosTableBuilder.c | 3 - > .../Include/SmbiosNameSpaceObjects.h | 19 + > .../SmbiosType16Lib/SmbiosType16Generator.c | 361 ++++++++++++++++++ > .../SmbiosType16Lib/SmbiosType16Lib.inf | 35 ++ > 4 files changed, 415 insertions(+), 3 deletions(-) create mode 100644 > DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator > .c > create mode 100644 > DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf >=20 > diff --git > a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c > b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c > index bfddaac3aa..5feafcac66 100644 > --- > a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c > +++ > b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder > +++ .c > @@ -312,7 +312,6 @@ exit_handler: > } > } >=20 > - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); > return Status; nit: these debug statements were added in the commit with title " DynamicTablesPkg: Split the ACPI and SMBIOS table generators" Should these be removed there? Jose > } >=20 > @@ -432,7 +431,6 @@ BuildAndInstallSmbiosTable ( > )); > } >=20 > - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); > return Status; > } >=20 > @@ -516,7 +514,6 @@ ProcessSmbiosTables ( > )); > } >=20 > - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); > return Status; > } >=20 > diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h > b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h > index e44d703fac..760b082021 100644 > --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h > +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h > @@ -107,6 +107,25 @@ typedef struct { > SMBIOS_TABLE_GENERATOR_ID GeneratorId; > } CONTAINED_CM_OBJECTS; >=20 > +/** A structure that describes the Physical Memory Array. > + > + SMBIOS Specification v3.6.0 Type 16 > + > + ID: ESmbiosObjPhysicalMemoryArray > +**/ > +typedef struct CmSmbiosPhysicalMemoryArray { > + UINT8 Use; > + UINT8 Location; > + UINT16 MemoryErrorCorrection; > + UINT16 MemoryErrorInformationHandle; > + UINT16 NumberOfMemoryDevices; > + UINT8 MemoryErrorCorrectionType; > + UINT64 Size; > + UINT8 NumMemDevices; > + CM_OBJECT_TOKEN MemoryErrInfoToken; > + CM_OBJECT_TOKEN PhysMemArrayToken; > +} CM_SMBIOS_PHYSICAL_MEMORY_ARRAY; > + > #pragma pack() >=20 > #endif // SMBIOS_NAMESPACE_OBJECTS_H_ > diff --git > a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generat > or.c > b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generat > or.c > new file mode 100644 > index 0000000000..dad7588ed5 > --- /dev/null > +++ > b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Genera > +++ tor.c > @@ -0,0 +1,361 @@ > +/** @file > + SMBIOS Type16 Table Generator. > + > + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > + Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#include > +#include > +#include > +#include > +#include #include > + > +#include > + > +// Module specific include files. > +#include #include > + #include > + > +#include > +#include > +#include > + > +/** This macro expands to a function that retrieves the Memory Device > + information from the Configuration Manager. > +*/ > +GET_OBJECT_LIST ( > + EObjNameSpaceSmbios, > + ESmbiosObjPhysicalMemoryArray, > + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY > + ) > + > +#define EXTENDED_SIZE_THRESHOLD (SIZE_2TB) > + > +/** > + * Free any resources allocated when installing SMBIOS Type16 table. > + * > + * @param [in] This Pointer to the SMBIOS table generat= or. > + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory > + Protocol interface. > + > + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table > information. > + * @param [in] CfgMgrProtocol Pointer to the Configuration Manage= r > + 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 f= or > + the requested object. > + * @retval EFI_INVALID_PARAMETER A parameter is invalid. > + * @retval EFI_NOT_FOUND Could not find information. > + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. > + * @retval EFI_UNSUPPORTED Unsupported configuration. > +**/ > +STATIC > +EFI_STATUS > +FreeSmbiosType16TableEx ( > + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, > + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST > 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 **CmO= bjectToken, > + IN CONST UINTN Table= Count > + ) > +{ > + UINTN Index; > + SMBIOS_STRUCTURE **TableList; > + > + TableList =3D *Table; > + for (Index =3D 0; Index < TableCount; Index++) { > + if (TableList[Index] !=3D NULL) { > + FreePool (TableList[Index]); > + } > + } > + > + if (*CmObjectToken !=3D NULL) { > + FreePool (*CmObjectToken); > + } > + > + if (TableList !=3D NULL) { > + FreePool (TableList); > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + * Update the Size encoding for Type 16. > + * > + * @param [in] SizeBytes Size of the Memory device. > + * @param [out] SmbiosRecord SMBIOS record to update. > +**/ > +STATIC > +VOID > +UpdateSmbiosType16Size ( > + IN UINT64 SizeBytes, > + IN OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord > + ) > +{ > + UINT64 SizeKb =3D SizeBytes / SIZE_1KB; > + > + if (SizeBytes < EXTENDED_SIZE_THRESHOLD) { > + SmbiosRecord->MaximumCapacity =3D SizeKb; > + } else { > + SmbiosRecord->MaximumCapacity =3D 0x80000000; > + SmbiosRecord->ExtendedMaximumCapacity =3D SizeKb; > + } > +} > + > +/** > + * Add the SMBIOS table handle reference to the Error Tables. > + * > + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table > Factory. > + * @param [in] CmObjToken CM Token to lookup.. > + * @param [out] SmbiosRecord SMBIOS record to update. > +**/ > +STATIC > +VOID > +AddMemErrDeviceHandle ( > + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST > TableFactoryProtocol, > + IN CM_OBJECT_TOKEN CmObjToken, > + OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord > + ) > +{ > + EFI_SMBIOS_HANDLE Handle; > + SMBIOS_HANDLE_MAP *HandleMap; > + > + HandleMap =3D TableFactoryProtocol->GetSmbiosHandle (CmObjToken); if > + (HandleMap =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", > __FUNCTION__)); > + Handle =3D 0xFFFF; > + } else { > + Handle =3D HandleMap->SmbiosTblHandle; } > + > + SmbiosRecord->MemoryErrorInformationHandle =3D Handle; } > + > +/** Construct SMBIOS Type16 Table describing memory devices. > + > + If this function allocates any resources then they must be freed in > + the FreeXXXXTableResources function. > + > + * @param [in] This Pointer to the SMBIOS table generat= or. > + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory > + * Protocol interface. > + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table > information. > + * @param [in] CfgMgrProtocol Pointer to the Configuration Manage= r > + * Protocol interface. > + * @param [out] Table Pointer to the SMBIOS table. > + * @param [out] CmObjectToken Pointer to the CM Object Token Arra= y. > + * @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 f= or > + * the requested object. > + * @retval EFI_INVALID_PARAMETER A parameter is invalid. > + * @retval EFI_NOT_FOUND Could not find information. > + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. > + * @retval EFI_UNSUPPORTED Unsupported configuration. > +**/ > +STATIC > +EFI_STATUS > +BuildSmbiosType16TableEx ( > + IN CONST SMBIOS_TABLE_GENERATOR *This, > + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST > TableFactoryProtocol, > + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableIn= fo, > + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST > CfgMgrProtocol, > + OUT SMBIOS_STRUCTURE ***Table, > + OUT CM_OBJECT_TOKEN **CmObjectTok= en, > + OUT UINTN *CONST TableCount > + ) > +{ > + EFI_STATUS Status; > + SMBIOS_STRUCTURE **TableList; > + SMBIOS_TABLE_TYPE16 *SmbiosRecord; > + CM_OBJECT_TOKEN *CmObjectList; > + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY *PhysMemoryArray; > + UINT32 NumObj; > + UINTN Index; > + > + ASSERT (This !=3D NULL); > + ASSERT (SmbiosTableInfo !=3D NULL); > + ASSERT (CfgMgrProtocol !=3D NULL); > + ASSERT (Table !=3D NULL); > + ASSERT (TableCount !=3D NULL); > + ASSERT (SmbiosTableInfo->TableGeneratorId =3D=3D This->GeneratorID); > + > + if ((This =3D=3D NULL) || (SmbiosTableInfo =3D=3D NULL) || (CfgMgrProt= ocol =3D=3D NULL) > || > + (Table =3D=3D NULL) || (TableCount =3D=3D NULL) || > + (SmbiosTableInfo->TableGeneratorId !=3D This->GeneratorID)) { > + DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + *Table =3D NULL; > + Status =3D GetESmbiosObjPhysicalMemoryArray ( > + CfgMgrProtocol, > + CM_NULL_TOKEN, > + &PhysMemoryArray, > + &NumObj > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "%a: Failed to get Memory Devices CM Object %r\n", > + __FUNCTION__, > + Status > + )); > + return Status; > + } > + > + TableList =3D (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof > + (SMBIOS_STRUCTURE *) * NumObj); if (TableList =3D=3D NULL) { > + DEBUG (( > + DEBUG_ERROR, > + "%a: Failed to alloc memory for %u devices table\n", > + __FUNCTION__, > + NumObj > + )); > + Status =3D EFI_OUT_OF_RESOURCES; > + goto exitBuildSmbiosType16Table; > + } > + > + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof > + (CM_OBJECT_TOKEN *) * NumObj); if (CmObjectList =3D=3D NULL) { > + DEBUG (( > + DEBUG_ERROR, > + "%a: Failed to alloc memory for %u CM Objects.\n", > + __FUNCTION__, > + NumObj > + )); > + Status =3D EFI_OUT_OF_RESOURCES; > + goto exitBuildSmbiosType16Table; > + } > + > + for (Index =3D 0; Index < NumObj; Index++) { > + /** > + * Per Spec each structure is terminated by a double-NULL if there a= re no > + * strings. > + */ > + SmbiosRecord =3D (SMBIOS_TABLE_TYPE16 *)AllocateZeroPool (sizeof > (SMBIOS_TABLE_TYPE16) + 1 + 1); > + if (SmbiosRecord =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto exitBuildSmbiosType16Table; > + } > + > + UpdateSmbiosType16Size (PhysMemoryArray->Size, SmbiosRecord); > + SmbiosRecord->Location =3D PhysMemoryArray[Index].Locat= ion; > + SmbiosRecord->Use =3D PhysMemoryArray[Index].Use; > + SmbiosRecord->MemoryErrorCorrection =3D > PhysMemoryArray[Index].MemoryErrorCorrectionType; > + SmbiosRecord->NumberOfMemoryDevices =3D PhysMemoryArray- > >NumMemDevices; > + if (PhysMemoryArray[Index].MemoryErrInfoToken !=3D CM_NULL_TOKEN) { > + AddMemErrDeviceHandle ( > + TableFactoryProtocol, > + PhysMemoryArray[Index].MemoryErrInfoToken, > + SmbiosRecord > + ); > + } else { > + SmbiosRecord->MemoryErrorInformationHandle =3D 0xFFFF; > + } > + > + // Setup the header > + SmbiosRecord->Hdr.Type =3D > EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY; > + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE16); > + > + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; > + CmObjectList[Index] =3D PhysMemoryArray[Index].PhysMemArrayToken; > + } > + > + *Table =3D TableList; > + *CmObjectToken =3D CmObjectList; > + *TableCount =3D NumObj; > +exitBuildSmbiosType16Table: > + return Status; > +} > + > +/** The interface for the SMBIOS Type16 Table Generator. > +*/ > +STATIC > +CONST > +SMBIOS_TABLE_GENERATOR SmbiosType16Generator =3D { > + // Generator ID > + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType16), > + // Generator Description > + L"SMBIOS.TYPE16.GENERATOR", > + // SMBIOS Table Type > + EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, > + NULL, > + NULL, > + // Build table function. > + BuildSmbiosType16TableEx, > + // Free function. > + FreeSmbiosType16TableEx, > +}; > + > +/** Register the Generator with the SMBIOS Table Factory. > + > + @param [in] ImageHandle The handle to the image. > + @param [in] SystemTable Pointer to the System Table. > + > + @retval EFI_SUCCESS The Generator is registered. > + @retval EFI_INVALID_PARAMETER A parameter is invalid. > + @retval EFI_ALREADY_STARTED The Generator for the Table ID > + is already registered. > +**/ > +EFI_STATUS > +EFIAPI > +SmbiosType16LibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D RegisterSmbiosTableGenerator (&SmbiosType16Generator); > + DEBUG (( > + DEBUG_INFO, > + "SMBIOS Type 16: Register Generator. Status =3D %r\n", > + Status > + )); > + ASSERT_EFI_ERROR (Status); > + > + return Status; > +} > + > +/** Deregister the Generator from the SMBIOS Table Factory. > + > + @param [in] ImageHandle The handle to the image. > + @param [in] SystemTable Pointer to the System Table. > + > + @retval EFI_SUCCESS The Generator is deregistered. > + @retval EFI_INVALID_PARAMETER A parameter is invalid. > + @retval EFI_NOT_FOUND The Generator is not registered. > +**/ > +EFI_STATUS > +EFIAPI > +SmbiosType16LibDestructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType16Generator); > + DEBUG (( > + DEBUG_INFO, > + "SMBIOS Type16: Deregister Generator. Status =3D %r\n", > + Status > + )); > + ASSERT_EFI_ERROR (Status); > + return Status; > +} > diff --git > a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf > b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf > new file mode 100644 > index 0000000000..5bb40db21c > --- /dev/null > +++ > b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.in > +++ f > @@ -0,0 +1,35 @@ > +## @file > +# SMBIOS Type17 Table Generator > +# > +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reser= ved. > +# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
# # > +SPDX-License-Identifier: BSD-2-Clause-Patent ## > + > +[Defines] > + INF_VERSION =3D 0x0001001B > + BASE_NAME =3D SmbiosType16LibArm > + FILE_GUID =3D a256956a-de0b-4aa7-8eac-5ce13bbfbb1f > + VERSION_STRING =3D 1.0 > + MODULE_TYPE =3D DXE_DRIVER > + LIBRARY_CLASS =3D NULL|DXE_DRIVER > + CONSTRUCTOR =3D SmbiosType16LibConstructor > + DESTRUCTOR =3D SmbiosType16LibDestructor > + > +[Sources] > + SmbiosType16Generator.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > + ArmPlatformPkg/ArmPlatformPkg.dec > + DynamicTablesPkg/DynamicTablesPkg.dec > + > +[Protocols] > + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUM= ED > + > +[LibraryClasses] > + BaseLib > + DebugLib > -- > 2.17.1 >=20 >=20 >=20 >=20 >=20 -=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 (#108021): https://edk2.groups.io/g/devel/message/108021 Mute This Topic: https://groups.io/mt/100361564/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-