summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-07-16 01:22:51 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-07-16 01:22:51 +0000
commit29870c8d619f4e7b3d6486b29a52ef279164d2e5 (patch)
treedd1a418b37939d7c20dc495b071bc34571bd08a6 /MdePkg
parent631c199143d55ca5f47933fd9c207e6ab927af1a (diff)
downloadedk2-platforms-29870c8d619f4e7b3d6486b29a52ef279164d2e5.tar.xz
Clean up HiiLib.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5481 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/HiiLib/HiiLanguage.c7
-rw-r--r--MdePkg/Library/HiiLib/HiiLib.c35
-rw-r--r--MdePkg/Library/HiiLib/HiiString.c16
3 files changed, 39 insertions, 19 deletions
diff --git a/MdePkg/Library/HiiLib/HiiLanguage.c b/MdePkg/Library/HiiLib/HiiLanguage.c
index f5c8f032a9..3d9a36d468 100644
--- a/MdePkg/Library/HiiLib/HiiLanguage.c
+++ b/MdePkg/Library/HiiLib/HiiLanguage.c
@@ -124,7 +124,6 @@ HiiLibGetSupportedLanguages (
UINTN BufferSize;
CHAR8 *LanguageString;
- ASSERT (HiiHandle != NULL);
ASSERT (IsHiiHandleRegistered (HiiHandle));
//
// Collect current supported Languages for given HII handle
@@ -140,7 +139,7 @@ HiiLibGetSupportedLanguages (
Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
- gBS->FreePool (LanguageString);
+ FreePool (LanguageString);
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
@@ -190,7 +189,7 @@ HiiLibGetSupportedLanguageNumber (
HiiLibGetNextLanguage (&LanguageString, Lang);
LangNumber++;
}
- gBS->FreePool (Languages);
+ FreePool (Languages);
return LangNumber;
}
@@ -235,7 +234,7 @@ HiiLibGetSupportedSecondaryLanguages (
Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
- gBS->FreePool (LanguageString);
+ FreePool (LanguageString);
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
diff --git a/MdePkg/Library/HiiLib/HiiLib.c b/MdePkg/Library/HiiLib/HiiLib.c
index 749b004d9f..a178012b6e 100644
--- a/MdePkg/Library/HiiLib/HiiLib.c
+++ b/MdePkg/Library/HiiLib/HiiLib.c
@@ -32,6 +32,9 @@ LocateHiiProtocols (
EFI_STATUS Status;
if (mHiiProtocolsInitialized) {
+ //
+ // Only need to initialize the protocol instance once.
+ //
return;
}
@@ -52,6 +55,13 @@ LocateHiiProtocols (
package header that defined by UEFI VFR compiler and StringGather
tool.
+ #pragma pack (push, 1)
+ typedef struct {
+ UINT32 BinaryLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ } TIANO_AUTOGEN_PACKAGES_HEADER;
+ #pragma pack (pop)
+
If there is not enough resource for the new package list,
the function will ASSERT.
@@ -86,6 +96,9 @@ InternalHiiLibPreparePackages (
for (Index = 0; Index < NumberOfPackages; Index++) {
CopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
+ //
+ // Do not count the BinaryLength field.
+ //
PackageListLength += (PackageLength - sizeof (UINT32));
}
@@ -95,6 +108,7 @@ InternalHiiLibPreparePackages (
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
PackageListHeader = AllocateZeroPool (PackageListLength);
ASSERT (PackageListHeader != NULL);
+
CopyMem (&PackageListHeader->PackageListGuid, GuidId, sizeof (EFI_GUID));
PackageListHeader->PackageLength = PackageListLength;
@@ -127,11 +141,11 @@ InternalHiiLibPreparePackages (
If not enough resource to complete the operation, then ASSERT.
@param NumberOfPackages Number of packages.
- @param GuidId Package GUID.
- @param ... Variable argument list for packages to be assembled.
+ @param GuidId Package GUID.
+ @param ... Variable argument list for packages to be assembled.
@return EFI_HII_PACKAGE_LIST_HEADER Pointer of EFI_HII_PACKAGE_LIST_HEADER. The function will ASSERT if system has
- not enough resource to complete the operation.
+ not enough resource to complete the operation.
**/
EFI_HII_PACKAGE_LIST_HEADER *
@@ -222,8 +236,6 @@ HiiLibAddPackages (
@param HiiHandle The handle that was previously registered to the data base that is requested for removal.
List later.
- @return VOID
-
**/
VOID
EFIAPI
@@ -232,7 +244,7 @@ HiiLibRemovePackages (
)
{
EFI_STATUS Status;
- ASSERT (HiiHandle != NULL);
+ ASSERT (IsHiiHandleRegistered (HiiHandle));
LocateHiiProtocols ();
@@ -328,6 +340,7 @@ HiiLibExtractGuidFromHiiHandle (
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
ASSERT (Guid != NULL);
+ ASSERT (IsHiiHandleRegistered (Handle));
//
// Get HII PackageList
@@ -355,7 +368,7 @@ HiiLibExtractGuidFromHiiHandle (
//
CopyMem (Guid, &HiiPackageList->PackageListGuid, sizeof (EFI_GUID));
- gBS->FreePool (HiiPackageList);
+ FreePool (HiiPackageList);
return EFI_SUCCESS;
}
@@ -425,7 +438,7 @@ HiiLibDevicePathToHiiHandle (
break;
}
}
- gBS->FreePool (Handles);
+ FreePool (Handles);
if (DriverHandle == NULL) {
return NULL;
@@ -447,7 +460,7 @@ HiiLibDevicePathToHiiHandle (
HiiHandles
);
if (Status == EFI_BUFFER_TOO_SMALL) {
- gBS->FreePool (HiiHandles);
+ FreePool (HiiHandles);
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
@@ -461,7 +474,7 @@ HiiLibDevicePathToHiiHandle (
}
if (EFI_ERROR (Status)) {
- gBS->FreePool (HiiHandles);
+ FreePool (HiiHandles);
return NULL;
}
@@ -482,7 +495,7 @@ HiiLibDevicePathToHiiHandle (
}
}
- gBS->FreePool (HiiHandles);
+ FreePool (HiiHandles);
return HiiHandle;
}
diff --git a/MdePkg/Library/HiiLib/HiiString.c b/MdePkg/Library/HiiLib/HiiString.c
index 05e9aa8b68..0d07ebc68a 100644
--- a/MdePkg/Library/HiiLib/HiiString.c
+++ b/MdePkg/Library/HiiLib/HiiString.c
@@ -57,6 +57,10 @@ HiiLibNewString (
while (*LangStrings != 0) {
HiiLibGetNextLanguage (&LangStrings, Lang);
+ //
+ // For each language supported by the package,
+ // a string token is created.
+ //
Status = mHiiStringProt->NewString (
mHiiStringProt,
PackageList,
@@ -119,6 +123,10 @@ HiiLibSetString (
while (*LangStrings != 0) {
HiiLibGetNextLanguage (&LangStrings, Lang);
+ //
+ // For each language supported by the package,
+ // the string is updated.
+ //
Status = mHiiStringProt->SetString (
mHiiStringProt,
PackageList,
@@ -195,7 +203,7 @@ HiiLibGetStringFromToken (
Out:
if (HiiHandleBuffer != NULL) {
- gBS->FreePool (HiiHandleBuffer);
+ FreePool (HiiHandleBuffer);
}
return Status;
}
@@ -262,7 +270,7 @@ HiiLibGetString (
LangStrings = Languages;
HiiLibGetNextLanguage (&LangStrings, Lang);
- gBS->FreePool (Languages);
+ FreePool (Languages);
Status = mHiiStringProt->GetString (
mHiiStringProt,
@@ -318,7 +326,7 @@ HiiLibGetStringFromHandle (
Status = HiiLibGetString (HiiHandle, StringId, *String, &StringSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
- gBS->FreePool (*String);
+ FreePool (*String);
*String = AllocateZeroPool (StringSize);
if (*String == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -336,7 +344,7 @@ HiiLibGetStringFromHandle (
// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
// The last 2 CHAR8 values are the ISO 639-1 code.
//
-CHAR8 Iso639ToRfc3066ConversionTable[] =
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Iso639ToRfc3066ConversionTable[] =
"\
aaraa\
abkab\