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

@@ -1857,7 +1857,6 @@ RegisterFontPackage (
EFI_STATUS Status;
EFI_HII_SIMPLE_FONT_PACKAGE_HDR *SimplifiedFont;
UINT32 PackageLength;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
UINT8 *Package;
UINT8 *Location;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
@@ -1873,7 +1872,7 @@ RegisterFontPackage (
ASSERT_EFI_ERROR (Status);
//
// Add 4 bytes to the header for entire length for HiiLibPreparePackageList use only.
// Add 4 bytes to the header for entire length for HiiAddPackages use only.
//
// +--------------------------------+ <-- Package
// | |
@@ -1905,10 +1904,13 @@ RegisterFontPackage (
//
// Add this simplified font package to a package list then install it.
//
PackageList = HiiLibPreparePackageList (1, &mFontPackageListGuid, Package);
Status = HiiDatabase->NewPackageList (HiiDatabase, PackageList, NULL, &mHiiHandle);
ASSERT_EFI_ERROR (Status);
FreePool (PackageList);
mHiiHandle = HiiAddPackages (
&mFontPackageListGuid,
NULL,
Package,
NULL
);
ASSERT (mHiiHandle != NULL);
FreePool (Package);
}

View File

@@ -170,21 +170,21 @@ ValidatePassword (
//
// Get user input password
//
BufferSize = 21 * sizeof (CHAR16);
Password = AllocateZeroPool (BufferSize);
ASSERT (Password != NULL);
Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);
if (EFI_ERROR (Status)) {
Password = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
if (Password == NULL) {
return EFI_NOT_READY;
}
if (StrLen (Password) > 20) {
FreePool (Password);
return Status;
return EFI_NOT_READY;
}
//
// Validate old password
//
EncodedPassword = AllocateCopyPool (21 * sizeof (CHAR16), Password);
EncodedPassword = AllocateZeroPool (21 * sizeof (CHAR16));
ASSERT (EncodedPassword != NULL);
StrnCpy (EncodedPassword, Password, 21);
EncodePassword (EncodedPassword, 20 * sizeof (CHAR16));
if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, 20 * sizeof (CHAR16)) != 0) {
//
@@ -219,6 +219,7 @@ SetPassword (
{
EFI_STATUS Status;
CHAR16 *Password;
CHAR16 *TempPassword;
UINTN PasswordSize;
DRIVER_SAMPLE_CONFIGURATION *Configuration;
UINTN BufferSize;
@@ -242,13 +243,19 @@ SetPassword (
// Get user input password
//
Password = &PrivateData->Configuration.WhatIsThePassword2[0];
PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
ZeroMem (Password, PasswordSize);
Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);
if (EFI_ERROR (Status)) {
return Status;
TempPassword = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
if (TempPassword == NULL) {
return EFI_NOT_READY;
}
if (StrLen (TempPassword) > PasswordSize / sizeof (CHAR16)) {
FreePool (TempPassword);
return EFI_NOT_READY;
}
StrnCpy (Password, TempPassword, PasswordSize / sizeof (CHAR16));
FreePool (TempPassword);
//
// Retrive uncommitted data from Browser
@@ -786,7 +793,6 @@ DriverSampleInit (
{
EFI_STATUS Status;
EFI_STATUS SavedStatus;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle[2];
EFI_SCREEN_DESCRIPTOR Screen;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
@@ -878,26 +884,17 @@ DriverSampleInit (
//
// Publish our HII data
//
PackageList = HiiLibPreparePackageList (
2,
&mFormSetGuid,
DriverSampleStrings,
VfrBin
);
if (PackageList == NULL) {
HiiHandle[0] = HiiAddPackages (
&mFormSetGuid,
DriverHandle[0],
DriverSampleStrings,
VfrBin,
NULL
);
if (HiiHandle[0] == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = HiiDatabase->NewPackageList (
HiiDatabase,
PackageList,
DriverHandle[0],
&HiiHandle[0]
);
FreePool (PackageList);
if (EFI_ERROR (Status)) {
return Status;
}
PrivateData->HiiHandle[0] = HiiHandle[0];
//
@@ -913,26 +910,17 @@ DriverSampleInit (
PrivateData->DriverHandle[1] = DriverHandle[1];
PackageList = HiiLibPreparePackageList (
2,
&mInventoryGuid,
DriverSampleStrings,
InventoryBin
);
if (PackageList == NULL) {
HiiHandle[1] = HiiAddPackages (
&mInventoryGuid,
DriverHandle[1],
DriverSampleStrings,
InventoryBin,
NULL
);
if (HiiHandle[1] == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = HiiDatabase->NewPackageList (
HiiDatabase,
PackageList,
DriverHandle[1],
&HiiHandle[1]
);
FreePool (PackageList);
if (EFI_ERROR (Status)) {
return Status;
}
PrivateData->HiiHandle[1] = HiiHandle[1];
//
@@ -941,9 +929,8 @@ DriverSampleInit (
//
NewString = L"700 Mhz";
Status = HiiLibSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString);
if (EFI_ERROR (Status)) {
return Status;
if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString, NULL) == 0) {
return EFI_OUT_OF_RESOURCES;
}
//

View File

@@ -34,6 +34,7 @@ Revision History
#include <Guid/MdeModuleHii.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -53,7 +54,7 @@ extern UINT8 VfrMyIfrNVDataBlockName[];
//
// This is the generated IFR binary data for each formset defined in VFR.
// This data array is ready to be used as input of HiiLibPreparePackageList() to
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
extern UINT8 VfrBin[];
@@ -61,7 +62,7 @@ extern UINT8 InventoryBin[];
//
// This is the generated String package data for all .UNI files.
// This data array is ready to be used as input of HiiLibPreparePackageList() to
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
extern UINT8 DriverSampleStrings[];

View File

@@ -46,6 +46,7 @@
[LibraryClasses]
BaseLib
MemoryAllocationLib
UefiBootServicesTableLib
UefiDriverEntryPoint

View File

@@ -715,7 +715,7 @@ IScsiFormCallback (
UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);
DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;
HiiLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);
HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);
IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);
@@ -840,13 +840,13 @@ IScsiConfigUpdateForm (
// Compose the Port string and create a new EFI_STRING_ID.
//
UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);
HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);
ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);
//
// Compose the help string of this port and create a new EFI_STRING_ID.
//
UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString);
HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);
ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);
InsertTailList (&mIScsiConfigFormList, &ConfigFormEntry->Link);
mNumberOfIScsiDevices++;
@@ -931,7 +931,6 @@ IScsiConfigFormInit (
{
EFI_STATUS Status;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);
@@ -974,19 +973,16 @@ IScsiConfigFormInit (
//
// Publish our HII data
//
PackageList = HiiLibPreparePackageList (2, &mVendorGuid, IScsiDxeStrings, IScsiConfigDxeBin);
ASSERT (PackageList != NULL);
Status = HiiDatabase->NewPackageList (
HiiDatabase,
PackageList,
CallbackInfo->DriverHandle,
&CallbackInfo->RegisteredHandle
);
FreePool (PackageList);
if (EFI_ERROR (Status)) {
CallbackInfo->RegisteredHandle = HiiAddPackages (
&mVendorGuid,
CallbackInfo->DriverHandle,
IScsiDxeStrings,
IScsiConfigDxeBin,
NULL
);
if (CallbackInfo->RegisteredHandle == NULL) {
FreePool(CallbackInfo);
return Status;
return EFI_OUT_OF_RESOURCES;
}
mCallbackInfo = CallbackInfo;

View File

@@ -108,17 +108,15 @@ UpdateCheckBoxStringToken (
{
CHAR16 Str[MAXIMUM_VALUE_CHARACTERS];
EFI_STRING_ID Id;
EFI_STATUS Status;
ASSERT (Statement != NULL);
ASSERT (Statement->Operand == EFI_IFR_NUMERIC_OP);
UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
Status = HiiLibNewString (FormSet->HiiHandle, &Id, Str);
if (EFI_ERROR (Status)) {
return Status;
Id = HiiSetString (FormSet->HiiHandle, 0, Str, NULL);
if (Id == 0) {
return EFI_OUT_OF_RESOURCES;
}
Statement->VarStoreInfo.VarName = Id;

View File

@@ -525,7 +525,6 @@ InitializeSetup (
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
//
// Locate required Hii relative protocols
@@ -554,15 +553,13 @@ InitializeSetup (
//
// Publish our HII data
//
PackageList = HiiLibPreparePackageList (1, &gSetupBrowserGuid, SetupBrowserStrings);
ASSERT (PackageList != NULL);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
PackageList,
ImageHandle,
&gHiiHandle
);
ASSERT_EFI_ERROR (Status);
gHiiHandle = HiiAddPackages (
&gSetupBrowserGuid,
ImageHandle,
SetupBrowserStrings,
NULL
);
ASSERT (gHiiHandle != NULL);
//
// Initialize Driver private data
@@ -603,11 +600,9 @@ NewString (
)
{
EFI_STRING_ID StringId;
EFI_STATUS Status;
StringId = 0;
Status = HiiLibNewString (HiiHandle, &StringId, String);
ASSERT_EFI_ERROR (Status);
StringId = HiiSetString (HiiHandle, 0, String, NULL);
ASSERT (StringId != 0);
return StringId;
}
@@ -631,7 +626,8 @@ DeleteString (
CHAR16 NullChar;
NullChar = CHAR_NULL;
return HiiLibSetString (HiiHandle, StringId, &NullChar);
HiiSetString (HiiHandle, StringId, &NullChar, NULL);
return EFI_SUCCESS;
}
@@ -651,29 +647,11 @@ GetToken (
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
CHAR16 *String;
UINTN BufferLength;
EFI_STRING String;
//
// Set default string size assumption at no more than 256 bytes
//
BufferLength = 0x100;
String = AllocateZeroPool (BufferLength);
String = HiiGetString (HiiHandle, Token, NULL);
ASSERT (String != NULL);
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (String);
String = AllocateZeroPool (BufferLength);
ASSERT (String != NULL);
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
}
ASSERT_EFI_ERROR (Status);
return String;
return (CHAR16 *) String;
}

View File

@@ -41,6 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/HiiLib.h>
#include <Library/PcdLib.h>
#include <Library/DevicePathLib.h>
#include "Colors.h"

View File

@@ -59,7 +59,8 @@
DebugLib
PrintLib
HiiLib
DevicePathLib
[Guids]
gEfiIfrTianoGuid ## CONSUMES ## GUID
gEfiIfrFrameworkGuid ## CONSUMES ## GUID

View File

@@ -1448,6 +1448,102 @@ AdjustDateAndTimePosition (
return PadLineNumber;
}
/**
Find HII Handle in the 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
DevicePathToHiiHandle (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
UINTN BufferSize;
UINTN HandleCount;
UINTN Index;
EFI_HANDLE Handle;
EFI_HANDLE DriverHandle;
EFI_HII_HANDLE *HiiHandles;
EFI_HII_HANDLE HiiHandle;
ASSERT (DevicePath != NULL);
TmpDevicePath = DevicePath;
//
// Locate Device Path Protocol handle buffer
//
Status = gBS->LocateDevicePath (
&gEfiDevicePathProtocolGuid,
&TmpDevicePath,
&DriverHandle
);
if (EFI_ERROR (Status) || !IsDevicePathEnd (TmpDevicePath)) {
return NULL;
}
//
// Retrieve all HII Handles from HII database
//
BufferSize = 0x1000;
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = mHiiDatabase->ListPackageLists (
mHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferSize,
HiiHandles
);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (HiiHandles);
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = mHiiDatabase->ListPackageLists (
mHiiDatabase,
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 = mHiiDatabase->GetPackageListHandle (
mHiiDatabase,
HiiHandles[Index],
&Handle
);
if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
HiiHandle = HiiHandles[Index];
break;
}
}
FreePool (HiiHandles);
return HiiHandle;
}
/**
Display menu and wait for user to select one menu option, then return it.
@@ -2382,7 +2478,7 @@ UiDisplayMenu (
}
}
Selection->Handle = HiiLibDevicePathToHiiHandle (DevicePath);
Selection->Handle = DevicePathToHiiHandle (DevicePath);
if (Selection->Handle == NULL) {
//
// If target Hii Handle not found, exit