From nobody Thu May 2 16:02:56 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+70832+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+70832+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1611798452; cv=none; d=zohomail.com; s=zohoarc; b=neBrUwu+oWILsedDPvHoQHxF0OM8hrzmf1hktJb3UTF2vJpRhEhqG1aCMsLWLtBm5rH2VsJewYY4ltS8eQSRq6fL8QuQj0znbFDHX6XikMGenkxSudu/gkVFeED/Yug0oSIbkB0vWXogUK30rH/+mXFFueaDs9GggderppO4CcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611798452; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=EtuAwzNA+bnZHhbq+aEidk1slxFuB2141OOkNF2eP/c=; b=YdnYNSJ874DuEItDBsAf9QkFHYVwZeR3VPXvlvsRf7lvsnzSVbETgROHKQXGd1eB+FgnBRXZ/bNFphz/p9sZk5T66ok4zXk3QH7f2OZZEtA4x4Ra1BdY1XBtXLI51ybbneDdtWq5OIXbJj96BYD5eErBXxusnEh1xQa2p4+7Qb4= 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+70832+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 1611798452580803.3478579359863; Wed, 27 Jan 2021 17:47:32 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HwKlYY1788612xkAcc0RrTaZ; Wed, 27 Jan 2021 17:47:32 -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.18488.1611798445912723195 for ; Wed, 27 Jan 2021 17:47:26 -0800 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10S1ccAK005965; Thu, 28 Jan 2021 01:47:25 GMT X-Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0a-002e3701.pphosted.com with ESMTP id 36b5wnedc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jan 2021 01:47:25 +0000 X-Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id B9185A3; Thu, 28 Jan 2021 01:47:24 +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 9E34F3A; Thu, 28 Jan 2021 01:47:23 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Dandan Bi , Eric Dong , Nickle Wang Subject: [edk2-devel] [PATCH v2 RESEND] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish Date: Thu, 28 Jan 2021 08:58:40 +0800 Message-Id: <20210128005840.1692-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: nbY2KqpOAjXAzg06A6pl4dKcx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611798452; bh=d1IpPGj3vL7BcNSEAgWus0mqMLMjpcb1Q8HrCrXqEUk=; h=Cc:Date:From:Reply-To:Subject:To; b=Pz01Xb7yivYD1UIkVOKeg/S40h4TfFHj/B+dbdTmEN59hfV+MmZjYAAi4hNz1+OMl7+ qiX87poQOUKv/5vnErKQomd4tGt7ERer2KZJ21bq6T96huJ5LORKH8+uuyNYncS0AYaoJ 81kzkGo2Sl8ym1jqNNO9QMmyyYtqeQCcCn0= 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 | 79 ++++++++++++++++----- 2 files changed, 101 insertions(+), 19 deletions(-) diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/L= ibrary/HiiLib.h index c475cb74a1..14dcc3b5b6 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.If FALSE, the Language= must be assigned + for the StringID. + + @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..2d6c9968ba 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,45 @@ 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.If FALSE, the Language= must be assigned + for the StringID. + + @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; @@ -231,7 +270,10 @@ HiiGetString ( =20 ASSERT (HiiHandle !=3D NULL); ASSERT (StringId !=3D 0); - + // + // Language must be specified if TryBestLanguage =3D FALSE. + // + ASSERT (!(TryBestLanguage =3D=3D FALSE && Language =3D=3D NULL)); // // Initialize all allocated buffers to NULL // @@ -261,21 +303,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 +384,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 (#70832): https://edk2.groups.io/g/devel/message/70832 Mute This Topic: https://groups.io/mt/80174343/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-