summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdePkg/Include/Library/HiiLib.h26
-rw-r--r--MdePkg/Include/Library/UefiLib.h28
-rw-r--r--MdePkg/Library/HiiLib/HiiLanguage.c50
-rw-r--r--MdePkg/Library/HiiLib/HiiLib.c44
-rw-r--r--MdePkg/Library/HiiLib/HiiLib.inf12
-rw-r--r--MdePkg/Library/HiiLib/HiiString.c2
-rw-r--r--MdePkg/Library/HiiLib/InternalHiiLib.h13
-rw-r--r--MdePkg/Library/UefiLib/UefiLib.c46
-rw-r--r--MdePkg/Library/UefiLib/UefiLib.inf7
-rw-r--r--MdePkg/Library/UefiLib/UefiLibInternal.h2
10 files changed, 108 insertions, 122 deletions
diff --git a/MdePkg/Include/Library/HiiLib.h b/MdePkg/Include/Library/HiiLib.h
index 59e1780a99..36fd8f602c 100644
--- a/MdePkg/Include/Library/HiiLib.h
+++ b/MdePkg/Include/Library/HiiLib.h
@@ -15,11 +15,6 @@
#ifndef __HII_LIB_H__
#define __HII_LIB_H__
-///
-/// Limited buffer size recommended by RFC3066
-/// (42 characters plus a NULL terminator)
-///
-#define RFC_3066_ENTRY_SIZE (42 + 1)
#define ISO_639_2_ENTRY_SIZE 3
@@ -289,27 +284,6 @@ HiiLibDevicePathToHiiHandle (
/**
- 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
-HiiLibGetCurrentLanguage (
- OUT CHAR8 *Lang
- );
-
-/**
Get next language from language code list (with separator ';').
If LangCode is NULL, then ASSERT.
diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
index 13ab258ebe..fa04704c33 100644
--- a/MdePkg/Include/Library/UefiLib.h
+++ b/MdePkg/Include/Library/UefiLib.h
@@ -23,6 +23,12 @@
#include <Protocol/DriverDiagnostics2.h>
///
+/// Limited buffer size recommended by RFC3066
+/// (42 characters plus a NULL terminator)
+///
+#define RFC_3066_ENTRY_SIZE (42 + 1)
+
+///
/// Unicode String Table
///
typedef struct {
@@ -986,4 +992,26 @@ EfiLibInstallAllDriverProtocols2 (
IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL
);
+/**
+ 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/MdePkg/Library/HiiLib/HiiLanguage.c b/MdePkg/Library/HiiLib/HiiLanguage.c
index 8c03bb993a..147e5a3942 100644
--- a/MdePkg/Library/HiiLib/HiiLanguage.c
+++ b/MdePkg/Library/HiiLib/HiiLanguage.c
@@ -16,52 +16,6 @@
#include "InternalHiiLib.h"
/**
- 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
-HiiLibGetCurrentLanguage (
- 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;
-}
-
-
-/**
Get next language from language code list (with separator ';').
If LangCode is NULL, then ASSERT.
@@ -136,8 +90,6 @@ HiiLibGetSupportedLanguages (
return NULL;
}
- LocateHiiProtocols ();
-
Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
@@ -232,8 +184,6 @@ HiiLibGetSupportedSecondaryLanguages (
return NULL;
}
- LocateHiiProtocols ();
-
Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
diff --git a/MdePkg/Library/HiiLib/HiiLib.c b/MdePkg/Library/HiiLib/HiiLib.c
index d5d6670405..cee31b20ae 100644
--- a/MdePkg/Library/HiiLib/HiiLib.c
+++ b/MdePkg/Library/HiiLib/HiiLib.c
@@ -18,29 +18,35 @@ CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabaseProt = NULL;
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProt = NULL;
/**
-
This function locate Hii relative protocols for later usage.
+
+ The constructor function caches the protocol pointer of HII Database Protocol
+ and Hii String Protocol.
+
+ It will ASSERT() if either of the protocol can't be located.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
-VOID
-LocateHiiProtocols (
- VOID
+EFI_STATUS
+EFIAPI
+HiiLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
- if (mHiiStringProt != NULL && mHiiDatabaseProt != NULL) {
- //
- // Only need to initialize the protocol instance once.
- //
- return;
- }
-
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabaseProt);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &mHiiStringProt);
ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
}
@@ -213,8 +219,6 @@ HiiLibAddPackages (
ASSERT (HiiHandle != NULL);
- LocateHiiProtocols ();
-
VA_START (Args, HiiHandle);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Args);
@@ -250,8 +254,6 @@ HiiLibRemovePackages (
EFI_STATUS Status;
ASSERT (IsHiiHandleRegistered (HiiHandle));
- LocateHiiProtocols ();
-
Status = mHiiDatabaseProt->RemovePackageList (mHiiDatabaseProt, HiiHandle);
ASSERT_EFI_ERROR (Status);
}
@@ -287,8 +289,6 @@ HiiLibGetHiiHandles (
BufferLength = 0;
- LocateHiiProtocols ();
-
//
// Try to find the actual buffer size for HiiHandle Buffer.
//
@@ -353,8 +353,6 @@ HiiLibExtractGuidFromHiiHandle (
BufferSize = 0;
HiiPackageList = NULL;
- LocateHiiProtocols ();
-
Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);
ASSERT (Status != EFI_NOT_FOUND);
@@ -450,8 +448,6 @@ HiiLibDevicePathToHiiHandle (
return NULL;
}
- LocateHiiProtocols ();
-
//
// Retrieve all Hii Handles from HII database
//
@@ -538,8 +534,6 @@ HiiLibExportPackageLists (
ASSERT (PackageListSize != NULL);
ASSERT (PackageListHeader != NULL);
- LocateHiiProtocols ();
-
if (Handle != NULL) {
ASSERT (IsHiiHandleRegistered (Handle));
}
@@ -597,8 +591,6 @@ HiiLibListPackageLists (
*HandleBufferLength = 0;
*HandleBuffer = NULL;
- LocateHiiProtocols ();
-
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
PackageType,
@@ -652,8 +644,6 @@ IsHiiHandleRegistered (
HiiPackageList = NULL;
BufferSize = 0;
- LocateHiiProtocols ();
-
Status = mHiiDatabaseProt->ExportPackageLists (
mHiiDatabaseProt,
HiiHandle,
diff --git a/MdePkg/Library/HiiLib/HiiLib.inf b/MdePkg/Library/HiiLib/HiiLib.inf
index 9713f32c7d..db3769a030 100644
--- a/MdePkg/Library/HiiLib/HiiLib.inf
+++ b/MdePkg/Library/HiiLib/HiiLib.inf
@@ -24,6 +24,8 @@
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
+ CONSTRUCTOR = HiiLibConstructor
+
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
@@ -46,14 +48,14 @@
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
DevicePathLib
+ UefiLib
[Protocols]
gEfiHiiDatabaseProtocolGuid # ALWAYS_CONSUMED
gEfiHiiStringProtocolGuid # ALWAYS_CONSUMED
gEfiDevicePathProtocolGuid
-
-[Guids]
- gEfiGlobalVariableGuid
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
+[Depex]
+ gEfiHiiDatabaseProtocolGuid AND
+ gEfiHiiStringProtocolGuid
+
diff --git a/MdePkg/Library/HiiLib/HiiString.c b/MdePkg/Library/HiiLib/HiiString.c
index ed816c1b3b..fbeb2dbdb6 100644
--- a/MdePkg/Library/HiiLib/HiiString.c
+++ b/MdePkg/Library/HiiLib/HiiString.c
@@ -251,7 +251,7 @@ HiiLibGetString (
ASSERT (!(*StringSize != 0 && String == NULL));
ASSERT (IsHiiHandleRegistered (PackageList));
- HiiLibGetCurrentLanguage (CurrentLang);
+ GetCurrentLanguage (CurrentLang);
Status = mHiiStringProt->GetString (
mHiiStringProt,
diff --git a/MdePkg/Library/HiiLib/InternalHiiLib.h b/MdePkg/Library/HiiLib/InternalHiiLib.h
index f9294eb876..255939152a 100644
--- a/MdePkg/Library/HiiLib/InternalHiiLib.h
+++ b/MdePkg/Library/HiiLib/InternalHiiLib.h
@@ -21,8 +21,6 @@
#include <Protocol/HiiString.h>
#include <Protocol/DevicePath.h>
-#include <Guid/GlobalVariable.h>
-
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HiiLib.h>
@@ -32,6 +30,7 @@
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/DevicePathLib.h>
+#include <Library/UefiLib.h>
#define HII_LIB_DEFAULT_STRING_SIZE 0x200
@@ -53,14 +52,4 @@ IsHiiHandleRegistered (
EFI_HII_HANDLE HiiHandle
);
-/**
-
- This function locate Hii relative protocols for later usage.
-
-**/
-VOID
-LocateHiiProtocols (
- VOID
- );
-
#endif
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 <Guid/EventGroup.h>
#include <Guid/EventLegacyBios.h>
+#include <Guid/GlobalVariable.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>