【UEFI实战】HII之常用函数---HiiAddPackages
创始人
2024-06-02 14:36:57
0

资源安装
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,

)

简单来说就是将资源(代码中用Package标识,这里将其翻译为资源似乎更好理解,它表示的可能是uni文件对应的字符串、vfr文件对应的Setup骨架、字体等等)安装HII数据库中,并返回数据库的Handle,后续要使用资源就要用到这个Handle。

它的第一个参数是GUID,用来唯一地标识安装的资源,目前不确定其作用,似乎是为了防止重复安装的;DeviceHandle用来在其上安装DEVICE_PATH_PROTOCOL实例,通过这种方式就可以将资源与安装在DeviceHandle之上的其它内容(比如设备)等联系在一起;…表示的是需要安装的资源。

下面是一个简单的例子,为了使用字符串资源,这里首先通过HiiAddPackages()进行安装:

VOID
InitializeStringSupport (
VOID
)
{
gStringPackHandle = HiiAddPackages (
&mUiStringPackGuid,
gImageHandle,
UiAppStrings,
NULL
);
ASSERT (gStringPackHandle != NULL);
}

UiAppStrings对应uni文件得到的数据,它通过HiiAddPackages()安装,并返回全局的gStringPackHandle,这个后面会用到,而另外一个gImageHandle在本例中并不重要。使用字符串资源的代码示例:

String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
1
STR_MISSING_STRING是uni文件中定义的宏,gStringPackHandle是前面调用HiiAddPackages时的返回值,第三个参数NULL表示跟随当前语言。另外需要注意的是这里的返回值String后面需要释放。

另一个比较复杂的示例,首先也是安装:

//
// Publish our HII data
//
gFrontPagePrivate.HiiHandle = HiiAddPackages (
&mFrontPageGuid,
gFrontPagePrivate.DriverHandle,
FrontPageVfrBin,
UiAppStrings,
NULL
);

这里的mFrontPageGuid跟vfr文件(MdeModulePkg\Application\UiApp\FrontPageVfr.Vfr)中的GUID一致,就是下面的FORMSET_GUID:

#define FORMSET_GUID { 0x9e0c30bc, 0x3f06, 0x4ba6, 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }

#define FRONT_PAGE_FORM_ID 0x1000

#define LABEL_FRANTPAGE_INFORMATION 0x1000
#define LABEL_END 0xffff

formset
guid = FORMSET_GUID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE),
help = STRING_TOKEN(STR_EMPTY_STRING ),
classguid = FORMSET_GUID,

返回的gFrontPagePrivate.HiiHandle会在EFI_FORM_BROWSER2_PROTOCOL中使用:

Status = gFormBrowser2->SendForm (
gFormBrowser2,
&gFrontPagePrivate.HiiHandle,
1,
&mFrontPageGuid,
0,
NULL,
&ActionRequest
);

这里也用到了mFrontPageGuid,且应该是必须的,跟classguid = FORMSET_GUID匹配。

目前可添加的Packages有如下的种类:

Font
Simplified Font
String
Image
Device Path
keyboard Layout
GUID
Forms
本例中就使用了Font和String这些Package。

创建操作码
操作码可以在vfr文件中指定,也可以通过代码创建,下面介绍一些简单的创建操作码的函数。

HiiAllocateOpCodeHandle/HiiFreeOpCodeHandle
HiiAllocateOpCodeHandle()创建HII_LIB_OPCODE_BUFFER结构体并返回:

VOID *
EFIAPI
HiiAllocateOpCodeHandle (
VOID
)

其结构如下:

typedef struct {
UINT8 *Buffer;
UINTN BufferSize;
UINTN Position;
} HII_LIB_OPCODE_BUFFER;

创建好之后的结构体中Buffer是一个大小为0x200字节的空间;BufferSize就是0x200;Position初始化为0。

HiiFreeOpCodeHandle()用来释放HiiAllocateOpCodeHandle()分配的数据,两者配合使用。

Buffer里面存放到就是各类操作码,如果操作码多,则Buffer还会根据实际的情况重新分配大小以存放所有的操作码。

HiiCreateActionOpCode
创建一个可以执行的操作码,其函数原型:

/**
Create EFI_IFR_ACTION_OP opcode.

If OpCodeHandle is NULL, then ASSERT().
If any reserved bits are set in QuestionFlags, then ASSERT().

@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@param[in] QuestionConfig String ID for configuration

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateActionOpCode (
IN VOID *OpCodeHandle,
IN EFI_QUESTION_ID QuestionId,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN EFI_STRING_ID QuestionConfig
)

操作码对应的结构体:

typedef struct _EFI_IFR_ACTION {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
EFI_STRING_ID QuestionConfig;
} EFI_IFR_ACTION;

HiiCreateGotoExOpCode
创建的操作码用于跳转,其函数原型:

/**
Create EFI_IFR_REF_OP, EFI_IFR_REF2_OP, EFI_IFR_REF3_OP and EFI_IFR_REF4_OP opcode.

When RefDevicePath is not zero, EFI_IFR_REF4 opcode will be created.
When RefDevicePath is zero and RefFormSetId is not NULL, EFI_IFR_REF3 opcode will be created.
When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is not zero, EFI_IFR_REF2 opcode will be created.
When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is zero, EFI_IFR_REF opcode will be created.

If OpCodeHandle is NULL, then ASSERT().
If any reserved bits are set in QuestionFlags, then ASSERT().

@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] RefFormId The Destination Form ID.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header
@param[in] QuestionId Question ID.
@param[in] RefQuestionId The question on the form to which this link is referring.
If its value is zero, then the link refers to the top of the form.
@param[in] RefFormSetId The form set to which this link is referring. If its value is NULL, and RefDevicePath is
zero, then the link is to the current form set.
@param[in] RefDevicePath The string identifier that specifies the string containing the text representation of
the device path to which the form set containing the form specified by FormId.
If its value is zero, then the link refers to the current page.

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateGotoExOpCode (
IN VOID *OpCodeHandle,
IN EFI_FORM_ID RefFormId,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN EFI_QUESTION_ID QuestionId,
IN EFI_QUESTION_ID RefQuestionId,
IN EFI_GUID *RefFormSetId, OPTIONAL
IN EFI_STRING_ID RefDevicePath
)

创建的结构体根据参数的不同而存在差异:

typedef struct _EFI_IFR_REF {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
EFI_FORM_ID FormId;
} EFI_IFR_REF;

typedef struct _EFI_IFR_REF2 {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
EFI_FORM_ID FormId;
EFI_QUESTION_ID QuestionId;
} EFI_IFR_REF2;

typedef struct _EFI_IFR_REF3 {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
EFI_FORM_ID FormId;
EFI_QUESTION_ID QuestionId;
EFI_GUID FormSetId;
} EFI_IFR_REF3;

typedef struct _EFI_IFR_REF4 {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
EFI_FORM_ID FormId;
EFI_QUESTION_ID QuestionId;
EFI_GUID FormSetId;
EFI_STRING_ID DevicePath;
} EFI_IFR_REF4;

typedef struct _EFI_IFR_REF5 {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
} EFI_IFR_REF5;
其实现中有如下的代码:

//
// Cacluate OpCodeSize based on the input Ref value.
// Try to use the small OpCode to save size.
//
OpCodeSize = sizeof (EFI_IFR_REF);
if (RefDevicePath != 0) {
OpCodeSize = sizeof (EFI_IFR_REF4);
} else if (RefFormSetId != NULL) {
OpCodeSize = sizeof (EFI_IFR_REF3);
} else if (RefQuestionId != 0) {
OpCodeSize = sizeof (EFI_IFR_REF2);
}

从这里可以看到指定了不同的操作码。

HiiCreateGuidOpCode
函数原型:

/**
Create EFI_IFR_GUID opcode.

If OpCodeHandle is NULL, then ASSERT().
If Guid is NULL, then ASSERT().
If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().

@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] Guid Pointer to EFI_GUID of this guided opcode.
@param[in] GuidOpCode Pointer to an EFI_IFR_GUID opcode. This is an
optional parameter that may be NULL. If this
parameter is NULL, then the GUID extension
region of the created opcode is filled with zeros.
If this parameter is not NULL, then the GUID
extension region of GuidData will be copied to
the GUID extension region of the created opcode.
@param[in] OpCodeSize The size, in bytes, of created opcode. This value
must be >= sizeof(EFI_IFR_GUID).

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateGuidOpCode (
IN VOID *OpCodeHandle,
IN CONST EFI_GUID *Guid,
IN CONST VOID *GuidOpCode, OPTIONAL
IN UINTN OpCodeSize
)

创建EFI_IFR_GUID操作码,它是现有的GUID的扩展,本身包含不同的格式,通过一个GUID来标识,现有的有gEfiIfrTianoGuid,它包含的格式有:

///
/// EDKII implementation extension opcodes, new extension can be added here later.
///
#define EFI_IFR_EXTEND_OP_LABEL 0x0
#define EFI_IFR_EXTEND_OP_BANNER 0x1
#define EFI_IFR_EXTEND_OP_TIMEOUT 0x2
#define EFI_IFR_EXTEND_OP_CLASS 0x3
#define EFI_IFR_EXTEND_OP_SUBCLASS 0x4

下面是创建一个LABLE的示例:

//
// Create Hii Extend Label OpCode.
//
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
StartOpCodeHandle,
&gEfiIfrTianoGuid,
NULL,
sizeof (EFI_IFR_GUID_LABEL)
);

参数说明:

OpCodeHandle:对应容纳操作码的HII_LIB_OPCODE_BUFFER结构体;
HiiCreateOneOfOpCode
函数原型:

/**
Create EFI_IFR_ONE_OF_OP opcode.

If OpCodeHandle is NULL, then ASSERT().
If any reserved bits are set in QuestionFlags, then ASSERT().
If any reserved bits are set in OneOfFlags, then ASSERT().

@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
@param[in] VarOffset Offset in Storage or String ID of the name (VarName)
for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@param[in] OneOfFlags Flags for oneof opcode
@param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
@param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
is an optional parameter that may be NULL.

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateOneOfOpCode (
IN VOID *OpCodeHandle,
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 OneOfFlags,
IN VOID *OptionsOpCodeHandle,
IN VOID *DefaultsOpCodeHandle OPTIONAL
)

创建EFI_IFR_ONE_OF操作码,它表示的是select-one-of question,其实就是单选框,比如Front Page中的语言选择框:

其对应的结构体:

typedef struct _EFI_IFR_ONE_OF {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question; // 单选框结构体中的EFI_IFR_QUESTION_HEADER
UINT8 Flags;
MINMAXSTEP_DATA data;
} EFI_IFR_ONE_OF;

下面是一个示例:

HiiCreateOneOfOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_LANGUAGE,
0,
0,
STRING_TOKEN (STR_LANGUAGE_SELECT),
STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),
EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);

参数说明:

OpCodeHandle:应该是上一层操作码对应的HII_LIB_OPCODE_BUFFER结构体;
QuestionId:其实是一个UINT16类型的数值,它是一个在当前驱动唯一的值,通过它回调函数(由EFI_HII_ACCESS_FORM_CALLBACK声明)就能够知道需要处理的数据具体是哪个;(UEFI规范中的说明:A unique value which is sent to the original exporting driver so that it can identify the type of data to expect. The format of the data tends to vary based on the opcode that generated the callback. )
EFI_HII_ACCESS_FORM_CALLBACK回调函数的声明如下:

/**

This function is called to provide results data to the driver.
This data consists of a unique key that is used to identify
which data is either being passed back or being asked for.

@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser.
@param QuestionId A unique value which is sent to the original
exporting driver so that it can identify the type
of data to expect. The format of the data tends to
vary based on the opcode that generated the callback.
@param Type The type of value for the question.
@param Value A pointer to the data being sent to the original
exporting driver.
@param ActionRequest On return, points to the action requested by the
callback function.

@retval EFI_SUCCESS The callback successfully handled the action.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be saved.
@retval EFI_UNSUPPORTED The specified Action is not supported by the
callback.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_HII_ACCESS_FORM_CALLBACK)(
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN OUT EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);

它是EFI_HII_CONFIG_ACCESS_PROTOCOL的接口。

VarStoreId/VarOffset:这里通过一个ID指定对应的变量,通过Offset指定对应的成员,对该操作码的修改就对应的变量;如果没有变量与之对应,就直接写0就可以了;
Prompt:对应显示;
Help:对应操作的帮助;
QuestionFlags:表示选项的属性,比如只读、回调,等等,对应的值如下所示:
//
// Flag values of EFI_IFR_QUESTION_HEADER
//
#define EFI_IFR_FLAG_READ_ONLY 0x01
#define EFI_IFR_FLAG_CALLBACK 0x04
#define EFI_IFR_FLAG_RESET_REQUIRED 0x10
#define EFI_IFR_FLAG_REST_STYLE 0x20
#define EFI_IFR_FLAG_RECONNECT_REQUIRED 0x40
#define EFI_IFR_FLAG_OPTIONS_ONLY 0x80

EFI_IFR_QUESTION_HEADER在不少操作码都存在,比如这里创建的单选框(见结构体中的Question成员)就有,其结构体:

typedef struct _EFI_IFR_QUESTION_HEADER {
EFI_IFR_STATEMENT_HEADER Header;
EFI_QUESTION_ID QuestionId;
EFI_VARSTORE_ID VarStoreId;
union {
EFI_STRING_ID VarName;
UINT16 VarOffset;
} VarStoreInfo;
UINT8 Flags; // 对应QuestionFlags
} EFI_IFR_QUESTION_HEADER;

OneOfFlags:单选框的Flags,有如下的值:
//
// Flags related to the numeric question
//
#define EFI_IFR_NUMERIC_SIZE 0x03
#define EFI_IFR_NUMERIC_SIZE_1 0x00
#define EFI_IFR_NUMERIC_SIZE_2 0x01
#define EFI_IFR_NUMERIC_SIZE_4 0x02
#define EFI_IFR_NUMERIC_SIZE_8 0x03

#define EFI_IFR_DISPLAY 0x30
#define EFI_IFR_DISPLAY_INT_DEC 0x00
#define EFI_IFR_DISPLAY_UINT_DEC 0x10
#define EFI_IFR_DISPLAY_UINT_HEX 0x20

它表示的意义目前有两种,第一种表示值的类型,第二种表示显示的格式;

OptionsOpCodeHandle:表示单选框操作码本身,它里面通常还需要包含EFI_IFR_ONE_OF_OPTION_OP操作码,表示单选框中的子选项;
DefaultsOpCodeHandle:表示默认显示的单选框子选项;
关于子选项,见HiiCreateOneOfOptionOpCode。

HiiCreateOneOfOptionOpCode
函数原型:

/**
Create EFI_IFR_ONE_OF_OPTION_OP opcode.

If OpCodeHandle is NULL, then ASSERT().
If Type is invalid, then ASSERT().
If Flags is invalid, then ASSERT().

@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] StringId StringId for the option
@param[in] Flags Flags for the option
@param[in] Type Type for the option
@param[in] Value Value for the option

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateOneOfOptionOpCode (
IN VOID *OpCodeHandle,
IN UINT16 StringId,
IN UINT8 Flags,
IN UINT8 Type,
IN UINT64 Value
)

创建的操作码对应的结构体:

typedef struct _EFI_IFR_ONE_OF_OPTION {
EFI_IFR_OP_HEADER Header;
EFI_STRING_ID Option;
UINT8 Flags;
UINT8 Type;
EFI_IFR_TYPE_VALUE Value;
} EFI_IFR_ONE_OF_OPTION;

HiiCreateSubTitleOpCode
函数原型:

/**
Create EFI_IFR_SUBTITLE_OP opcode.

If OpCodeHandle is NULL, then ASSERT().
If any reserved bits are set in Flags, then ASSERT().
If Scope > 1, then ASSERT().

@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] Flags Subtitle opcode flags
@param[in] Scope 1 if this opcode is the beginning of a new scope.
0 if this opcode is within the current scope.

@retval NULL There is not enough space left in Buffer to add the opcode.
@retval Other A pointer to the created opcode.

**/
UINT8 *
EFIAPI
HiiCreateSubTitleOpCode (
IN VOID *OpCodeHandle,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 Flags,
IN UINT8 Scope
)

创建的操作码对应的结构体:

typedef struct _EFI_IFR_SUBTITLE {
EFI_IFR_OP_HEADER Header;
EFI_IFR_STATEMENT_HEADER Statement;
UINT8 Flags;
} EFI_IFR_SUBTITLE;

字符串操作
HiiGetString
函数原型:

/**
Retrieves a string from a string package in a specific language specified in Language
or in the best lanaguage. See HiiGetStringEx () for the details.

@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
);

这个函数用来获取字符串,字符串通过Language来确定语种,StringId确定使用哪个字段,这个字段定义在uni文件中,而uni文件通过函数HiiAddPackages()安装,下面是一个例子(来自MdeModulePkg\Application\UiApp\UiApp.inf):

//
// Publish our HII data
//
gFrontPagePrivate.HiiHandle = HiiAddPackages (
&mFrontPageGuid,
gFrontPagePrivate.DriverHandle,
FrontPageVfrBin,
UiAppStrings,
NULL
);

UiAppStrings是一个中间文件(AutoGen.c)中定义的变量,在Build目录中生成,它的名字来自inf中设置的MODULE_UNI_FILE:

MODULE_UNI_FILE = UiApp.uni
1
两者的关系是uni文件去掉后缀并加上Strings就得到的用在HiiAddPackages()中的变量。不过模块中的uni文件并不需要都是这个名字,可以有多个不同名的uni文件。

下面是使用HiiGetString()的一个例子:

//
// Update default banner string.
//
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);

STR_CUSTOMIZE_BANNER_LINE4_LEFT就是在某个uni文件(FrontPageStrings.uni)中定义的(目前是空的):

#string STR_CUSTOMIZE_BANNER_LINE4_LEFT #language en-US “”
#language fr-FR “”

而gFrontPagePrivate.HiiHandle是使用HiiAddPackages()安装时的返回值。

HiiSetString
函数原型:

/**
This function creates 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 String is added
or updated in the String Package associated with
HiiHandle for the set of languages specified by
SupportedLanguages. The format of
SupportedLanguages must follow the language
format assumed in 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表示新增,否则就表示修改原有的字符串。

Form操作
HiiUpdateForm
用于更新界面结构,函数原型:

EFI_STATUS
EFIAPI
HiiUpdateForm (
IN EFI_HII_HANDLE HiiHandle,
IN EFI_GUID *FormSetGuid, OPTIONAL
IN EFI_FORM_ID FormId,
IN VOID *StartOpCodeHandle,
IN VOID *EndOpCodeHandle OPTIONAL
)

这里的HiiHandle就是HiiAddPackages()添加元素数据之后的返回值:

gFrontPagePrivate.HiiHandle = HiiAddPackages (
&mFrontPageGuid,
gFrontPagePrivate.DriverHandle,
FrontPageVfrBin,
UiAppStrings,
NULL
);

FormSetGuid是HiiAddPackages()中的第一个参数,即mFrontPageGuid。

FormId是定义在vfr文件中:

form formid = FRONT_PAGE_FORM_ID,
1
StartOpCodeHandle和EndOpCodeHandle由HiiAllocateOpCodeHandle()创建。

相关内容

热门资讯

瑞天 图书 收钱吗-瑞天书店,... 哎呀,说到这个瑞天书店,我真是哭笑不得!你知道吗,每次我走进去,心里都在打鼓,这家店到底收不收钱?首...
朝阳医院电话是多少-朝阳医院电... 哎呀,说到朝阳医院的电话,我可是有一肚子的话要说!你知道吗,每次有个头疼脑热,我就得翻箱倒柜找那张写...
触动内心的悸动画:简单风景与故... 在这个喧嚣的世界里,总有一些画面能够触动内心最柔软的地方,它们就像是一幅幅悸动画,让我们的心跳不由自...
gps精确度-GPS 导航:是... 哎呀,说到GPS,我这心里就五味杂陈啊!你有没有过那种经历,明明跟着GPS走,结果却走进了个死胡同,...
safari浏览器书签同步-S... 嘿,亲爱的Safari用户们,你们有没有经历过那种心碎的瞬间——当你在一台新电脑上打开Safari,...
c反应蛋白肺炎-C 反应蛋白:... 哎呀,最近这C反应蛋白啊,简直成了我们健康的晴雨表。一听到这个名字,心里就不由得咯噔一下。这不,最近...
recover4all怎么注册... 哎呀,说到这个Recover4All注册,真是让人又爱又恨!你想啊,这个软件这么神奇,能帮你找回那些...
ubuntu 17.04 dv... 哟,大家好!今天我要聊聊我那个闪闪发光的宝贝——Ubuntu17.04DVD。这可不是普通的DVD哦...
刺客信条以停止工作-刺客信条总... 哎呀,我的天!刺客信条,你这是怎么了?每次我兴冲冲地点开你,想要在那些古老的街巷里飞檐走壁,你却总是...
盗版gta5mod安装教程-盗... 哎呀,说到这个盗版GTA5Mod安装教程,我真的气不打一处来!你们这些新手玩家,听我说,千万别被那些...
警惕!可移动磁盘病毒来袭,如何... 哎呀,说到这个可移动磁盘病毒,我就一肚子火!你想想,本来这小小的U盘,是我们传递文件的好帮手,现在倒...
监控布线图解-探秘监控布线世界... 大家好,我是你们的“探秘小能手”,今天我们要一起潜入那些神秘的监控布线世界,揭开它们的神秘面纱!是不...
洋地黄类药物治疗护理-洋地黄:... 哎呀,说到洋地黄,这可是我们医护人员心中的“老朋友”了!别看它名字土土的,作用可大着呢!这小家伙,专...
逆魂界7.25攻略-7.25 ... 嘿,各位逆魂界的战士们!今天我要带你们深入7.25版本的攻略,这可不是一般的战斗,这是热血与汗水的较...
克罗恩病是重大疾病吗-克罗恩病... 克罗恩病,这个名字听起来就像是来自某个遥远星球的神秘疾病,但实际上,它就在我们身边,悄无声息地侵蚀着...
电脑换64位系统怎么换-电脑换... 哎呀,说到电脑换64位系统,我这心里就像过山车一样,七上八下的。刚开始,我还以为这事儿多难呢,结果一...
qq空间 邮箱无法打开-QQ ... 哎哟喂,今天真是倒霉透顶了!我刚刚想查一下我的QQ空间邮箱,看看有没有什么重要消息,结果呢?页面愣是...
数组初始化为1-编程世界里数组... 哎呀,说到数组初始化为1,我这心里就有点儿小情绪!你说说,这编程世界里,数组咋就这么爱1呢?每次新建...
aceru盘重装系统-Acer... 大家好,我今天真的是要哭出来了!我的Acer笔记本最近卡得不行,打开个网页都要等半天,简直让人抓狂。...
赵丽颖雅虎搜星视频-重温雅虎搜... 哎呀,说到赵丽颖,我就忍不住激动起来!你们看过她在雅虎搜星的视频吗?那简直是太迷人了!记得第一次看到...