From nobody Wed May 8 02:12:38 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+70826+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+70826+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1611759953; cv=none; d=zohomail.com; s=zohoarc; b=VfT42X+9G2QlaFEBfyfMzWpPoolC/hj3tl0GlC9lLSDeR0SplS3fkePByviQ5T8XPe5xE81aEaKNiZfP+0/qpGjiZ8hyLs5ZBrjEF755REDoixdGtGbaj2jDyVT4Bu1VKeGcud6ebMNzsyvfLbd3eAw757pozJnCit8xCbkZ5Hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611759953; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=zhvE7thJXaqVdOWSVNBMB/Ti6Uy4J2F7BpqR92Nzsqo=; b=ii0GwZ/5OiUw2Cr1Nl8uK1ybG9LkVfrLV/CU9EgT3JaCewr/cXlvOiyqDPHuCWtAY65ikBPA6eCKBQoDRRK2h2We89st9qqbjMznKmv58giwpE0oJ9Gz6jpXRywG+4UZvoXHWArafeTtj4KMmHggrc4UGiaPAW3HlkmpRfC2j3w= 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+70826+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 1611759953449976.7509302614577; Wed, 27 Jan 2021 07:05:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ki91YY1788612xHmneZV4xg9; Wed, 27 Jan 2021 07:05:53 -0800 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web08.8771.1611759950777085608 for ; Wed, 27 Jan 2021 07:05:51 -0800 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10REwvqH005361; Wed, 27 Jan 2021 15:05:49 GMT X-Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 36b20p4215-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jan 2021 15:05:49 +0000 X-Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 22EA189; Wed, 27 Jan 2021 15:05:49 +0000 (UTC) X-Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 0871737; Wed, 27 Jan 2021 15:05:47 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Dandan Bi , Eric Dong , Nickle Wang Subject: [edk2-devel] [PATCH v2] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish Date: Wed, 27 Jan 2021 22:17:06 +0800 Message-Id: <20210127141706.30267-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: 3LpQU5aWJATgTUG9sAhl4HQ6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611759953; bh=hEnpUCPcX9ob7QSD1Ewt6IXa3VP9dxW3JJQsVxe+0Ko=; h=Cc:Date:From:Reply-To:Subject:To; b=wHvJNMFagJvqjkhKQm0Y/znGcSzfsKeqZM12oacbxB/FzUs+MrW/7DSUW/O6SqkuNdh IiO8AA4kB7KNoUnWTeoZKy6A9n0Gdxl5ODX0OApHGnbm+/xutGGDd9ydUrbZccFsZGJlB hHFoul/oVdT7h05FzaecUaJQEV/uPN/u+hw= 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 (#70826): https://edk2.groups.io/g/devel/message/70826 Mute This Topic: https://groups.io/mt/80158955/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-