From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (NAM04-BN8-obe.outbound.protection.outlook.com [40.107.100.55]) by mx.groups.io with SMTP id smtpd.web10.639.1663039469671201614 for ; Mon, 12 Sep 2022 20:24:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=Dvfl2ayr; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.100.55, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esofris+EQZn0eJbbS8gb7vv5tocoMr84QxiA8Aeu/OarLv7/m7x1HrHu6QLNJbSXmtC7+F05pBiAw7pqpIVdUAz/231UsWLwZcDeW5B+cTeJaB++iHrgYlSMlaKp05hyeRZZnnl9uy86LDzSaAVRHKGFEk+p+9xrTAq3hDsUjo8TmQ96/kHoo8SeTS5F1fR7ts4WfqKuhmGYqjwgXzhvGs2eT5ciNf/CBru9KJ6dQzz1ZyFlhM0i2WfjniX2xS4yH6nZT0TnD/aPKHxmIrbXYWuaQbJ54pCI6MiTIxSS/0SqPXabkNyel8lYzv7+UNmccwRa5pGq6ajpZYReqreeQ== 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=azpJST7uNlGiJ7EfNIzldZ/WoXF7Z4kvbOPiU7FasGU=; b=nY1VKvGd2nTbscd35F+0+Jx9DVRRAd03Hd+H8SnPb4V3NDoObJmzUIC1X5Lea3sXADG1ufzxGDr4+7BNFyHho0RkS4N8W7TF81/GlddzDQZkI4Y/iYYXOHFV+kaTS62XDCRmQkNIq8J4UqZM70T5IOjFMC/RhEIyD4/t6SL0DqZ3KP9PBsfaiFmlRvMJ3tjbDUStxpx5Y91DA2Wj8jBIuHh87c513evZzv5IMfjx9xGgyR2D1eJBQzGDDTDCvBAEwVlAYLa+dTEaTCU3uDlJoIa4K5YM97hoGeWdGqDxnQlqMjJmE4A3ceb05sKKQNNeemwkahzbOLQ5AUTt6Sj8+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=azpJST7uNlGiJ7EfNIzldZ/WoXF7Z4kvbOPiU7FasGU=; b=Dvfl2ayrthCHuNb8t+BwOt3qoJ7fmSMQDXzvFNCNNgXFVu1tHjLvfjrhrTpc+T5LZMYo/5XKheOLRlkgLuJ9fjPgRKS/oWI6HRUSialEXc7UJk+hwoA2GV3mUejHOVo4eXdEu6RhEv/L0av2Xy0truIOMnNGWISW2Bj0LPo+mWg= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by SJ0PR12MB5470.namprd12.prod.outlook.com (2603:10b6:a03:3bd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.19; Tue, 13 Sep 2022 03:24:26 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::9c44:17db:7f29:1fa8]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::9c44:17db:7f29:1fa8%7]) with mapi id 15.20.5612.022; Tue, 13 Sep 2022 03:24:26 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "sami.mujawar@arm.com" CC: "Alexei.Fedorov@arm.com" , "pierre.gondois@arm.com" , "gmahadevan@nvidia.com" , "jbrasen@nvidia.com" , "ashishsingha@nvidia.com" , "nramirez@nvidia.com" , "wwatson@nvidia.com" , "Samer.El-Haj-Mahmoud@arm.com" , "Akanksha.Jain2@arm.com" , "Matteo.Carlini@arm.com" , "Ben.Adderson@arm.com" , "nd@arm.com" Subject: Re: [edk2-devel] [PATCH v1 1/1] DynamicTablesPkg: Add SMBIOS String table helper library Thread-Topic: [edk2-devel] [PATCH v1 1/1] DynamicTablesPkg: Add SMBIOS String table helper library Thread-Index: AQHYxrKpuPXzc8NwHE2am6bjEgJnOK3csI8Q Date: Tue, 13 Sep 2022 03:24:26 +0000 Message-ID: References: <20220912141850.35064-1-sami.mujawar@arm.com> In-Reply-To: <20220912141850.35064-1-sami.mujawar@arm.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-09-13T03:24:24Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=a14fd833-0fb4-4c2c-9bcb-cf0701352a20; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|SJ0PR12MB5470:EE_ x-ms-office365-filtering-correlation-id: b744a748-9967-4aee-d88d-08da9537762a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ++vKGRQ9zMgruPLBlFzFF1DM2goamILiosQWbghG8pKN56kZhGeD8R8IDmWb+bLEFipGaKl8t7x7vimJEDDUj5v5mHgDw97YTxU91p6ok8biDI/XBzRwrbn7xLtIWKHgJOZ5VhKXY+YDEPTR5iLKRnoafOm8Phe7l16Xpag9hIx27S6HM5kfWdaqsdJpkIYKvnU9upLBXw3pd85VDXGssFW3ngY9hOQCT98MjBBUpWGPX+nt8ZJJD/SSUccTa9zU9kVBPcnoZ+efqoH9Mo8Oi41WUhMOpsr/SZmq1qas5tAGhsUJPcmgjzFLT7S5Kq1kXWwuLxDKClVOxyzQlSVFag19jz+A90EoqrYc4m+vLrvbg1dSBWUvi/40g0xhjtWtmGcUHrpzQT/GUIyOe8CEZbBeT071mAYtu0gafli7DQGGtlQvsWV49Jyt+FpSIJPWWbH0kbuacSzJadAGWNybxsi4Otkj4263Xl8KwuV4012Yttl4xnVc+Z/r01+eFzfzfnul12OPO2Qg/v63ghXjmc9YLjwHlHYJJYl4hp+nG3dmPbzc6Kv9CB7PsmJpHv3KV3MbbfSBiY92EUf2fS+9z1bFh7ZjMuht2M2YRJ6yDefrRDVrHGvkq2YW0tjEtLcKETRm1frjYGmVnxnJEsAnvgsuAoXh7/xsuxlZ0qmb7MGj7bQsfNEVs/aru5yubZtWiwSzbmwzfYLDrvIXBJU9x+BQmtmQdLH3tauFiluEanaQjzY3vdbYeKfHBF8iP++q55aw770E8+zDV1LJOkBFBScBvXNFzO/6KAqb/ST5BnUwHZEJmKmRwOJCl664/VbrF7FUTDfh0nCPFleq/4EBGA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(346002)(376002)(39860400002)(451199015)(30864003)(966005)(186003)(86362001)(9686003)(53546011)(316002)(41300700001)(64756008)(478600001)(7416002)(110136005)(7696005)(33656002)(8936002)(122000001)(83380400001)(54906003)(52536014)(38100700002)(4326008)(66446008)(76116006)(66556008)(71200400001)(6506007)(5660300002)(45080400002)(66946007)(26005)(19627235002)(8676002)(66476007)(38070700005)(55016003)(2906002)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ZNDV3jiG0NxinC8jPydz8whnOebnINozRqeiCZO6PKLzm72YWbHtO2uM6oIh?= =?us-ascii?Q?eYZGDP38+KnTBcWRBfOho1tyjW+5bu+VcVKKvbeOPdwZPoMn50D7Tv/A5+Ml?= =?us-ascii?Q?mg9VDsFzztg5+gTcDRpat6CxF+Gm1W66nX54vLCvOMybmIR6eVqNRKkyWanJ?= =?us-ascii?Q?caOI3M3Clp5WXBBsK2JcS1y7mNOSlIbbFDdlGYM+7Poqad9/v8fuGo7UIp9j?= =?us-ascii?Q?FG+V1M3H/bKwhsxb1RjOru3rG1xhjzb+6A897n/VVKlth5LLx4Lxb4nekOy1?= =?us-ascii?Q?X4xdx6KZv4NSaCtsmUI+VHkrrpDhskBKB6mXT4KXkm/6hmqSZNwIzKnS8a7/?= =?us-ascii?Q?C5+onGQU7EDZXYqjlakH50sBzAadnilY4V5YTOIXJfq/RfBk6t0Nd45Z9UvR?= =?us-ascii?Q?b5wrXy+8frVTzbL+L05jFv67svsJjAwO+R3PVQwgGPZf5C7FiV3IH+4oz0ZE?= =?us-ascii?Q?V1rD0GCSODAcypngvTmgb8e3QNeFxEp5M3B2baSCjaGEHNgo4OXFNAPyJ0PI?= =?us-ascii?Q?HQDiA95QyTf9e9i0R7581FNpdoDt2pJy/vK+wmbVG5NAaM9X8Tgb8tzXvq7q?= =?us-ascii?Q?7p32Bl9iKxWuPMYVE2h/w4HQTzJBkY0gtP9KeGjWER8NhP+s+vVjO7F7RlSi?= =?us-ascii?Q?1q/yMg7zLl+4UbaaWKIkOrL9dRUUo7Vk72WtkTc8QrQfOLB53TbICmXqgDeW?= =?us-ascii?Q?p3pSCzS9JauZp9urHl6ugZ7kPixKAY6SBGlWA5FyapnGmPcYWT/x0Sm0KmRJ?= =?us-ascii?Q?+9nuIJ3fiCBLFBpV58D9a+p2NJ3i+rgJwqfhybRu2o54+k1laHJbIgIjwLsU?= =?us-ascii?Q?NVLD2VhJtWJ9PP/B2bMAT5k03l4n3RBzleEU0lcqj2amkk1/eS8ZZZMkvVuF?= =?us-ascii?Q?iXHWq7wpqoH6Qug5yNwdXw7JazwrGWbck3wJAUlQnAR4wr8W6EeTxP4YrMzZ?= =?us-ascii?Q?SKW5gzxq4dFVbpzrPidNWS2Qsrv05Dd/MzflZtKG6h1OvyaNSFM5BMjx2z8t?= =?us-ascii?Q?mpxT+i6Bph4uNvIciEs56dn83xMVBiwqht5vkfY9M8xBwHWQqNs3eKAr04Lx?= =?us-ascii?Q?AbgJ8FlMlmszBAiBoY/as2xjVgzkAti0meyo2TabE0egEiXIji15Ee6gH5YQ?= =?us-ascii?Q?Rc/BwDscNGrRjUBjbKhEFHjUJB1HUIdIUbYVevVIIZGFBMAexSE6YOWZMYSo?= =?us-ascii?Q?Xr6vBkoRZ1XPbbw2S4mqkIjMr0nT9DTB1OXJcHNiu3wewP40iZqg+SfeMBpM?= =?us-ascii?Q?VnzAKw9INpaORlOB/WLhVECWmdnmcxFKQh5HWxSiloWloPI3D81RUhLEmES3?= =?us-ascii?Q?UwBYneELVdnn3xrbYCqdmTgyeSgO8wOjZrvrTvTaTaXrsaszOL8SyFdQT4kN?= =?us-ascii?Q?uzPbS+Kw3u/QEDweUOtdBhROHFVBNj28CF1Q0NHMgdG0bv/aF+jEGqXl5ky7?= =?us-ascii?Q?yeTgpW6LNaMLbs4ZpECCazIh9meg/kBCD7emeeky0pO8WZMLdJ7J+MVr6yOF?= =?us-ascii?Q?Hze1YXxYPU0RsZ/hul1FUKX2yKO4tlKhooTCNbmZs8IQZesjnMwus39ZAcK4?= =?us-ascii?Q?P0Ni4qR2FL7OY1x0zHw=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b744a748-9967-4aee-d88d-08da9537762a X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Sep 2022 03:24:26.4137 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: B+7EMwiNX9LoBfufD5+n3DIsmWi8lQvfSulukZCce1mDWS4KQGlZQdG3q7M+JEvTPytaIHzji3FzSHX6g3G9oQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5470 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] I am not the reviewer or maintainer of DynamicTablePkg, however this patch = looks good. Abner > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sami > Mujawar via groups.io > Sent: Monday, September 12, 2022 10:19 PM > To: devel@edk2.groups.io > Cc: Sami Mujawar ; Alexei.Fedorov@arm.com; > pierre.gondois@arm.com; gmahadevan@nvidia.com; jbrasen@nvidia.com; > ashishsingha@nvidia.com; nramirez@nvidia.com; wwatson@nvidia.com; > Samer.El-Haj-Mahmoud@arm.com; Akanksha.Jain2@arm.com; > Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com > Subject: [edk2-devel] [PATCH v1 1/1] DynamicTablesPkg: Add SMBIOS String > table helper library >=20 > [CAUTION: External Email] >=20 > The Section 6.1.3, SMBIOS specification version 3.6.0 describes the handl= ing > of test strings in SMBIOS tables. >=20 > Test strings are added at the end of the formatted portion of the SMBIOS > structure and are referenced by index in the SMBIOS structure. >=20 > Therefore, introduce a SmbiosStringTableLib to simplify the publishing of= the > string set. >=20 > SmbiosStringTableLib introduces a concept of string table which records t= he > references to the SMBIOS strings as they are added and returns an string > reference which is then assigned to the string field in the formatted por= tion > of the SMBIOS structure. Once all strings are added, the library provides= an > interface to get the required size for the string set. This allows suffic= ient > memory to be allocated for the SMBIOS table. > The library also provides an interface to publish the string set in accor= dance > with the SMBIOS specification. >=20 > Example: > EFI_STATUS > BuildSmbiosType17Table () { > STRING_TABLE StrTable; > UINT8 DevLocatorRef; > UINT8 BankLocatorRef; > SMBIOS_TABLE_TYPE17 *SmbiosRecord; > CHAR8 *StringSet; > ... >=20 > // Initialize string table for 7 strings > StringTableInitialize (&StrTable, 7); >=20 > StringTableAddString (&StrTable, "SIMM 3", &DevLocatorRef); > StringTableAddString (&StrTable, "Bank 0", &BankLocatorRef); > ... >=20 > SmbiosRecord =3D AllocateZeroPool ( > sizeof (SMBIOS_TABLE_TYPE17) + > StringTableGetStringSetSize (&StrTable) > ); > ... > SmbiosRecord->DeviceLocator =3D DevLocatorRef; > SmbiosRecord->BankLocator =3D BankLocatorRef; > ... > // get the string set area > StringSet =3D (CHAR8*)(SmbiosRecord + 1); >=20 > // publish the string set > StringTablePublishStringSet ( > &StrTable, > StringSet, > StringTableGetStringSetSize (&StrTable) > ); >=20 > // free string table > StringTableFree (&StrTable); >=20 > return EFI_SUCCESS; > } >=20 > Signed-off-by: Sami Mujawar > Cc: Alexei Fedorov > Cc: Pierre Gondois > Cc: Girish Mahadevan > Cc: Jeff Brasen > Cc: Ashish Singhal > Cc: Nick Ramirez > Cc: William Watson > Cc: Samer El-Haj-Mahmoud > --- > The changes can be seen at: > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgith > ub.com%2Fsamimujawar%2Fedk2%2Ftree%2F2370_smbios_stringlib_v1&am > p;data=3D05%7C01%7Cabner.chang%40amd.com%7C2f4f246601944c95e16c08d > a94c9c7f6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637985891 > 657718377%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj > oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sd > ata=3DLfZx8a24uMDMQPXHNCVJOAl8JaNmqaBZaTbJvxG1nMU%3D&rese > rved=3D0 >=20 > DynamicTablesPkg/DynamicTables.dsc.inc = | 3 +- > DynamicTablesPkg/DynamicTablesPkg.dec = | 5 +- > DynamicTablesPkg/DynamicTablesPkg.dsc = | 3 +- > DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h = | 119 > ++++++++++ >=20 > DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl > eLib.c | 227 ++++++++++++++++++++ >=20 > DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl > eLib.inf | 25 +++ > 6 files changed, 379 insertions(+), 3 deletions(-) >=20 > diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc > b/DynamicTablesPkg/DynamicTables.dsc.inc > index > 3d4fa0c4c4b67d6770aee8705c80cc18d20c823a..d35acc1788f2ddc5e2b5fc3e4b > edfd48251f7ec8 100644 > --- a/DynamicTablesPkg/DynamicTables.dsc.inc > +++ b/DynamicTablesPkg/DynamicTables.dsc.inc > @@ -1,7 +1,7 @@ > ## @file > # Dsc include file for Dynamic Tables Framework. > # > -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
> +# Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -18,6 +18,7 @@ > [LibraryClasses.common] >=20 > SsdtPcieSupportLib|DynamicTablesPkg/Library/Common/SsdtPcieSupportLib > /SsdtPcieSupportLib.inf >=20 > SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFi > xupLib/SsdtSerialPortFixupLib.inf >=20 > TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableH > elperLib.inf > + > + > SmbiosStringTableLib|DynamicTablesPkg/Library/Common/SmbiosStringTabl > e > + Lib/SmbiosStringTableLib.inf >=20 > [Components.common] > # > diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec > b/DynamicTablesPkg/DynamicTablesPkg.dec > index > cc34c2bdd6ff9b5ca508961b3d0fe85ffbb73c12..2a79cfd4edebbdff05bee66fa0 > 1a17d68252e8a7 100644 > --- a/DynamicTablesPkg/DynamicTablesPkg.dec > +++ b/DynamicTablesPkg/DynamicTablesPkg.dec > @@ -1,7 +1,7 @@ > ## @file > # dec file for Dynamic Tables Framework. > # > -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
> +# Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -39,6 +39,9 @@ > [LibraryClasses] > ## @libraryclass Defines a set of helper methods. > TableHelperLib|Include/Library/TableHelperLib.h >=20 > + ## @libraryclass Defines a set of SMBIOS string helper methods. > + SmbiosStringTableLib|Include/Library/SmbiosStringTableLib.h > + > [Protocols] > # Configuration Manager Protocol GUID > gEdkiiConfigurationManagerProtocolGuid =3D { 0xd85a4835, 0x5a82, 0x489= 4, > { 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } } diff --git > a/DynamicTablesPkg/DynamicTablesPkg.dsc > b/DynamicTablesPkg/DynamicTablesPkg.dsc > index > 07cc837552f587fe5bf9031e0061b0234e8698d4..bd5084a9008f040acdd16200ae > 8cdb23455ac101 100644 > --- a/DynamicTablesPkg/DynamicTablesPkg.dsc > +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc > @@ -2,7 +2,7 @@ > # Dsc file for Dynamic Tables Framework. > # > # Copyright (c) 2019, Linaro Limited. All rights reserved.
-# Copy= right (c) > 2019 - 2021, Arm Limited. All rights reserved.
> +# Copyright (c) 2019 - 2022, Arm Limited. All rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -46,6 +46,7 @@ > [Components.common] > DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf > DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf >=20 > DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo > Lib.inf > + > + > DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl > e > + Lib.inf >=20 > [BuildOptions] > *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git > a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h > b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h > new file mode 100644 > index > 0000000000000000000000000000000000000000..246d4d30ddf901640ea720c10 > 8e2971552ec6c96 > --- /dev/null > +++ b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h > @@ -0,0 +1,119 @@ > +/** @file > + SMBIOS String Table Helper library. > + > + Copyright (c) 2022, Arm Limited. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#ifndef SMBIOS_STRING_TABLE_H_ > +#define SMBIOS_STRING_TABLE_H_ > + > +/** A structure representing a string in the string table. > +*/ > +typedef struct StringElement { > + /// Length of the string (does not include the NULL termination) > + UINTN StringLen; > + > + /// Reference to the string > + CONST CHAR8 *String; > +} STRING_ELEMENT; > + > +/** A structure representing a string table. > +*/ > +typedef struct StringTable { > + /// Count of strings in the table > + UINT8 StrCount; > + > + /// Total length of all strings in the table (does not include // > + the NULL termination for each string) > + UINTN TotalStrLen; > + > + /// Maximum string count > + UINT8 MaxStringElements; > + > + /// Pointer to the string table elements > + STRING_ELEMENT *Elements; > +} STRING_TABLE; > + > +/** Add a string to the string table > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] Str Pointer to the string > + @param [OUT] StrRef Optional pointer to retrieve the string field > + reference of the string in the string table > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_BUFFER_TOO_SMALL Insufficient space to add string > +**/ > +EFI_STATUS > +EFIAPI > +StringTableAddString ( > + IN STRING_TABLE *CONST StrTable, > + IN CONST CHAR8 *Str, > + OUT UINT8 *StrRef OPTIONAL > + ); > + > +/** Returns the total size required to publish the strings to the SMBIOS > + string area. > + > + @param [IN] StrTable Pointer to the string table > + > + @return Total size required to publish the strings in the SMBIOS strin= g area. > +**/ > +UINTN > +EFIAPI > +StringTableGetStringSetSize ( > + IN STRING_TABLE *CONST StrTable > + ); > + > +/** Iterate through the string table and publish the strings in the SMBI= OS > + string area. > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] SmbiosStringAreaStart Start address of the SMBIOS string > area. > + @param [IN] SmbiosStringAreaSize Size of the SMBIOS string area. > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_BUFFER_TOO_SMALL Insufficient space to publish strings > +**/ > +EFI_STATUS > +EFIAPI > +StringTablePublishStringSet ( > + IN STRING_TABLE *CONST StrTable, > + IN CHAR8 *CONST SmbiosStringAreaStart, > + IN CONST UINTN SmbiosStringAreaSize > + ); > + > +/** Initialise the string table and allocate memory for the string eleme= nts. > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] MaxStringElements Maximum number of strings that the > string > + table can hold. > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_OUT_OF_RESOURCES Failed to allocate memory for string > elements > +**/ > +EFI_STATUS > +EFIAPI > +StringTableInitialize ( > + IN STRING_TABLE *CONST StrTable, > + IN UINTN MaxStringElements > + ); > + > +/** Free memory allocated for the string elements in the string table. > + > + @param [IN] StrTable Pointer to the string table > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer or string > +elements **/ EFI_STATUS EFIAPI StringTableFree ( > + IN STRING_TABLE *CONST StrTable > + ); > + > +#endif // SMBIOS_STRING_TABLE_H_ > diff --git > a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTa > bleLib.c > b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTa > bleLib.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..bd186f27fe1613cf819b6600e6 > 2960c003a796d6 > --- /dev/null > +++ > b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringT > +++ ableLib.c > @@ -0,0 +1,227 @@ > +/** @file > + SMBIOS String Table Helper > + > + Copyright (c) 2022, Arm Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > + @par Reference(s): > + - DSP0134 - SMBIOS Specification Version 3.6.0, 2022-06-17 **/ > + > +#include > +#include > +#include > +#include #include > + > + > +/** Add a string to the string table > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] Str Pointer to the string > + @param [OUT] StrRef Optional pointer to retrieve the string field > + reference of the string in the string table > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_BUFFER_TOO_SMALL Insufficient space to add string > +**/ > +EFI_STATUS > +EFIAPI > +StringTableAddString ( > + IN STRING_TABLE *CONST StrTable, > + IN CONST CHAR8 *Str, > + OUT UINT8 *StrRef OPTIONAL > + ) > +{ > + UINTN StrLength; > + STRING_ELEMENT *StrElement; > + > + if ((StrTable =3D=3D NULL) || (Str =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (StrTable->StrCount >=3D StrTable->MaxStringElements) { > + return EFI_BUFFER_TOO_SMALL; > + } > + > + StrLength =3D AsciiStrLen (Str); > + if (StrLength =3D=3D 0) { > + return EFI_INVALID_PARAMETER; > + } > + > + // Update the string element > + StrElement =3D &StrTable->Elements[StrTable->StrCount]; > + StrElement->StringLen =3D StrLength; > + StrElement->String =3D Str; > + > + // Update String table information > + StrTable->TotalStrLen +=3D StrLength; > + StrTable->StrCount++; > + > + // Return the index of the string in the string table if requested > + if (StrRef !=3D NULL) { > + // Note: SMBIOS string field references start at 1. So, return the > + // StrCount as the string refrence after it is updated. > + *StrRef =3D StrTable->StrCount; > + } > + > + return EFI_SUCCESS; > +} > + > +/** Returns the total size required to publish the strings to the SMBIOS > + string area. > + > + @param [IN] StrTable Pointer to the string table > + > + @return Total size required to publish the strings in the SMBIOS strin= g area. > +**/ > +UINTN > +EFIAPI > +StringTableGetStringSetSize ( > + IN STRING_TABLE *CONST StrTable > + ) > +{ > + if (StrTable =3D=3D NULL) { > + ASSERT (0); > + return 0; > + } > + > + // See Section 6.1.3 Text strings, SMBIOS Specification Version 3.6.0 > + // - If the formatted portion of the structure contains string-referenc= e > + // fields and all the string fields are set to 0 (no string referenc= es), > + // the formatted section of the structure is followed by two null (0= 0h) > + // BYTES. > + // - Each string is terminated with a null (00h) BYTE // - and the > + set of strings is terminated with an additional null (00h) BYTE. > + > + // Therefore, if string count =3D 0, return 2 > + // if string count > 0, the string set size =3D > + // StrTable->TotalStrLen (total length of the strings in the string > +table) > + // + StrTable->StrCount (add string count to include '\0' for each > +string) > + // +1 (an additional '\0' is required at the end of the string set). > + return (StrTable->StrCount =3D=3D 0) ? 2 : > + (StrTable->TotalStrLen + StrTable->StrCount + 1); } > + > +/** Iterate through the string table and publish the strings in the SMBI= OS > + string area. > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] SmbiosStringAreaStart Start address of the SMBIOS string > area. > + @param [IN] SmbiosStringAreaSize Size of the SMBIOS string area. > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_BUFFER_TOO_SMALL Insufficient space to publish strings > +**/ > +EFI_STATUS > +EFIAPI > +StringTablePublishStringSet ( > + IN STRING_TABLE *CONST StrTable, > + IN CHAR8 *CONST SmbiosStringAreaStart, > + IN CONST UINTN SmbiosStringAreaSize > + ) > +{ > + UINT8 Index; > + STRING_ELEMENT *StrElement; > + CHAR8 *SmbiosString; > + UINTN BytesRemaining; > + UINTN BytesCopied; > + > + if ((StrTable =3D=3D NULL) || (SmbiosStringAreaStart =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (SmbiosStringAreaSize < StringTableGetStringSetSize (StrTable)) { > + return EFI_BUFFER_TOO_SMALL; > + } > + > + SmbiosString =3D SmbiosStringAreaStart; > + BytesRemaining =3D SmbiosStringAreaSize; > + > + if (StrTable->StrCount =3D=3D 0) { > + // See Section 6.1.3 Text strings, SMBIOS Specification Version 3.6.= 0 > + // If the formatted portion of the structure contains string-referen= ce > + // fields and all the string fields are set to 0 (no string referenc= es), > + // the formatted section of the structure is followed by two null (0= 0h) > + // BYTES. > + *SmbiosString++ =3D '\0'; > + } else { > + for (Index =3D 0; Index < StrTable->StrCount; Index++) { > + StrElement =3D &StrTable->Elements[Index]; > + AsciiStrCpyS (SmbiosString, BytesRemaining, StrElement->String); > + > + // See Section 6.1.3 Text strings, SMBIOS Specification Version 3.= 6.0 > + // - Each string is terminated with a null (00h) BYTE > + // Bytes Copied =3D String length + 1 for the string NULL terminat= or. > + BytesCopied =3D StrElement->StringLen + 1; > + BytesRemaining -=3D BytesCopied; > + SmbiosString +=3D BytesCopied; > + } > + } > + > + // See Section 6.1.3 Text strings, SMBIOS Specification Version 3.6.0 > + // - the set of strings is terminated with an additional null (00h) BY= TE. > + *SmbiosString =3D '\0'; > + return EFI_SUCCESS; > +} > + > +/** Initialise the string table and allocate memory for the string eleme= nts. > + > + @param [IN] StrTable Pointer to the string table > + @param [IN] MaxStringElements Maximum number of strings that the > string > + table can hold. > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer > + @return EFI_OUT_OF_RESOURCES Failed to allocate memory for string > elements > +**/ > +EFI_STATUS > +EFIAPI > +StringTableInitialize ( > + IN STRING_TABLE *CONST StrTable, > + IN UINTN MaxStringElements > + ) > +{ > + STRING_ELEMENT *Elements; > + > + if ((StrTable =3D=3D NULL) || (MaxStringElements > MAX_UINT8)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (StrTable, sizeof (STRING_TABLE)); > + > + Elements =3D (STRING_ELEMENT *)AllocateZeroPool ( > + sizeof (STRING_ELEMENT) * MaxStringElem= ents > + ); > + if (Elements =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + StrTable->Elements =3D Elements; > + StrTable->MaxStringElements =3D (UINT8)MaxStringElements; > + return EFI_SUCCESS; > +} > + > +/** Free memory allocated for the string elements in the string table. > + > + @param [IN] StrTable Pointer to the string table > + > + @return EFI_SUCCESS Success > + @return EFI_INVALID_PARAMETER Invalid string table pointer or string > +elements **/ EFI_STATUS EFIAPI StringTableFree ( > + IN STRING_TABLE *CONST StrTable > + ) > +{ > + if ((StrTable =3D=3D NULL) || (StrTable->Elements =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + FreePool (StrTable->Elements); > + ZeroMem (StrTable, sizeof (STRING_TABLE)); > + return EFI_SUCCESS; > +} > diff --git > a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTa > bleLib.inf > b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTa > bleLib.inf > new file mode 100644 > index > 0000000000000000000000000000000000000000..88624c50e3f3e930074222b6d > 686f75485538b26 > --- /dev/null > +++ > b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringT > +++ ableLib.inf > @@ -0,0 +1,25 @@ > +## @file > +# SMBIOS String Table Helper library. > +# > +# Copyright (c) 2022, Arm Limited. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent ## > + > +[Defines] > + INF_VERSION =3D 0x0001001B > + BASE_NAME =3D SmbiosStringTableLib > + FILE_GUID =3D 8C570DD8-531E-473F-85C6-9252746DBAC1 > + VERSION_STRING =3D 1.0 > + MODULE_TYPE =3D DXE_DRIVER > + LIBRARY_CLASS =3D SmbiosStringTableLib > + > +[Sources] > + SmbiosStringTableLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + DynamicTablesPkg/DynamicTablesPkg.dec > + > +[LibraryClasses] > + BaseLib > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >=20 >=20 >=20 >=20 >=20