From: "Abner Chang" <abner.chang@hpe.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"gaoliming@byosoft.com.cn" <gaoliming@byosoft.com.cn>
Cc: 'Dandan Bi' <dandan.bi@intel.com>,
'Eric Dong' <eric.dong@intel.com>,
"Wang, Nickle (HPS SW)" <nickle.wang@hpe.com>
Subject: Re: [edk2-devel] [PATCH v2 RESEND] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish
Date: Mon, 1 Feb 2021 04:01:02 +0000 [thread overview]
Message-ID: <CS1PR8401MB11441AFDCA2CF2610EDB174AFFB69@CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <000701d6f83f$97003690$c500a3b0$@byosoft.com.cn>
Thanks for catching this. V3 sent.
Abner
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> gaoliming
> Sent: Monday, February 1, 2021 10:12 AM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> <abner.chang@hpe.com>
> Cc: 'Dandan Bi' <dandan.bi@intel.com>; 'Eric Dong' <eric.dong@intel.com>;
> Wang, Nickle (HPS SW) <nickle.wang@hpe.com>
> Subject: 回复: [edk2-devel] [PATCH v2 RESEND] MdeModulePkg/Library:
> Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish
>
> Abner:
> I have two comments for this patch.
>
> 1. Please specify new ASSERT in the function header.
> 2. Please update the function description for the new behavior when
> TryBestLanguage is FALSE. HiiGetStringEx() function description should be
> different from HiiGetString().
>
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: bounce+27952+70832+4905953+8761045@groups.io
> > <bounce+27952+70832+4905953+8761045@groups.io> 代表 Abner Chang
> > 发送时间: 2021年1月28日 8:59
> > 收件人: devel@edk2.groups.io
> > 抄送: Dandan Bi <dandan.bi@intel.com>; Eric Dong <eric.dong@intel.com>;
> > Nickle Wang <nickle.wang@hpe.com>
> > 主题: [edk2-devel] [PATCH v2 RESEND] MdeModulePkg/Library: Add
> > HiiGetStringEx to UefiHiiLib for EDK2 Redfish
> >
> > 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 <jiaxin.wu@intel.com>
> > Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> > Signed-off-by: Fan Wang <fan.wang@intel.com>
> > Signed-off-by: Abner Chang <abner.chang@hpe.com>
> > Cc: Dandan Bi <dandan.bi@intel.com>
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Nickle Wang <nickle.wang@hpe.com>
> > ---
> > 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/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
> >
> > -Copyright (c) 2007 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> > +Copyright (c) 2007 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > @@ -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
> > + retrieved
> > 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 retrieved
> > 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
> > + );
> >
> > /**
> > 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.
> >
> > - Copyright (c) 2006 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> > + Copyright (c) 2006 - 2021, Intel Corporation. All rights
> > + reserved.<BR>
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > @@ -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
> > + retrieved
> > 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 retrieved
> > 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 (
> >
> > ASSERT (HiiHandle != NULL);
> > ASSERT (StringId != 0);
> > -
> > + //
> > + // Language must be specified if TryBestLanguage = FALSE.
> > + //
> > + ASSERT (!(TryBestLanguage == FALSE && Language == NULL));
> > //
> > // Initialize all allocated buffers to NULL
> > //
> > @@ -261,21 +303,26 @@ HiiGetString (
> > Language = "";
> > }
> >
> > - //
> > - // Get the best matching language from SupportedLanguages
> > - //
> > - BestLanguage = GetBestLanguage (
> > - SupportedLanguages,
> > - FALSE,
> > // RFC 4646 mode
> > - Language,
> > // Highest priority
> > - PlatformLanguage != NULL ? PlatformLanguage : "",
> > // Next highest priority
> > - SupportedLanguages,
> > // Lowest priority
> > - NULL
> > - );
> > - if (BestLanguage == NULL) {
> > - goto Error;
> > + if (TryBestLanguage) {
> > + //
> > + // Get the best matching language from SupportedLanguages
> > + //
> > + BestLanguage = GetBestLanguage (
> > + SupportedLanguages,
> > + FALSE,
> > // RFC 4646 mode
> > + Language,
> > // Highest priority
> > + PlatformLanguage != NULL ? PlatformLanguage :
> > "", // Next highest priority
> > + SupportedLanguages,
> > // Lowest priority
> > + NULL
> > + );
> > + if (BestLanguage == NULL) {
> > + goto Error;
> > + }
> > + } else {
> > + BestLanguage = (CHAR8 *) Language;
> > }
> >
> > +
> > //
> > // Retrieve the size of the string in the string package for the
> > BestLanguage
> > //
> > @@ -337,7 +384,7 @@ Error:
> > if (PlatformLanguage != NULL) {
> > FreePool (PlatformLanguage);
> > }
> > - if (BestLanguage != NULL) {
> > + if (TryBestLanguage && BestLanguage != NULL) {
> > FreePool (BestLanguage);
> > }
> >
> > --
> > 2.17.1
> >
> >
> >
> >
> >
>
>
>
>
>
>
>
prev parent reply other threads:[~2021-02-01 4:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 0:58 [PATCH v2 RESEND] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish Abner Chang
2021-02-01 2:11 ` 回复: [edk2-devel] " gaoliming
2021-02-01 4:01 ` Abner Chang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CS1PR8401MB11441AFDCA2CF2610EDB174AFFB69@CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox