HII Library Class interface refine.

The "HiiLib" prefix for all HII Library API function names changed to "Hii".

Remove: 
  HiiLibPreparePackageList(), replaced by HiiAddPackages()
  HiiLibNewString(), replaced by HiiSetString()
  HiiLibGetStringFromHandle(), replaced by HiiGetString()
  HiiLibGetStringFromToken(), replaced by HiiGetPackageString()
  HiiLibExtractGuidFromHiiHandle()
  HiiLibDevicePathToHiiHandle()
  HiiLibGetSupportedSecondaryLanguages()
  HiiLibGetSupportedLanguageNumber()
  HiiLibExportPackageLists()
  HiiLibListPackageLists()
  
Interface change:
  HiiAddPackages()
  HiiSetString()
  HiiGetString()
  HiiGetHiiHandles()

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8083 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
rsun3
2009-04-14 10:47:19 +00:00
parent 169a34619b
commit cb7d01c0c9
40 changed files with 1571 additions and 1770 deletions

View File

@@ -19,16 +19,26 @@
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
//
// Form Browser2 Protocol
//
EFI_FORM_BROWSER2_PROTOCOL *mUefiFormBrowser2 = NULL;
//
// Template used to mark the end of a list of packages
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_PACKAGE_HEADER mEndOfPakageList = {
sizeof (EFI_HII_PACKAGE_HEADER),
EFI_HII_PACKAGE_END
};
/**
This funciton build the package list based on the package number,
the GUID of the package list and the list of pointer which point to
package header that defined by UEFI VFR compiler and StringGather
tool.
Registers a list of packages in the HII Database and returns the HII Handle
associated with that registration. If an HII Handle has already been registered
with the same PackageListGuid, then NULL is returned. If there are not enough
resources to perform the registration, then NULL is returned. If an empty list
of packages is passed in, then NULL is returned. If the size of the list of
package is 0, then NULL is returned.
The variable arguments are pointers which point to package header that defined
by UEFI VFR compiler and StringGather tool.
#pragma pack (push, 1)
typedef struct {
@@ -36,267 +46,269 @@ EFI_FORM_BROWSER2_PROTOCOL *mUefiFormBrowser2 = NULL;
EFI_HII_PACKAGE_HEADER PackageHeader;
} EDKII_AUTOGEN_PACKAGES_HEADER;
#pragma pack (pop)
If there is not enough resource for the new package list,
the function will ASSERT.
@param NumberOfPackages The number of packages be
@param GuidId The GUID for the package list to be generated.
@param Marker The variable argument list. Each entry represent a specific package header that is
generated by VFR compiler and StrGather tool. The first 4 bytes is a UINT32 value
that indicate the overall length of the package.
@return The pointer to the package list header.
**/
EFI_HII_PACKAGE_LIST_HEADER *
InternalHiiLibPreparePackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN VA_LIST Marker
)
{
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
UINT8 *PackageListData;
UINT32 PackageListLength;
UINT32 PackageLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
UINT8 *PackageArray;
UINTN Index;
VA_LIST MarkerBackup;
PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
MarkerBackup = Marker;
//
// Count the length of the final package list.
//
for (Index = 0; Index < NumberOfPackages; Index++) {
CopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
//
// Do not count the BinaryLength field.
//
PackageListLength += (PackageLength - sizeof (UINT32));
}
//
// Include the length of EFI_HII_PACKAGE_END
//
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
PackageListHeader = AllocateZeroPool (PackageListLength);
ASSERT (PackageListHeader != NULL);
CopyGuid (&PackageListHeader->PackageListGuid, GuidId);
PackageListHeader->PackageLength = PackageListLength;
@param[in] PackageListGuid The GUID of the package list.
@param[in] DeviceHandle If not NULL, the Device Handle on which
an instance of DEVICE_PATH_PROTOCOL is installed.
This Device Handle uniquely defines the device that
the added packages are associated with.
@param[in] ... The variable argument list that contains pointers
to packages terminated by a NULL.
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
Marker = MarkerBackup;
//
// Prepare the final package list.
//
for (Index = 0; Index < NumberOfPackages; Index++) {
PackageArray = (UINT8 *) VA_ARG (Marker, VOID *);
//
// CopyMem is used for UINT32 to cover the unaligned address access.
//
CopyMem (&PackageLength, PackageArray, sizeof (UINT32));
PackageLength -= sizeof (UINT32);
PackageArray += sizeof (UINT32);
CopyMem (PackageListData, PackageArray, PackageLength);
PackageListData += PackageLength;
}
//
// Append EFI_HII_PACKAGE_END
//
PackageHeader.Type = EFI_HII_PACKAGE_END;
PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
CopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
return PackageListHeader;
}
/**
Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
If GuidId is NULL, then ASSERT.
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.
@return Pointer of EFI_HII_PACKAGE_LIST_HEADER.
@retval NULL A HII Handle has already been registered in the HII Database with
the same PackageListGuid.
@retval NULL The HII Handle could not be created.
@retval NULL An empty list of packages was passed in.
@retval NULL All packages are empty.
@retval Other The HII Handle associated with the newly registered package list.
**/
EFI_HII_PACKAGE_LIST_HEADER *
EFI_HII_HANDLE
EFIAPI
HiiLibPreparePackageList (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
HiiAddPackages (
IN CONST EFI_GUID *PackageListGuid,
IN EFI_HANDLE DeviceHandle OPTIONAL,
...
)
{
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
VA_LIST Marker;
EFI_STATUS Status;
EFI_HII_HANDLE *HiiHandleBuffer;
VA_LIST Args;
UINT32 *Package;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
EFI_HII_HANDLE HiiHandle;
UINT32 Length;
UINT8 *Data;
ASSERT (GuidId != NULL);
ASSERT (PackageListGuid != NULL);
VA_START (Marker, GuidId);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Marker);
VA_END (Marker);
return PackageListHeader;
}
/**
This function allocates pool for an EFI_HII_PACKAGE_LIST structure
with additional space that is big enough to host all packages described by the variable
argument list of package pointers. The allocated structure is initialized using NumberOfPackages,
GuidId, and the variable length argument list of package pointers.
Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The
Handle to the newly registered Package List is returned through HiiHandle.
If HiiHandle is NULL, then ASSERT.
@param NumberOfPackages The number of HII packages to register.
@param GuidId Package List GUID ID.
@param DriverHandle Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.
This DriverHandle uniquely defines the device that the added packages are associated with.
@param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package
List later. If the functions failed to add the package to the default HII database, this value will
be set to NULL.
@param ... The variable argument list describing all HII Package.
@return EFI_SUCCESS If the packages are successfully added to the default HII database.
@return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.
**/
EFI_STATUS
EFIAPI
HiiLibAddPackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN EFI_HANDLE DriverHandle, OPTIONAL
OUT EFI_HII_HANDLE *HiiHandle,
...
)
{
VA_LIST Args;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
EFI_STATUS Status;
ASSERT (HiiHandle != NULL);
VA_START (Args, HiiHandle);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Args);
Status = gHiiDatabase->NewPackageList (gHiiDatabase, PackageListHeader, DriverHandle, HiiHandle);
if (HiiHandle != NULL) {
if (EFI_ERROR (Status)) {
*HiiHandle = NULL;
}
//
// Check to see if an HII Handle has already been registered with the same
// PackageListGuid
//
HiiHandleBuffer = HiiGetHiiHandles (PackageListGuid);
if (HiiHandleBuffer != NULL) {
FreePool (HiiHandleBuffer);
return NULL;
}
FreePool (PackageListHeader);
//
// Calculate the length of all the packages in the variable argument list
//
for (Length = 0, VA_START (Args, DeviceHandle); (Package = VA_ARG (Args, UINT32 *)) != NULL; ) {
Length += (ReadUnaligned32 (Package) - sizeof (UINT32));
}
VA_END (Args);
return Status;
//
// If there are no packages in the variable argument list or all the packages
// are empty, then return a NULL HII Handle
//
if (Length == 0) {
return NULL;
}
//
// Add the length of the Package List Header and the terminating Package Header
//
Length += sizeof (EFI_HII_PACKAGE_LIST_HEADER) + sizeof (EFI_HII_PACKAGE_HEADER);
//
// Allocate the storage for the entire Package List
//
PackageListHeader = AllocateZeroPool (Length);
//
// If the Packahge List can not be allocated, then return a NULL HII Handle
//
if (PackageListHeader == NULL) {
return NULL;
}
//
// Fill in the GUID and Length of the Package List Header
//
CopyGuid (&PackageListHeader->PackageListGuid, PackageListGuid);
PackageListHeader->PackageLength = Length;
//
// Initialize a pointer to the beginning if the Package List data
//
Data = (UINT8 *)(PackageListHeader + 1);
//
// Copy the data from each package in the variable argument list
//
for (VA_START (Args, DeviceHandle); (Package = VA_ARG (Args, UINT32 *)) != NULL; ) {
Length = ReadUnaligned32 (Package) - sizeof (UINT32);
CopyMem (Data, Package + 1, Length);
Data += Length;
}
VA_END (Args);
//
// Append a package of type EFI_HII_PACKAGE_END to mark the end of the package list
//
CopyMem (Data, &mEndOfPakageList, sizeof (mEndOfPakageList));
//
// Register the package list with the HII Database
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageListHeader,
DeviceHandle,
&HiiHandle
);
if (EFI_ERROR (Status)) {
HiiHandle = NULL;
}
//
// Free the allocated package list
//
FreePool (PackageListHeader);
//
// Return the new HII Handle
//
return HiiHandle;
}
/**
Removes a package list from the default HII database.
Removes a package list from the HII database.
If HiiHandle is NULL, then ASSERT.
If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.
If HiiHandle is not a valid EFI_HII_HANDLE in the HII database, then ASSERT.
@param HiiHandle The handle that was previously registered to the data base that is requested for removal.
List later.
@param[in] HiiHandle The handle that was previously registered in the HII database
**/
VOID
EFIAPI
HiiLibRemovePackages (
HiiRemovePackages (
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
ASSERT (IsHiiHandleRegistered (HiiHandle));
ASSERT (HiiHandle != NULL);
Status = gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);
ASSERT_EFI_ERROR (Status);
}
/**
Determines the handles that are currently active in the database.
It's the caller's responsibility to free handle buffer.
Retrieves the array of all the HII Handles or the HII handle of a specific
package list in the HII Database.
This array is terminated with a NULL HII Handle.
This function allocates the returned array using AllocatePool().
The caller is responsible for freeing the array with FreePool().
If HandleBufferLength is NULL, then ASSERT.
If HiiHandleBuffer is NULL, then ASSERT.
@param[in] PackageListGuid An optional parameter that is used to request
an HII Handle that is associatd with a specific
Package List GUID. If this parameter is NULL
then all the HII Handles in the HII Database
are returned. If this parameter is not NULL
then at most 1 HII Handle is returned.
@param HandleBufferLength On input, a pointer to the length of the handle
buffer. On output, the length of the handle buffer
that is required for the handles found.
@param HiiHandleBuffer Pointer to an array of Hii Handles returned.
@retval EFI_SUCCESS Get an array of Hii Handles successfully.
@retval NULL No HII handles were found in the HII database
@retval NULL The array of HII Handles could not be retrieved
@retval Other A pointer to the NULL terminated array of HII Handles
**/
EFI_STATUS
EFI_HII_HANDLE *
EFIAPI
HiiLibGetHiiHandles (
IN OUT UINTN *HandleBufferLength,
OUT EFI_HII_HANDLE **HiiHandleBuffer
HiiGetHiiHandles (
IN CONST EFI_GUID *PackageListGuid OPTIONAL
)
{
EFI_STATUS Status;
ASSERT (HandleBufferLength != NULL);
ASSERT (HiiHandleBuffer != NULL);
*HandleBufferLength = 0;
*HiiHandleBuffer = NULL;
EFI_STATUS Status;
UINTN HandleBufferLength;
EFI_HII_HANDLE TempHiiHandleBuffer;
EFI_HII_HANDLE *HiiHandleBuffer;
EFI_GUID Guid;
UINTN Index;
//
// Try to find the actual buffer size for HiiHandle Buffer.
// Retrieve the size required for the buffer of all HII handles.
//
HandleBufferLength = 0;
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
HandleBufferLength,
*HiiHandleBuffer
);
if (Status == EFI_BUFFER_TOO_SMALL) {
*HiiHandleBuffer = AllocateZeroPool (*HandleBufferLength);
ASSERT (*HiiHandleBuffer != NULL);
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
HandleBufferLength,
*HiiHandleBuffer
);
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&HandleBufferLength,
&TempHiiHandleBuffer
);
if (EFI_ERROR (Status)) {
FreePool (*HiiHandleBuffer);
*HiiHandleBuffer = NULL;
}
//
// If ListPackageLists() returns EFI_SUCCESS for a zero size,
// then there are no HII handles in the HII database. If ListPackageLists()
// returns an error other than EFI_BUFFER_TOO_SMALL, then there are no HII
// handles in the HII database.
//
if (Status != EFI_BUFFER_TOO_SMALL) {
//
// Return NULL if the size can not be retrieved, or if there are no HII
// handles in the HII Database
//
return NULL;
}
return Status;
//
// Allocate the array of HII handles to hold all the HII Handles and a NULL terminator
//
HiiHandleBuffer = AllocateZeroPool (HandleBufferLength + sizeof (EFI_HII_HANDLE));
if (HiiHandleBuffer == NULL) {
//
// Return NULL if allocation fails.
//
return NULL;
}
//
// Retrieve the array of HII Handles in the HII Database
//
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&HandleBufferLength,
HiiHandleBuffer
);
if (EFI_ERROR (Status)) {
//
// Free the buffer and return NULL if the HII handles can not be retrieved.
//
FreePool (HiiHandleBuffer);
return NULL;
}
if (PackageListGuid == NULL) {
//
// Return the NULL terminated array of HII handles in the HII Database
//
return HiiHandleBuffer;
} else {
for (Index = 0; HiiHandleBuffer[Index] != NULL; Index++) {
Status = InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
ASSERT_EFI_ERROR (Status);
if (CompareGuid (&Guid, PackageListGuid)) {
HiiHandleBuffer[0] = HiiHandleBuffer[Index];
HiiHandleBuffer[1] = NULL;
return HiiHandleBuffer;
}
}
FreePool (HiiHandleBuffer);
return NULL;
}
}
/**
Extract Hii package list GUID for given HII handle.
If HiiHandle could not be found in the default HII database, then ASSERT.
If HiiHandle could not be found in the HII database, then ASSERT.
If Guid is NULL, then ASSERT.
@param Handle Hii handle
@@ -307,7 +319,7 @@ HiiLibGetHiiHandles (
**/
EFI_STATUS
EFIAPI
HiiLibExtractGuidFromHiiHandle (
InternalHiiExtractGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
OUT EFI_GUID *Guid
)
@@ -317,7 +329,7 @@ HiiLibExtractGuidFromHiiHandle (
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
ASSERT (Guid != NULL);
ASSERT (IsHiiHandleRegistered (Handle));
ASSERT (Handle != NULL);
//
// Get HII PackageList
@@ -349,326 +361,6 @@ HiiLibExtractGuidFromHiiHandle (
return EFI_SUCCESS;
}
/**
Find HII Handle in the default HII database associated with given Device Path.
If DevicePath is NULL, then ASSERT.
@param DevicePath Device Path associated with the HII package list
handle.
@retval Handle HII package list Handle associated with the Device
Path.
@retval NULL Hii Package list handle is not found.
**/
EFI_HII_HANDLE
EFIAPI
HiiLibDevicePathToHiiHandle (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
UINTN BufferSize;
UINTN HandleCount;
UINTN Index;
EFI_HANDLE *Handles;
EFI_HANDLE Handle;
UINTN Size;
EFI_HANDLE DriverHandle;
EFI_HII_HANDLE *HiiHandles;
EFI_HII_HANDLE HiiHandle;
ASSERT (DevicePath != NULL);
//
// Locate Device Path Protocol handle buffer
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiDevicePathProtocolGuid,
NULL,
&HandleCount,
&Handles
);
if (EFI_ERROR (Status)) {
return NULL;
}
//
// Search Driver Handle by Device Path
//
DriverHandle = NULL;
BufferSize = GetDevicePathSize (DevicePath);
for(Index = 0; Index < HandleCount; Index++) {
Handle = Handles[Index];
gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &TmpDevicePath);
//
// Check whether DevicePath match
//
Size = GetDevicePathSize (TmpDevicePath);
if ((Size == BufferSize) && CompareMem (DevicePath, TmpDevicePath, Size) == 0) {
DriverHandle = Handle;
break;
}
}
FreePool (Handles);
if (DriverHandle == NULL) {
return NULL;
}
//
// Retrieve all Hii Handles from HII database
//
BufferSize = 0x1000;
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferSize,
HiiHandles
);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (HiiHandles);
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferSize,
HiiHandles
);
}
if (EFI_ERROR (Status)) {
FreePool (HiiHandles);
return NULL;
}
//
// Search Hii Handle by Driver Handle
//
HiiHandle = NULL;
HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
for (Index = 0; Index < HandleCount; Index++) {
Status = gHiiDatabase->GetPackageListHandle (
gHiiDatabase,
HiiHandles[Index],
&Handle
);
if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
HiiHandle = HiiHandles[Index];
break;
}
}
FreePool (HiiHandles);
return HiiHandle;
}
/**
Exports the contents of one or all package lists in the HII database into a buffer.
If Handle is not NULL and not a valid EFI_HII_HANDLE registered in the database,
then ASSERT.
If PackageListHeader is NULL, then ASSERT.
If PackageListSize is NULL, then ASSERT.
@param Handle The HII Handle.
@param PackageListHeader A pointer to a buffer that will contain the results of
the export function.
@param PackageListSize On output, the length of the buffer that is required for the exported data.
@retval EFI_SUCCESS Package exported.
@retval EFI_OUT_OF_RESOURCES Not enought memory to complete the operations.
**/
EFI_STATUS
EFIAPI
HiiLibExportPackageLists (
IN EFI_HII_HANDLE Handle,
OUT EFI_HII_PACKAGE_LIST_HEADER **PackageListHeader,
OUT UINTN *PackageListSize
)
{
EFI_STATUS Status;
UINTN Size;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHdr;
ASSERT (PackageListSize != NULL);
ASSERT (PackageListHeader != NULL);
if (Handle != NULL) {
ASSERT (IsHiiHandleRegistered (Handle));
}
Size = 0;
PackageListHdr = NULL;
Status = gHiiDatabase->ExportPackageLists (
gHiiDatabase,
Handle,
&Size,
PackageListHdr
);
ASSERT_EFI_ERROR (Status != EFI_BUFFER_TOO_SMALL);
if (Status == EFI_BUFFER_TOO_SMALL) {
PackageListHdr = AllocateZeroPool (Size);
if (PackageListHeader == NULL) {
return EFI_OUT_OF_RESOURCES;
} else {
Status = gHiiDatabase->ExportPackageLists (
gHiiDatabase,
Handle,
&Size,
PackageListHdr
);
}
}
if (!EFI_ERROR (Status)) {
*PackageListHeader = PackageListHdr;
*PackageListSize = Size;
} else {
FreePool (PackageListHdr);
}
return Status;
}
/**
This function returns a list of the package handles of the
specified type that are currently active in the HII database. The
pseudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package
handles to be listed.
If HandleBufferLength is NULL, then ASSERT.
If HandleBuffer is NULL, the ASSERT.
If PackageType is EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is
NULL, then ASSERT.
If PackageType is not EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is not
NULL, then ASSERT.
@param PackageType Specifies the package type of the packages
to list or EFI_HII_PACKAGE_TYPE_ALL for
all packages to be listed.
@param PackageGuid If PackageType is
EFI_HII_PACKAGE_TYPE_GUID, then this is
the pointer to the GUID which must match
the Guid field of
EFI_HII_PACKAGE_GUID_HEADER. Otherwise, it
must be NULL.
@param HandleBufferLength On output, the length of the handle buffer
that is required for the handles found.
@param HandleBuffer On output, an array of EFI_HII_HANDLE instances returned.
The caller is responcible to free this pointer allocated.
@retval EFI_SUCCESS The matching handles are outputed successfully.
HandleBufferLength is updated with the actual length.
@retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operation.
@retval EFI_NOT_FOUND No matching handle could not be found in database.
**/
EFI_STATUS
EFIAPI
HiiLibListPackageLists (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN OUT UINTN *HandleBufferLength,
OUT EFI_HII_HANDLE **HandleBuffer
)
{
EFI_STATUS Status;
ASSERT (HandleBufferLength != NULL);
ASSERT (HandleBuffer != NULL);
*HandleBufferLength = 0;
*HandleBuffer = NULL;
if (PackageType == EFI_HII_PACKAGE_TYPE_GUID) {
ASSERT (PackageGuid != NULL);
} else {
ASSERT (PackageGuid == NULL);
}
Status = gHiiDatabase->ListPackageLists (
gHiiDatabase,
PackageType,
PackageGuid,
HandleBufferLength,
*HandleBuffer
);
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
//
// No packages is registered to UEFI HII Database, just return.
//
//
return Status;
}
*HandleBuffer = AllocateZeroPool (*HandleBufferLength);
if (*HandleBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return gHiiDatabase->ListPackageLists (
gHiiDatabase,
PackageType,
PackageGuid,
HandleBufferLength,
*HandleBuffer
);
}
/**
This function check if the Hii Handle is a valid handle registered
in the HII database.
@param HiiHandle The HII Handle.
@retval TRUE If it is a valid HII handle.
@retval FALSE If it is a invalid HII handle.
**/
BOOLEAN
IsHiiHandleRegistered (
EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
UINTN BufferSize;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
ASSERT (HiiHandle != NULL);
HiiPackageList = NULL;
BufferSize = 0;
Status = gHiiDatabase->ExportPackageLists (
gHiiDatabase,
HiiHandle,
&BufferSize,
HiiPackageList
);
return (BOOLEAN) (Status == EFI_BUFFER_TOO_SMALL);
}
/**
Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for
hex digits that appear between a '=' and a '&' in a config string.
@@ -2916,3 +2608,4 @@ HiiIfrLibExtractDefault(
return EFI_SUCCESS;
}