#include <Protocol/DevicePathToText.h>\r
#include <Protocol/DevicePath.h>\r
\r
-#include <Guid/GlobalVariable.h>\r
-\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/UefiLib.h>\r
#include <Library/ExtendedIfrSupportLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
#include <Library/DevicePathLib.h>\r
#include "PlatOverMngr.h"\r
\r
EFI_DEVICE_PATH_PROTOCOL *mControllerDevicePathProtocol[MAX_CHOICE_NUM];\r
UINTN mSelectedDriverImageNum;\r
UINTN mLastSavedDriverImageNum;\r
-CHAR8 mLanguage[RFC_3066_ENTRY_SIZE];\r
UINT16 mCurrentPage;\r
\r
/**\r
);\r
\r
/**\r
- Do string convertion for the ComponentName supported language. It do\r
- the convertion just for english language code from RFC 3066 to ISO 639-2.\r
- Then it will check whether the converted language is in the supported language list.\r
- If not supported, NULL is returned.\r
- If Language is not english, NULL is returned.\r
+ Worker function to get the driver name by ComponentName or ComponentName2 protocol \r
+ according to the driver binding handle.\r
\r
- @param SupportedLanguages Pointer to ComponentName supported language string list. ISO 639-2 language\r
- @param Language The language string. RFC 3066 language\r
+ @param DriverBindingHandle The Handle of DriverBinding.\r
+ @param ProtocolGuid The pointer to Component Name (2) protocol GUID.\r
+ @param VariableName The name of the RFC 4646 or ISO 639-2 language variable.\r
\r
- @return English language string (ISO 639-2)\r
- @return NULL if the conertion is not successful.\r
+ @retval !NULL Pointer into the image name if the image name is found,\r
+ @retval NULL Pointer to NULL if the image name is not found.\r
\r
**/\r
-CHAR8 *\r
-ConvertComponentNameSupportLanguage (\r
- IN CHAR8 *SupportedLanguages,\r
- IN CHAR8 *Language\r
+CHAR16 *\r
+GetComponentNameWorker (\r
+ IN EFI_HANDLE DriverBindingHandle,\r
+ IN EFI_GUID *ProtocolGuid,\r
+ IN CONST CHAR16 *VariableName\r
)\r
{\r
- CHAR8 *LangCode;\r
- LangCode = NULL;\r
+ EFI_STATUS Status;\r
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;\r
+ CHAR16 *DriverName;\r
+ CHAR8 *Language;\r
+ CHAR8 *BestLanguage;\r
\r
- //\r
- // Check the input language is English\r
- //\r
- if (AsciiStrnCmp (Language, "en-", 3) != 0) {\r
+ Status = gBS->OpenProtocol (\r
+ DriverBindingHandle,\r
+ ProtocolGuid,\r
+ (VOID *) &ComponentName,\r
+ NULL,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
- \r
+\r
//\r
- // Check SupportedLanguages format\r
+ // Find the best matching language.\r
//\r
- if (AsciiStrStr (SupportedLanguages, "en-") != NULL) {\r
- //\r
- // Create RFC 3066 language\r
- //\r
- LangCode = AllocateZeroPool(AsciiStrSize (Language));\r
- AsciiStrCpy (LangCode, Language);\r
- } else if (AsciiStrStr (SupportedLanguages, "en") != NULL) {\r
- //\r
- // Create ISO 639-2 Language\r
- //\r
- LangCode = AllocateZeroPool(4);\r
- AsciiStrCpy (LangCode, "eng"); \r
+ Language = GetEfiGlobalVariable (VariableName);\r
+ BestLanguage = GetBestLanguage (\r
+ ComponentName->SupportedLanguages,\r
+ (BOOLEAN) (ProtocolGuid == &gEfiComponentNameProtocolGuid),\r
+ Language,\r
+ NULL\r
+ );\r
+\r
+ DriverName = NULL;\r
+ if (BestLanguage != NULL) {\r
+ ComponentName->GetDriverName (\r
+ ComponentName,\r
+ BestLanguage,\r
+ &DriverName\r
+ );\r
+ FreePool (BestLanguage);\r
}\r
- \r
- return LangCode;\r
+\r
+ if (Language != NULL) {\r
+ FreePool (Language);\r
+ }\r
+\r
+ return DriverName;\r
}\r
\r
+\r
/**\r
Get the driver name by ComponentName or ComponentName2 protocol \r
according to the driver binding handle\r
IN EFI_HANDLE DriverBindingHandle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;\r
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;\r
- CHAR8 *SupportedLanguage;\r
- CHAR16 *DriverName;\r
-\r
- ComponentName = NULL;\r
- ComponentName2 = NULL;\r
- Status = gBS->OpenProtocol (\r
- DriverBindingHandle,\r
- &gEfiComponentName2ProtocolGuid,\r
- (VOID **) &ComponentName2,\r
- NULL,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR(Status)) {\r
- Status = gBS->OpenProtocol (\r
- DriverBindingHandle,\r
- &gEfiComponentNameProtocolGuid,\r
- (VOID **) &ComponentName,\r
- NULL,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- }\r
-\r
- Status = EFI_SUCCESS;\r
- DriverName = NULL;\r
- if (ComponentName != NULL) {\r
- if (ComponentName->GetDriverName != NULL) {\r
- SupportedLanguage = ConvertComponentNameSupportLanguage (ComponentName->SupportedLanguages, mLanguage);\r
- if (SupportedLanguage != NULL) {\r
- Status = ComponentName->GetDriverName (\r
- ComponentName,\r
- SupportedLanguage,\r
- &DriverName\r
- );\r
- FreePool (SupportedLanguage);\r
- }\r
- }\r
- } else if (ComponentName2 != NULL) {\r
- if (ComponentName2->GetDriverName != NULL) {\r
- Status = ComponentName2->GetDriverName (\r
- ComponentName2,\r
- mLanguage,\r
- &DriverName\r
- );\r
- }\r
- }\r
+ CHAR16 *DriverName;\r
\r
- if (EFI_ERROR (Status)) {\r
- return NULL;\r
+ //\r
+ // Try RFC 4646 Component Name 2 protocol first.\r
+ //\r
+ DriverName = GetComponentNameWorker (DriverBindingHandle, &gEfiComponentName2ProtocolGuid, L"PlatformLang");\r
+ if (DriverName == NULL) {\r
+ //\r
+ // If we can not get driver name from Component Name 2 protocol, we can try ISO 639-2 Component Name protocol. \r
+ //\r
+ DriverName = GetComponentNameWorker (DriverBindingHandle, &gEfiComponentNameProtocolGuid, L"Lang");\r
}\r
\r
return DriverName;\r
\r
/**\r
Get the image name from EFI UI section.\r
- Get FV protocol by its loaded image protoocl to abastract EFI UI section.\r
+ Get FV protocol by its loaded image protocol to abstract EFI UI section.\r
\r
@param Image Pointer to the loaded image protocol\r
\r
{\r
EFI_HII_UPDATE_DATA UpdateData;\r
EFI_STATUS Status;\r
- UINTN LangSize;\r
UINTN Index;\r
UINTN DevicePathHandleCount;\r
CHAR16 *NewString;\r
//\r
mCurrentPage = FORM_ID_DEVICE; \r
\r
- //\r
- // Get Platform supported Language (RFC_3066 format)\r
- //\r
- LangSize = RFC_3066_ENTRY_SIZE;\r
- Status = gRT->GetVariable (\r
- L"PlatformLang",\r
- &gEfiGlobalVariableGuid,\r
- NULL,\r
- &LangSize,\r
- mLanguage\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
//\r
// Initial the mapping database in memory\r
//\r