mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
26af9aca92
commit
36384ceb64
|
@ -779,6 +779,44 @@ GetGuidFromStringName(
|
|||
return (EFI_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue