diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-08-10 01:10:05 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-08-10 01:10:05 +0000 |
commit | 36384ceb64c64b903495cd7bd462676f394f674a (patch) | |
tree | df37b5822feee08f04ffe258869823a342fa181e /ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | |
parent | 26af9aca92e11b77dbb9cf942d9dae92a71bfbbd (diff) | |
download | edk2-platforms-36384ceb64c64b903495cd7bd462676f394f674a.tar.xz |
Refine get default language logic for command "drivers".
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13603 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c')
-rw-r--r-- | ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 400b24046c..e9e3d8204d 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -780,6 +780,44 @@ GetGuidFromStringName( }
/**
+ Get best support language for this driver.
+
+ First base on the current platform used language to search,Second base on the
+ default language to search. The caller need to free the buffer of the best
+ language.
+
+ @param[in] SupportedLanguages The support languages for this driver.
+ @param[in] Iso639Language Whether get language for ISO639.
+
+ @return The best support language for this driver.
+**/
+CHAR8 *
+GetBestLanguageForDriver (
+ IN CONST CHAR8 *SupportedLanguages,
+ IN BOOLEAN Iso639Language
+ )
+{
+ CHAR8 *LanguageVariable;
+ CHAR8 *BestLanguage;
+
+ LanguageVariable = GetVariable (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid);
+
+ BestLanguage = GetBestLanguage(
+ SupportedLanguages,
+ Iso639Language,
+ (LanguageVariable != NULL) ? LanguageVariable : "",
+ Iso639Language ? "en" : "en-US",
+ NULL
+ );
+
+ if (LanguageVariable != NULL) {
+ FreePool (LanguageVariable);
+ }
+
+ return BestLanguage;
+}
+
+/**
Function to retrieve the driver name (if possible) from the ComponentName or
ComponentName2 protocol
@@ -799,6 +837,9 @@ GetStringNameFromHandle( EFI_COMPONENT_NAME2_PROTOCOL *CompNameStruct;
EFI_STATUS Status;
CHAR16 *RetVal;
+ CHAR8 *BestLang;
+
+ BestLang = NULL;
Status = gBS->OpenProtocol(
TheHandle,
@@ -808,7 +849,16 @@ GetStringNameFromHandle( NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
+ if (Language == NULL) {
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);
+ Language = BestLang;
+ }
Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);
+
+ if (BestLang != NULL) {
+ FreePool (BestLang);
+ BestLang = NULL;
+ }
if (!EFI_ERROR(Status)) {
return (RetVal);
}
@@ -821,7 +871,15 @@ GetStringNameFromHandle( NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
+ if (Language == NULL) {
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);
+ Language = BestLang;
+ }
Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);
+
+ if (BestLang != NULL) {
+ FreePool (BestLang);
+ }
if (!EFI_ERROR(Status)) {
return (RetVal);
}
|