summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2013-09-05 03:02:14 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2013-09-05 03:02:14 +0000
commita71003f2491a26b96b808064d35c8fd01d6422ed (patch)
treede9861440b48f2907654a7b15ba8805656fbd959 /ShellPkg
parentc683aa9cd1074135a1d22b11c0ca85631e9a7813 (diff)
downloadedk2-platforms-a71003f2491a26b96b808064d35c8fd01d6422ed.tar.xz
Refine the select language logic.
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14629 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c38
-rw-r--r--ShellPkg/Include/Library/HandleParsingLib.h23
-rw-r--r--ShellPkg/Library/UefiDpLib/DpUtilities.c3
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c32
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c19
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c41
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h1
7 files changed, 46 insertions, 111 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index e1aadb845d..89132969b6 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -645,8 +645,6 @@ EfiShellGetDeviceName(
UINTN LoopVar;
CHAR16 *DeviceNameToReturn;
CHAR8 *Lang;
- CHAR8 *TempChar;
-
UINTN ParentControllerCount;
EFI_HANDLE *ParentControllerBuffer;
UINTN ParentDriverCount;
@@ -703,23 +701,7 @@ EfiShellGetDeviceName(
if (EFI_ERROR(Status)) {
continue;
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetControllerName(CompName2, DeviceHandle, NULL, Lang, &DeviceNameToReturn);
FreePool(Lang);
Lang = NULL;
@@ -762,23 +744,7 @@ EfiShellGetDeviceName(
if (EFI_ERROR(Status)) {
continue;
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
FreePool(Lang);
Lang = NULL;
diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h
index 8c0b81d12c..c2e182bd9d 100644
--- a/ShellPkg/Include/Library/HandleParsingLib.h
+++ b/ShellPkg/Include/Library/HandleParsingLib.h
@@ -1,7 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -95,6 +95,27 @@ GetStringNameFromHandle(
IN CONST CHAR8 *Language
);
+/**
+ Get best support language for this driver.
+
+ First base on the user input language to search, second base on the current
+ platform used language to search, third get the first language from the
+ support language list. The caller need to free the buffer of the best language.
+
+ @param[in] SupportedLanguages The support languages for this driver.
+ @param[in] InputLanguage The user input language.
+ @param[in] Iso639Language Whether get language for ISO639.
+
+ @return The best support language for this driver.
+**/
+CHAR8 *
+EFIAPI
+GetBestLanguageForDriver (
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *InputLanguage,
+ IN BOOLEAN Iso639Language
+ );
+
#define HR_UNKNOWN 0
#define HR_IMAGE_HANDLE BIT1
#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding
diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/Library/UefiDpLib/DpUtilities.c
index 57c81288da..f7e17c252c 100644
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ b/ShellPkg/Library/UefiDpLib/DpUtilities.c
@@ -23,6 +23,7 @@
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Library/DevicePathLib.h>
+#include <Library/HandleParsingLib.h>
#include <Pi/PiFirmwareFile.h>
#include <Library/DxeServicesLib.h>
@@ -252,7 +253,7 @@ GetNameFromHandle (
//
// Get the current platform language setting
//
- GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL);
+ PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE);
Status = ComponentName2->GetDriverName (
ComponentName2,
PlatformLanguage != NULL ? PlatformLanguage : "en-US",
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 0c78d0da20..515fab3294 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -778,18 +778,21 @@ 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.
+ First base on the user input language to search, second base on the current
+ platform used language to search, third get the first language from the
+ support language list. The caller need to free the buffer of the best language.
@param[in] SupportedLanguages The support languages for this driver.
+ @param[in] InputLanguage The user input language.
@param[in] Iso639Language Whether get language for ISO639.
@return The best support language for this driver.
**/
CHAR8 *
+EFIAPI
GetBestLanguageForDriver (
- IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *InputLanguage,
IN BOOLEAN Iso639Language
)
{
@@ -801,8 +804,9 @@ GetBestLanguageForDriver (
BestLanguage = GetBestLanguage(
SupportedLanguages,
Iso639Language,
+ (InputLanguage != NULL) ? InputLanguage : "",
(LanguageVariable != NULL) ? LanguageVariable : "",
- Iso639Language ? "en" : "en-US",
+ SupportedLanguages,
NULL
);
@@ -845,12 +849,8 @@ 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);
-
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
+ Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
BestLang = NULL;
@@ -867,12 +867,8 @@ 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);
-
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
+ Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index bfbd8d76b0..1bb3191f41 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -60,7 +60,6 @@ GetDriverName (
)
{
CHAR8 *Lang;
- CHAR8 *TempChar;
EFI_STATUS Status;
EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
CHAR16 *NameToReturn;
@@ -87,23 +86,7 @@ GetDriverName (
if (EFI_ERROR(Status)) {
return (EFI_NOT_FOUND);
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetDriverName(CompName2, Lang, &NameToReturn);
FreePool(Lang);
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
index 986dc3a056..c3c1b575e8 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
@@ -1,7 +1,7 @@
/** @file
Main file for DrvDiag shell Driver1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -71,7 +71,6 @@ DoDiagnostics (
UINTN HandleIndex1;
UINTN HandleIndex2;
CHAR8 *Language;
- CHAR8 *TempChar;
BOOLEAN Found;
if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
@@ -180,24 +179,8 @@ DoDiagnostics (
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- if (Lang == NULL) {
- Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
- TempChar = AsciiStrStr(Language, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Language = AllocateZeroPool(AsciiStrSize(Lang));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, Lang);
- }
+ if (!EFI_ERROR(Status) && (DriverDiagnostics2 != NULL)) {
+ Language = GetBestLanguageForDriver(DriverDiagnostics2->SupportedLanguages, Lang, FALSE);
Found = TRUE;
Status = DriverDiagnostics2->RunDiagnostics(
DriverDiagnostics2,
@@ -220,23 +203,7 @@ DoDiagnostics (
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
- if (Lang == NULL) {
- Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
- TempChar = AsciiStrStr(Language, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Language = AllocateZeroPool(AsciiStrSize(Lang));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, Lang);
- }
+ Language = GetBestLanguageForDriver(DriverDiagnostics->SupportedLanguages, Lang, FALSE);
Status = DriverDiagnostics->RunDiagnostics(
DriverDiagnostics,
ControllerHandleList[ControllerHandleListLoop],
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
index 46ba8fdd8f..8962d32897 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
@@ -54,6 +54,7 @@
#include <Library/PrintLib.h>
#include <Library/HandleParsingLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/HandleParsingLib.h>
extern EFI_HANDLE gShellDriver1HiiHandle;