diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/Library/HiiLib.h index a92431ab4d..04601b9719 100644 --- a/MdeModulePkg/Include/Library/HiiLib.h +++ b/MdeModulePkg/Include/Library/HiiLib.h @@ -497,4 +497,26 @@ Rfc3066ToIso639 ( CHAR8 *SupportedLanguages ); + +/** + Determine what is the current language setting. The space reserved for Lang + must be at least RFC_3066_ENTRY_SIZE bytes; + + If Lang is NULL, then ASSERT. + + @param Lang Pointer of system language. Lang will always be filled with + a valid RFC 3066 language string. If "PlatformLang" is not + set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang + is returned. + + @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang. + @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang. + +**/ +EFI_STATUS +EFIAPI +GetCurrentLanguage ( + OUT CHAR8 *Lang + ); + #endif diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c b/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c index 147e5a3942..58817c1baf 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c @@ -204,3 +204,50 @@ HiiLibGetSupportedSecondaryLanguages ( } +/** + Determine what is the current language setting. The space reserved for Lang + must be at least RFC_3066_ENTRY_SIZE bytes; + + If Lang is NULL, then ASSERT. + + @param Lang Pointer of system language. Lang will always be filled with + a valid RFC 3066 language string. If "PlatformLang" is not + set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang + is returned. + + @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang. + @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang. + +**/ +EFI_STATUS +EFIAPI +GetCurrentLanguage ( + OUT CHAR8 *Lang + ) +{ + EFI_STATUS Status; + UINTN Size; + + ASSERT (Lang != NULL); + + // + // Get current language setting + // + Size = RFC_3066_ENTRY_SIZE; + Status = gRT->GetVariable ( + L"PlatformLang", + &gEfiGlobalVariableGuid, + NULL, + &Size, + Lang + ); + + if (EFI_ERROR (Status)) { + AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang)); + } + + return Status; +} + + + diff --git a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h b/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h index 18d168ec70..28c738fb06 100644 --- a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h +++ b/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -29,6 +31,8 @@ #include #include #include +#include +#include #define HII_LIB_DEFAULT_STRING_SIZE 0x200 diff --git a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf b/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf index f355d02f1b..08dc64a704 100644 --- a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf +++ b/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf @@ -48,12 +48,20 @@ UefiBootServicesTableLib DevicePathLib UefiLib + PcdLib + UefiRuntimeServicesTableLib [Protocols] gEfiHiiDatabaseProtocolGuid # ALWAYS_CONSUMED gEfiHiiStringProtocolGuid # ALWAYS_CONSUMED gEfiDevicePathProtocolGuid +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang + +[Guids] + gEfiGlobalVariableGuid + [Depex] gEfiHiiDatabaseProtocolGuid AND gEfiHiiStringProtocolGuid diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index 243c5ee9f5..c2917a9233 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -40,6 +40,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #define HII_DATABASE_NOTIFY_GUID \ { \ diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf index d64a3f22cb..6d2ce944a5 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -59,6 +59,7 @@ DebugLib IfrSupportLib UefiLib + HiiLib [Protocols] gEfiConsoleControlProtocolGuid