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.40]) by mx.groups.io with SMTP id smtpd.web10.11287.1664894338011449777 for ; Tue, 04 Oct 2022 07:38:58 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=ozGsQRN4; 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.40, mailfrom: gmahadevan@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hwa+D9sYU7FQMljxJQQaTtTMbuvEiPHECTkjP6GoFHbUB0A5AQegi4yTLiwgxJjNkx+NNlFJy0efqauG5i0f7HVQ5WEAYYMOsS7ExP2y5+LsdaTnu55O7mRSlY1BFn/JfHYl19RfHQ+hyx28C/L6a21IHOO0owJrRk+50Sy2WXzrbm3mtybQelCTwngrRksZ9HeqcF3yFMG0SV6rO0Ga9Ic3QBW772/nvGS8ZIYPu2UMz2tHkgoTNEIgCtDsfiwLDtLTOAAoNk5REYq8WaMnpxM3plczCtto4Uq1kU+4aCXSWELSI8DJntmE9iti81wLg/yGCjM45h6ez9cG71aA0g== 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=v+UbrPvu7l+b1G35yl5eXBZ8E1p1dJ8F8kReDEg5vt8=; b=TOq8Vj6QRtLs3FGmHFHUOIJH3xxidv5gPRGRmwwmO/ltO+poBpZWPsygKeay6J4+Q+0Vx5nNEfgPEm3jIy1dwMHoCwdxrFSTuywT3wO1mz+GnaZn9r3mXB2hr5LhXE8/stwvwasWLa1VOMUG5slQPmwzwdyaO/5pCVk8bEXIU9ud0k4k+Fq4uDtCql6WT5ZhebPpyIalCYeSbTUnxdS2dwlV51bWir1DPNGD0wxo2yizx/e3RANKxi7Qq1eUXSJXRHpaHeqPewG1XUFpqzosAseJl0Num9sg7BNO4trzLW42/vvLOaGXFC4MiJyjT7yVF8QroMGtbfEjX34GU1LwyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=v+UbrPvu7l+b1G35yl5eXBZ8E1p1dJ8F8kReDEg5vt8=; b=ozGsQRN4p1oWXMiKh4DNlLevrTv0nmWuxGhcx2yxLACcFqc5yGcudTXFPvx5jbZFqcaYAR/Fmcy+LPH40cdYPRwvLZ8f89yy7dFFE6rzSBBl00KWD6LJV03IOZ9aesA8uPhpzFzK0wjd+kb8CTwl+IIXOk6qnKUlH9fUoohdFWQlvx5DW6IQn1VyVlvZV2MfR7jfBQKRWH4oEKQLM2tfwLUfcFkcgxMCrHHG/cOSDOjANGgsuuBFrMkoIP5bY+kFdyApbmpJXdmBQJds+jefgmKyvEN4etX0cV78xo8H8zUOJgJnG37/k6JZsUBY1TOy6lr2m5Qu9J9jD4e6NRpxNQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) by LV2PR12MB5920.namprd12.prod.outlook.com (2603:10b6:408:172::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Tue, 4 Oct 2022 14:38:54 +0000 Received: from CY5PR12MB6297.namprd12.prod.outlook.com ([fe80::b00c:10c1:3a2e:5b98]) by CY5PR12MB6297.namprd12.prod.outlook.com ([fe80::b00c:10c1:3a2e:5b98%6]) with mapi id 15.20.5676.028; Tue, 4 Oct 2022 14:38:53 +0000 Message-ID: Date: Tue, 4 Oct 2022 08:38:51 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v1 1/1] DynamicTablesPkg: Add SMBIOS String table helper library To: Sami Mujawar , devel@edk2.groups.io CC: Alexei.Fedorov@arm.com, pierre.gondois@arm.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 References: <20220912141850.35064-1-sami.mujawar@arm.com> <73ca18d0-1984-e428-2c2a-96244172e9f3@nvidia.com> From: "Girish Mahadevan" In-Reply-To: X-ClientProxiedBy: BY3PR03CA0013.namprd03.prod.outlook.com (2603:10b6:a03:39a::18) To CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) Return-Path: gmahadevan@nvidia.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6297:EE_|LV2PR12MB5920:EE_ X-MS-Office365-Filtering-Correlation-Id: 4271346b-8844-42e5-c46c-08daa6162923 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bV1+aCFfoxW1cNHoHn+P9/osKh36cHGfXYqv/7kmNIwuBa7Jv/RBeYCixou5E4g3PCt8rWRzwzIwbG7jxtazWZ9gtDxCyMNywgO7wwKll0tXqy/Bbjmw2qG/tsOatb/h/TR79T3GSRdtW4YuJtAZ9yDN7Js4VYdCSeHmT47n94Mqnl1jRCkzpwAiQZbjfFXM5xT+wdR874g9ZxFXvTe/7iQFg5QRToq5XjnUAd2gABPGhEijh5eFwd64xz2lqMXHYRoukLCPgrvETbDJPxWUm01tUoaJuBjCx5uzAD1Ww6awLnpdY2st6un8TfCa7JoPiLjK1JNuNkuwxr0zz2LNxArhW5yHtzYcRZsKxyu8G6LSaFa3ZPGPnMCZPzDIbqcjmRCd70wHQQXQoqOMUes0KbaIAAVD1aqfASMKYXu0wD7eeVMj6yLyv8mnW29p45c7TfLUrcQ3eZWQGE6yS1bQLuxLObctvtGp8aari5YpeL7UB8m8sjf+AFOGds0D9PkRCt9PZ7DWuMEXALR5t0qQv3bSnDyvZxYC8HjuNJKKmVreevc+pi6tm8HQu7IOFuEmNcAXEyP2xs3UP4p18eXQ6Nq00+deBWl8Bcf4BV3GD0bUOsXf7qL495BDI+oMJYzy1K7CyTzK2U4t9krdT2VF1zSKrscXy33xLumDxxLznRwwUcCOe0gseZGfUQLp7+5M6Nz6iFu3eFGkupbfMWFqNPGBnIw8Ty1YGl84bo9sc8+QWauqixRfIE0sEXhzoHnFFPGkX/d52Nwlfqe3ZF136X6YpAcsg/J+LKVeRIz1IO/rLWzczzrgEy3/DkMH9HOn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6297.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(366004)(396003)(451199015)(36756003)(31696002)(31686004)(86362001)(30864003)(5660300002)(186003)(83380400001)(19627235002)(53546011)(45080400002)(6512007)(26005)(6506007)(966005)(6486002)(478600001)(66556008)(316002)(66476007)(2616005)(4326008)(8676002)(66946007)(38100700002)(8936002)(2906002)(41300700001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+snjUlFaBeuXLiyG+GEsewaMG7vYJ5OypnCpPLCyjk0jGveOt8d1Vf/QyNKy?= =?us-ascii?Q?i0ZbB6lWxuX4d5dYOWtR3ct9c9XNDmUNWGVoMOWMq+aCfHL/R3AAWACcGOzw?= =?us-ascii?Q?qCdanVpaJ6BIYl4h+6C13MKR13VcIuHnxiKvaWoNHNLOnMOyW31DSkKM+bgL?= =?us-ascii?Q?rfwPuOnbRhlX/v9cPPadMJLHXILWP+CP9fbLrw3B13cEOGu2X7F8bXMQblI0?= =?us-ascii?Q?Ta7pP3tRq+9Dy9b/C0yMJ3uBUztqiGYbCwGbgaN4dobn10Pfpws9n9pR5lQN?= =?us-ascii?Q?QeXBJvpxz4BMq4cWgtJ78NaKuvXBV3/2xs050KO8BJfbbiSy5UrVtWV1862G?= =?us-ascii?Q?GsFgRh24iKT5qbnd0aQSX7k2QFilp9nWxJAXikCzR82TaxmWZecXeDX5hGVX?= =?us-ascii?Q?hEe8XI5BjsQTAIPGKkD0JfDGh/wqiEIwAdVXKqEBUgc/ZwbtgbvGIJ2vpadm?= =?us-ascii?Q?j11vwFgK2RL1i7Zov/WBdJzbWnCIP7oRDCc9bSaigsh1lxXGfs7qnRwCRpCo?= =?us-ascii?Q?SkJv/PH0Oj88gre8ER+36ledBVjWLMQ2zuUUjfa2PH/aJ2y7GeE5iT1j8z3Y?= =?us-ascii?Q?b9ccUc2WLs/xkDZmmO/8V+FsXSE6HKeUTezRylKze4vhuEZD9XlKNl75YF5d?= =?us-ascii?Q?fKscWVPk+JNeh8BbUj157DLBcVviIyy3wgxTfJBI7jDOxswlvJ/WAaOwM95R?= =?us-ascii?Q?c8sWwGfsXepBZSj1qS2oR1MeQYZq3guAclC3NBRvyU/eliVz2QXi4IE83Dv9?= =?us-ascii?Q?dUlGFF89lHYiaRPBBKmr1vtFINKyX9qWYyqIcBHK+GkOe4D6SxA9rL/JfjdD?= =?us-ascii?Q?J3tQEl4K5zBgN5kPXkBrWm7pGQmTH9y0Ey3H59KWYE8AAWhDgpUbTm1Jj9J0?= =?us-ascii?Q?xk/D7AdkPCEn9EZCTkBwTF43bmHSPzu2TQBP66guTRYzV3z8TJPLbElEZc6R?= =?us-ascii?Q?3PB0EGk1SS7W1rDdWv7rN0/2+kEo/5GeMOuveUr4FqIbAzEo6VCycosXrgKs?= =?us-ascii?Q?k9C4heHsGQSlmbraSavVdIj4VlgJvwWzAdaGsmGYs/vOzCRuiiM6sJtsyh8s?= =?us-ascii?Q?Dw7Q+TGmXTj2AqgDN9N1Jt65xCS7tFONWOzu6r+4KZekc4ShJCEM63hZJfvN?= =?us-ascii?Q?YCDEta/ogADVXFXw0T4TPPzeCGbMeS7KVN6GiXR0MAR3ySNmA/Zayd2nMMF6?= =?us-ascii?Q?lH1UI79TYM1vg7qGCArXBmAT6BtaBXSyr8s4gCU8Jm/GEhZDQ1WCavv6f332?= =?us-ascii?Q?Syjc57A9RC0RtYuvmHfnmMjzrZorfoGcxK6P5QUuRCLlzQ7j4Kkv9L9VgVJm?= =?us-ascii?Q?W1O0BE0t8Da/tLg91u4RY6WELqxEymmloDd185DnbXHw47PHZ+qFBkHF0xAj?= =?us-ascii?Q?Qvsw+q2I1lGfwapdC8nu805I5Fj/4NpFBpPwJ+Inyc94tOhdJALmtEVyFBw0?= =?us-ascii?Q?RicztynYKKwwThsBjt1bsdlNJ972GPYHNfyPh4+A0uOMt/yDQQ5NvkeJElPe?= =?us-ascii?Q?YTE6bbnpw4xOFhaffGikWug6XLCppSp7y4WSRYWk+ui36hULmVu9x9pMcEfK?= =?us-ascii?Q?2NCMwohdQgugZTaUSZO6qphWHemhhMTpzsP8SzIPdZAdKuUQhbrpnn1xO3tu?= =?us-ascii?Q?Og=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4271346b-8844-42e5-c46c-08daa6162923 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6297.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2022 14:38:53.8391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9IOdW0qO1rRSTiKqEqG0QVEk1afqqmbdk0CeLTlFGpEyNW9F40ui3GaNNlSYd0+waVp2QwjD6TKUhMyhNjIq0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5920 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Sami Response inline.[GM] Best Regards Girish On 10/4/2022 2:16 AM, Sami Mujawar wrote: > External email: Use caution opening links or attachments >=20 >=20 > Hi Girish, >=20 > There are 2 cases that need handling. Please see my response inline > marked [SAMI]. >=20 > Regards, >=20 > Sami Mujawar >=20 > On 04/10/2022 04:01 am, Girish Mahadevan wrote: >> Hello Sami, >> >> My apologies for the late response. I had one question/comment. >> >> Comment marked with [GM] inline. >> >> Best Regards >> Girish >> >> On 9/12/2022 8:18 AM, Sami Mujawar wrote: >>> External email: Use caution opening links or attachments >>> >>> >>> The Section 6.1.3, SMBIOS specification version 3.6.0 describes the >>> handling of test strings in SMBIOS tables. >>> >>> Test strings are added at the end of the formatted portion of the SMBIO= S >>> structure and are referenced by index in the SMBIOS structure. >>> >>> Therefore, introduce a SmbiosStringTableLib to simplify the publishing >>> of the string set. >>> >>> SmbiosStringTableLib introduces a concept of string table which records >>> the 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 portion 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 sufficient memory to be allocated for the SMBIOS table= . >>> The library also provides an interface to publish the string set in >>> accordance with the SMBIOS specification. >>> >>> Example: >>> EFI_STATUS >>> BuildSmbiosType17Table () { >>> =C2=A0=C2=A0 STRING_TABLE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 StrTable; >>> =C2=A0=C2=A0 UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 DevLocatorRef; >>> =C2=A0=C2=A0 UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BankLocatorRef; >>> =C2=A0=C2=A0 SMBIOS_TABLE_TYPE17=C2=A0 *SmbiosRecord; >>> =C2=A0=C2=A0 CHAR8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *StringSet; >>> =C2=A0=C2=A0 ... >>> >>> =C2=A0=C2=A0 // Initialize string table for 7 strings >>> =C2=A0=C2=A0 StringTableInitialize (&StrTable, 7); >>> >>> =C2=A0=C2=A0 StringTableAddString (&StrTable, "SIMM 3", &DevLocatorRef)= ; >>> =C2=A0=C2=A0 StringTableAddString (&StrTable, "Bank 0", &BankLocatorRef= ); >>> =C2=A0=C2=A0 ... >>> >>> =C2=A0=C2=A0 SmbiosRecord =3D AllocateZeroPool ( >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof (SMBIOS_TABLE_TYPE17) = + >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 StringTableGetStr= ingSetSize (&StrTable) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >>> =C2=A0=C2=A0 ... >>> =C2=A0=C2=A0 SmbiosRecord->DeviceLocator =3D DevLocatorRef; >>> =C2=A0=C2=A0 SmbiosRecord->BankLocator =3D BankLocatorRef; >>> =C2=A0=C2=A0 ... >>> =C2=A0=C2=A0 // get the string set area >>> =C2=A0=C2=A0 StringSet =3D (CHAR8*)(SmbiosRecord + 1); >>> >>> =C2=A0=C2=A0 // publish the string set >>> =C2=A0=C2=A0 StringTablePublishStringSet ( >>> =C2=A0=C2=A0=C2=A0=C2=A0 &StrTable, >>> =C2=A0=C2=A0=C2=A0=C2=A0 StringSet, >>> =C2=A0=C2=A0=C2=A0=C2=A0 StringTableGetStringSetSize (&StrTable) >>> =C2=A0=C2=A0=C2=A0=C2=A0 ); >>> >>> =C2=A0=C2=A0 // free string table >>> =C2=A0=C2=A0 StringTableFree (&StrTable); >>> >>> =C2=A0=C2=A0 return EFI_SUCCESS; >>> } >>> >>> 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%2Fgit= hub.com%2Fsamimujawar%2Fedk2%2Ftree%2F2370_smbios_stringlib_v1&data=3D0= 5%7C01%7Cgmahadevan%40nvidia.com%7Cc983eff139e143b459ea08daa5e0c308%7C43083= d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638004682041794981%7CUnknown%7CTWFpbG= Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C= 3000%7C%7C%7C&sdata=3DS5QKosbQutvQs17jTnZUHrxrTcxJmClwuUpdMRVoJKU%3D&am= p;reserved=3D0 >>> >>> DynamicTablesPkg/DynamicTables.dsc.inc |=C2=A0=C2=A0 3 +- >>> DynamicTablesPkg/DynamicTablesPkg.dec |=C2=A0=C2=A0 5 +- >>> DynamicTablesPkg/DynamicTablesPkg.dsc |=C2=A0=C2=A0 3 +- >>> DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h | 119 +++++++++= + >>> DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableL= ib.c >>> | 227 ++++++++++++++++++++ >>> DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableL= ib.inf >>> |=C2=A0 25 +++ >>> =C2=A0 6 files changed, 379 insertions(+), 3 deletions(-) >>> >>> diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc >>> b/DynamicTablesPkg/DynamicTables.dsc.inc >>> index >>> 3d4fa0c4c4b67d6770aee8705c80cc18d20c823a..d35acc1788f2ddc5e2b5fc3e4bedf= d48251f7ec8 >>> 100644 >>> --- a/DynamicTablesPkg/DynamicTables.dsc.inc >>> +++ b/DynamicTablesPkg/DynamicTables.dsc.inc >>> @@ -1,7 +1,7 @@ >>> =C2=A0 ## @file >>> =C2=A0 #=C2=A0 Dsc include file for Dynamic Tables Framework. >>> =C2=A0 # >>> -#=C2=A0 Copyright (c) 2017 - 2021, Arm Limited. All rights reserved. >>> +#=C2=A0 Copyright (c) 2017 - 2022, Arm Limited. All rights reserved. >>> =C2=A0 # >>> =C2=A0 #=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >>> =C2=A0 # >>> @@ -18,6 +18,7 @@ [LibraryClasses.common] >>> SsdtPcieSupportLib|DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/S= sdtPcieSupportLib.inf >>> SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFi= xupLib/SsdtSerialPortFixupLib.inf >>> TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelp= erLib.inf >>> + >>> SmbiosStringTableLib|DynamicTablesPkg/Library/Common/SmbiosStringTableL= ib/SmbiosStringTableLib.inf >>> >>> =C2=A0 [Components.common] >>> =C2=A0=C2=A0=C2=A0 # >>> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec >>> b/DynamicTablesPkg/DynamicTablesPkg.dec >>> index >>> cc34c2bdd6ff9b5ca508961b3d0fe85ffbb73c12..2a79cfd4edebbdff05bee66fa01a1= 7d68252e8a7 >>> 100644 >>> --- a/DynamicTablesPkg/DynamicTablesPkg.dec >>> +++ b/DynamicTablesPkg/DynamicTablesPkg.dec >>> @@ -1,7 +1,7 @@ >>> =C2=A0 ## @file >>> =C2=A0 # dec file for Dynamic Tables Framework. >>> =C2=A0 # >>> -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
>>> +# Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
>>> =C2=A0 # >>> =C2=A0 # SPDX-License-Identifier: BSD-2-Clause-Patent >>> =C2=A0 # >>> @@ -39,6 +39,9 @@ [LibraryClasses] >>> =C2=A0=C2=A0=C2=A0 ##=C2=A0 @libraryclass=C2=A0 Defines a set of helper= methods. >>> =C2=A0=C2=A0=C2=A0 TableHelperLib|Include/Library/TableHelperLib.h >>> >>> +=C2=A0 ##=C2=A0 @libraryclass=C2=A0 Defines a set of SMBIOS string hel= per methods. >>> +=C2=A0 SmbiosStringTableLib|Include/Library/SmbiosStringTableLib.h >>> + >>> =C2=A0 [Protocols] >>> =C2=A0=C2=A0=C2=A0 # Configuration Manager Protocol GUID >>> =C2=A0=C2=A0=C2=A0 gEdkiiConfigurationManagerProtocolGuid =3D { 0xd85a4= 835, 0x5a82, >>> 0x4894, { 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } } >>> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc >>> b/DynamicTablesPkg/DynamicTablesPkg.dsc >>> index >>> 07cc837552f587fe5bf9031e0061b0234e8698d4..bd5084a9008f040acdd16200ae8cd= b23455ac101 >>> 100644 >>> --- a/DynamicTablesPkg/DynamicTablesPkg.dsc >>> +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc >>> @@ -2,7 +2,7 @@ >>> =C2=A0 #=C2=A0 Dsc file for Dynamic Tables Framework. >>> =C2=A0 # >>> =C2=A0 #=C2=A0 Copyright (c) 2019, Linaro Limited. All rights reserved.=
>>> -#=C2=A0 Copyright (c) 2019 - 2021, Arm Limited. All rights reserved. >>> +#=C2=A0 Copyright (c) 2019 - 2022, Arm Limited. All rights reserved. >>> =C2=A0 # >>> =C2=A0 #=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >>> =C2=A0 # >>> @@ -46,6 +46,7 @@ [Components.common] >>> DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf >>> DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf >>> DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepoLib.i= nf >>> + >>> DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableL= ib.inf >>> >>> =C2=A0 [BuildOptions] >>> =C2=A0=C2=A0=C2=A0 *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFA= CES >>> diff --git a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h >>> b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h >>> new file mode 100644 >>> index >>> 0000000000000000000000000000000000000000..246d4d30ddf901640ea720c108e29= 71552ec6c96 >>> --- /dev/null >>> +++ b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h >>> @@ -0,0 +1,119 @@ >>> +/** @file >>> +=C2=A0 SMBIOS String Table Helper library. >>> + >>> +=C2=A0 Copyright (c) 2022, Arm Limited. All rights reserved.
>>> +=C2=A0 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 { >>> +=C2=A0 /// Length of the string (does not include the NULL termination= ) >>> +=C2=A0 UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Str= ingLen; >>> + >>> +=C2=A0 /// Reference to the string >>> +=C2=A0 CONST CHAR8=C2=A0=C2=A0=C2=A0 *String; >>> +} STRING_ELEMENT; >>> + >>> +/** A structure representing a string table. >>> +*/ >>> +typedef struct StringTable { >>> +=C2=A0 /// Count of strings in the table >>> +=C2=A0 UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 StrCount; >>> + >>> +=C2=A0 /// Total length of all strings in the table (does not include >>> +=C2=A0 // the NULL termination for each string) >>> +=C2=A0 UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 TotalStrLen; >>> + >>> +=C2=A0 /// Maximum string count >>> +=C2=A0 UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 MaxStringElements; >>> + >>> +=C2=A0 /// Pointer to the string table elements >>> +=C2=A0 STRING_ELEMENT=C2=A0=C2=A0=C2=A0 *Elements; >>> +} STRING_TABLE; >>> + >>> +/** Add a string to the string table >>> + >>> +=C2=A0 @param [IN]=C2=A0=C2=A0 StrTable=C2=A0 Pointer to the string ta= ble >>> +=C2=A0 @param [IN]=C2=A0=C2=A0 Str=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= Pointer to the string >>> +=C2=A0 @param [OUT]=C2=A0 StrRef=C2=A0=C2=A0=C2=A0 Optional pointer to= retrieve the string field >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 reference of the string in the string table >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to = add string >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableAddString ( >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE *CONS= T=C2=A0 StrTable, >>> +=C2=A0 IN=C2=A0 CONST CHAR8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Str, >>> +=C2=A0 OUT=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UINT8=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *S= trRef=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 OPTIONAL >>> +=C2=A0 ); >>> + >>> +/** Returns the total size required to publish the strings to the >>> SMBIOS >>> +=C2=A0=C2=A0=C2=A0 string area. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Pointer to the string table >>> + >>> +=C2=A0 @return Total size required to publish the strings in the SMBIO= S >>> string area. >>> +**/ >>> +UINTN >>> +EFIAPI >>> +StringTableGetStringSetSize ( >>> +=C2=A0 IN=C2=A0 STRING_TABLE *CONST=C2=A0 StrTable >>> +=C2=A0 ); >>> + >>> +/** Iterate through the string table and publish the strings in the >>> SMBIOS >>> +=C2=A0=C2=A0=C2=A0 string area. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Pointer to the string table >>> +=C2=A0 @param [IN] SmbiosStringAreaStart Start address of the SMBIOS >>> string area. >>> +=C2=A0 @param [IN] SmbiosStringAreaSize=C2=A0 Size of the SMBIOS strin= g area. >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to = publish strings >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTablePublishStringSet ( >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE=C2=A0= *CONST=C2=A0 StrTable, >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CHAR8=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *CONST=C2=A0 SmbiosStringAreaStart, >>> +=C2=A0 IN=C2=A0 CONST UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SmbiosStringAreaSize >>> +=C2=A0 ); >>> + >>> +/** Initialise the string table and allocate memory for the string >>> elements. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 Pointer to the string table >>> +=C2=A0 @param [IN] MaxStringElements=C2=A0 Maximum number of strings t= hat the >>> string >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 table can hold. >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_OUT_OF_RESOURCES=C2=A0=C2=A0 Failed to allocate mem= ory for >>> string elements >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableInitialize ( >>> +=C2=A0 IN STRING_TABLE *CONST=C2=A0 StrTable, >>> +=C2=A0 IN UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MaxStringElements >>> +=C2=A0 ); >>> + >>> +/** Free memory allocated for the string elements in the string table. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 Pointer to the string table >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r or >>> string elements >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableFree ( >>> +=C2=A0 IN STRING_TABLE *CONST=C2=A0 StrTable >>> +=C2=A0 ); >>> + >>> +#endif // SMBIOS_STRING_TABLE_H_ >>> diff --git >>> a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.c >>> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.c >>> >>> new file mode 100644 >>> index >>> 0000000000000000000000000000000000000000..bd186f27fe1613cf819b6600e6296= 0c003a796d6 >>> --- /dev/null >>> +++ >>> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.c >>> @@ -0,0 +1,227 @@ >>> +/** @file >>> +=C2=A0 SMBIOS String Table Helper >>> + >>> +=C2=A0 Copyright (c) 2022, Arm Limited. All rights reserved.
>>> + >>> +=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >>> + >>> +=C2=A0 @par Reference(s): >>> +=C2=A0 - DSP0134 - SMBIOS Specification Version 3.6.0, 2022-06-17 >>> +**/ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +/** Add a string to the string table >>> + >>> +=C2=A0 @param [IN]=C2=A0=C2=A0 StrTable=C2=A0 Pointer to the string ta= ble >>> +=C2=A0 @param [IN]=C2=A0=C2=A0 Str=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= Pointer to the string >>> +=C2=A0 @param [OUT]=C2=A0 StrRef=C2=A0=C2=A0=C2=A0 Optional pointer to= retrieve the string field >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 reference of the string in the string table >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to = add string >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableAddString ( >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE *CONS= T=C2=A0 StrTable, >>> +=C2=A0 IN=C2=A0 CONST CHAR8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Str, >>> +=C2=A0 OUT=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UINT8=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *S= trRef=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 OPTIONAL >>> +=C2=A0 ) >>> +{ >>> +=C2=A0 UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 StrLength; >>> +=C2=A0 STRING_ELEMENT=C2=A0 *StrElement; >>> + >>> +=C2=A0 if ((StrTable =3D=3D NULL) || (Str =3D=3D NULL)) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >>> +=C2=A0 } >>> + >>> +=C2=A0 if (StrTable->StrCount >=3D StrTable->MaxStringElements) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_BUFFER_TOO_SMALL; >>> +=C2=A0 } >>> + >>> +=C2=A0 StrLength =3D AsciiStrLen (Str); >>> +=C2=A0 if (StrLength =3D=3D 0) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >>> +=C2=A0 } >>> + >>> +=C2=A0 // Update the string element >>> +=C2=A0 StrElement=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D &StrTable->Elements[StrTable->StrCount]; >>> +=C2=A0 StrElement->StringLen =3D StrLength; >>> +=C2=A0 StrElement->String=C2=A0=C2=A0=C2=A0 =3D Str; >>> + >>> +=C2=A0 // Update String table information >>> +=C2=A0 StrTable->TotalStrLen +=3D StrLength; >>> +=C2=A0 StrTable->StrCount++; >>> + >>> +=C2=A0 // Return the index of the string in the string table if reques= ted >>> +=C2=A0 if (StrRef !=3D NULL) { >>> +=C2=A0=C2=A0=C2=A0 // Note: SMBIOS string field references start at 1.= So, return the >>> +=C2=A0=C2=A0=C2=A0 // StrCount as the string refrence after it is upda= ted. >>> +=C2=A0=C2=A0=C2=A0 *StrRef =3D StrTable->StrCount; >>> +=C2=A0 } >>> + >>> +=C2=A0 return EFI_SUCCESS; >>> +} >>> + >>> +/** Returns the total size required to publish the strings to the >>> SMBIOS >>> +=C2=A0=C2=A0=C2=A0 string area. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Pointer to the string table >>> + >>> +=C2=A0 @return Total size required to publish the strings in the SMBIO= S >>> string area. >>> +**/ >>> +UINTN >>> +EFIAPI >>> +StringTableGetStringSetSize ( >>> +=C2=A0 IN=C2=A0 STRING_TABLE *CONST=C2=A0 StrTable >>> +=C2=A0 ) >>> +{ >>> +=C2=A0 if (StrTable =3D=3D NULL) { >>> +=C2=A0=C2=A0=C2=A0 ASSERT (0); >>> +=C2=A0=C2=A0=C2=A0 return 0; >>> +=C2=A0 } >>> + >>> +=C2=A0 // See Section 6.1.3 Text strings, SMBIOS Specification Version= 3.6.0 >>> +=C2=A0 // - If the formatted portion of the structure contains >>> string-reference >>> +=C2=A0 //=C2=A0=C2=A0 fields and all the string fields are set to 0 (n= o string >>> references), >>> +=C2=A0 //=C2=A0=C2=A0 the formatted section of the structure is follow= ed by two >>> null (00h) >>> +=C2=A0 //=C2=A0=C2=A0 BYTES. >>> +=C2=A0 // - Each string is terminated with a null (00h) BYTE >>> +=C2=A0 // - and the set of strings is terminated with an additional nu= ll >>> (00h) BYTE. >>> + >>> +=C2=A0 // Therefore, if string count =3D 0, return 2 >>> +=C2=A0 // if string count > 0, the string set size =3D >>> +=C2=A0 // StrTable->TotalStrLen (total length of the strings in the >>> string table) >>> +=C2=A0 // + StrTable->StrCount (add string count to include '\0' for e= ach >>> string) >>> +=C2=A0 // +1 (an additional '\0' is required at the end of the string = set). >>> +=C2=A0 return (StrTable->StrCount =3D=3D 0) ? 2 : >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (StrTable->TotalStrLe= n + StrTable->StrCount + 1); >>> +} >>> + >>> +/** Iterate through the string table and publish the strings in the >>> SMBIOS >>> +=C2=A0=C2=A0=C2=A0 string area. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Pointer to the string table >>> +=C2=A0 @param [IN] SmbiosStringAreaStart Start address of the SMBIOS >>> string area. >>> +=C2=A0 @param [IN] SmbiosStringAreaSize=C2=A0 Size of the SMBIOS strin= g area. >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to = publish strings >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTablePublishStringSet ( >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE=C2=A0= *CONST=C2=A0 StrTable, >>> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CHAR8=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *CONST=C2=A0 SmbiosStringAreaStart, >>> +=C2=A0 IN=C2=A0 CONST UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SmbiosStringAreaSize >>> +=C2=A0 ) >>> +{ >>> +=C2=A0 UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 Index; >>> +=C2=A0 STRING_ELEMENT=C2=A0 *StrElement; >>> +=C2=A0 CHAR8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *SmbiosString; >>> +=C2=A0 UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 BytesRemaining; >>> +=C2=A0 UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 BytesCopied; >>> + >>> +=C2=A0 if ((StrTable =3D=3D NULL) || (SmbiosStringAreaStart =3D=3D NUL= L)) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >>> +=C2=A0 } >>> + >>> +=C2=A0 if (SmbiosStringAreaSize < StringTableGetStringSetSize (StrTabl= e)) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_BUFFER_TOO_SMALL; >>> +=C2=A0 } >>> + >>> +=C2=A0 SmbiosString=C2=A0=C2=A0 =3D SmbiosStringAreaStart; >>> +=C2=A0 BytesRemaining =3D SmbiosStringAreaSize; > [SAMI] SmbiosString points to the startof the sting storage area. >>> + >>> +=C2=A0 if (StrTable->StrCount =3D=3D 0) { >>> +=C2=A0=C2=A0=C2=A0 // See Section 6.1.3 Text strings, SMBIOS Specifica= tion Version >>> 3.6.0 >>> +=C2=A0=C2=A0=C2=A0 // If the formatted portion of the structure contai= ns >>> string-reference >>> +=C2=A0=C2=A0=C2=A0 // fields and all the string fields are set to 0 (n= o string >>> references), >>> +=C2=A0=C2=A0=C2=A0 // the formatted section of the structure is follow= ed by two >>> null (00h) >>> +=C2=A0=C2=A0=C2=A0 // BYTES. >>> +=C2=A0=C2=A0=C2=A0 *SmbiosString++ =3D '\0'; > [SAMI] Case 1: SmbiosString[0] is set to '\0' and the pointer is > incremented. So now it points to SmbiosString[1] which will be updated > with the String table null terminator before the function returns. >>> +=C2=A0 } else { >>> +=C2=A0=C2=A0=C2=A0 for (Index =3D 0; Index < StrTable->StrCount; Index= ++) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 StrElement =3D &StrTable->Elements[Inde= x]; >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 AsciiStrCpyS (SmbiosString, BytesRemain= ing, StrElement->String); >>> + >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // See Section 6.1.3 Text strings, SMBI= OS Specification >>> Version 3.6.0 >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // - Each string is terminated with a n= ull (00h) BYTE >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // Bytes Copied =3D String length + 1 f= or the string NULL >>> terminator. >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BytesCopied=C2=A0=C2=A0=C2=A0=C2=A0 =3D= StrElement->StringLen + 1; >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BytesRemaining -=3D BytesCopied; >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SmbiosString=C2=A0=C2=A0 +=3D BytesCopi= ed; > [SAMI] Case 2: AsciiStrCpyS() copies the string including the > terrminating null character and BytesCopied is incremented accordingly. > SmbiosString is then incremented by BytesCopied. So, SmbiosString should > point to the byte where the next string starts or will be updated with > the String table null terminator before the function returns. >>> +=C2=A0=C2=A0=C2=A0 } >>> +=C2=A0 } >>> + >>> +=C2=A0 // See Section 6.1.3 Text strings, SMBIOS Specification Version= 3.6.0 >>> +=C2=A0 // - the set of strings is terminated with an additional null >>> (00h) BYTE. >>> +=C2=A0 *SmbiosString =3D '\0'; >> [GM] Shouldn't you advance the SmbiosString pointer by one more ? >> After the loop isn't SmbiosString going to be at the NULL char of the >> last string ? And we're trying to add one more NULL character ? >> Should it be: >> SmbiosString++; > [SAMI] I don't think this increment is required for the reasons > explained above in Case 1 & Case 2. However, please let me know if I > have missed something. >> *SmbiosString =3D '\0'; >> [GM] Got it. Thanks for detail. Patch looks good to me, I've tested it as well. Thanks a lot. >> >>> +=C2=A0 return EFI_SUCCESS; >>> +} >>> + >>> +/** Initialise the string table and allocate memory for the string >>> elements. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 Pointer to the string table >>> +=C2=A0 @param [IN] MaxStringElements=C2=A0 Maximum number of strings t= hat the >>> string >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 table can hold. >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r >>> +=C2=A0 @return EFI_OUT_OF_RESOURCES=C2=A0=C2=A0 Failed to allocate mem= ory for >>> string elements >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableInitialize ( >>> +=C2=A0 IN STRING_TABLE *CONST=C2=A0 StrTable, >>> +=C2=A0 IN UINTN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MaxStringElements >>> +=C2=A0 ) >>> +{ >>> +=C2=A0 STRING_ELEMENT=C2=A0 *Elements; >>> + >>> +=C2=A0 if ((StrTable =3D=3D NULL) || (MaxStringElements > MAX_UINT8)) = { >>> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >>> +=C2=A0 } >>> + >>> +=C2=A0 ZeroMem (StrTable, sizeof (STRING_TABLE)); >>> + >>> +=C2=A0 Elements =3D (STRING_ELEMENT *)AllocateZeroPool ( >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof (STRING_ELEMENT) * >>> MaxStringElements >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >>> +=C2=A0 if (Elements =3D=3D NULL) { >>> +=C2=A0=C2=A0=C2=A0 return EFI_OUT_OF_RESOURCES; >>> +=C2=A0 } >>> + >>> +=C2=A0 StrTable->Elements=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 =3D Elements; >>> +=C2=A0 StrTable->MaxStringElements =3D (UINT8)MaxStringElements; >>> +=C2=A0 return EFI_SUCCESS; >>> +} >>> + >>> +/** Free memory allocated for the string elements in the string table. >>> + >>> +=C2=A0 @param [IN] StrTable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 Pointer to the string table >>> + >>> +=C2=A0 @return EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Success >>> +=C2=A0 @return EFI_INVALID_PARAMETER=C2=A0 Invalid string table pointe= r or >>> string elements >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +StringTableFree ( >>> +=C2=A0 IN STRING_TABLE *CONST=C2=A0 StrTable >>> +=C2=A0 ) >>> +{ >>> +=C2=A0 if ((StrTable =3D=3D NULL) || (StrTable->Elements =3D=3D NULL))= { >>> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >>> +=C2=A0 } >>> + >>> +=C2=A0 FreePool (StrTable->Elements); >>> +=C2=A0 ZeroMem (StrTable, sizeof (STRING_TABLE)); >>> +=C2=A0 return EFI_SUCCESS; >>> +} >>> diff --git >>> a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.inf >>> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.inf >>> >>> new file mode 100644 >>> index >>> 0000000000000000000000000000000000000000..88624c50e3f3e930074222b6d686f= 75485538b26 >>> --- /dev/null >>> +++ >>> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTabl= eLib.inf >>> @@ -0,0 +1,25 @@ >>> +## @file >>> +#=C2=A0 SMBIOS String Table Helper library. >>> +# >>> +#=C2=A0 Copyright (c) 2022, Arm Limited. All rights reserved. >>> +# >>> +#=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >>> +## >>> + >>> +[Defines] >>> +=C2=A0 INF_VERSION=C2=A0=C2=A0=C2=A0 =3D 0x0001001B >>> +=C2=A0 BASE_NAME=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D SmbiosStringTableLi= b >>> +=C2=A0 FILE_GUID=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 8C570DD8-531E-473F-= 85C6-9252746DBAC1 >>> +=C2=A0 VERSION_STRING =3D 1.0 >>> +=C2=A0 MODULE_TYPE=C2=A0=C2=A0=C2=A0 =3D DXE_DRIVER >>> +=C2=A0 LIBRARY_CLASS=C2=A0 =3D SmbiosStringTableLib >>> + >>> +[Sources] >>> +=C2=A0 SmbiosStringTableLib.c >>> + >>> +[Packages] >>> +=C2=A0 MdePkg/MdePkg.dec >>> +=C2=A0 DynamicTablesPkg/DynamicTablesPkg.dec >>> + >>> +[LibraryClasses] >>> +=C2=A0 BaseLib >>> --=20 >>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >>>