From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B8F87AC0868 for ; Wed, 27 Mar 2024 02:40:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ZRLmSEVx8zzUFCd3Zb7OmFmECnMiS/0m4h47XonPOI8=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1711507223; v=1; b=qVKZc46MTD2xu2dVyxI+Q1mMk42GaAiJPH20d/NeLdhY+gleEdTocXU8IjGgHSJfk8pFFSXH 54rQIdlsWK736h64RwjnpJ+M0MdWtxIi/GKrTxC3rtyZM463Hf4zbFhlf1ManOHVOKnApRcEWrF aSWr9i6iLmw7hSYZVdXyzoFHoQZiCJdnJ/FQCV3HQrK1WNxKdMgz+NeWlqCPbJlgATSqRWgLF0Y r6CM1j78Sghn2f+k231hwCu8QAd6fDmjpIzFbNeahaEwHMsla5viUVVCls/txbTakv/swEue6t+ GyFOTwSn4EcaZBtt8C3X5QTJRYh7qK4qGq4ph24l8rDSQ== X-Received: by 127.0.0.2 with SMTP id IStOYY7687511xJtd799S5pi; Tue, 26 Mar 2024 19:40:23 -0700 X-Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.105]) by mx.groups.io with SMTP id smtpd.web10.28549.1711507222320364916 for ; Tue, 26 Mar 2024 19:40:22 -0700 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by SJ2PR12MB8883.namprd12.prod.outlook.com (2603:10b6:a03:538::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Wed, 27 Mar 2024 02:40:17 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::fef9:2c9c:21b5:6f50]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::fef9:2c9c:21b5:6f50%2]) with mapi id 15.20.7409.031; Wed, 27 Mar 2024 02:40:17 +0000 From: "Nickle Wang via groups.io" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-devel] [PATCH V2 1/6] RedfishPkg/RedfishPlatformConfigDxe: Config language searching optimization Thread-Topic: [PATCH V2 1/6] RedfishPkg/RedfishPlatformConfigDxe: Config language searching optimization Thread-Index: AQHaf5B43FOsoNjhM0ygHBzoksV9xbFK4JEQ Date: Wed, 27 Mar 2024 02:40:17 +0000 Message-ID: References: <20240326151503.106-1-abner.chang@amd.com> <20240326151503.106-2-abner.chang@amd.com> In-Reply-To: <20240326151503.106-2-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|SJ2PR12MB8883:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: r0hLKPpjwWHYA+ZXoQv+Eg5UActpiJy7BdnsjGRFSTVROQT81RDjplrMyuVgsnxYXsXi+fi/QswX1lUCmOvwqezIFY1oPGxIHO6fnTjDZBGiZ7+6L27pj6pZYJLW2nvcN2P6TpQqTyjWupzlpdITPn89E3UjSy78+Vqjwz4kITInJT+IH5pKgbuPs2Bv+R8kXSgKyIYVPrBxiBu1+J5JIgw8LuRCb7yq/MJCDUVBi23sZZFp356esO4jmKOq8Dgii6z3pbNQjtIBN3pBQtG2NJK52p8oYcyzhrtARWvVnZSWBdQKYcnF4y7S/87WHMXfZat8jHUwCacXNYsybA6T5/8ROIwYSilCJMMCV0bn6r4SbUbirvQvWgDaqa3b5puqX3VZM6paq2HHMMHWfAjT0wHywDMUEN9EL2SRGCNclEheC+7BX9kbqaf4f3cgu9kEQWFaKYzzwDOHJvxE1uRRmiDkij5EPDOVppQEp5rAx7pBm9TMEfnyKq//U25bXRs4PPsYeZPXuFqNFxecJg7ZesnvS0tIKT2+bkc+q7iiMc155XOVoXTER7jptTiFH1E/nh6/4vzRejWOAxzkK0TRLWP0b6vI+jmfrwUDgOt3wa6TCNv723e1Hsu0zVArcqO8If5RbouBkAYH7n2KDzHqzCtErwuhcx4NKMhUUIk/hFc= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?W/sdZV82sjiGrZOa7GVsFod+V2YPEqqosAphmsjEJkbcZb0qQyvqWrOQlXBI?= =?us-ascii?Q?ARfeUPqb2trCOOHnC8iELRFRLWqWdajx224WSyVWPPoxXPQfke81zSTnTSrs?= =?us-ascii?Q?dREYVSCECObV+YcsQpgXOXINBXjTsIy95r1E7rEsZMoxSpC9KUEZbOj+Mtoe?= =?us-ascii?Q?HW+CXuS+4VcyQ0e4WL6YY/iy8E0H3MPT+my+AE/40AduNtDhI/+gK6RCeuKL?= =?us-ascii?Q?P0RzydCQWRnsruR184yPlK9QfzmWb3uyqeLlAeySqobnmEaDkt9nS6bKxg9j?= =?us-ascii?Q?EG8G/aJLxCNhamVd+8kP1Lo/eQbH6gY8vvCdb+k9lRuaNwAD3rD2wrOCgp6Z?= =?us-ascii?Q?DqHO7UhalY64v5mLT/8qh3gTaa4VDkxYgsoM1yTRWGIwh962KtwzPebA7YZj?= =?us-ascii?Q?s4y44PLrbw4TeePphsbrJHsdauWbEnrRE+SmB3ZCH7tNnIfpE0Oc+20t9cRa?= =?us-ascii?Q?QbbAuj1xDBUBPVEjxdACcI6lufOl/B9ZO3+BQwpIV49cv/E2z9lTWoKnZ3OJ?= =?us-ascii?Q?gX7gB9dAIDgwo+MAA8BxM/DjbuZHpNTwCAC6v217qD00wPeuw1qX74gr9OJm?= =?us-ascii?Q?foGQmclhu4qhGZry2xh7Ak0Cro//h8c1w4NIxPig+eSJYNeYmbBGG10JJRGH?= =?us-ascii?Q?wDZtVzijTUmhhj5Omvf/91AY2Qz30kolt1XonJIlTlXywGK+l9x5EU85+7jq?= =?us-ascii?Q?LnAYRGQdxNt9Of8aWnd8W5n/H42+mUb28IcebiINZEFaEWMr/kJAbEa3cwIg?= =?us-ascii?Q?KNtm0xURRVYuCUQCCRaW0qMPF7GBA4Q0zeHmWEPPgeHrubYjyyyjOQpojj3h?= =?us-ascii?Q?QlY8GNjAmNc4SgSoyZ5BrIeWOZn1k0zzAMMO9raCcPW6BWBn/5zDmBsxCqZY?= =?us-ascii?Q?lZIuZQmZdp+g7AO9tcq7PvIHHDeyOKq5uJxV8G0JZgLjnsvZsQG59OsVdUIG?= =?us-ascii?Q?lE61XNp9dyG/gpW9OQA/25mGQZCeGSOlj6f7paebSfSbiX1mqNYjlpoL8lmR?= =?us-ascii?Q?FlFo565nGQpeNJ++byRquj6YZ2J1U02BsH0Px9B+0bXyieyYtUz3XpYQGLnf?= =?us-ascii?Q?fG0u/GYKWHaSR1q1dW2mkr7PxKPJB1rC6MfuS1iSKhNcazZUNDWIU+7fTjCp?= =?us-ascii?Q?yy9fMxsJSKLc99m/e8GQT68DIKUGPJFJHJGYa78Urht2VdGFi0vXsoFq5r6R?= =?us-ascii?Q?GU4oXmvfQYBvNMtC4CObpcT2PtFhGIgO3cZ9/kUdkAIHQ7QPZQf59N80EqyO?= =?us-ascii?Q?JTzWiGehPCOLCj/hAJX10bV10irywpFJ9FU05b8XHavwyeRms+A74boWc/Nj?= =?us-ascii?Q?mwmPH2w7R7yRBQC/7GIrZXIY2tiEFT+2v3CEemJJlM5kvpkbLTtjy7Y7yvLv?= =?us-ascii?Q?HFYELtMl+jQo7TdADn8QL6T5QGO6uKKb5Ke+6da74fh/tUEDOxVr9c79BO1V?= =?us-ascii?Q?hMrwm1lE+w0SqQq3AdyLzyFBWTU87/Y4L0cIYuaGMReUiwfSTClNSa9JKgmh?= =?us-ascii?Q?17CDuHPhPCgdUQs8cWMp5iZN428M2nUZGaQN0UErgL3/GPbHF6y3Geei0VHB?= =?us-ascii?Q?3T0I4FGBDUQpdvfYw70=3D?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd58697d-f7ad-44b3-cfb7-08dc4e073cc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2024 02:40:17.0664 (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: oTcaW5dazlfLcNY6nAWP1gzBjNjDiPf1C1bgP2bBsjviVQ2SPlaNANFPcUiEac8udR4X5V2ku172YD+p8HcaWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8883 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 26 Mar 2024 19:40:22 -0700 Reply-To: devel@edk2.groups.io,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: o038NSNST4PrnkFOzZnTCIzcx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=qVKZc46M; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Abner, Could we change "DescriptionStr" below to something like "XuefiString", so = people don't think it is a regular English string of HII statement? > + EFI_STRING_ID Description; // String = token of this question. > + CHAR16 *DescriptionStr; // String = of this question. > + EFI_STRING_ID Help; // String = token of help message. Thanks, Nickle > -----Original Message----- > From: abner.chang@amd.com > Sent: Tuesday, March 26, 2024 11:15 PM > To: devel@edk2.groups.io > Cc: Nickle Wang ; Igor Kulchytskyy > Subject: [PATCH V2 1/6] RedfishPkg/RedfishPlatformConfigDxe: Config langu= age > searching optimization >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: abnchang >=20 > Build up the x-uefi-redfish string database for the Redfish confg languag= e > searching, instead of using HII String protocol. > This can improve the time consumption lot on searching strings. >=20 > Signed-off-by: Abner Chang > Co-authored-by: Nickle Wang > Cc: Igor Kulchytskyy > --- > .../RedfishPlatformConfigImpl.h | 107 ++- > .../RedfishPlatformConfigDxe.c | 23 +- > .../RedfishPlatformConfigImpl.c | 820 +++++++++++++++++- > 3 files changed, 878 insertions(+), 72 deletions(-) >=20 > diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImp= l.h > b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h > index 9f4312decf5..6e6c7fdb8a9 100644 > --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h > +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h > @@ -2,7 +2,8 @@ > This file defines the EDKII Redfish Platform Config Protocol private s= tructure. >=20 > (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> - Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights > + reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -30,6 +31,10 @@ > #define ENGLISH_LANGUAGE_CODE "en-US" > #define X_UEFI_SCHEMA_PREFIX "x-uefi-redfish-" >=20 > +#define MAX_X_UEFI_REDFISH_STRING_SIZE (128 * 2)// 128 character in UCS= . > + > +typedef struct _REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE > +REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE; > + > // > // Definition of REDFISH_PLATFORM_CONFIG_PRIVATE. > // > @@ -46,17 +51,49 @@ typedef struct { > CHAR8 **SchemaList; // Schema list > } REDFISH_PLATFORM_CONFIG_SCHEMA; >=20 > +// Defines the number of elements in array #define > +X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER 1024 > + > +// > +// Definition of x-uefi-redfish string element. > +// > +typedef struct { > + EFI_STRING_ID StringId; > + CHAR16 *UcsString; > +} REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT; > + > +// > +// Discrete string array buffer, each has > X_UEFI_REDFISH_STRING_ARRAY_NUMBER element. > +// > +typedef struct { > + LIST_ENTRY NextArray; > + REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT *ArrayEntryAddress; > +} REDFISH_X_UEFI_STRINGS_ARRAY; > + > +// > +// x-uefi-redfish string database, x-uefi-redfish language based. > +// > +typedef struct { > + LIST_ENTRY NextXuefiRedfishLanguage; = // Link to the > next suppoted x-uefi-Redfish language. > + CHAR8 *XuefiRedfishLanguage; = // x-uefi-redfish > language. > + UINTN StringsArrayBlocks; = // Number of the array > blocks that accommodate X_UEFI_REDFISH_STRING_ARRAY_NUMBER > + = // elements in each. > + LIST_ENTRY XuefiRedfishStringArrays; = // Link entry of x- > uefi-redfish string array. > +} REDFISH_X_UEFI_STRING_DATABASE; > + > // > // Definition of REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE > // > typedef struct { > LIST_ENTRY Link; > - HII_FORMSET *HiiFormSet; // Pointer to HII f= ormset data. > - EFI_GUID Guid; // Formset GUID. > - EFI_HII_HANDLE HiiHandle; // Hii Handle of th= is formset. > - LIST_ENTRY HiiFormList; // Form list that k= eep form data under > this formset. > - CHAR16 *DevicePathStr; // Device path of t= his formset. > - REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schema that is > supported in this formset. > + HII_FORMSET *HiiFormSet; // Point= er to HII formset data. > + EFI_GUID Guid; // Forms= et GUID. > + EFI_HII_HANDLE HiiHandle; // Hii H= andle of this formset. > + EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader; // Hii P= ackage > list header. > + LIST_ENTRY HiiFormList; // Form = list that keep form data > under this formset. > + CHAR16 *DevicePathStr; // Devic= e path of this formset. > + REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schem= a > that is supported in this formset. > + LIST_ENTRY XuefiRedfishStringDatabase; // x-uef= i-redfish > string/Id data base; > } REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE; >=20 > #define REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK(a) BASE_CR (a, > REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE, Link) @@ -90,19 +127,19 > @@ typedef struct { // // Definition of > REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE > // > -typedef struct { > +struct _REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE { > LIST_ENTRY Link; > REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *ParentForm; > - HII_STATEMENT *HiiStatement; // Pointer t= o HII statement > data. > - EFI_QUESTION_ID QuestionId; // Question = ID of this > statement. > - EFI_STRING_ID Description; // String to= ken of this question. > - EFI_STRING_ID Help; // String to= ken of help message. > - EFI_STRING DesStringCache; // The strin= g cache for search > function. > - UINT8 Flags; // The state= ment flag. > - REDFISH_PLATFORM_CONFIG_STATEMENT_DATA StatementData; // The > max/min for statement value. > - BOOLEAN Suppressed; // Statement= is suppressed. > - BOOLEAN GrayedOut; // Statement= is GrayedOut. > -} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE; > + HII_STATEMENT *HiiStatement; // Pointer= to HII statement > data. > + EFI_QUESTION_ID QuestionId; // Questio= n ID of this > statement. > + EFI_STRING_ID Description; // String = token of this question. > + CHAR16 *DescriptionStr; // String = of this question. > + EFI_STRING_ID Help; // String = token of help message. > + UINT8 Flags; // The sta= tement flag. > + REDFISH_PLATFORM_CONFIG_STATEMENT_DATA StatementData; // The > max/min for statement value. > + BOOLEAN Suppressed; // Stateme= nt is suppressed. > + BOOLEAN GrayedOut; // Stateme= nt is GrayedOut. > +}; >=20 > #define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a) BASE_CR (a, > REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link) >=20 > @@ -347,4 +384,38 @@ ReleaseStatementList ( > IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList > ); >=20 > +/** > + Return the HII string length. We don't check word alignment > + of the input string as the same as the checking in StrLen > + function. Because the HII string in the database is compact > + at the byte alignment. > + > + @param[in] String Input UCS format string. > + > + @retval Length of > + > +**/ > +UINTN > +EFIAPI > +HiiStrLen ( > + IN CONST CHAR16 *String > + ); > + > +/** > + Return the HII string size. We don't check word alignment > + of the input string as the same as the checking in StrLen > + function. Because the HII string in the database is compact > + at the byte alignment. > + > + @param[in] String Input UCS format string. > + > + @retval Size of the string. > + > +**/ > +UINTN > +EFIAPI > +HiiStrSize ( > + IN CONST CHAR16 *String > + ); > + > #endif > diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe= .c > b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c > index f970e317b3f..664b48eb50e 100644 > --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c > +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c > @@ -2,7 +2,8 @@ > The implementation of EDKII Redfish Platform Config Protocol. >=20 > (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> - Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights > + reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -928,6 +929,10 @@ HiiStringToOneOfOptionValue ( > Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); >=20 > TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentForm= set- > >HiiHandle, Schema, Option->Text); > + if (TmpString =3D=3D NULL) { > + TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentFo= rmset- > >HiiHandle, ENGLISH_LANGUAGE_CODE, Option->Text); > + } > + > if (TmpString !=3D NULL) { > if (StrCmp (TmpString, HiiString) =3D=3D 0) { > CopyMem (Value, &Option->Value, sizeof (HII_STATEMENT_VALUE)); @= @ - > 1227,6 +1232,10 @@ HiiStringToOrderedListOptionValue ( > Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); >=20 > TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentForm= set- > >HiiHandle, Schema, Option->Text); > + if (TmpString =3D=3D NULL) { > + TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentFo= rmset- > >HiiHandle, ENGLISH_LANGUAGE_CODE, Option->Text); > + } > + > if (TmpString !=3D NULL) { > if (StrCmp (TmpString, HiiString) =3D=3D 0) { > *Value =3D ExtendHiiValueToU64 (&Option->Value); @@ -1491,7 +150= 0,7 @@ > StrToAsciiStr ( > return NULL; > } >=20 > - StringLen =3D StrLen (UnicodeString) + 1; > + StringLen =3D HiiStrLen (UnicodeString) + 1; > Buffer =3D AllocatePool (StringLen * sizeof (CHAR8)); > if (Buffer =3D=3D NULL) { > return NULL; > @@ -2000,7 +2009,6 @@ RedfishPlatformConfigProtocolGetConfigureLang ( > REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST StatementList; > REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef; > LIST_ENTRY *NextLink; > - EFI_STRING TmpString; > EFI_STRING *TmpConfigureLangList; > UINTN Index; > CHAR8 *FullSchema; > @@ -2054,12 +2062,9 @@ RedfishPlatformConfigProtocolGetConfigureLang ( >=20 > ASSERT (StatementRef->Statement->Description !=3D 0); > if (StatementRef->Statement->Description !=3D 0) { > - TmpString =3D HiiGetRedfishString (StatementRef->Statement->Pare= ntForm- > >ParentFormset->HiiHandle, FullSchema, StatementRef->Statement- > >Description); > - ASSERT (TmpString !=3D NULL); > - if (TmpString !=3D NULL) { > - TmpConfigureLangList[Index] =3D TmpString; > - ++Index; > - } > + ASSERT (StatementRef->Statement->DescriptionStr !=3D NULL); > + TmpConfigureLangList[Index] =3D AllocateCopyPool (HiiStrSize (St= atementRef- > >Statement->DescriptionStr), (VOID *)StatementRef->Statement- > >DescriptionStr); > + ++Index; > } > } > } > diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImp= l.c > b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c > index 47d35abc088..8b1ddf4360a 100644 > --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c > +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c > @@ -3,6 +3,7 @@ >=20 > (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights > + reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -143,6 +144,88 @@ DumpFormsetList ( > return EFI_SUCCESS; > } >=20 > +/** > + Return the HII string length. We don't check word alignment > + of the input string as same as the checking in StrLen > + function, because the HII string in the database is compact > + at the byte alignment. > + > + @param[in] String Input UCS format string. > + > + @retval Length of the string. > + > +**/ > +UINTN > +EFIAPI > +HiiStrLen ( > + IN CONST CHAR16 *String > + ) > +{ > + UINTN Length; > + > + ASSERT (String !=3D NULL); > + > + for (Length =3D 0; *String !=3D L'\0'; String++, Length++) { } > + > + return Length; > +} > + > +/** > + Return the HII string size. We don't check word alignment > + of the input string as same as the checking in StrLen > + function, because the HII string in the database is compact > + at the byte alignment. > + > + @param[in] String Input UCS format string. > + > + @retval Size of the string. > + > +**/ > +UINTN > +EFIAPI > +HiiStrSize ( > + IN CONST CHAR16 *String > + ) > +{ > + return (HiiStrLen (String) + 1) * sizeof (*String); } > + > +/** > + Compare two HII strings. We don't check word alignment > + of the input string as same as the checking in StrLen > + function, because the HII string in the database is compact > + at the byte alignment. > + > + @param[in] FirstString Input UCS format of string to search. > + @param[in] SecondString Input UCS format of string to look for in > + FirstString; > + > + @retval 0 The strings are identical. > + !0 The strings are not identical. > + > +**/ > +INTN > +EFIAPI > +HiiStrCmp ( > + IN CONST CHAR16 *FirstString, > + IN CONST CHAR16 *SecondString > + ) > +{ > + // > + // ASSERT both strings are less long than > +PcdMaximumUnicodeStringLength > + // > + ASSERT (HiiStrSize (FirstString) !=3D 0); > + ASSERT (HiiStrSize (SecondString) !=3D 0); > + > + while ((*FirstString !=3D L'\0') && (*FirstString =3D=3D *SecondString= )) { > + FirstString++; > + SecondString++; > + } > + > + return *FirstString - *SecondString; > +} > + > /** > Delete a string from HII Package List by given HiiHandle. >=20 > @@ -301,28 +384,6 @@ HiiGetRedfishAsciiString ( > return AsciiString; > } >=20 > -/** > - Get string from HII database in English language. The returned string = is allocated > - using AllocatePool(). The caller is responsible for freeing the alloca= ted buffer > using > - FreePool(). > - > - @param[in] HiiHandle A handle that was previously registered = in the HII > Database. > - @param[in] StringId The identifier of the string to retrieve= d from the > string > - package associated with HiiHandle. > - > - @retval NULL The string specified by StringId is not present in the = string > package. > - @retval Other The string was returned. > - > -**/ > -EFI_STRING > -HiiGetEnglishString ( > - IN EFI_HII_HANDLE HiiHandle, > - IN EFI_STRING_ID StringId > - ) > -{ > - return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId= ); -} > - > /** > Get ASCII string from HII database in English language. The returned s= tring is > allocated > using AllocatePool(). The caller is responsible for freeing the alloca= ted buffer > using @@ -562,7 +623,7 @@ GetStatementPrivateByConfigureLangRegex ( > HiiStatementPrivate =3D > REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink); >=20 > if ((HiiStatementPrivate->Description !=3D 0) && !HiiStatementPr= ivate- > >Suppressed) { > - TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandl= e, Schema, > HiiStatementPrivate->Description); > + TmpString =3D HiiStatementPrivate->DescriptionStr; > if (TmpString !=3D NULL) { > Status =3D RegularExpressionProtocol->MatchString ( > RegularExpressionProto= col, @@ -592,8 +653,9 @@ > GetStatementPrivateByConfigureLangRegex ( > InsertTailList (&StatementList->StatementList, &StatementR= ef->Link); > ++StatementList->Count; > } > - > - FreePool (TmpString); > + } else { > + DEBUG ((DEBUG_ERROR, "%a: HiiStatementPrivate->DescriptionSt= r is > NULL, x-uefi-string has something wrong.\n", __func__)); > + ASSERT (FALSE); > } > } >=20 > @@ -676,14 +738,11 @@ GetStatementPrivateByConfigureLang ( > ); >=20 > if (HiiStatementPrivate->Description !=3D 0) { > - TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandl= e, Schema, > HiiStatementPrivate->Description); > + TmpString =3D HiiStatementPrivate->DescriptionStr; > if (TmpString !=3D NULL) { > - if (StrCmp (TmpString, ConfigureLang) =3D=3D 0) { > - FreePool (TmpString); > + if (HiiStrCmp (TmpString, ConfigureLang) =3D=3D 0) { > return HiiStatementPrivate; > } > - > - FreePool (TmpString); > } > } >=20 > @@ -741,10 +800,74 @@ GetFormsetPrivateByHiiHandle ( > return NULL; > } >=20 > +/** > + Release x-uefi-string related information. > + > + @param[in] FormsetPrivate Pointer to HII form-set private instanc= e. > + > + @retval EFI_STATUS > + > +**/ > +EFI_STATUS > +ReleaseXuefiStringDatabase ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate > + ) > +{ > + REDFISH_X_UEFI_STRING_DATABASE *ThisDatabase; > + REDFISH_X_UEFI_STRING_DATABASE *PreDatabase; > + REDFISH_X_UEFI_STRINGS_ARRAY *ThisStringArray; > + REDFISH_X_UEFI_STRINGS_ARRAY *PreStringArray; > + BOOLEAN EndDatabase; > + BOOLEAN EndArray; > + > + if (FormsetPrivate->HiiPackageListHeader !=3D NULL) { > + FreePool (FormsetPrivate->HiiPackageListHeader); > + } > + > + // Walk through x-uefi-redfish string database. > + if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { > + EndDatabase =3D FALSE; > + ThisDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode > (&FormsetPrivate->XuefiRedfishStringDatabase); > + while (!EndDatabase) { > + // Walk through string arrays. > + if (!IsListEmpty (&ThisDatabase->XuefiRedfishStringArrays)) { > + EndArray =3D FALSE; > + ThisStringArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode > (&ThisDatabase->XuefiRedfishStringArrays); > + while (!EndArray) { > + // Remove this array > + FreePool (ThisStringArray->ArrayEntryAddress); > + EndArray =3D IsNodeAtEnd (&ThisDatabase->XuefiRedfishStr= ingArrays, > &ThisStringArray->NextArray); > + PreStringArray =3D ThisStringArray; > + if (!EndArray) { > + ThisStringArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextN= ode > (&ThisDatabase->XuefiRedfishStringArrays, &ThisStringArray->NextArray); > + } > + > + RemoveEntryList (&PreStringArray->NextArray); > + FreePool (PreStringArray); > + } > + } > + > + // > + // Remove this database > + // > + EndDatabase =3D IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDa= tabase, > &ThisDatabase->NextXuefiRedfishLanguage); > + PreDatabase =3D ThisDatabase; > + if (!EndDatabase) { > + ThisDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode > (&FormsetPrivate->XuefiRedfishStringDatabase, &ThisDatabase- > >NextXuefiRedfishLanguage); > + } > + > + RemoveEntryList (&PreDatabase->NextXuefiRedfishLanguage); > + FreePool (PreDatabase); > + } > + } > + > + return EFI_SUCCESS; > +} > + > /** > Release formset and all the forms and statements that belong to this f= ormset. >=20 > - @param[in] FormsetPrivate Pointer to HP_HII_FORM_SET_PRIVATE > + @param[in] FormsetPrivate Pointer to HII form-set private instanc= e. >=20 > @retval EFI_STATUS >=20 > @@ -779,12 +902,6 @@ ReleaseFormset ( > // > // HiiStatementPrivate->HiiStatement will be released in DestroyFo= rmSet(). > // > - > - if (HiiStatementPrivate->DesStringCache !=3D NULL) { > - FreePool (HiiStatementPrivate->DesStringCache); > - HiiStatementPrivate->DesStringCache =3D NULL; > - } > - > RemoveEntryList (&HiiStatementPrivate->Link); > FreePool (HiiStatementPrivate); > HiiStatementLink =3D HiiNextStatementLink; @@ -821,6 +938,8 @@ > ReleaseFormset ( > FormsetPrivate->SupportedSchema.Count =3D 0; > } >=20 > + ReleaseXuefiStringDatabase (FormsetPrivate); > + > return EFI_SUCCESS; > } >=20 > @@ -846,17 +965,607 @@ NewFormsetPrivate ( > // Initial newly created formset private data. > // > InitializeListHead (&NewFormsetPrivate->HiiFormList); > + InitializeListHead (&NewFormsetPrivate->XuefiRedfishStringDatabase); >=20 > return NewFormsetPrivate; > } >=20 > +/** > + Create new x-uefi-redfish string array. > + > + @param[in] FormsetPrivate Pointer to HII form-set pr= ivate instance. > + @param[in] XuefiRedfishStringDatabase The x-uefi-redfish string = database. > + > + @retval EFI_OUT_OF_RESOURCES Not enough memory for creating a > new array. > + EFI_SUCCESS New array is created successfull= y. > + > +**/ > +EFI_STATUS > +NewRedfishXuefiStringArray ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatab= ase > + ) > +{ > + REDFISH_X_UEFI_STRINGS_ARRAY *ArrayAddress; > + > + // Initial first REDFISH_X_UEFI_STRINGS_ARRAY memory. > + ArrayAddress =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)AllocateZeroPool > + (sizeof (REDFISH_X_UEFI_STRINGS_ARRAY)); if (ArrayAddress =3D=3D NULL)= { > + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate > REDFISH_X_UEFI_STRINGS_ARRAY.\n", __func__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + InitializeListHead (&ArrayAddress->NextArray); > + > + // Allocate memory buffer for REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT > elements. > + ArrayAddress->ArrayEntryAddress =3D \ > + (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT *)AllocateZeroPool (sizeof > + (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT) * > + X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER); > + if (ArrayAddress->ArrayEntryAddress =3D=3D NULL) { > + FreePool (ArrayAddress); > + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate array for > REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENTs.\n", __func__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + XuefiRedfishStringDatabase->StringsArrayBlocks++; > + InsertTailList > +(&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, > +&ArrayAddress->NextArray); > + return EFI_SUCCESS; > +} > + > +/** > + Get the pointer of x-uefi-redfish database or create a new database. > + > + @param[in] FormsetPrivate Pointer to HII form-set privat= e instance. > + @param[in] HiiStringPackageHeader HII string package header. > + > + @retval Pointer to REDFISH_X_UEFI_STRING_DATABASE. > + If NULL, it fails to obtain x-uefi-redfish database. > + > +**/ > +REDFISH_X_UEFI_STRING_DATABASE * > +GetExitOrCreateXuefiStringDatabase ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader > + ) > +{ > + EFI_STATUS Status; > + BOOLEAN CreateNewOne; > + REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; > + > + DEBUG ((DEBUG_INFO, "%a: Entry\n", __func__)); > + > + CreateNewOne =3D TRUE; > + XuefiRedfishStringDatabase =3D NULL; > + if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { > + XuefiRedfishStringDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE > + *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase); > + > + while (TRUE) { > + if (AsciiStriCmp (XuefiRedfishStringDatabase->XuefiRedfishLanguage= , > HiiStringPackageHeader->Language) =3D=3D 0) { > + CreateNewOne =3D FALSE; > + break; > + } > + > + if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, > &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) { > + break; > + } > + > + XuefiRedfishStringDatabase =3D \ > + (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (&FormsetPrivate- > >XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase- > >NextXuefiRedfishLanguage); > + } > + } > + > + if (CreateNewOne) { > + DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, " Creating x-uefi-redfish > (%a) string database...\n", HiiStringPackageHeader->Language)); > + XuefiRedfishStringDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE > *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRING_DATABASE)); > + if (XuefiRedfishStringDatabase =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, " Failed to allocate > REDFISH_X_UEFI_STRING_DATABASE.\n")); > + return NULL; > + } > + > + InitializeListHead (&XuefiRedfishStringDatabase->NextXuefiRedfishLan= guage); > + InitializeListHead (&XuefiRedfishStringDatabase->XuefiRedfishStringA= rrays); > + XuefiRedfishStringDatabase->StringsArrayBlocks =3D 0; > + XuefiRedfishStringDatabase->XuefiRedfishLanguage =3D > + HiiStringPackageHeader->Language; > + > + Status =3D NewRedfishXuefiStringArray (FormsetPrivate, > XuefiRedfishStringDatabase); > + if (EFI_ERROR (Status)) { > + FreePool (XuefiRedfishStringDatabase); > + return NULL; > + } > + > + DEBUG (( > + REDFISH_PLATFORM_CONFIG_DEBUG, > + " x-uefi-redfish (%a):\n String array is added to > XuefiRedfishStringDatabase, total %d arrays now.\n", > + XuefiRedfishStringDatabase->XuefiRedfishLanguage, > + XuefiRedfishStringDatabase->StringsArrayBlocks > + )); > + > + // Link string database to FormsetPrivate. > + InsertTailList (&FormsetPrivate->XuefiRedfishStringDatabase, > + &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage); > + } > + > + return XuefiRedfishStringDatabase; > +} > + > +/** > + Check and allocate a new x-uefi-redfish array if it is insufficient > +for the > + newly added x-uefi-redfish string. > + > + @param[in] FormsetPrivate Pointer to HII form-set pr= ivate instance. > + @param[in] XuefiRedfishStringDatabase Pointer to the x-uefi-redf= ish > database. > + @param[in] StringId String ID added to databas= e. > + > + @retval EFI_SUCCESS The size of x-uefi-string = array is adjusted or > + is not required to be adju= sted. > + Otherwise, refer to the error code returned from > NewRedfishXuefiStringArray(). > + > +**/ > +EFI_STATUS > +RedfishXuefiStringAdjustArrays ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatab= ase, > + IN EFI_STRING_ID StringId > + ) > +{ > + EFI_STATUS Status; > + > + while (((StringId + X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) / > X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) > > (UINT16)XuefiRedfishStringDatabase->StringsArrayBlocks) { > + Status =3D NewRedfishXuefiStringArray (FormsetPrivate, > XuefiRedfishStringDatabase); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-uefi-string array", > __func__)); > + return Status; > + } > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + Insert a x-uefi-redfish string to database. > + > + @param[in] FormsetPrivate Pointer to HII form-set privat= e instance. > + @param[in] HiiStringPackageHeader Pointer to HII string package. > + @param[in] StringId The HII string ID > + @param[in] StringTextPtr Pointer to HII string text. > + > + @retval EFI_SUCCESS The HII string is added to dat= abase. > + EFI_LOAD_ERROR Something wrong when insert an= HII string > + to database. > + > +**/ > +EFI_STATUS > +RedfishXuefiStringInsertDatabase ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader, > + IN EFI_STRING_ID StringId, > + IN CHAR16 *StringTextPtr > + ) > +{ > + EFI_STATUS Status; > + UINTN StringIdOffset; > + REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; > + REDFISH_X_UEFI_STRINGS_ARRAY *ThisArray; > + > + XuefiRedfishStringDatabase =3D GetExitOrCreateXuefiStringDatabase > + (FormsetPrivate, HiiStringPackageHeader); if (XuefiRedfishStringDataba= se =3D=3D > NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to get > REDFISH_X_UEFI_STRING_DATABASE of x-uefi-redfish language %a.\n", > __func__, HiiStringPackageHeader->Language)); > + ReleaseXuefiStringDatabase (FormsetPrivate); > + return EFI_LOAD_ERROR; > + } > + > + Status =3D RedfishXuefiStringAdjustArrays (FormsetPrivate, > + XuefiRedfishStringDatabase, StringId); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-uefi-redfish string arr= ay.\n", > __func__)); > + return EFI_LOAD_ERROR; > + } > + > + // Insert string to x-uefi-redfish string array. > + StringIdOffset =3D (UINTN)StringId; > + ThisArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode > (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays); > + while (StringIdOffset >=3D X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) { > + ThisArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode > (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &ThisArray- > >NextArray); > + StringIdOffset -=3D X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER; > + } > + > + // Insert string > + (ThisArray->ArrayEntryAddress + StringIdOffset)->StringId =3D > + StringId; (ThisArray->ArrayEntryAddress + StringIdOffset)->UcsString > + =3D StringTextPtr; > + > + DEBUG (( > + REDFISH_PLATFORM_CONFIG_DEBUG, > + " Insert string ID: (%d) to database\n x-uefi-string: \"%s\"\n = Language: > %a.\n", > + StringId, > + StringTextPtr, > + HiiStringPackageHeader->Language > + )); > + return EFI_SUCCESS; > +} > + > +/** > + Get x-uefi-redfish string and language by string ID. > + > + @param[in] FormsetPrivate Pointer to HII form-set privat= e instance. > + @param[in] HiiStringPackageHeader HII string package header. > + > + @retval TRUE x-uefi-redfish string and ID map is inserted to databa= se. > + FALSE Something is wrong when insert x-uefi-redfish string a= nd ID map. > + > +**/ > +BOOLEAN > +CreateXuefiLanguageStringIdMap ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader > + ) > +{ > + EFI_STATUS Status; > + UINT8 *BlockHdr; > + EFI_STRING_ID CurrentStringId; > + UINTN BlockSize; > + UINTN Index; > + UINT8 *StringTextPtr; > + UINTN Offset; > + UINT16 StringCount; > + UINT16 SkipCount; > + UINT8 Length8; > + EFI_HII_SIBT_EXT2_BLOCK Ext2; > + UINT32 Length32; > + UINT8 *StringBlockInfo; > + > + // > + // Parse the string blocks to get the string text and font. > + // > + StringBlockInfo =3D (UINT8 *)((UINTN)HiiStringPackageHeader + > HiiStringPackageHeader->StringInfoOffset); > + BlockHdr =3D StringBlockInfo; > + BlockSize =3D 0; > + Offset =3D 0; > + CurrentStringId =3D 1; > + while (*BlockHdr !=3D EFI_HII_SIBT_END) { > + switch (*BlockHdr) { > + case EFI_HII_SIBT_STRING_SCSU: > + Offset =3D sizeof (EFI_HII_STRING_BLOCK); > + StringTextPtr =3D BlockHdr + Offset; > + BlockSize +=3D Offset + AsciiStrSize ((CHAR8 *)StringTextPtr)= ; > + CurrentStringId++; > + break; > + > + case EFI_HII_SIBT_STRING_SCSU_FONT: > + Offset =3D sizeof (EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK) -= sizeof > (UINT8); > + StringTextPtr =3D BlockHdr + Offset; > + BlockSize +=3D Offset + AsciiStrSize ((CHAR8 *)StringTextPtr)= ; > + CurrentStringId++; > + break; > + > + case EFI_HII_SIBT_STRINGS_SCSU: > + CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK),= sizeof > (UINT16)); > + StringTextPtr =3D (UINT8 *)((UINTN)BlockHdr + sizeof > (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8)); > + BlockSize +=3D StringTextPtr - BlockHdr; > + > + for (Index =3D 0; Index < StringCount; Index++) { > + BlockSize +=3D AsciiStrSize ((CHAR8 *)StringTextPtr); > + StringTextPtr =3D StringTextPtr + AsciiStrSize ((CHAR8 *)Strin= gTextPtr); > + CurrentStringId++; > + } > + > + break; > + > + case EFI_HII_SIBT_STRINGS_SCSU_FONT: > + CopyMem ( > + &StringCount, > + (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + si= zeof > (UINT8)), > + sizeof (UINT16) > + ); > + StringTextPtr =3D (UINT8 *)((UINTN)BlockHdr + sizeof > (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8)); > + BlockSize +=3D StringTextPtr - BlockHdr; > + > + for (Index =3D 0; Index < StringCount; Index++) { > + BlockSize +=3D AsciiStrSize ((CHAR8 *)StringTextPtr); > + StringTextPtr =3D StringTextPtr + AsciiStrSize ((CHAR8 *)Strin= gTextPtr); > + CurrentStringId++; > + } > + > + break; > + > + case EFI_HII_SIBT_STRING_UCS2: > + Offset =3D sizeof (EFI_HII_STRING_BLOCK); > + StringTextPtr =3D BlockHdr + Offset; > + > + // x-uefi-redfish string is always encoded as UCS and started wi= th '/'. > + if (*StringTextPtr =3D=3D (UINT16)'/') { > + Status =3D RedfishXuefiStringInsertDatabase ( > + FormsetPrivate, > + HiiStringPackageHeader, > + CurrentStringId, > + (CHAR16 *)StringTextPtr > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to insert x-uefi-redfish st= ring > %s.\n", __func__, StringTextPtr)); > + return FALSE; > + } > + } > + > + BlockSize +=3D (Offset + HiiStrSize ((CHAR16 *)StringTextPtr)); > + CurrentStringId++; > + break; > + > + case EFI_HII_SIBT_STRING_UCS2_FONT: > + Offset =3D sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) = - sizeof > (CHAR16); > + StringTextPtr =3D BlockHdr + Offset; > + BlockSize +=3D (Offset + HiiStrSize ((CHAR16 *)StringTextPtr)= ); > + CurrentStringId++; > + break; > + > + case EFI_HII_SIBT_STRINGS_UCS2: > + Offset =3D sizeof (EFI_HII_SIBT_STRINGS_UCS2_BLOCK) - siz= eof (CHAR16); > + StringTextPtr =3D BlockHdr + Offset; > + BlockSize +=3D Offset; > + CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK),= sizeof > (UINT16)); > + for (Index =3D 0; Index < StringCount; Index++) { > + BlockSize +=3D HiiStrSize ((CHAR16 *)StringTextPtr); > + StringTextPtr =3D StringTextPtr + HiiStrSize ((CHAR16 *)String= TextPtr); > + CurrentStringId++; > + } > + > + break; > + > + case EFI_HII_SIBT_STRINGS_UCS2_FONT: > + Offset =3D sizeof (EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK) = - sizeof > (CHAR16); > + StringTextPtr =3D BlockHdr + Offset; > + BlockSize +=3D Offset; > + CopyMem ( > + &StringCount, > + (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + si= zeof > (UINT8)), > + sizeof (UINT16) > + ); > + for (Index =3D 0; Index < StringCount; Index++) { > + BlockSize +=3D HiiStrSize ((CHAR16 *)StringTextPtr); > + StringTextPtr =3D StringTextPtr + HiiStrSize ((CHAR16 *)String= TextPtr); > + CurrentStringId++; > + } > + > + break; > + > + case EFI_HII_SIBT_DUPLICATE: > + BlockSize +=3D sizeof (EFI_HII_SIBT_DUPLICATE_BLOCK); > + CurrentStringId++; > + break; > + > + case EFI_HII_SIBT_SKIP1: > + SkipCount =3D (UINT16)(*(UINT8 *)((UINTN)BlockHdr + sizeof > (EFI_HII_STRING_BLOCK))); > + CurrentStringId =3D (UINT16)(CurrentStringId + SkipCount); > + BlockSize +=3D sizeof (EFI_HII_SIBT_SKIP1_BLOCK); > + break; > + > + case EFI_HII_SIBT_SKIP2: > + CopyMem (&SkipCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), s= izeof > (UINT16)); > + CurrentStringId =3D (UINT16)(CurrentStringId + SkipCount); > + BlockSize +=3D sizeof (EFI_HII_SIBT_SKIP2_BLOCK); > + break; > + > + case EFI_HII_SIBT_EXT1: > + CopyMem ( > + &Length8, > + (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + si= zeof > (UINT8)), > + sizeof (UINT8) > + ); > + BlockSize +=3D Length8; > + break; > + > + case EFI_HII_SIBT_EXT2: > + CopyMem (&Ext2, BlockHdr, sizeof (EFI_HII_SIBT_EXT2_BLOCK)); > + BlockSize +=3D Ext2.Length; > + break; > + > + case EFI_HII_SIBT_EXT4: > + CopyMem ( > + &Length32, > + (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + si= zeof > (UINT8)), > + sizeof (UINT32) > + ); > + > + BlockSize +=3D Length32; > + break; > + > + default: > + break; > + } > + > + BlockHdr =3D (UINT8 *)(StringBlockInfo + BlockSize); } > + > + return TRUE; > +} > + > +/** > + Get x-uefi-redfish string and language by string ID. > + > + @param[in] FormsetPrivate Pointer to HII form-set private i= nstance. > + @param[in] StringId The HII string ID. > + @param[out] String Optionally return USC string. > + @param[out] Language Optionally return x-uefi-redfish = language. > + @param[out] XuefiStringDatabase Optionally return x-uefi-redfish > database. > + > + @retval EFI_SUCCESS String information is returned. > + EFI_INVALID_PARAMETER One of the given parameters to this fu= nction is > + invalid. > + EFI_NOT_FOUND String is not found. > + > +**/ > +EFI_STATUS > +GetXuefiStringAndLangByStringId ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, > + IN EFI_STRING_ID StringId, > + OUT CHAR16 **String OPTIONAL, > + OUT CHAR8 **Language OPTIONAL, > + OUT REDFISH_X_UEFI_STRING_DATABASE **XuefiStringDatabase > OPTIONAL > + ) > +{ > + REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; > + REDFISH_X_UEFI_STRINGS_ARRAY *StringArray; > + UINT16 StringIndex; > + > + if ((String =3D=3D NULL) && (Language =3D=3D NULL) && (XuefiStringData= base =3D=3D NULL)) > { > + DEBUG ((DEBUG_ERROR, "%a: Invalid parameters for this function.\n", > __func__)); > + return EFI_INVALID_PARAMETER; > + } > + > + if (IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { > + return EFI_NOT_FOUND; > + } > + > + XuefiRedfishStringDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE > + *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase); > + while (TRUE) { > + if (Language !=3D NULL) { > + *Language =3D XuefiRedfishStringDatabase->XuefiRedfishLanguage; > + } > + > + StringArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode > + (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays); > + > + // Loop to the correct string array. > + StringIndex =3D StringId; > + while (StringIndex >=3D X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) { > + if (IsNodeAtEnd (&XuefiRedfishStringDatabase->XuefiRedfishStringAr= rays, > &StringArray->NextArray)) { > + goto ErrorEixt; > + } > + > + StringArray =3D (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode > (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &StringArray- > >NextArray); > + StringIndex -=3D X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER; > + } > + > + // > + // NOTE: The string ID in the formset is a unique number. > + // If the string in the array is NULL, then the matched string= ID > + // should be in another x-uefi-redfish database. > + // > + if ((StringArray->ArrayEntryAddress + StringIndex)->UcsString !=3D N= ULL) { > + // > + // String ID is belong to this x-uef-redfish language database. > + // > + if (String !=3D NULL) { > + *String =3D (StringArray->ArrayEntryAddress + StringIndex)->UcsS= tring; > + } > + > + if (XuefiStringDatabase !=3D NULL) { > + *XuefiStringDatabase =3D XuefiRedfishStringDatabase; > + } > + > + return EFI_SUCCESS; > + } > + > + if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, > &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) { > + return EFI_NOT_FOUND; > + } > + > + XuefiRedfishStringDatabase =3D (REDFISH_X_UEFI_STRING_DATABASE > *)GetNextNode ( > + &Fo= rmsetPrivate- > >XuefiRedfishStringDatabase, > + &Xu= efiRedfishStringDatabase- > >NextXuefiRedfishLanguage > + ); > + } > + > +ErrorEixt:; > + DEBUG ((DEBUG_ERROR, "%a: String ID (%d) is not in any x-uef-redfish > +string databases.\n", __func__, StringId)); > + return EFI_NOT_FOUND; > +} > + > +/** > + Build a x-uefi-redfish database for the newly added x-uefi-redfish lan= guage. > + > + @param[in] FormsetPrivate Pointer to HII form-set privat= e instance. > + > +**/ > +VOID > +BuildXUefiRedfishStringDatabase ( > + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate > + ) > +{ > + EFI_STATUS Status; > + UINTN BufferSize; > + EFI_HII_PACKAGE_HEADER *PackageHeader; > + UINTN EndingPackageAddress; > + EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader; > + UINTN SupportedSchemaLangCount; > + CHAR8 **SupportedSchemaLang; > + BOOLEAN StringIdMapIsBuilt; > + > + DEBUG ((DEBUG_INFO, "%a: Building x-uefi-redfish string database, HII > + Formset GUID - %g.\n", __func__, FormsetPrivate->Guid)); > + > + BufferSize =3D 0; > + Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->ExportPacka= geLists ( > + mRedfishPla= tformConfigPrivate->HiiDatabase, > + FormsetPriv= ate->HiiHandle, > + &BufferSize= , > + FormsetPriv= ate->HiiPackageListHeader > + ); if > + (Status !=3D EFI_BUFFER_TOO_SMALL) { > + DEBUG ((DEBUG_ERROR, " Failed to export package list.\n")); > + return; > + } > + > + FormsetPrivate->HiiPackageListHeader =3D (EFI_HII_PACKAGE_LIST_HEADER > + *)AllocateZeroPool (BufferSize); if (FormsetPrivate->HiiPackageListHea= der =3D=3D > NULL) { > + DEBUG ((DEBUG_ERROR, " Failed to allocate memory for the exported > package list.\n")); > + return; > + } > + > + Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->ExportPackageLi= sts ( > + mRedfishPlatfor= mConfigPrivate->HiiDatabase, > + FormsetPrivate-= >HiiHandle, > + &BufferSize, > + FormsetPrivate-= >HiiPackageListHeader > + ); if > + (EFI_ERROR (Status)) { > + return; > + } > + > + // > + // Finding the string package. > + // > + EndingPackageAddress =3D (UINTN)FormsetPrivate->HiiPackageListHeader + > FormsetPrivate->HiiPackageListHeader->PackageLength; > + PackageHeader =3D (EFI_HII_PACKAGE_HEADER *)(FormsetPrivate- > >HiiPackageListHeader + 1); > + SupportedSchemaLang =3D FormsetPrivate->SupportedSchema.SchemaList; > + while ((UINTN)PackageHeader < EndingPackageAddress) { > + switch (PackageHeader->Type) { > + case EFI_HII_PACKAGE_STRINGS: > + StringIdMapIsBuilt =3D FALSE; > + HiiStringPackageHeader =3D (EFI_HII_STRING_PACKAGE_HDR > + *)PackageHeader; > + > + // Check if this is the string package for x-uefi-redfish > + for (SupportedSchemaLangCount =3D 0; > + SupportedSchemaLangCount < FormsetPrivate- > >SupportedSchema.Count; > + SupportedSchemaLangCount++ > + ) > + { > + if (AsciiStrnCmp ( > + *(SupportedSchemaLang + SupportedSchemaLangCount), > + HiiStringPackageHeader->Language, > + AsciiStrLen (HiiStringPackageHeader->Language) > + ) =3D=3D 0) > + { > + StringIdMapIsBuilt =3D CreateXuefiLanguageStringIdMap (Forms= etPrivate, > HiiStringPackageHeader); > + break; > + } > + } > + > + if (StringIdMapIsBuilt =3D=3D FALSE) { > + if (AsciiStrStr (HiiStringPackageHeader->Language, > X_UEFI_SCHEMA_PREFIX) =3D=3D NULL) { > + DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, " No need to build x= - > uefi-redfish string ID map for HII language %a\n", HiiStringPackageHeader= - > >Language)); > + } else { > + DEBUG ((DEBUG_ERROR, " Failed to build x-uefi-redfish strin= g ID map of > HII language %a\n", HiiStringPackageHeader->Language)); > + } > + } > + > + default: > + PackageHeader =3D (EFI_HII_PACKAGE_HEADER *)((UINTN)PackageHeade= r + > PackageHeader->Length); > + } > + } > +} > + > /** > Load the HII formset from the given HII handle. >=20 > @param[in] HiiHandle Target HII handle to load. > @param[out] FormsetPrivate The formset private data. >=20 > - @retval EFI_STATUS > + @retval EFI_STATUS The formset is loaded successfully. > + @retval EFI_UNSUPPORTED This formset doesn't have any x-uefi-redfi= sh > configuration. >=20 > **/ > EFI_STATUS > @@ -875,6 +1584,7 @@ LoadFormset ( > REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; > EFI_GUID ZeroGuid; > EXPRESS_RESULT ExpressionResult; > + CHAR16 *String; >=20 > if ((HiiHandle =3D=3D NULL) || (FormsetPrivate =3D=3D NULL)) { > return EFI_INVALID_PARAMETER; > @@ -882,6 +1592,7 @@ LoadFormset ( >=20 > HiiFormSet =3D AllocateZeroPool (sizeof (HII_FORMSET)); > if (HiiFormSet =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: No memory resource for HII_FORMSET - > + %g\n", __func__, FormsetPrivate->Guid)); > return EFI_OUT_OF_RESOURCES; > } >=20 > @@ -891,6 +1602,7 @@ LoadFormset ( > ZeroMem (&ZeroGuid, sizeof (ZeroGuid)); > Status =3D CreateFormSetFromHiiHandle (HiiHandle, &ZeroGuid, HiiFormSe= t); > if (EFI_ERROR (Status) || IsListEmpty (&HiiFormSet->FormListHead)) { > + DEBUG ((DEBUG_ERROR, "%a: Formset not found by HII handle - %g\n", > + __func__, FormsetPrivate->Guid)); > Status =3D EFI_NOT_FOUND; > goto ErrorExit; > } > @@ -909,7 +1621,11 @@ LoadFormset ( > FormsetPrivate->DevicePathStr =3D ConvertDevicePathToText (HiiFormSet- > >DevicePath, FALSE, FALSE); > Status =3D GetSupportedSchema (FormsetPrivate->= HiiHandle, > &FormsetPrivate->SupportedSchema); > if (EFI_ERROR (Status)) { > - DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%a: No schema from HII > handle: 0x%x found: %r\n", __func__, FormsetPrivate->HiiHandle, Status)); > + DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%a: No x-uefi-redfish > configuration found on the formset - %g\n", __func__, FormsetPrivate->Gui= d)); > + return EFI_UNSUPPORTED; // Can't build AttributeRegistry Meni path w= ith > returning EFI_UNSUPPORTED. > + } else { > + // Building x-uefi-redfish string database > + BuildXUefiRedfishStringDatabase (FormsetPrivate); > } >=20 > HiiFormLink =3D GetFirstNode (&HiiFormSet->FormListHead); @@ -919,6 +1= 635,7 > @@ LoadFormset ( > HiiFormPrivate =3D AllocateZeroPool (sizeof > (REDFISH_PLATFORM_CONFIG_FORM_PRIVATE)); > if (HiiFormPrivate =3D=3D NULL) { > Status =3D EFI_OUT_OF_RESOURCES; > + DEBUG ((DEBUG_ERROR, "%a: No memory resource for > + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE.\n", __func__)); > goto ErrorExit; > } >=20 > @@ -944,6 +1661,7 @@ LoadFormset ( >=20 > HiiStatementPrivate =3D AllocateZeroPool (sizeof > (REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE)); > if (HiiStatementPrivate =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: No memory resource for > + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE.\n", __func__)); > Status =3D EFI_OUT_OF_RESOURCES; > goto ErrorExit; > } > @@ -981,10 +1699,18 @@ LoadFormset ( > } > } >=20 > - // > - // Attach to statement list. > - // > - InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPriva= te->Link); > + // Get x-uefi-redfish string using String ID. > + Status =3D GetXuefiStringAndLangByStringId (FormsetPrivate, > HiiStatementPrivate->Description, &String, NULL, NULL); > + if (!EFI_ERROR (Status)) { > + HiiStatementPrivate->DescriptionStr =3D String; > + // > + // Attach to statement list. > + // > + InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPri= vate- > >Link); > + } else { > + FreePool (HiiStatementPrivate); > + } > + > HiiStatementLink =3D GetNextNode (&HiiForm->StatementListHead, > HiiStatementLink); > } >=20 > @@ -1052,7 +1778,7 @@ LoadFormsetList ( > // > Status =3D LoadFormset (HiiHandle, FormsetPrivate); > if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "%a: failed to load formset: %r\n", __func__, > Status)); > + DEBUG ((DEBUG_ERROR, "%a: Formset is not loaded for edk2 redfish: > + %r\n", __func__, Status)); > FreePool (FormsetPrivate); > return Status; > } > @@ -1325,7 +2051,11 @@ ProcessPendingList ( >=20 > Status =3D LoadFormsetList (Target->HiiHandle, FormsetList); > if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "%a: load formset from HII handle: 0x%x fai= led: > %r\n", __func__, Target->HiiHandle, Status)); > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_ERROR, " The formset has no x-uefi-redfish > configurations.\n")); > + } else { > + DEBUG ((DEBUG_ERROR, " load formset from HII handle: 0x%x fai= led: > %r\n", Target->HiiHandle, Status)); > + } > } > } >=20 > -- > 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117145): https://edk2.groups.io/g/devel/message/117145 Mute This Topic: https://groups.io/mt/105159783/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-