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
This commit is contained in:
qwang12 2008-09-21 08:50:52 +00:00
parent c0522bd7df
commit f8d18bada5
10 changed files with 108 additions and 122 deletions

View File

@ -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
@ -288,27 +283,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 ';').

View File

@ -22,6 +22,12 @@
#include <Protocol/DriverDiagnostics.h>
#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
///
@ -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

View File

@ -15,52 +15,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 ';').
@ -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) {

View File

@ -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,

View File

@ -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

View File

@ -251,7 +251,7 @@ HiiLibGetString (
ASSERT (!(*StringSize != 0 && String == NULL));
ASSERT (IsHiiHandleRegistered (PackageList));
HiiLibGetCurrentLanguage (CurrentLang);
GetCurrentLanguage (CurrentLang);
Status = mHiiStringProt->GetString (
mHiiStringProt,

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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>