From nobody Sat May 4 12:11:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70661+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70661+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1611288242; cv=none; d=zohomail.com; s=zohoarc; b=lijLSNtFVwfBbKPsJqYusIhm//DSvoBZvRQNLElLxfPfY1Vk7eN5aNXq7EasDbcOzuLVUvFP0c6wQ2gQ/w088BfcKcpTN6C1Ar8jguhtPckOGGKnrJ5wcHki13y2Z7CZ4ee0ohPtCSOjf8zzuF/CoKR0+VB1/n6IR7eovX8oB9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611288242; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=C3OS9bTx3OQ7LydvIk0WB+vgPmNFVzOH0Vo3pAFg9h4=; b=cSpZSxOqYZjOuXvXcxQoEy6AC8iRzj6To53vluvvqzLtsWEXMzl0wET7Umq1zoXnj5D/WjRD7LCbTmig+61kgz95mGOB5Qm2wj4ZFUdD9YjQPQMlhj3g2cz3VKy1wiXw63Nk2AWkhQ0z6ic5A+gwQ2s4jgce+VU55UjdhmgyVxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70661+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 161128824224097.06713955097052; Thu, 21 Jan 2021 20:04:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UXqCYY1788612xK9xasH3WoP; Thu, 21 Jan 2021 20:04:01 -0800 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.4415.1611288236327171020 for ; Thu, 21 Jan 2021 20:03:56 -0800 X-Received: from pps.filterd (m0134421.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10M3xBS0006234; Fri, 22 Jan 2021 04:03:55 GMT X-Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0b-002e3701.pphosted.com with ESMTP id 367jnx1nm2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jan 2021 04:03:55 +0000 X-Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g9t5009.houston.hpe.com (Postfix) with ESMTP id 766DA5B; Fri, 22 Jan 2021 04:03:54 +0000 (UTC) X-Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id 4334945; Fri, 22 Jan 2021 04:03:53 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Dandan Bi , Eric Dong , Nickle Wang Subject: [edk2-devel] [PATCH] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish Date: Fri, 22 Jan 2021 11:15:25 +0800 Message-Id: <20210122031525.30972-1-abner.chang@hpe.com> X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: IJSH1ojY8iZmgwxOiBuUJGjyx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611288241; bh=19yKOllqG/Fmj9EcooMY2FTxcZ/TKI35sZLtQ2A1nvs=; h=Cc:Date:From:Reply-To:Subject:To; b=UBOfOZCqrf2PWXzCIIcXYT/A+i2YUWKxkOqK91nPz9ELodeZ9XxgHtMKfN4ccTKtt0F f4oERUVLzNuO7aeE7T/G7Uyjf4cOwx5kegh9ONAeIEJkPrbc86OFUY8CSzVB8D/uZ3Ri+ yaxEpwB2gYaWhq4dAJKx9euVc6ZmnZVKx68= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add HiiGetStringEx and leveraged by HiiGetString function to support getting string with the best language in optionally. This avoids the string in x-uefi language is misled to the language defined by "PlatformLang" or the "Supported Languages". This change is introduced to support x-uefi keyword language for configuring BIOS setting. Signed-off-by: Jiaxin Wu Signed-off-by: Siyuan Fu Signed-off-by: Fan Wang Signed-off-by: Abner Chang Cc: Dandan Bi Cc: Eric Dong Cc: Nickle Wang --- MdeModulePkg/Include/Library/HiiLib.h | 41 +++++++++++- MdeModulePkg/Library/UefiHiiLib/HiiString.c | 73 ++++++++++++++++----- 2 files changed, 96 insertions(+), 18 deletions(-) diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/L= ibrary/HiiLib.h index c475cb74a1..66c654dcd3 100644 --- a/MdeModulePkg/Include/Library/HiiLib.h +++ b/MdeModulePkg/Include/Library/HiiLib.h @@ -1,7 +1,7 @@ /** @file Public include file for the HII Library =20 -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -152,8 +152,43 @@ HiiGetString ( IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL - ) -; + ); + +/** + Retrieves a string from a string package in a specific language. If the= language + is not specified, then a string from a string package in the current pla= tform + language is retrieved. If the string can not be retrieved using the spe= cified + language or the current platform language, then the string is retrieved = from + the string package in the first language the string package supports. T= he + returned string is allocated using AllocatePool(). The caller is respon= sible + for freeing the allocated buffer using FreePool(). + + If HiiHandle is NULL, then ASSERT(). + If StringId is 0, then ASSET. + + @param[in] HiiHandle A handle that was previously registered in= the HII Database. + @param[in] StringId The identifier of the string to retrieved = from the string + package associated with HiiHandle. + @param[in] Language The language of the string to retrieve. I= f this parameter + is NULL, then the current platform languag= e is used. The + format of Language must follow the languag= e format assumed + the HII Database. + @param[in] TryBestLanguage If TRUE, try to get the best matching lang= uage from all + supported languages. + + + @retval NULL The string specified by StringId is not present in the st= ring package. + @retval Other The string was returned. + +**/ +EFI_STRING +EFIAPI +HiiGetStringEx ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_STRING_ID StringId, + IN CONST CHAR8 *Language OPTIONAL, + IN BOOLEAN TryBestLanguage + ); =20 /** Retrieves a string from a string package named by GUID, in the specified= language. diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiString.c b/MdeModulePkg/Lib= rary/UefiHiiLib/HiiString.c index 95229f8a8c..f3c52ace56 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiString.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiString.c @@ -1,7 +1,7 @@ /** @file HII Library implementation that uses DXE protocols and services. =20 - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -220,6 +220,44 @@ HiiGetString ( IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL ) +{ + return HiiGetStringEx (HiiHandle, StringId, Language, TRUE); +} + +/** + Retrieves a string from a string package in a specific language. If the= language + is not specified, then a string from a string package in the current pla= tform + language is retrieved. If the string can not be retrieved using the spe= cified + language or the current platform language, then the string is retrieved = from + the string package in the first language the string package supports. T= he + returned string is allocated using AllocatePool(). The caller is respon= sible + for freeing the allocated buffer using FreePool(). + + If HiiHandle is NULL, then ASSERT(). + If StringId is 0, then ASSET. + + @param[in] HiiHandle A handle that was previously registered in= the HII Database. + @param[in] StringId The identifier of the string to retrieved = from the string + package associated with HiiHandle. + @param[in] Language The language of the string to retrieve. I= f this parameter + is NULL, then the current platform languag= e is used. The + format of Language must follow the languag= e format assumed + the HII Database. + @param[in] TryBestLanguage If TRUE, try to get the best matching lang= uage from all + supported languages. + + @retval NULL The string specified by StringId is not present in the st= ring package. + @retval Other The string was returned. + +**/ +EFI_STRING +EFIAPI +HiiGetStringEx ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_STRING_ID StringId, + IN CONST CHAR8 *Language OPTIONAL, + IN BOOLEAN TryBestLanguage + ) { EFI_STATUS Status; UINTN StringSize; @@ -261,21 +299,26 @@ HiiGetString ( Language =3D ""; } =20 - // - // Get the best matching language from SupportedLanguages - // - BestLanguage =3D GetBestLanguage ( - SupportedLanguages, - FALSE, // R= FC 4646 mode - Language, // H= ighest priority - PlatformLanguage !=3D NULL ? PlatformLanguage : "", //= Next highest priority - SupportedLanguages, // L= owest priority - NULL - ); - if (BestLanguage =3D=3D NULL) { - goto Error; + if (TryBestLanguage) { + // + // Get the best matching language from SupportedLanguages + // + BestLanguage =3D GetBestLanguage ( + SupportedLanguages, + FALSE, //= RFC 4646 mode + Language, //= Highest priority + PlatformLanguage !=3D NULL ? PlatformLanguage : "", = // Next highest priority + SupportedLanguages, //= Lowest priority + NULL + ); + if (BestLanguage =3D=3D NULL) { + goto Error; + } + } else { + BestLanguage =3D (CHAR8 *) Language; } =20 + // // Retrieve the size of the string in the string package for the BestLan= guage // @@ -337,7 +380,7 @@ Error: if (PlatformLanguage !=3D NULL) { FreePool (PlatformLanguage); } - if (BestLanguage !=3D NULL) { + if (TryBestLanguage && BestLanguage !=3D NULL) { FreePool (BestLanguage); } =20 --=20 2.17.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 (#70661): https://edk2.groups.io/g/devel/message/70661 Mute This Topic: https://groups.io/mt/80023228/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-