From f8d18bada5af6d1f89cfc3cd50580d590a641e50 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Sun, 21 Sep 2008 08:50:52 +0000 Subject: HiiLibGetCurrentLanguage returns the current UEFI variable "PlatformLang" (if this variable does not exist, a default value is returned). This function is called by HiiDatabase itself. Now, HiiLibGetCurrentLanguage is in HiiLib. Because of this, we can't add location of Hii protoocol in the library constructor of HiiLib. This cause Hii Database driver never get loaded (circular dependency). By moving HiiLibGetCurrentLanguage to UefiLib, library constructor (depex) can be added back to HiiLib to make sure the execution order is correct. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5938 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/UefiLib/UefiLib.c | 46 ++++++++++++++++++++++++++++++++ MdePkg/Library/UefiLib/UefiLib.inf | 7 ++++- MdePkg/Library/UefiLib/UefiLibInternal.h | 2 ++ 3 files changed, 54 insertions(+), 1 deletion(-) (limited to 'MdePkg/Library/UefiLib') diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c index a58878e5d3..1acccb0522 100644 --- a/MdePkg/Library/UefiLib/UefiLib.c +++ b/MdePkg/Library/UefiLib/UefiLib.c @@ -1221,4 +1221,50 @@ FreeUnicodeStringTable ( return EFI_SUCCESS; } +/** + 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/MdePkg/Library/UefiLib/UefiLib.inf b/MdePkg/Library/UefiLib/UefiLib.inf index b3006ab11e..04c61c83f1 100644 --- a/MdePkg/Library/UefiLib/UefiLib.inf +++ b/MdePkg/Library/UefiLib/UefiLib.inf @@ -53,7 +53,7 @@ BaseMemoryLib BaseLib UefiBootServicesTableLib - + UefiRuntimeServicesTableLib [Guids] gEfiEventReadyToBootGuid # ALWAYS_CONSUMED @@ -72,6 +72,7 @@ [Pcd.common] gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang [FeaturePcd.common] gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable @@ -79,3 +80,7 @@ gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable +[Guids] + gEfiGlobalVariableGuid + + diff --git a/MdePkg/Library/UefiLib/UefiLibInternal.h b/MdePkg/Library/UefiLib/UefiLibInternal.h index 886287f25d..ff575f69fc 100644 --- a/MdePkg/Library/UefiLib/UefiLibInternal.h +++ b/MdePkg/Library/UefiLib/UefiLibInternal.h @@ -26,8 +26,10 @@ #include #include +#include #include #include +#include #include #include #include -- cgit v1.2.3