From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.52]) by mx.groups.io with SMTP id smtpd.web11.8251.1664871402128157340 for ; Tue, 04 Oct 2022 01:16:43 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=PsV0MxHC; spf=pass (domain: arm.com, ip: 40.107.14.52, mailfrom: sami.mujawar@arm.com) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=erum1FyoFo7OywICOaZ961mYcXQozhYKMbzXi9YvK+YpGJFtQmL6z4oHlTYtazv0zJ5JXw2Rd+USdTIUuRZSWmbxPp3XNYssoPZdRQH1fJf+PVpd58e8CLX8HF71x8V2OfvuLaKX3HkS5LCsmYBcelxHny9iDjKNIadMdoGbwKKyibLZCF5h/Z/jMs+iWCdlxB7JDPqrqTEuCe/glvWvOvGqvOCG3POtny47Tea8AKBoFe4raDV0TsKtGCS1NoG7wyx+o/tkIfIKLKL89pA+4UZsTQM2QknHPZzMiUoZQzQn2e6FlxRthKo9dmlDQgXuPdMQ2So7jdJBX3Q81rQk2w== ARC-Message-Signature: i=2; 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=Kc0x9pcT8+grMhCFJBZNljonfHxlJizfARU9IA87OcI=; b=K9/OxP3OmbKG/fNHqm2qGh67Gci7/aEqAV9ivzHSEgdMQB0v/81PsH0ThaK2uTDy6ib7Rn1LahUvyg+OJf16YrWuWXB51DJ38UBAEgCg9hScIONNHjeSYfOA4vxSUVibN1vwyXLSC7wH7c/d64NfIgLVPaVVmhRlFv/E8IHVeMcM2O6f8k5CJxastb6IRtZs/0Uq7MKFRh6VW32CePglw7W1xJvXTxZl55NFdLhWqS+HtoM17trkagDFMSrx60ChnDs2xPiXdbMJFVVeKIpkM91c54QFpJ98gnRPA7cEYKA7piwbkvjr4+DAT1JasViuMHpaeJvfvNxNq0o5GwoLcg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kc0x9pcT8+grMhCFJBZNljonfHxlJizfARU9IA87OcI=; b=PsV0MxHCx9W/LPnUL+wHIPsxJAQeodI7rM8aXtWvFHme+qXx1JZ53M3Kj62QvEMl9fpcI8Qj1YLZyPQaLDi+6G9Koilwx0vMKJwsLP2qMLCUkxdPhSPlW5QBfI7a23I8KjGn7YDEJtp8938Q5B6QD400V0NQzM52PZLbJdhhTG0= Received: from AM6P194CA0084.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::25) by VE1PR08MB5567.eurprd08.prod.outlook.com (2603:10a6:800:1a7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Tue, 4 Oct 2022 08:16:33 +0000 Received: from AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::23) by AM6P194CA0084.outlook.office365.com (2603:10a6:209:8f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Tue, 4 Oct 2022 08:16:33 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT062.mail.protection.outlook.com (100.127.140.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Tue, 4 Oct 2022 08:16:33 +0000 Received: ("Tessian outbound ce981123c49d:v128"); Tue, 04 Oct 2022 08:16:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cb49221723a04b23 X-CR-MTA-TID: 64aa7808 Received: from 84d180bde7c2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5089FB2D-7928-434C-93EC-EE5E7C2634CA.1; Tue, 04 Oct 2022 08:16:33 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 84d180bde7c2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 04 Oct 2022 08:16:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OBcDwtP149L+PutVsxAhMOo5cFd+3MO26y/6nitkmwWLRyPZm2Kpb1qtAMJHngrqC9eMkEQDQWBaiVbOOb1BJFThK8Htw0ZdMO5Qr3tffwAt57/g/70FtdVuVSzv5HxuFV/yYnkLGhDCTPuUro+sLVSOyqtBCNkx90I00gNHKQeat14AfFl873QXzCaSYGT/oO1McI6+yF9hc2h8x9y+wn/WOGXI8g4YvjtNwzTEnXQLmOF91J3ZHVgKKwfVNmRLM/jjt5zS5AnNv8XYDvAv8NITqpfsgVa7ycS9clyzggEpjecF3aBJIgIX83/svCkAjdakzyue+1OetsLSRbW2KA== 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=Kc0x9pcT8+grMhCFJBZNljonfHxlJizfARU9IA87OcI=; b=YumUnVDFFoX8D3vmNL8F8nW5jPdNSoa9dsPWUYcXibG8IeAlqa5z+RnoGr1oSrK7mswMvoQEIb/N1u+PAJv7r9NZZEUZDav31dLn2f2rcO+FCyiSQ/C+1N2lEE0L0JBKyfSXzlZwQxWwJSGwVA1DvaO/QaN5if8iWlGI6ocNDh1XbtRVOg1bfIWjIRlZQqO7kascz1V1TU0ak01YJPnL70p3gbNx1Lme4adyA3lV75bhFzG1z4EgTO0s/OBo9jok25Lpl1uA6jiXKwu1A/nFjkBDcNl2HcaK3qtzu/xqYrPWYDh/iSSpxisYfeHF7O3h+SnMJoiBPLSYgKFeI5vnoA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kc0x9pcT8+grMhCFJBZNljonfHxlJizfARU9IA87OcI=; b=PsV0MxHCx9W/LPnUL+wHIPsxJAQeodI7rM8aXtWvFHme+qXx1JZ53M3Kj62QvEMl9fpcI8Qj1YLZyPQaLDi+6G9Koilwx0vMKJwsLP2qMLCUkxdPhSPlW5QBfI7a23I8KjGn7YDEJtp8938Q5B6QD400V0NQzM52PZLbJdhhTG0= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AS8PR08MB8419.eurprd08.prod.outlook.com (2603:10a6:20b:567::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Tue, 4 Oct 2022 08:16:22 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::283c:fe2e:699d:2bf]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::283c:fe2e:699d:2bf%4]) with mapi id 15.20.5676.031; Tue, 4 Oct 2022 08:16:21 +0000 Message-ID: Date: Tue, 4 Oct 2022 09:16:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v1 1/1] DynamicTablesPkg: Add SMBIOS String table helper library To: Girish Mahadevan , 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: "Sami Mujawar" In-Reply-To: <73ca18d0-1984-e428-2c2a-96244172e9f3@nvidia.com> X-ClientProxiedBy: LO2P265CA0040.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::28) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|AS8PR08MB8419:EE_|AM7EUR03FT062:EE_|VE1PR08MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: c4d902ce-220a-4758-43c2-08daa5e0bfcd 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: 9GESMnV5/furK6dWNVAvCY35ybSwqnZdjyAEvtropiupOCV46wt+4JVeyAzWUorAAKv41pRptkFCbmwTywDP/Vo3FPtHE6MFRYY1L9CKsxhWSAnQDDU/dkNBaBzXRJHgqEjwOtwBYla24+Lcthqp08G0Mv5x5kamodKDdTXg9Z7S8HrbkZ3fSZAh8uFdYnQ7GZIjSO/R+wyEnidWcR1KZir3rqxq526A0N32PG/TVFV+nfYsO0HZ/gHZ6UZdMqzI8jciRJra6S1CI4X4ANzzpWMyvR376CRZDaQJ9+Hrmu8EgbnCYFYm2BWjLpbF0LsFm6KZNgBElRacrrJfEmgYDnesgeyeg1Cp9jvOQUsJcBCnvpiWC5UNzgAFQEWdp4vx6AR4BBEWKeYn5ik2pLDMWuRopQZwHbzUX8wdu7xnfM+hONOhV5qy24iqnOhSps/kcQKMlL+OCKctQhcpJRnr8EM34SzW8xKJE+XcOdYaYlmW/rv6oIJfMZDfhJYaxcgSIdsTqnnlIbGMhc96pv3eOWPJaa0JJgrGiwf0h5/dkXWvJJyQcISPiQMKiav/wlxn2hDY1gVbzfpq/9OBtbZaYauMyiOk8PHIfKxaCoTE7TufxtLcFa95xucZ+U3P2uvqLHznvgdpefFAq9XBl9GPS/k+ROZxQOOjLO0dx555Aqs0P5LDnwu/C5vMaBOHQKGOLKWy/x37wnhxcJ+2LSXwY5pkv5uKBuR7n6kgEhjQTbF2pzNmz5cGMVBmonGzyyTpNDrlOqkMMXIPETEGTIMKFX8tiCcjN7tKUS4k5Yu9purey1Y2WuU/pmADpN7SivjhI8nRIvKcQ5TXAhP5JaYlsQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199015)(26005)(6512007)(8676002)(53546011)(66476007)(66556008)(6506007)(4326008)(19627235002)(478600001)(2616005)(36756003)(66946007)(966005)(6486002)(31696002)(38100700002)(86362001)(186003)(83380400001)(316002)(31686004)(44832011)(30864003)(8936002)(41300700001)(5660300002)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8419 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d07ecc79-24df-47a8-7f58-08daa5e0b846 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VQLgz5nmYxF7klAK8sIEbEq0hHjHY0LWgUW0NlFi7deWUpJt/eXb3IL9YkM//fXiFMgx8GzBqkC4AMPzOg+JSPXS3u7bip59fh9FVPd/hQTvMUsr5wn3/EPaO8cKsBikmd7mO8vNFCfSGOzz7DEwWxulihHXgapctNXjA+ESqPgmJ+zNKrMv5N1eEIXrWUO3JioI15oPpeEwaqyvMpd0qNfWjVOWy91337hqBjFHcvaalExKhGneNv1pyileh5Pawg5ELC+/U5XwQpcxbbEI2j82rUYUsUtvM6yPAE2fRuLn4ufz5lC0+Xgu58+rsX5+XBGeplhHeRVwSyLOF3Ghnhk132GSTyMFJ0W1p9rRy3KcWZffGn5SvSLAYbjsfGv3fVWpR4BIvvmv24ff6aAo9Ysra0suSrXO+35FwFWykRx2MAEF3aZn8k6LZ0yArW51I5OY6naayaN8oej9WYtk38STlKpzWLLKjRxY7gEZwVOcC3yM+XwrjVJn8HEAKkuKHsZIHik9atOdUyRyMiZtLMniUHlQSibmMrSXKhM80qvw25KHc5GebEkmU5Pid0NTkRQgc+79p31WLI7MxXx2msjmJ34FGV6o2NJQW1BDCmhiWHQdX4nU35zBEqStDVpfrhyX3LRg0/nnUwgbmuowOnBpaRtY0p7QynERaF96plCZqz8kR7kIxs3VArI9JBKPLh4A8FRw6yxWCNIn0LoE4aLgbfBPuOkbnhQM4ecxj4s3DjtY7RHQTlWeVGdejNCo/Tj3LB4eGB32F9dz6nabgLNVYW9y6xfeKiO7PoMSs5s= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(39850400004)(396003)(346002)(451199015)(46966006)(36840700001)(31686004)(4326008)(70586007)(36756003)(8936002)(5660300002)(6512007)(44832011)(8676002)(6486002)(316002)(478600001)(82310400005)(966005)(19627235002)(41300700001)(30864003)(86362001)(70206006)(31696002)(47076005)(6506007)(53546011)(2616005)(336012)(2906002)(83380400001)(40480700001)(26005)(186003)(82740400003)(356005)(36860700001)(81166007)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2022 08:16:33.4879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4d902ce-220a-4758-43c2-08daa5e0bfcd 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: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5567 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Girish, There are 2 cases that need handling. Please see my response inline=20 marked [SAMI]. Regards, Sami Mujawar 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 SMBIOS >> 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=20 >> 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 StringTableGetString= SetSize (&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://github.com/samimujawar/edk2/tree/2370_smbios_stringlib_v1 >> >> 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/SmbiosStringTableLi= b.c=20 >> | 227 ++++++++++++++++++++ >> DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableLi= b.inf=20 >> |=C2=A0 25 +++ >> =C2=A0 6 files changed, 379 insertions(+), 3 deletions(-) >> >> diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc=20 >> b/DynamicTablesPkg/DynamicTables.dsc.inc >> index=20 >> 3d4fa0c4c4b67d6770aee8705c80cc18d20c823a..d35acc1788f2ddc5e2b5fc3e4bedfd= 48251f7ec8=20 >> 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/Ss= dtPcieSupportLib.inf >> SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFix= upLib/SsdtSerialPortFixupLib.inf >> TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelpe= rLib.inf >> +=20 >> SmbiosStringTableLib|DynamicTablesPkg/Library/Common/SmbiosStringTableLi= b/SmbiosStringTableLib.inf >> >> =C2=A0 [Components.common] >> =C2=A0=C2=A0=C2=A0 # >> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec=20 >> b/DynamicTablesPkg/DynamicTablesPkg.dec >> index=20 >> cc34c2bdd6ff9b5ca508961b3d0fe85ffbb73c12..2a79cfd4edebbdff05bee66fa01a17= d68252e8a7=20 >> 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 help= er 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 { 0xd85a48= 35, 0x5a82,=20 >> 0x4894, { 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } } >> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc=20 >> b/DynamicTablesPkg/DynamicTablesPkg.dsc >> index=20 >> 07cc837552f587fe5bf9031e0061b0234e8698d4..bd5084a9008f040acdd16200ae8cdb= 23455ac101=20 >> 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.<= BR> >> -#=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.in= f >> +=20 >> DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableLi= b.inf >> >> =C2=A0 [BuildOptions] >> =C2=A0=C2=A0=C2=A0 *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFAC= ES >> diff --git a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h=20 >> b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h >> new file mode 100644 >> index=20 >> 0000000000000000000000000000000000000000..246d4d30ddf901640ea720c108e297= 1552ec6c96 >> --- /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 Stri= ngLen; >> + >> +=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 tab= le >> +=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 pointer >> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to a= dd string >> +**/ >> +EFI_STATUS >> +EFIAPI >> +StringTableAddString ( >> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE *CONST= =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=20 >> 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 SMBIOS= =20 >> 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=20 >> 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=20 >> string area. >> +=C2=A0 @param [IN] SmbiosStringAreaSize=C2=A0 Size of the SMBIOS string= 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 pointer >> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to p= ublish 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=20 >> 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 th= at the=20 >> 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 pointer >> +=C2=A0 @return EFI_OUT_OF_RESOURCES=C2=A0=C2=A0 Failed to allocate memo= ry for=20 >> 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 pointer= or=20 >> string elements >> +**/ >> +EFI_STATUS >> +EFIAPI >> +StringTableFree ( >> +=C2=A0 IN STRING_TABLE *CONST=C2=A0 StrTable >> +=C2=A0 ); >> + >> +#endif // SMBIOS_STRING_TABLE_H_ >> diff --git=20 >> a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.c=20 >> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.c=20 >> >> new file mode 100644 >> index=20 >> 0000000000000000000000000000000000000000..bd186f27fe1613cf819b6600e62960= c003a796d6 >> --- /dev/null >> +++=20 >> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.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 tab= le >> +=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 pointer >> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to a= dd string >> +**/ >> +EFI_STATUS >> +EFIAPI >> +StringTableAddString ( >> +=C2=A0 IN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 STRING_TABLE *CONST= =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 request= ed >> +=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 updat= ed. >> +=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=20 >> 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 SMBIOS= =20 >> 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=20 >> string-reference >> +=C2=A0 //=C2=A0=C2=A0 fields and all the string fields are set to 0 (no= string=20 >> references), >> +=C2=A0 //=C2=A0=C2=A0 the formatted section of the structure is followe= d by two=20 >> 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 nul= l=20 >> (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=20 >> string table) >> +=C2=A0 // + StrTable->StrCount (add string count to include '\0' for ea= ch=20 >> string) >> +=C2=A0 // +1 (an additional '\0' is required at the end of the string s= et). >> +=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->TotalStrLen= + StrTable->StrCount + 1); >> +} >> + >> +/** Iterate through the string table and publish the strings in the=20 >> 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=20 >> string area. >> +=C2=A0 @param [IN] SmbiosStringAreaSize=C2=A0 Size of the SMBIOS string= 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 pointer >> +=C2=A0 @return EFI_BUFFER_TOO_SMALL=C2=A0=C2=A0 Insufficient space to p= ublish 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 NULL= )) { >> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >> +=C2=A0 } >> + >> +=C2=A0 if (SmbiosStringAreaSize < StringTableGetStringSetSize (StrTable= )) { >> +=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 Specificat= ion Version=20 >> 3.6.0 >> +=C2=A0=C2=A0=C2=A0 // If the formatted portion of the structure contain= s=20 >> string-reference >> +=C2=A0=C2=A0=C2=A0 // fields and all the string fields are set to 0 (no= string=20 >> references), >> +=C2=A0=C2=A0=C2=A0 // the formatted section of the structure is followe= d by two=20 >> 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=20 incremented. So now it points to SmbiosString[1] which will be updated=20 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[Index= ]; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 AsciiStrCpyS (SmbiosString, BytesRemaini= ng, StrElement->String); >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // See Section 6.1.3 Text strings, SMBIO= S Specification=20 >> Version 3.6.0 >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // - Each string is terminated with a nu= ll (00h) BYTE >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // Bytes Copied =3D String length + 1 fo= r the string NULL=20 >> 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 BytesCopie= d; [SAMI] Case 2: AsciiStrCpyS() copies the string including the=20 terrminating null character and BytesCopied is incremented accordingly.=20 SmbiosString is then incremented by BytesCopied. So, SmbiosString should=20 point to the byte where the next string starts or will be updated with=20 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=20 >> (00h) BYTE. >> +=C2=A0 *SmbiosString =3D '\0'; > [GM] Shouldn't you advance the SmbiosString pointer by one more ?=20 > After the loop isn't SmbiosString going to be at the NULL char of the=20 > 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=20 explained above in Case 1 & Case 2. However, please let me know if I=20 have missed something. > *SmbiosString =3D '\0'; > > >> +=C2=A0 return EFI_SUCCESS; >> +} >> + >> +/** Initialise the string table and allocate memory for the string=20 >> 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 th= at the=20 >> 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 pointer >> +=C2=A0 @return EFI_OUT_OF_RESOURCES=C2=A0=C2=A0 Failed to allocate memo= ry for=20 >> 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) *= =20 >> 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 pointer= or=20 >> 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=20 >> a/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.inf=20 >> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.inf=20 >> >> new file mode 100644 >> index=20 >> 0000000000000000000000000000000000000000..88624c50e3f3e930074222b6d686f7= 5485538b26 >> --- /dev/null >> +++=20 >> b/DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTable= Lib.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 SmbiosStringTableLib >> +=C2=A0 FILE_GUID=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 8C570DD8-531E-473F-8= 5C6-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)' >>