diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-09-21 08:50:52 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-09-21 08:50:52 +0000 |
commit | f8d18bada5af6d1f89cfc3cd50580d590a641e50 (patch) | |
tree | 2faa78e2f906e072bb6770167c6c31d6e9675099 /MdePkg/Library/HiiLib | |
parent | c0522bd7dfae2dd290726dad1b55abd8d4925711 (diff) | |
download | edk2-platforms-f8d18bada5af6d1f89cfc3cd50580d590a641e50.tar.xz |
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
Diffstat (limited to 'MdePkg/Library/HiiLib')
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLanguage.c | 50 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLib.c | 44 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLib.inf | 12 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiString.c | 2 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/InternalHiiLib.h | 13 |
5 files changed, 26 insertions, 95 deletions
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
|