HiiAddPackages()
原型如下:
/**
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 and DeviceHandle, 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 {
UINT32 BinaryLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
} EDKII_AUTOGEN_PACKAGES_HEADER;
#pragma pack (pop)
@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.
@retval NULL A HII Handle has already been registered in the HII Database with
the same PackageListGuid and DeviceHandle.
@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_HANDLE
EFIAPI
HiiAddPackages (
IN CONST EFI_GUID *PackageListGuid,
IN EFI_HANDLE DeviceHandle OPTIONAL,
...
)
该函数的作用就是将有PackageListGuid表示的一个Package(它包含一系列的构成交互界面的元素)注册到HII数据库中,并返回一个HII句柄来指向刚注册的元素。
它是一个不定函数,之后可以跟若干个Package,并以NULL结尾。
下面是一个例子:
//
// Publish the HII package list to HII Database.
//
mInstalledPackages = HiiAddPackages (
&gEfiCallerIdGuid, // PackageListGuid
ImageHandle, // associated DeviceHandle
PlatformDxeStrings, // 1st package
PlatformFormsBin, // 2nd package
NULL // terminator
);
if (mInstalledPackages == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto UninstallProtocols;
}
函数执行成功与否的判断条件是看返回的HII句柄是否为NULL。
上述例子中注册了两个Package,一个是String类型的,另一个是FORM类型的。
HiiRemovePackages()
该函数与HiiAddPackages()对应,原型如下:
/**
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 HII database, then ASSERT.
@param[in] HiiHandle The handle that was previously registered in the HII database
**/
VOID
EFIAPI
HiiRemovePackages (
IN EFI_HII_HANDLE HiiHandle
)
HiiHandle就是HiiAddPackages()时的返回值,这个函数就没有必要多介绍了。
HiiGetString()
该函数用来获取字符串,这个字符串是之前通过HiiAddPackages()注册了的,原型如下:
/**
Retrieves a string from a string package in a specific language. If the language
is not specified, then a string from a string package in the current platform
language is retrieved. If the string can not be retrieved using the specified
language or the current platform language, then the string is retrieved from
the string package in the first language the string package supports. The
returned string is allocated using AllocatePool(). The caller is responsible
for freeing the allocated buffer using FreePool().
If HiiHandle is NULL, then ASSERT().
If StringId is 0, then ASSET.
@param[in] HiiHandle A handle that was previously registered in the HII Database.
@param[in] StringId The identifier of the string to retrieved from the string
package associated with HiiHandle.
@param[in] Language The language of the string to retrieve. If this parameter
is NULL, then the current platform language is used. The
format of Language must follow the language format assumed
the HII Database.
@retval NULL The string specified by StringId is not present in the string package.
@retval Other The string was returned.
**/
EFI_STRING
EFIAPI
HiiGetString (
IN EFI_HII_HANDLE HiiHandle,
IN EFI_STRING_ID StringId,
IN CONST CHAR8 *Language OPTIONAL
)
第一个参数HiiHandle就是HiiAddPackages()的返回值。
第二个参数其实是一个STRING_TOKEN,在UNI文件中定义。
第三个参数表示的是语言类型,如果不指定(NULL),则会使用当前默认的语言。
HiiSetString()
该函数在原有的Package中(HiiHandle指定的)增加或者更新字符串。
/**
This function create a new string in String Package or updates an existing
string in a String Package. If StringId is 0, then a new string is added to
a String Package. If StringId is not zero, then a string in String Package is
updated. If SupportedLanguages is NULL, then the string is added or updated
for all the languages that the String Package supports. If SupportedLanguages
is not NULL, then the string is added or updated for the set of languages
specified by SupportedLanguages.
If HiiHandle is NULL, then ASSERT().
If String is NULL, then ASSERT().
@param[in] HiiHandle A handle that was previously registered in the
HII Database.
@param[in] StringId If zero, then a new string is created in the
String Package associated with HiiHandle. If
non-zero, then the string specified by StringId
is updated in the String Package associated
with HiiHandle.
@param[in] String A pointer to the Null-terminated Unicode string
to add or update in the String Package associated
with HiiHandle.
@param[in] SupportedLanguages A pointer to a Null-terminated ASCII string of
language codes. If this parameter is NULL, then
String is added or updated in the String Package
associated with HiiHandle for all the languages
that the String Package supports. If this
parameter is not NULL, then then String is added
or updated in the String Package associated with
HiiHandle for the set oflanguages specified by
SupportedLanguages. The format of
SupportedLanguages must follow the language
format assumed the HII Database.
@retval 0 The string could not be added or updated in the String Package.
@retval Other The EFI_STRING_ID of the newly added or updated string.
**/
EFI_STRING_ID
EFIAPI
HiiSetString (
IN EFI_HII_HANDLE HiiHandle,
IN EFI_STRING_ID StringId, OPTIONAL
IN CONST EFI_STRING String,
IN CONST CHAR8 *SupportedLanguages OPTIONAL
)
当StringId的值是0的时候,表示新增字符串。
String就是需要增加或者更新的字符串。
其它参数同HiiSetString()。
HiiConstructConfigHdr()
该函数用来创建一个字符串,这个字符串有一定的结构。
/**
Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing
information that includes a GUID, an optional Unicode string name, and a device
path. The string returned is allocated with AllocatePool(). The caller is
responsible for freeing the allocated string with FreePool().
The format of a <ConfigHdr> is as follows:
GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>
@param[in] Guid Pointer to an EFI_GUID that is the routing information
GUID. Each of the 16 bytes in Guid is converted to
a 2 Unicode character hexadecimal string. This is
an optional parameter that may be NULL.
@param[in] Name Pointer to a Null-terminated Unicode string that is
the routing information NAME. This is an optional
parameter that may be NULL. Each 16-bit Unicode
character in Name is converted to a 4 character Unicode
hexadecimal string.
@param[in] DriverHandle The driver handle which supports a Device Path Protocol
that is the routing information PATH. Each byte of
the Device Path associated with DriverHandle is converted
to a 2 Unicode character hexadecimal string.
@retval NULL DriverHandle does not support the Device Path Protocol.
@retval Other A pointer to the Null-terminate Unicode <ConfigHdr> string
**/
EFI_STRING
EFIAPI
HiiConstructConfigHdr (
IN CONST EFI_GUID *Guid, OPTIONAL
IN CONST CHAR16 *Name, OPTIONAL
IN EFI_HANDLE DriverHandle
)
它在EFI_HII_CONFIG_ACCESS_PROTOCOL中会经常用到。