summaryrefslogtreecommitdiff
path: root/MdePkg/Library/HiiLib/HiiLib.c
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/Library/HiiLib/HiiLib.c
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/Library/HiiLib/HiiLib.c')
-rw-r--r--MdePkg/Library/HiiLib/HiiLib.c35
1 files changed, 24 insertions, 11 deletions
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;
}