From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.28078.1612145507608636108 for ; Sun, 31 Jan 2021 18:11:49 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 01 Feb 2021 10:11:39 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Dandan Bi'" , "'Eric Dong'" , "'Nickle Wang'" References: <20210128005840.1692-1-abner.chang@hpe.com> In-Reply-To: <20210128005840.1692-1-abner.chang@hpe.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIHYyIFJFU0VORF0gTWRlTW9kdWxlUGtnL0xpYnJhcnk6IEFkZCBIaWlHZXRTdHJpbmdFeCB0byBVZWZpSGlpTGliIGZvciBFREsyIFJlZGZpc2g=?= Date: Mon, 1 Feb 2021 10:11:45 +0800 Message-ID: <000701d6f83f$97003690$c500a3b0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIbeFVlijVEkZ/+GOzdjTiy+eIdxqm5ixzQ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Abner: I have two comments for this patch.=20 1. Please specify new ASSERT in the function header.=20 2. Please update the function description for the new behavior when TryBestLanguage is FALSE. HiiGetStringEx() function description should be different from HiiGetString(). Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: bounce+27952+70832+4905953+8761045@groups.io > =B4=FA=B1=ED Abner Chang > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA1=D4=C228=C8=D5 8:59 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Dandan Bi ; Eric Dong ; > Nickle Wang > =D6=F7=CC=E2: [edk2-devel] [PATCH v2 RESEND] MdeModulePkg/Library: Add > HiiGetStringEx to UefiHiiLib for EDK2 Redfish >=20 > 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. >=20 > 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(-) >=20 > diff --git a/MdeModulePkg/Include/Library/HiiLib.h > b/MdeModulePkg/Include/Library/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 platform > + language is retrieved. If the string can not be retrieved using the > specified > + language or the current platform language, then the string is retriev= ed > from > + the string package in the first language the string package supports. The > + returned string is allocated using AllocatePool(). The caller is responsible > + 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 retriev= ed > from the string > + package associated with HiiHandle. > + @param[in] Language The language of the string to retrieve. > If this parameter > + is NULL, then the current platform > language is used. The > + format of Language must follow the > language format assumed > + the HII Database. > + @param[in] TryBestLanguage If TRUE, try to get the best matching > language 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 > string 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/Library/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 platform > + language is retrieved. If the string can not be retrieved using the > specified > + language or the current platform language, then the string is retriev= ed > from > + the string package in the first language the string package supports. The > + returned string is allocated using AllocatePool(). The caller is responsible > + 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 retriev= ed > from the string > + package associated with HiiHandle. > + @param[in] Language The language of the string to retrieve. > If this parameter > + is NULL, then the current platform > language is used. The > + format of Language must follow the > language format assumed > + the HII Database. > + @param[in] TryBestLanguage If TRUE, try to get the best matching > language 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 > string 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, > // RFC 4646 mode > - Language, > // Highest priority > - PlatformLanguage !=3D NULL ? PlatformLanguage : "", > // Next highest priority > - SupportedLanguages, > // Lowest 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 > BestLanguage > // > @@ -337,7 +384,7 @@ Error: > if (PlatformLanguage !=3D NULL) { > FreePool (PlatformLanguage); > } > - if (BestLanguage !=3D NULL) { > + if (TryBestLanguage && BestLanguage !=3D NULL) { > FreePool (BestLanguage); > } >=20 > -- > 2.17.1 >=20 >=20 >=20 >=20 >=20