diff options
Diffstat (limited to 'ShellPkg/Library')
3 files changed, 71 insertions, 15 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);
}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c index 18912e8f07..1f7675b8b5 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c @@ -221,19 +221,17 @@ ShellCommandRunDrivers ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- ASSERT(Language == NULL);
- // Language = AllocateZeroPool(10);
- // AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
+ if (ShellCommandLineGetFlag(Package, L"-l")){
+ Lang = ShellCommandLineGetValue(Package, L"-l");
+ if (Lang != NULL) {
+ Language = AllocateZeroPool(StrSize(Lang));
+ AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
+ } else {
+ ASSERT(Language == NULL);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"-l");
+ ShellCommandLineFreeVarList (Package);
+ return (SHELL_INVALID_PARAMETER);
+ }
}
if (ShellCommandLineGetFlag(Package, L"-sfo")) {
@@ -261,7 +259,7 @@ ShellCommandRunDrivers ( DriverVersion = ReturnDriverVersion(*HandleWalker);
DriverConfig = ReturnDriverConfig(*HandleWalker);
DriverDiag = ReturnDriverDiag (*HandleWalker);
- Lang = GetStringNameFromHandle(*HandleWalker, Language==NULL?"en":Language);
+ Lang = GetStringNameFromHandle(*HandleWalker, Language);
ShellPrintEx(
-1,
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c index 0cb7840391..368948307e 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c @@ -99,7 +99,7 @@ TraverseHandleDatabase ( default: OpenTypeString = StringUnknown; break;
}
HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
- Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, "en");
+ Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
if (OpenInfo[OpenInfoIndex].ControllerHandle!=NULL) {
ShellPrintHiiEx(
-1,
|