From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: solarflare.com, ip: 148.163.129.52, mailfrom: tpilar@solarflare.com) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by groups.io with SMTP; Mon, 02 Sep 2019 02:35:18 -0700 X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us2.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5648168005C; Mon, 2 Sep 2019 09:35:17 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 2 Sep 2019 10:35:11 +0100 Received: from ukex01.SolarFlarecom.com ([fe80::35fe:bff1:83ad:65d6]) by ukex01.SolarFlarecom.com ([fe80::35fe:bff1:83ad:65d6%14]) with mapi id 15.00.1395.000; Mon, 2 Sep 2019 10:35:11 +0100 From: "Tomas Pilar (tpilar)" To: Devel EDK2 , Tom Zhao , "liming.gao@intel.com" CC: "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Topic: [edk2-devel] [PATCH v2 1/1] MdePkg: UefiLib: Add a function to check if a language is supported Thread-Index: AQHVXybdKM1wahm9ZUSNWPo0Cd8nK6cXt8/ggABsNF4= Date: Mon, 2 Sep 2019 09:35:11 +0000 Message-ID: <1567416911221.25686@solarflare.com> References: <7fd22bc9-2a47-6e04-8541-fb73577f0cc0@solarflare.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E4F01CC@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4F01CC@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.17.20.51] x-tm-as-product-ver: SMEX-12.5.0.1300-8.5.1010-24884.003 x-tm-as-result: No-14.780700-8.000000-10 x-tmase-matchedrid: gjZGo2H/wj+8rRvefcjeTRvgzEPRJaDEWw/S0HB7eoMTiSW9r3PknBkX +si55c+xKJwGDRM+ng8RbKrXycDHEpcLewwAa76fKwKG2+GJYN0ftukM6FmmNpGJXR6jRFu4GJr 8wqQuXQNbATg3hG2hnKavMue2tPwaWL/SZmf7PbAnTBdLg83j/9GOcAfHKa6umFIIRNo/mvnZTA EszxrPVHgVNbMoKNzVkY2Fn4KiafHlqSNkc6xFsbxygpRxo469u8ZgmQ167rUN+F513KGyq/6RO KSr3u5/5yyJNwYSHNCcGzUbGeWF9ltFsD8r+sfMzNY33yIEF4a/m13BpxkSej2oN6UPe8wyU9a6 zfLFA1YIMldhYVnVvHDlPghqPnfyYlldA0POS1J1e7Xbb6Im2qxT+JfQDbCP7L2+zGEubN799l5 L+UMQBM+LbuzpUR1GyESByYJH5y8IVdJlj1AInlllim4HFeWA4Le00//0aGrzKmWRh0UD1WWj+T 4SrJuefS0Ip2eEHnzUHQeTVDUrIqHkM5YY92pZuRuWSuAIu/jdB/CxWTRRu92KvEVWmYr1HFtCU s5eCb0GgGGG+ZEIBIfMgtaig6gOwHAruDKzxZN/DZFVGLj2bw== x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No x-tmase-result: 10--14.780700-8.000000 x-tmase-version: SMEX-12.5.0.1300-8.5.1010-24884.003 MIME-Version: 1.0 X-MDID: 1567416918-5DhNHFfyLGrP Content-Language: en-GB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Liming, I think the very general idea is that UEFI spec requires language based Dr= iverModel protocol members to always check if the language is supported and return EFI_UNSUPPORTED ot= herwise. The procotols such as ComponentName2, DriverDiagnostics2, etc. usually also publish a me= mber string denoting=20 supported languages.=20 Therefore, a method that takes input language and checks against supported= languages is going to be quite popular in these functions. The refactor in UefiLib is merely incidental really. Cheers, (other) Tom ________________________________________ From: devel@edk2.groups.io on behalf of Liming Gao = Sent: 02 September 2019 04:13 To: Devel EDK2; Tom Zhao Cc: Kinney, Michael D Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg: UefiLib: Add a function t= o check if a language is supported Tom: New API IsLanguageSupported() only supports RFC 4646 language code for t= he Unicode string. If you think ISO 639-2 language code is obsolete, and don't plan to supp= ort it any longer. Please update IsLanguageSupported() function description to clarify this API fo= r RFC 4646 language code. And, I still want to know what other usage model for this new API IsLang= uageSupported(). For example, how UEFI HII driver consumes this API? If this API is only used in UefiL= ib, it can be the internal function in UefiLib library instance. Thanks Liming > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of To= m Zhao > Sent: Friday, August 30, 2019 7:34 PM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Kinney, Michael D > Subject: [edk2-devel] [PATCH v2 1/1] MdePkg: UefiLib: Add a function to = check if a language is supported > > BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2100 > > Add a function that checks if a target language is in the supported > languages list. Refactor UefiLib to use this function where appropriate > internally. > > Cc: Michael D Kinney > Cc: Liming Gao > Signed-off-by: Tom Zhao > --- > MdePkg/Include/Library/UefiLib.h | 16 ++++++ > MdePkg/Library/UefiLib/UefiLib.c | 59 +++++++++++++------- > 2 files changed, 54 insertions(+), 21 deletions(-) > > diff --git a/MdePkg/Include/Library/UefiLib.h > b/MdePkg/Include/Library/UefiLib.h > index 1650f30ddbc6..9dd170cbe2bf 100644 > --- a/MdePkg/Include/Library/UefiLib.h > +++ b/MdePkg/Include/Library/UefiLib.h > @@ -461,6 +461,22 @@ EfiTestChildHandle ( > IN CONST EFI_GUID *ProtocolGuid > ); > +/** > + * This function checks the supported languages list for a target langu= age > + * > + * @param SupportedLanguages The supported languages > + * @param TargetLanguage The target language > + * > + * @return Returns EFI_SUCCESS if the language is supported, > + * EFI_UNSUPPORTED otherwise > + */ > +EFI_STATUS > +EFIAPI > +IsLanguageSupported ( > + IN CONST CHAR8 *SupportedLanguages, > + IN CONST CHAR8 *TargetLanguage > + ); > + > /** > This function looks up a Unicode string in UnicodeStringTable. > diff --git a/MdePkg/Library/UefiLib/UefiLib.c > b/MdePkg/Library/UefiLib/UefiLib.c > index daa4af762e62..56281d25fd99 100644 > --- a/MdePkg/Library/UefiLib/UefiLib.c > +++ b/MdePkg/Library/UefiLib/UefiLib.c > @@ -640,6 +640,35 @@ EfiTestChildHandle ( > return Status; > } > +/** > + * This function checks the supported languages list for a target langu= age > + * > + * @param SupportedLanguages The supported languages > + * @param TargetLanguage The target language > + * > + * @return Returns EFI_SUCCESS if the language is supported, > + * EFI_UNSUPPORTED otherwise > + */ > +EFI_STATUS > +EFIAPI > +IsLanguageSupported ( > + IN CONST CHAR8 *SupportedLanguages, > + IN CONST CHAR8 *TargetLanguage > + ) > +{ > + UINTN Index; > + while (*SupportedLanguages !=3D 0) { > + for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && > SupportedLanguages[Index] !=3D ';'; Index++); > + if ((AsciiStrnCmp(SupportedLanguages, TargetLanguage, Index) =3D=3D= 0) > && (TargetLanguage[Index] =3D=3D 0)) { > + return EFI_SUCCESS; > + } > + SupportedLanguages +=3D Index; > + for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D ';'= ; > SupportedLanguages++); > + } > + > + return EFI_UNSUPPORTED; > +} > + > /** > This function looks up a Unicode string in UnicodeStringTable. > @@ -800,24 +829,19 @@ LookupUnicodeString2 ( > // Make sure Language is in the set of Supported Languages > // > Found =3D FALSE; > - while (*SupportedLanguages !=3D 0) { > - if (Iso639Language) { > + if (Iso639Language) { > + while (*SupportedLanguages !=3D 0) { > if (CompareIso639LanguageCode (Language, SupportedLanguages)) { > Found =3D TRUE; > break; > } > SupportedLanguages +=3D 3; > - } else { > - for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && > SupportedLanguages[Index] !=3D ';'; Index++); > - if ((AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) = && > (Language[Index] =3D=3D 0)) { > - Found =3D TRUE; > - break; > - } > - SupportedLanguages +=3D Index; > - for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D '= ;'; > SupportedLanguages++); > } > + } else { > + Found =3D !IsLanguageSupported(Language, SupportedLanguages); > } > + > // > // If Language is not a member of SupportedLanguages, then return > EFI_UNSUPPORTED > // > @@ -1099,24 +1123,17 @@ AddUnicodeString2 ( > // Make sure Language is a member of SupportedLanguages > // > Found =3D FALSE; > - while (*SupportedLanguages !=3D 0) { > - if (Iso639Language) { > + if (Iso639Language) { > + while (*SupportedLanguages !=3D 0) { > if (CompareIso639LanguageCode (Language, SupportedLanguages)) { > Found =3D TRUE; > break; > } > SupportedLanguages +=3D 3; > - } else { > - for (Index =3D 0; SupportedLanguages[Index] !=3D 0 && > SupportedLanguages[Index] !=3D ';'; Index++); > - if (AsciiStrnCmp(SupportedLanguages, Language, Index) =3D=3D 0) { > - Found =3D TRUE; > - break; > - } > - SupportedLanguages +=3D Index; > - for (; *SupportedLanguages !=3D 0 && *SupportedLanguages =3D=3D '= ;'; > SupportedLanguages++); > } > + } else { > + Found =3D !IsLanguageSupported(Language, SupportedLanguages); > } > - > // > // If Language is not a member of SupportedLanguages, then return > EFI_UNSUPPORTED > // > -- > 2.21.0 > > >