mirror of https://github.com/acidanthera/audk.git
1) Add in IfrParser so that the FrameworkHii->GetDefaultImage can scan UEFI IFR opcodes and get the default value embedded in the IFR.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5119 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c7ec71b4ed
commit
59336178ac
|
@ -332,8 +332,8 @@ ThunkExtractConfig (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = mUefiConfigRoutingProtocol->BlockToConfig (
|
Status = mHiiConfigRoutingProtocol->BlockToConfig (
|
||||||
mUefiConfigRoutingProtocol,
|
mHiiConfigRoutingProtocol,
|
||||||
Request,
|
Request,
|
||||||
Data,
|
Data,
|
||||||
DataSize,
|
DataSize,
|
||||||
|
@ -378,8 +378,8 @@ ThunkRouteConfig (
|
||||||
if (Data == NULL) {
|
if (Data == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
Status = mUefiConfigRoutingProtocol->ConfigToBlock (
|
Status = mHiiConfigRoutingProtocol->ConfigToBlock (
|
||||||
mUefiConfigRoutingProtocol,
|
mHiiConfigRoutingProtocol,
|
||||||
Configuration,
|
Configuration,
|
||||||
Data,
|
Data,
|
||||||
&LastModifiedByteIndex,
|
&LastModifiedByteIndex,
|
||||||
|
|
|
@ -16,6 +16,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
#include "HiiDatabase.h"
|
||||||
|
|
||||||
|
|
||||||
|
UINT8 mGlyphBuffer[EFI_GLYPH_WIDTH * 2 * EFI_GLYPH_HEIGHT];
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
HiiGetGlyph (
|
HiiGetGlyph (
|
||||||
|
@ -47,7 +50,7 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_SUCCESS;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -64,5 +67,5 @@ HiiGlyphToBlt (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_SUCCESS;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
#include "HiiDatabase.h"
|
||||||
|
#include "UefiIfrDefault.h"
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
@ -89,6 +90,7 @@ Returns:
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
HiiGetDefaultImage (
|
HiiGetDefaultImage (
|
||||||
|
@ -119,7 +121,31 @@ HiiGetDefaultImage (
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
return EFI_SUCCESS;
|
LIST_ENTRY *UefiDefaults;
|
||||||
|
EFI_HII_HANDLE UefiHiiHandle;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HII_THUNK_PRIVATE_DATA *Private;
|
||||||
|
|
||||||
|
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
||||||
|
|
||||||
|
UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle);
|
||||||
|
if (UefiHiiHandle == NULL) {
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
UefiDefaults = NULL;
|
||||||
|
Status = UefiIfrGetBufferTypeDefaults (UefiHiiHandle, &UefiDefaults);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = UefiDefaultsToFrameworkDefaults (UefiDefaults, DefaultMask, VariablePackList);
|
||||||
|
|
||||||
|
Done:
|
||||||
|
FreeDefaultList (UefiDefaults);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -143,8 +169,8 @@ ThunkUpdateFormCallBack (
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = mUefiHiiDatabaseProtocol->GetPackageListHandle (
|
Status = mHiiDatabase->GetPackageListHandle (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
HandleMapEntry->UefiHiiHandle,
|
HandleMapEntry->UefiHiiHandle,
|
||||||
&UefiDriverHandle
|
&UefiDriverHandle
|
||||||
);
|
);
|
||||||
|
@ -191,7 +217,7 @@ AppendToUpdateBuffer (
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
Framework2UefiCreateSubtitleOpCode (
|
F2UCreateSubtitleOpCode (
|
||||||
IN CONST FRAMEWORK_EFI_IFR_SUBTITLE *FwSubTitle,
|
IN CONST FRAMEWORK_EFI_IFR_SUBTITLE *FwSubTitle,
|
||||||
OUT EFI_HII_UPDATE_DATA *UefiData
|
OUT EFI_HII_UPDATE_DATA *UefiData
|
||||||
)
|
)
|
||||||
|
@ -209,7 +235,7 @@ Framework2UefiCreateSubtitleOpCode (
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
Framework2UefiCreateTextOpCode (
|
F2UCreateTextOpCode (
|
||||||
IN CONST FRAMEWORK_EFI_IFR_TEXT *FwText,
|
IN CONST FRAMEWORK_EFI_IFR_TEXT *FwText,
|
||||||
OUT EFI_HII_UPDATE_DATA *UefiData
|
OUT EFI_HII_UPDATE_DATA *UefiData
|
||||||
)
|
)
|
||||||
|
@ -260,11 +286,11 @@ ThunkFrameworkUpdateDataToUefiUpdateData (
|
||||||
for (Index = 0; Index < Data->DataCount; Index++) {
|
for (Index = 0; Index < Data->DataCount; Index++) {
|
||||||
switch (FrameworkOpcodeBuffer->OpCode) {
|
switch (FrameworkOpcodeBuffer->OpCode) {
|
||||||
case FRAMEWORK_EFI_IFR_SUBTITLE_OP:
|
case FRAMEWORK_EFI_IFR_SUBTITLE_OP:
|
||||||
Status = Framework2UefiCreateSubtitleOpCode ((FRAMEWORK_EFI_IFR_SUBTITLE *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
|
Status = F2UCreateSubtitleOpCode ((FRAMEWORK_EFI_IFR_SUBTITLE *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAMEWORK_EFI_IFR_TEXT_OP:
|
case FRAMEWORK_EFI_IFR_TEXT_OP:
|
||||||
Status = Framework2UefiCreateTextOpCode ((FRAMEWORK_EFI_IFR_TEXT *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
|
Status = F2UCreateTextOpCode ((FRAMEWORK_EFI_IFR_TEXT *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -285,6 +311,199 @@ ThunkFrameworkUpdateDataToUefiUpdateData (
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
GetPackageDataFromPackageList (
|
||||||
|
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
|
||||||
|
IN UINT32 PackageIndex,
|
||||||
|
OUT UINT32 *BufferLen,
|
||||||
|
OUT EFI_HII_PACKAGE_HEADER **Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 Index;
|
||||||
|
EFI_HII_PACKAGE_HEADER *Package;
|
||||||
|
UINT32 Offset;
|
||||||
|
UINT32 PackageListLength;
|
||||||
|
EFI_HII_PACKAGE_HEADER PackageHeader = {0, 0};
|
||||||
|
|
||||||
|
ASSERT(HiiPackageList != NULL);
|
||||||
|
|
||||||
|
if ((BufferLen == NULL) || (Buffer == NULL)) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Package = NULL;
|
||||||
|
Index = 0;
|
||||||
|
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||||
|
CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
|
||||||
|
while (Offset < PackageListLength) {
|
||||||
|
Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
|
||||||
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
||||||
|
if (Index == PackageIndex) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Offset += PackageHeader.Length;
|
||||||
|
Index++;
|
||||||
|
}
|
||||||
|
if (Offset >= PackageListLength) {
|
||||||
|
//
|
||||||
|
// no package found in this Package List
|
||||||
|
//
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
*BufferLen = PackageHeader.Length;
|
||||||
|
*Buffer = Package;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if Label exist in the IFR form package.
|
||||||
|
|
||||||
|
@param
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
LocateLabel (
|
||||||
|
IN CONST EFI_HII_PACKAGE_HEADER *Package,
|
||||||
|
IN EFI_FORM_LABEL Label,
|
||||||
|
OUT EFI_GUID *FormsetGuid,
|
||||||
|
OUT EFI_FORM_ID *FormId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Offset;
|
||||||
|
EFI_IFR_OP_HEADER *IfrOpHdr;
|
||||||
|
UINT8 ExtendOpCode;
|
||||||
|
UINT16 LabelNumber;
|
||||||
|
EFI_GUID InternalFormSetGuid;
|
||||||
|
EFI_FORM_ID InternalFormId;
|
||||||
|
BOOLEAN GetFormSet;
|
||||||
|
BOOLEAN GetForm;
|
||||||
|
|
||||||
|
IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
|
||||||
|
Offset = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
|
||||||
|
InternalFormId= 0;
|
||||||
|
ZeroMem (&InternalFormSetGuid, sizeof (EFI_GUID));
|
||||||
|
GetFormSet = FALSE;
|
||||||
|
GetForm = FALSE;
|
||||||
|
|
||||||
|
while (Offset < Package->Length) {
|
||||||
|
switch (IfrOpHdr->OpCode) {
|
||||||
|
case EFI_IFR_FORM_SET_OP :
|
||||||
|
CopyMem (&InternalFormSetGuid, &((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, sizeof (EFI_GUID));
|
||||||
|
GetFormSet = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_IFR_FORM_OP:
|
||||||
|
CopyMem (&InternalFormId, &((EFI_IFR_FORM *) IfrOpHdr)->FormId, sizeof (EFI_FORM_ID));
|
||||||
|
GetForm = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_IFR_GUID_OP :
|
||||||
|
ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
|
||||||
|
|
||||||
|
if (ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) {
|
||||||
|
//
|
||||||
|
// Go to the next Op-Code
|
||||||
|
//
|
||||||
|
Offset += IfrOpHdr->Length;
|
||||||
|
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
|
||||||
|
if (LabelNumber == Label) {
|
||||||
|
ASSERT (GetForm && GetFormSet);
|
||||||
|
CopyGuid (FormsetGuid, &InternalFormSetGuid);
|
||||||
|
*FormId = InternalFormId;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Go to the next Op-Code
|
||||||
|
//
|
||||||
|
Offset += IfrOpHdr->Length;
|
||||||
|
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find the first EFI_FORM_LABEL in FormSets for a given EFI_HII_HANLDE defined.
|
||||||
|
|
||||||
|
EFI_FORM_LABEL is a specific to Tiano implementation. The current implementation
|
||||||
|
does not restrict labels with same label value to be duplicated in either FormSet
|
||||||
|
scope or Form scope. This function will only locate the FIRST EFI_FORM_LABEL
|
||||||
|
with value as the same as the input Label in the Formset registered with UefiHiiHandle. The FormSet GUID
|
||||||
|
and Form ID is returned if such Label is found.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_INVALID_PARAMETER If UefiHiiHandle is not a valid handle.
|
||||||
|
@retval EFI_NOT_FOUND The package list identified by UefiHiiHandle deos not contain FormSet or
|
||||||
|
There is no Form ID with value Label found in all Form Sets in the pacakge
|
||||||
|
list.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The first found Form ID is returned in FormId.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ThunkLocateFormId (
|
||||||
|
IN EFI_HII_HANDLE Handle,
|
||||||
|
IN EFI_FORM_LABEL Label,
|
||||||
|
OUT EFI_GUID *FormsetGuid,
|
||||||
|
OUT EFI_FORM_ID *FormId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
||||||
|
UINT32 Index;
|
||||||
|
UINTN BufferSize;
|
||||||
|
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||||
|
EFI_HII_PACKAGE_HEADER *Package;
|
||||||
|
UINT32 PackageLength;
|
||||||
|
|
||||||
|
BufferSize = 0;
|
||||||
|
HiiPackageList = NULL;
|
||||||
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
HiiPackageList = AllocatePool (BufferSize);
|
||||||
|
ASSERT (HiiPackageList != NULL);
|
||||||
|
|
||||||
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Index = 0; ; Index++) {
|
||||||
|
Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
||||||
|
if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
|
||||||
|
Status = LocateLabel (Package, Label, FormsetGuid, FormId);
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Done:
|
||||||
|
FreePool (HiiPackageList);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
HiiUpdateForm (
|
HiiUpdateForm (
|
||||||
|
@ -317,6 +536,8 @@ Returns:
|
||||||
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
|
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
|
||||||
EFI_HII_UPDATE_DATA *UefiHiiUpdateData;
|
EFI_HII_UPDATE_DATA *UefiHiiUpdateData;
|
||||||
EFI_HII_HANDLE UefiHiiHandle;
|
EFI_HII_HANDLE UefiHiiHandle;
|
||||||
|
EFI_GUID FormsetGuid;
|
||||||
|
EFI_FORM_ID FormId;
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
@ -350,7 +571,10 @@ Returns:
|
||||||
|
|
||||||
ThunkFrameworkUpdateDataToUefiUpdateData (Data, AddData, &UefiHiiUpdateData);
|
ThunkFrameworkUpdateDataToUefiUpdateData (Data, AddData, &UefiHiiUpdateData);
|
||||||
|
|
||||||
Status = IfrLibUpdateForm (UefiHiiHandle, NULL, 0, Label, AddData, UefiHiiUpdateData);
|
Status = ThunkLocateFormId (UefiHiiHandle, Label, &FormsetGuid, &FormId);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, AddData, UefiHiiUpdateData);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
if (UefiHiiUpdateData != NULL) {
|
if (UefiHiiUpdateData != NULL) {
|
||||||
|
|
|
@ -33,6 +33,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
[Sources.common]
|
[Sources.common]
|
||||||
|
UefiIfrParserInternal.h
|
||||||
|
UefiIfrParserCommon.c
|
||||||
|
UefiIfrParserCommon.h
|
||||||
|
UefiIfrParser.c
|
||||||
|
UefiIfrParser.h
|
||||||
|
UefiIfrParserExpression.c
|
||||||
|
UefiIfrParserExpressionInternal.h
|
||||||
|
UefiIfrDefault.c
|
||||||
|
UefiIfrDefault.h
|
||||||
Keyboard.c
|
Keyboard.c
|
||||||
Fonts.c
|
Fonts.c
|
||||||
Package.c
|
Package.c
|
||||||
|
@ -44,6 +53,8 @@
|
||||||
ConfigAccess.h
|
ConfigAccess.h
|
||||||
Utility.c
|
Utility.c
|
||||||
Utility.h
|
Utility.h
|
||||||
|
R8Lib.c
|
||||||
|
R8Lib.h
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
|
@ -63,6 +74,7 @@
|
||||||
ExtendedHiiLib
|
ExtendedHiiLib
|
||||||
IfrSupportLib
|
IfrSupportLib
|
||||||
ExtendedIfrSupportLib
|
ExtendedIfrSupportLib
|
||||||
|
PrintLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiHiiProtocolGuid
|
gEfiHiiProtocolGuid
|
||||||
|
@ -73,6 +85,7 @@
|
||||||
gEfiHiiConfigRoutingProtocolGuid
|
gEfiHiiConfigRoutingProtocolGuid
|
||||||
gEfiHiiConfigAccessProtocolGuid
|
gEfiHiiConfigAccessProtocolGuid
|
||||||
gEfiFormCallbackProtocolGuid
|
gEfiFormCallbackProtocolGuid
|
||||||
|
gEfiUnicodeCollation2ProtocolGuid
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gEfiHiiImageProtocolGuid AND
|
gEfiHiiImageProtocolGuid AND
|
||||||
|
|
|
@ -56,11 +56,11 @@ EFI_HII_THUNK_PRIVATE_DATA HiiThunkPrivateDataTempate = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
CONST EFI_HII_DATABASE_PROTOCOL *mUefiHiiDatabaseProtocol;
|
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
|
||||||
CONST EFI_HII_FONT_PROTOCOL *mUefiHiiFontProtocol;
|
CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
|
||||||
CONST EFI_HII_IMAGE_PROTOCOL *mUefiHiiImageProtocol;
|
CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
|
||||||
CONST EFI_HII_STRING_PROTOCOL *mUefiStringProtocol;
|
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
|
||||||
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mUefiConfigRoutingProtocol;
|
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -96,35 +96,35 @@ Returns:
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiDatabaseProtocolGuid,
|
&gEfiHiiDatabaseProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mUefiHiiDatabaseProtocol
|
(VOID **) &mHiiDatabase
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiFontProtocolGuid,
|
&gEfiHiiFontProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mUefiHiiFontProtocol
|
(VOID **) &mHiiFontProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiImageProtocolGuid,
|
&gEfiHiiImageProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mUefiHiiImageProtocol
|
(VOID **) &mHiiImageProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiStringProtocolGuid,
|
&gEfiHiiStringProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mUefiStringProtocol
|
(VOID **) &mHiiStringProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiConfigRoutingProtocolGuid,
|
&gEfiHiiConfigRoutingProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mUefiConfigRoutingProtocol
|
(VOID **) &mHiiConfigRoutingProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
|
|
@ -46,18 +46,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/HiiLib.h>
|
#include <Library/HiiLib.h>
|
||||||
#include <Library/ExtendedHiiLib.h>
|
#include <Library/ExtendedHiiLib.h>
|
||||||
|
|
||||||
//
|
|
||||||
// There are some type redefinitions between Framework Ifr Support Library and
|
|
||||||
// UEFI HII Ifr Support Library. We undefine the duplicated Framework definition here
|
|
||||||
// so that the duplicated definitions in UEFI HII Ifr can be defined.
|
|
||||||
// In this Thunk Module, we will access all Framework definition with "FRAMEWORK_" prefix.
|
|
||||||
//
|
|
||||||
#undef IFR_OPTION
|
|
||||||
#undef EFI_HII_UPDATE_DATA
|
|
||||||
|
|
||||||
#include <Library/IfrSupportLib.h>
|
#include <Library/IfrSupportLib.h>
|
||||||
#include <Library/ExtendedIfrSupportLib.h>
|
#include <Library/ExtendedIfrSupportLib.h>
|
||||||
|
|
||||||
|
#include <MdeModuleHii.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macros
|
// Macros
|
||||||
//
|
//
|
||||||
|
@ -147,11 +140,11 @@ typedef struct {
|
||||||
//
|
//
|
||||||
// Extern Variables
|
// Extern Variables
|
||||||
//
|
//
|
||||||
extern CONST EFI_HII_DATABASE_PROTOCOL *mUefiHiiDatabaseProtocol;
|
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
|
||||||
extern CONST EFI_HII_FONT_PROTOCOL *mUefiHiiFontProtocol;
|
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
|
||||||
extern CONST EFI_HII_IMAGE_PROTOCOL *mUefiHiiImageProtocol;
|
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
|
||||||
extern CONST EFI_HII_STRING_PROTOCOL *mUefiStringProtocol;
|
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
|
||||||
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mUefiConfigRoutingProtocol;
|
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prototypes
|
// Prototypes
|
||||||
|
|
|
@ -86,8 +86,8 @@ LibExportPackageLists (
|
||||||
|
|
||||||
Size = 0;
|
Size = 0;
|
||||||
PackageListHdr = NULL;
|
PackageListHdr = NULL;
|
||||||
Status = mUefiHiiDatabaseProtocol->ExportPackageLists (
|
Status = mHiiDatabase->ExportPackageLists (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
UefiHiiHandle,
|
UefiHiiHandle,
|
||||||
&Size,
|
&Size,
|
||||||
PackageListHdr
|
PackageListHdr
|
||||||
|
@ -100,8 +100,8 @@ LibExportPackageLists (
|
||||||
if (PackageListHeader == NULL) {
|
if (PackageListHeader == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
Status = mUefiHiiDatabaseProtocol->ExportPackageLists (
|
Status = mHiiDatabase->ExportPackageLists (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
UefiHiiHandle,
|
UefiHiiHandle,
|
||||||
&Size,
|
&Size,
|
||||||
PackageListHdr
|
PackageListHdr
|
||||||
|
@ -140,8 +140,8 @@ InsertStringPackagesToIfrPackageList (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
Status = mUefiHiiDatabaseProtocol->UpdatePackageList (
|
Status = mHiiDatabase->UpdatePackageList (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
UefiHiiHandle,
|
UefiHiiHandle,
|
||||||
StringPackageListHeader
|
StringPackageListHeader
|
||||||
);
|
);
|
||||||
|
@ -253,23 +253,21 @@ PrepareUefiPackageListFromFrameworkHiiPackages (
|
||||||
return PackageListHeader;
|
return PackageListHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_GUID *
|
VOID
|
||||||
UefiGeneratePackageListGuidId (
|
GenerateGuidId (
|
||||||
IN CONST EFI_HII_PACKAGES * Packages
|
IN CONST EFI_GUID * InGuid,
|
||||||
|
OUT EFI_GUID * OutGuid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_GUID *Guid;
|
|
||||||
UINT64 MonotonicCount;
|
UINT64 MonotonicCount;
|
||||||
|
|
||||||
Guid = AllocateCopyPool (sizeof (EFI_GUID), Packages->GuidId);
|
CopyMem (OutGuid, InGuid, sizeof (EFI_GUID));
|
||||||
|
|
||||||
gBS->GetNextMonotonicCount (&MonotonicCount);
|
gBS->GetNextMonotonicCount (&MonotonicCount);
|
||||||
//
|
//
|
||||||
// Use Monotonic Count as a psedo random number generator.
|
// Use Monotonic Count as a psedo random number generator.
|
||||||
//
|
//
|
||||||
*((UINT64 *) Guid) = *((UINT64 *) Guid) + MonotonicCount;
|
*((UINT64 *) OutGuid) = *((UINT64 *) OutGuid) + MonotonicCount;
|
||||||
|
|
||||||
return Guid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -310,6 +308,9 @@ FindAndAddStringPackageToIfrPackageList(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONST EFI_GUID mAGuid =
|
||||||
|
{ 0x14f95e01, 0xd562, 0x432e, { 0x84, 0x4a, 0x95, 0xa4, 0x39, 0x5, 0x10, 0x7e } };
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
UefiRegisterPackageList(
|
UefiRegisterPackageList(
|
||||||
EFI_HII_THUNK_PRIVATE_DATA *Private,
|
EFI_HII_THUNK_PRIVATE_DATA *Private,
|
||||||
|
@ -322,20 +323,35 @@ UefiRegisterPackageList(
|
||||||
UINTN IfrPackNum;
|
UINTN IfrPackNum;
|
||||||
EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader;
|
EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader;
|
||||||
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
|
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
|
||||||
EFI_GUID *GuidId;
|
EFI_GUID GuidId;
|
||||||
EFI_HANDLE UefiHiiDriverHandle;
|
EFI_HANDLE UefiHiiDriverHandle;
|
||||||
|
|
||||||
GuidId = NULL;
|
|
||||||
UefiHiiDriverHandle = NULL;
|
UefiHiiDriverHandle = NULL;
|
||||||
|
|
||||||
Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum);
|
Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
//
|
||||||
|
// Thunk Layer only handle the following combinations of IfrPack, StringPkg and FontPack
|
||||||
|
//
|
||||||
|
if (IfrPackNum > 1) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
HandleMappingEntry = AllocateZeroPool (sizeof (*HandleMappingEntry));
|
HandleMappingEntry = AllocateZeroPool (sizeof (*HandleMappingEntry));
|
||||||
ASSERT (HandleMappingEntry != NULL);
|
ASSERT (HandleMappingEntry != NULL);
|
||||||
|
|
||||||
HandleMappingEntry->Signature = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE;
|
HandleMappingEntry->Signature = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE;
|
||||||
HandleMappingEntry->FrameworkHiiHandle = Private->StaticHiiHandle++;
|
HandleMappingEntry->FrameworkHiiHandle = Private->StaticHiiHandle++;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Packages->GuidId may be NULL. In such case, caller of FramworkHii->NewPack is registering
|
||||||
|
// package with StringPack and IfrPack.
|
||||||
|
//
|
||||||
|
if (Packages->GuidId == NULL) {
|
||||||
|
Packages->GuidId = &GuidId;
|
||||||
|
GenerateGuidId (&mAGuid, Packages->GuidId);
|
||||||
|
}
|
||||||
|
|
||||||
CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId);
|
CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId);
|
||||||
|
|
||||||
if ((StringPackNum == 0) && (IfrPackNum != 0)) {
|
if ((StringPackNum == 0) && (IfrPackNum != 0)) {
|
||||||
|
@ -344,7 +360,7 @@ UefiRegisterPackageList(
|
||||||
// In Framework HII implementation, Packages->GuidId is used as an identifier to associate
|
// In Framework HII implementation, Packages->GuidId is used as an identifier to associate
|
||||||
// a PackageList with only IFR to a Package list the with String package.
|
// a PackageList with only IFR to a Package list the with String package.
|
||||||
//
|
//
|
||||||
GuidId = UefiGeneratePackageListGuidId (Packages);
|
GenerateGuidId (Packages->GuidId, &GuidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -354,9 +370,9 @@ UefiRegisterPackageList(
|
||||||
if (IfrPackNum != 0) {
|
if (IfrPackNum != 0) {
|
||||||
InstallDefaultUefiConfigAccessProtocol (Packages, &UefiHiiDriverHandle, HandleMappingEntry);
|
InstallDefaultUefiConfigAccessProtocol (Packages, &UefiHiiDriverHandle, HandleMappingEntry);
|
||||||
}
|
}
|
||||||
UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, GuidId);
|
UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
|
||||||
Status = mUefiHiiDatabaseProtocol->NewPackageList (
|
Status = mHiiDatabase->NewPackageList (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
UefiPackageListHeader,
|
UefiPackageListHeader,
|
||||||
UefiHiiDriverHandle,
|
UefiHiiDriverHandle,
|
||||||
&HandleMappingEntry->UefiHiiHandle
|
&HandleMappingEntry->UefiHiiHandle
|
||||||
|
@ -413,7 +429,6 @@ Done:
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (UefiPackageListHeader);
|
FreePool (UefiPackageListHeader);
|
||||||
SafeFreePool (GuidId);
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -493,8 +508,8 @@ Returns:
|
||||||
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
|
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
|
||||||
|
|
||||||
if (HandleMapEntry->UefiHiiHandle != NULL) {
|
if (HandleMapEntry->UefiHiiHandle != NULL) {
|
||||||
Status = mUefiHiiDatabaseProtocol->RemovePackageList (
|
Status = mHiiDatabase->RemovePackageList (
|
||||||
mUefiHiiDatabaseProtocol,
|
mHiiDatabase,
|
||||||
HandleMapEntry->UefiHiiHandle
|
HandleMapEntry->UefiHiiHandle
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
|
@ -0,0 +1,244 @@
|
||||||
|
/**@file
|
||||||
|
Copyright (c) 2007, Intel Corporation
|
||||||
|
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include "R8Lib.h"
|
||||||
|
|
||||||
|
CHAR16
|
||||||
|
NibbleToHexChar (
|
||||||
|
IN UINT8 Nibble
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Converts the low nibble of a byte to hex unicode character.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
Nibble - lower nibble of a byte.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Hex unicode character.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
Nibble &= 0x0F;
|
||||||
|
if (Nibble <= 0x9) {
|
||||||
|
return (CHAR16)(Nibble + L'0');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CHAR16)(Nibble - 0xA + L'A');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts binary buffer to Unicode string.
|
||||||
|
At a minimum, any blob of data could be represented as a hex string.
|
||||||
|
|
||||||
|
@param Str Pointer to the string.
|
||||||
|
@param HexStringBufferLength Length in bytes of buffer to hold the hex string.
|
||||||
|
Includes tailing '\0' character. If routine return
|
||||||
|
with EFI_SUCCESS, containing length of hex string
|
||||||
|
buffer. If routine return with
|
||||||
|
EFI_BUFFER_TOO_SMALL, containg length of hex
|
||||||
|
string buffer desired.
|
||||||
|
@param Buf Buffer to be converted from.
|
||||||
|
@param Len Length in bytes of the buffer to be converted.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Routine success.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
R8_BufToHexString (
|
||||||
|
IN OUT CHAR16 *Str,
|
||||||
|
IN OUT UINTN *HexStringBufferLength,
|
||||||
|
IN UINT8 *Buf,
|
||||||
|
IN UINTN Len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Porting Guide:
|
||||||
|
// This library interface is simply obsolete.
|
||||||
|
// Include the source code to user code.
|
||||||
|
//
|
||||||
|
UINTN Idx;
|
||||||
|
UINT8 Byte;
|
||||||
|
UINTN StrLen;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure string is either passed or allocate enough.
|
||||||
|
// It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
|
||||||
|
// Plus the Unicode termination character.
|
||||||
|
//
|
||||||
|
StrLen = Len * 2;
|
||||||
|
if (StrLen > ((*HexStringBufferLength) - 1)) {
|
||||||
|
*HexStringBufferLength = StrLen + 1;
|
||||||
|
return EFI_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*HexStringBufferLength = StrLen + 1;
|
||||||
|
//
|
||||||
|
// Ends the string.
|
||||||
|
//
|
||||||
|
Str[StrLen] = L'\0';
|
||||||
|
|
||||||
|
for (Idx = 0; Idx < Len; Idx++) {
|
||||||
|
|
||||||
|
Byte = Buf[Idx];
|
||||||
|
Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
|
||||||
|
Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts Unicode string to binary buffer.
|
||||||
|
The conversion may be partial.
|
||||||
|
The first character in the string that is not hex digit stops the conversion.
|
||||||
|
At a minimum, any blob of data could be represented as a hex string.
|
||||||
|
|
||||||
|
@param Buf Pointer to buffer that receives the data.
|
||||||
|
@param Len Length in bytes of the buffer to hold converted
|
||||||
|
data. If routine return with EFI_SUCCESS,
|
||||||
|
containing length of converted data. If routine
|
||||||
|
return with EFI_BUFFER_TOO_SMALL, containg length
|
||||||
|
of buffer desired.
|
||||||
|
@param Str String to be converted from.
|
||||||
|
@param ConvertedStrLen Length of the Hex String consumed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Routine Success.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
R8_HexStringToBuf (
|
||||||
|
IN OUT UINT8 *Buf,
|
||||||
|
IN OUT UINTN *Len,
|
||||||
|
IN CHAR16 *Str,
|
||||||
|
OUT UINTN *ConvertedStrLen OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Porting Guide:
|
||||||
|
// This library interface is simply obsolete.
|
||||||
|
// Include the source code to user code.
|
||||||
|
//
|
||||||
|
|
||||||
|
UINTN HexCnt;
|
||||||
|
UINTN Idx;
|
||||||
|
UINTN BufferLength;
|
||||||
|
UINT8 Digit;
|
||||||
|
UINT8 Byte;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find out how many hex characters the string has.
|
||||||
|
//
|
||||||
|
for (Idx = 0, HexCnt = 0; R8_IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
|
||||||
|
|
||||||
|
if (HexCnt == 0) {
|
||||||
|
*Len = 0;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Two Unicode characters make up 1 buffer byte. Round up.
|
||||||
|
//
|
||||||
|
BufferLength = (HexCnt + 1) / 2;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Test if buffer is passed enough.
|
||||||
|
//
|
||||||
|
if (BufferLength > (*Len)) {
|
||||||
|
*Len = BufferLength;
|
||||||
|
return EFI_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*Len = BufferLength;
|
||||||
|
|
||||||
|
for (Idx = 0; Idx < HexCnt; Idx++) {
|
||||||
|
|
||||||
|
R8_IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
|
||||||
|
|
||||||
|
//
|
||||||
|
// For odd charaters, write the lower nibble for each buffer byte,
|
||||||
|
// and for even characters, the upper nibble.
|
||||||
|
//
|
||||||
|
if ((Idx & 1) == 0) {
|
||||||
|
Byte = Digit;
|
||||||
|
} else {
|
||||||
|
Byte = Buf[Idx / 2];
|
||||||
|
Byte &= 0x0F;
|
||||||
|
Byte = (UINT8) (Byte | Digit << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
Buf[Idx / 2] = Byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConvertedStrLen != NULL) {
|
||||||
|
*ConvertedStrLen = HexCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Determines if a Unicode character is a hexadecimal digit.
|
||||||
|
The test is case insensitive.
|
||||||
|
|
||||||
|
@param Digit Pointer to byte that receives the value of the hex
|
||||||
|
character.
|
||||||
|
@param Char Unicode character to test.
|
||||||
|
|
||||||
|
@retval TRUE If the character is a hexadecimal digit.
|
||||||
|
@retval FALSE Otherwise.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
R8_IsHexDigit (
|
||||||
|
OUT UINT8 *Digit,
|
||||||
|
IN CHAR16 Char
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Porting Guide:
|
||||||
|
// This library interface is simply obsolete.
|
||||||
|
// Include the source code to user code.
|
||||||
|
//
|
||||||
|
|
||||||
|
if ((Char >= L'0') && (Char <= L'9')) {
|
||||||
|
*Digit = (UINT8) (Char - L'0');
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Char >= L'A') && (Char <= L'F')) {
|
||||||
|
*Digit = (UINT8) (Char - L'A' + 0x0A);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Char >= L'a') && (Char <= L'f')) {
|
||||||
|
*Digit = (UINT8) (Char - L'a' + 0x0A);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/**@file
|
||||||
|
Copyright (c) 2007, Intel Corporation
|
||||||
|
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts binary buffer to Unicode string.
|
||||||
|
At a minimum, any blob of data could be represented as a hex string.
|
||||||
|
|
||||||
|
@param Str Pointer to the string.
|
||||||
|
@param HexStringBufferLength Length in bytes of buffer to hold the hex string.
|
||||||
|
Includes tailing '\0' character. If routine return
|
||||||
|
with EFI_SUCCESS, containing length of hex string
|
||||||
|
buffer. If routine return with
|
||||||
|
EFI_BUFFER_TOO_SMALL, containg length of hex
|
||||||
|
string buffer desired.
|
||||||
|
@param Buf Buffer to be converted from.
|
||||||
|
@param Len Length in bytes of the buffer to be converted.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Routine success.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
R8_BufToHexString (
|
||||||
|
IN OUT CHAR16 *Str,
|
||||||
|
IN OUT UINTN *HexStringBufferLength,
|
||||||
|
IN UINT8 *Buf,
|
||||||
|
IN UINTN Len
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts Unicode string to binary buffer.
|
||||||
|
The conversion may be partial.
|
||||||
|
The first character in the string that is not hex digit stops the conversion.
|
||||||
|
At a minimum, any blob of data could be represented as a hex string.
|
||||||
|
|
||||||
|
@param Buf Pointer to buffer that receives the data.
|
||||||
|
@param Len Length in bytes of the buffer to hold converted
|
||||||
|
data. If routine return with EFI_SUCCESS,
|
||||||
|
containing length of converted data. If routine
|
||||||
|
return with EFI_BUFFER_TOO_SMALL, containg length
|
||||||
|
of buffer desired.
|
||||||
|
@param Str String to be converted from.
|
||||||
|
@param ConvertedStrLen Length of the Hex String consumed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Routine Success.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
R8_HexStringToBuf (
|
||||||
|
IN OUT UINT8 *Buf,
|
||||||
|
IN OUT UINTN *Len,
|
||||||
|
IN CHAR16 *Str,
|
||||||
|
OUT UINTN *ConvertedStrLen OPTIONAL
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Determines if a Unicode character is a hexadecimal digit.
|
||||||
|
The test is case insensitive.
|
||||||
|
|
||||||
|
@param Digit Pointer to byte that receives the value of the hex
|
||||||
|
character.
|
||||||
|
@param Char Unicode character to test.
|
||||||
|
|
||||||
|
@retval TRUE If the character is a hexadecimal digit.
|
||||||
|
@retval FALSE Otherwise.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
R8_IsHexDigit (
|
||||||
|
OUT UINT8 *Digit,
|
||||||
|
IN CHAR16 Char
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
|
@ -267,8 +267,8 @@ Returns:
|
||||||
if (AsciiLanguage == NULL) {
|
if (AsciiLanguage == NULL) {
|
||||||
return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
|
return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
|
||||||
} else {
|
} else {
|
||||||
return mUefiStringProtocol->GetString (
|
return mHiiStringProtocol->GetString (
|
||||||
mUefiStringProtocol,
|
mHiiStringProtocol,
|
||||||
AsciiLanguage,
|
AsciiLanguage,
|
||||||
HandleMapEntry->UefiHiiHandle,
|
HandleMapEntry->UefiHiiHandle,
|
||||||
Token,
|
Token,
|
||||||
|
|
|
@ -0,0 +1,778 @@
|
||||||
|
/** @file
|
||||||
|
Function and Macro defintions for to extract default values from UEFI Form package.
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include <FrameworkDxe.h>
|
||||||
|
|
||||||
|
#include <Protocol/FrameworkHii.h>
|
||||||
|
#include <Protocol/HiiDatabase.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
|
||||||
|
#include "UefiIfrParser.h"
|
||||||
|
#include "UefiIfrDefault.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extern Variables
|
||||||
|
//
|
||||||
|
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
|
||||||
|
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
|
||||||
|
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
|
||||||
|
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
|
||||||
|
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
|
||||||
|
|
||||||
|
extern EFI_GUID gZeroGuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fetch the Ifr binary data of a FormSet.
|
||||||
|
|
||||||
|
@param Handle PackageList Handle
|
||||||
|
@param FormSetGuid GUID of a formset. If not specified (NULL or zero
|
||||||
|
GUID), take the first FormSet found in package
|
||||||
|
list.
|
||||||
|
@param BinaryLength The length of the FormSet IFR binary.
|
||||||
|
@param BinaryData The buffer designed to receive the FormSet.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Buffer filled with the requested FormSet.
|
||||||
|
BufferLength was updated.
|
||||||
|
@retval EFI_INVALID_PARAMETER The handle is unknown.
|
||||||
|
@retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
|
||||||
|
be found with the requested FormId.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GetIfrBinaryData (
|
||||||
|
IN EFI_HII_HANDLE Handle,
|
||||||
|
IN OUT EFI_GUID *FormSetGuid,
|
||||||
|
OUT UINTN *BinaryLength,
|
||||||
|
OUT UINT8 **BinaryData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
||||||
|
UINTN BufferSize;
|
||||||
|
UINT8 *Package;
|
||||||
|
UINT8 *OpCodeData;
|
||||||
|
UINT32 Offset;
|
||||||
|
UINT32 Offset2;
|
||||||
|
BOOLEAN ReturnDefault;
|
||||||
|
UINT32 PackageListLength;
|
||||||
|
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||||
|
|
||||||
|
OpCodeData = NULL;
|
||||||
|
Package = NULL;
|
||||||
|
ZeroMem (&PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));;
|
||||||
|
|
||||||
|
//
|
||||||
|
// if FormSetGuid is NULL or zero GUID, return first FormSet in the package list
|
||||||
|
//
|
||||||
|
if (FormSetGuid == NULL || CompareGuid (FormSetGuid, &gZeroGuid)) {
|
||||||
|
ReturnDefault = TRUE;
|
||||||
|
} else {
|
||||||
|
ReturnDefault = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get HII PackageList
|
||||||
|
//
|
||||||
|
BufferSize = 0;
|
||||||
|
HiiPackageList = NULL;
|
||||||
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
HiiPackageList = AllocatePool (BufferSize);
|
||||||
|
ASSERT (HiiPackageList != NULL);
|
||||||
|
|
||||||
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||||
|
}
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get Form package from this HII package List
|
||||||
|
//
|
||||||
|
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||||
|
Offset2 = 0;
|
||||||
|
CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
|
||||||
|
|
||||||
|
while (Offset < PackageListLength) {
|
||||||
|
Package = ((UINT8 *) HiiPackageList) + Offset;
|
||||||
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
||||||
|
|
||||||
|
if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
|
||||||
|
//
|
||||||
|
// Search FormSet in this Form Package
|
||||||
|
//
|
||||||
|
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
while (Offset2 < PackageHeader.Length) {
|
||||||
|
OpCodeData = Package + Offset2;
|
||||||
|
|
||||||
|
if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
|
||||||
|
//
|
||||||
|
// Check whether return default FormSet
|
||||||
|
//
|
||||||
|
if (ReturnDefault) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FormSet GUID is specified, check it
|
||||||
|
//
|
||||||
|
if (CompareGuid (FormSetGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Offset2 < PackageHeader.Length) {
|
||||||
|
//
|
||||||
|
// Target formset found
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Offset += PackageHeader.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Offset >= PackageListLength) {
|
||||||
|
//
|
||||||
|
// Form package not found in this Package List
|
||||||
|
//
|
||||||
|
gBS->FreePool (HiiPackageList);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ReturnDefault && FormSetGuid != NULL) {
|
||||||
|
//
|
||||||
|
// Return the default FormSet GUID
|
||||||
|
//
|
||||||
|
CopyMem (FormSetGuid, &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// To determine the length of a whole FormSet IFR binary, one have to parse all the Opcodes
|
||||||
|
// in this FormSet; So, here just simply copy the data from start of a FormSet to the end
|
||||||
|
// of the Form Package.
|
||||||
|
//
|
||||||
|
*BinaryLength = PackageHeader.Length - Offset2;
|
||||||
|
*BinaryData = AllocateCopyPool (*BinaryLength, OpCodeData);
|
||||||
|
|
||||||
|
gBS->FreePool (HiiPackageList);
|
||||||
|
|
||||||
|
if (*BinaryData == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize the internal data structure of a FormSet.
|
||||||
|
|
||||||
|
@param Handle PackageList Handle
|
||||||
|
@param FormSetGuid GUID of a formset. If not specified (NULL or zero
|
||||||
|
GUID), take the first FormSet found in package
|
||||||
|
list.
|
||||||
|
@param FormSet FormSet data structure.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The function completed successfully.
|
||||||
|
@retval EFI_NOT_FOUND The specified FormSet could not be found.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
InitializeFormSet (
|
||||||
|
IN EFI_HII_HANDLE Handle,
|
||||||
|
IN OUT EFI_GUID *FormSetGuid,
|
||||||
|
OUT FORM_BROWSER_FORMSET *FormSet
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE DriverHandle;
|
||||||
|
|
||||||
|
Status = GetIfrBinaryData (Handle, FormSetGuid, &FormSet->IfrBinaryLength, &FormSet->IfrBinaryData);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
FormSet->HiiHandle = Handle;
|
||||||
|
CopyMem (&FormSet->Guid, FormSetGuid, sizeof (EFI_GUID));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve ConfigAccess Protocol associated with this HiiPackageList
|
||||||
|
//
|
||||||
|
Status = mHiiDatabase->GetPackageListHandle (mHiiDatabase, Handle, &DriverHandle);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
FormSet->DriverHandle = DriverHandle;
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
DriverHandle,
|
||||||
|
&gEfiHiiConfigAccessProtocolGuid,
|
||||||
|
(VOID **) &FormSet->ConfigAccess
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Configuration Driver don't attach ConfigAccess protocol to its HII package
|
||||||
|
// list, then there will be no configuration action required
|
||||||
|
//
|
||||||
|
FormSet->ConfigAccess = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Parse the IFR binary OpCodes
|
||||||
|
//
|
||||||
|
Status = ParseOpCodes (FormSet);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the data position at Offset with Width in Node->Buffer based
|
||||||
|
the value passed in.
|
||||||
|
|
||||||
|
@param Node The Buffer Storage Node.
|
||||||
|
@param Value The input value.
|
||||||
|
@param Offset The offset in Node->Buffer for the update.
|
||||||
|
@param Width The length of the Value.
|
||||||
|
|
||||||
|
@retval VOID
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
SetNodeBuffer (
|
||||||
|
OUT UEFI_IFR_BUFFER_STORAGE_NODE *Node,
|
||||||
|
IN CONST EFI_HII_VALUE *Value,
|
||||||
|
IN UINTN Offset,
|
||||||
|
IN UINTN Width
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (Node->Signature == UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE);
|
||||||
|
ASSERT (Offset + Width <= Node->Size);
|
||||||
|
|
||||||
|
CopyMem (Node->Buffer + Offset, &Value->Value.u8, Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset Question to its default value.
|
||||||
|
|
||||||
|
@param FormSet FormSet data structure.
|
||||||
|
@param DefaultId The Class of the default.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Question is reset to default value.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GetQuestionDefault (
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
IN FORM_BROWSER_FORM *Form,
|
||||||
|
IN FORM_BROWSER_STATEMENT *Question,
|
||||||
|
IN UINT16 DefaultId,
|
||||||
|
IN UINT16 VarStoreId,
|
||||||
|
OUT UEFI_IFR_BUFFER_STORAGE_NODE *Node
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
LIST_ENTRY *Link;
|
||||||
|
QUESTION_DEFAULT *Default;
|
||||||
|
QUESTION_OPTION *Option;
|
||||||
|
EFI_HII_VALUE *HiiValue;
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Statement don't have storage, skip them
|
||||||
|
//
|
||||||
|
if (Question->QuestionId == 0) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Question->VarStoreId != VarStoreId) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Question->Storage->Type == EFI_HII_VARSTORE_BUFFER);
|
||||||
|
|
||||||
|
//
|
||||||
|
// There are three ways to specify default value for a Question:
|
||||||
|
// 1, use nested EFI_IFR_DEFAULT (highest priority)
|
||||||
|
// 2, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default)
|
||||||
|
// 3, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)
|
||||||
|
//
|
||||||
|
HiiValue = &Question->HiiValue;
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI_IFR_DEFAULT has highest priority
|
||||||
|
//
|
||||||
|
if (!IsListEmpty (&Question->DefaultListHead)) {
|
||||||
|
Link = GetFirstNode (&Question->DefaultListHead);
|
||||||
|
while (!IsNull (&Question->DefaultListHead, Link)) {
|
||||||
|
Default = QUESTION_DEFAULT_FROM_LINK (Link);
|
||||||
|
|
||||||
|
if (Default->DefaultId == DefaultId) {
|
||||||
|
if (Default->ValueExpression != NULL) {
|
||||||
|
//
|
||||||
|
// Default is provided by an Expression, evaluate it
|
||||||
|
//
|
||||||
|
Status = EvaluateExpression (FormSet, Form, Default->ValueExpression);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMem (HiiValue, &Default->ValueExpression->Result, sizeof (EFI_HII_VALUE));
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Default value is embedded in EFI_IFR_DEFAULT
|
||||||
|
//
|
||||||
|
CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetNodeBuffer (Node, HiiValue, Question->VarStoreInfo.VarOffset, Question->StorageWidth);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
Link = GetNextNode (&Question->DefaultListHead, Link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI_ONE_OF_OPTION
|
||||||
|
//
|
||||||
|
if ((Question->Operand == EFI_IFR_ONE_OF_OP) && !IsListEmpty (&Question->OptionListHead)) {
|
||||||
|
if (DefaultId <= EFI_HII_DEFAULT_CLASS_MANUFACTURING) {
|
||||||
|
//
|
||||||
|
// OneOfOption could only provide Standard and Manufacturing default
|
||||||
|
//
|
||||||
|
Link = GetFirstNode (&Question->OptionListHead);
|
||||||
|
while (!IsNull (&Question->OptionListHead, Link)) {
|
||||||
|
Option = QUESTION_OPTION_FROM_LINK (Link);
|
||||||
|
|
||||||
|
if (((DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) && (Option->Flags & EFI_IFR_OPTION_DEFAULT)) ||
|
||||||
|
((DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) && (Option->Flags & EFI_IFR_OPTION_DEFAULT_MFG))
|
||||||
|
) {
|
||||||
|
CopyMem (HiiValue, &Option->Value, sizeof (EFI_HII_VALUE));
|
||||||
|
|
||||||
|
SetNodeBuffer (Node, HiiValue, Question->VarStoreInfo.VarOffset, Question->StorageWidth);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
Link = GetNextNode (&Question->OptionListHead, Link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI_IFR_CHECKBOX - lowest priority
|
||||||
|
//
|
||||||
|
if (Question->Operand == EFI_IFR_CHECKBOX_OP) {
|
||||||
|
if (DefaultId <= EFI_HII_DEFAULT_CLASS_MANUFACTURING) {
|
||||||
|
//
|
||||||
|
// Checkbox could only provide Standard and Manufacturing default
|
||||||
|
//
|
||||||
|
if (((DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) && (Question->Flags & EFI_IFR_CHECKBOX_DEFAULT)) ||
|
||||||
|
((DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) && (Question->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG))
|
||||||
|
) {
|
||||||
|
HiiValue->Value.b = TRUE;
|
||||||
|
} else {
|
||||||
|
HiiValue->Value.b = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetNodeBuffer (Node, HiiValue, Question->VarStoreInfo.VarOffset, Question->StorageWidth);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset Questions in a Form to their default value.
|
||||||
|
|
||||||
|
@param FormSet FormSet data structure.
|
||||||
|
@param Form The Form which to be reset.
|
||||||
|
@param DefaultId The Class of the default.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The function completed successfully.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ExtractFormDefault (
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
IN FORM_BROWSER_FORM *Form,
|
||||||
|
IN UINT16 DefaultId,
|
||||||
|
IN UINT16 VarStoreId,
|
||||||
|
OUT UEFI_IFR_BUFFER_STORAGE_NODE *Node
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
LIST_ENTRY *Link;
|
||||||
|
FORM_BROWSER_STATEMENT *Question;
|
||||||
|
|
||||||
|
Link = GetFirstNode (&Form->StatementListHead);
|
||||||
|
while (!IsNull (&Form->StatementListHead, Link)) {
|
||||||
|
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
||||||
|
Link = GetNextNode (&Form->StatementListHead, Link);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reset Question to its default value
|
||||||
|
//
|
||||||
|
Status = GetQuestionDefault (FormSet, Form, Question, DefaultId, VarStoreId, Node);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destroy all the buffer allocated for the fileds of
|
||||||
|
UEFI_IFR_BUFFER_STORAGE_NODE. The Node itself
|
||||||
|
will be freed too.
|
||||||
|
|
||||||
|
@param FormSet FormSet data structure.
|
||||||
|
@param DefaultId The Class of the default.
|
||||||
|
|
||||||
|
@retval VOID
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
DestroyDefaultNode (
|
||||||
|
IN UEFI_IFR_BUFFER_STORAGE_NODE *Node
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SafeFreePool (Node->Buffer);
|
||||||
|
SafeFreePool (Node->Name);
|
||||||
|
SafeFreePool (Node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the default value for Buffer Type storage named by
|
||||||
|
a Default Store and a Storage Store from a FormSet.
|
||||||
|
The result is in the a instance of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
allocated by this function. It is inserted to the link list.
|
||||||
|
|
||||||
|
@param DefaultStore The Default Store.
|
||||||
|
@param Storage The Storage.
|
||||||
|
@param FormSet The Form Set.
|
||||||
|
@param UefiDefaultsListHead The head of link list for the output.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GetBufferTypeDefaultIdAndStorageId (
|
||||||
|
IN FORMSET_DEFAULTSTORE *DefaultStore,
|
||||||
|
IN FORMSET_STORAGE *Storage,
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
OUT LIST_ENTRY *UefiDefaultsListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UEFI_IFR_BUFFER_STORAGE_NODE *Node;
|
||||||
|
LIST_ENTRY *Link;
|
||||||
|
FORM_BROWSER_FORM *Form;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Node = AllocateZeroPool (sizeof (UEFI_IFR_BUFFER_STORAGE_NODE));
|
||||||
|
ASSERT (Node != NULL);
|
||||||
|
|
||||||
|
Node->Signature = UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE;
|
||||||
|
Node->Name = AllocateCopyPool (StrSize (Storage->Name), Storage->Name);
|
||||||
|
Node->DefaultId = DefaultStore->DefaultId;
|
||||||
|
CopyGuid (&Node->Guid, &Storage->Guid);
|
||||||
|
Node->Size = Storage->Size;
|
||||||
|
Node->Buffer = AllocateZeroPool (Node->Size);
|
||||||
|
//
|
||||||
|
// Extract default from IFR binary
|
||||||
|
//
|
||||||
|
Link = GetFirstNode (&FormSet->FormListHead);
|
||||||
|
while (!IsNull (&FormSet->FormListHead, Link)) {
|
||||||
|
Form = FORM_BROWSER_FORM_FROM_LINK (Link);
|
||||||
|
|
||||||
|
Status = ExtractFormDefault (FormSet, Form, DefaultStore->DefaultId, Storage->VarStoreId, Node);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Link = GetNextNode (&FormSet->FormListHead, Link);
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertTailList (UefiDefaultsListHead, &Node->List);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the default value for Buffer Type storage named by
|
||||||
|
a Default Store from a FormSet.
|
||||||
|
The result is in the a instance of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
allocated by this function. The output can be multiple instances
|
||||||
|
of UEFI_IFR_BUFFER_STORAGE_NODE. It is inserted to the link list.
|
||||||
|
|
||||||
|
@param DefaultStore The Default Store.
|
||||||
|
@param FormSet The Form Set.
|
||||||
|
@param UefiDefaultsListHead The head of link list for the output.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
GetBufferTypeDefaultId (
|
||||||
|
IN FORMSET_DEFAULTSTORE *DefaultStore,
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
OUT LIST_ENTRY *UefiDefaultsListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LIST_ENTRY *StorageListEntry;
|
||||||
|
FORMSET_STORAGE *Storage;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
StorageListEntry = GetFirstNode (&FormSet->StorageListHead);
|
||||||
|
|
||||||
|
while (!IsNull (&FormSet->StorageListHead, StorageListEntry)) {
|
||||||
|
Storage = FORMSET_STORAGE_FROM_LINK(StorageListEntry);
|
||||||
|
|
||||||
|
if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
|
||||||
|
Status = GetBufferTypeDefaultIdAndStorageId (DefaultStore, Storage, FormSet, UefiDefaultsListHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
StorageListEntry = GetNextNode (&FormSet->StorageListHead, StorageListEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the default value for Buffer Type storage from the first FormSet
|
||||||
|
in the Package List specified by a EFI_HII_HANDLE.
|
||||||
|
|
||||||
|
The results can be multiple instances of UEFI_IFR_BUFFER_STORAGE_NODE.
|
||||||
|
They are inserted to the link list.
|
||||||
|
|
||||||
|
@param UefiHiiHandle The handle for the package list.
|
||||||
|
@param UefiDefaultsListHead The head of link list for the output.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
UefiIfrGetBufferTypeDefaults (
|
||||||
|
IN EFI_HII_HANDLE UefiHiiHandle,
|
||||||
|
OUT LIST_ENTRY **UefiDefaults
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FORM_BROWSER_FORMSET *FormSet;
|
||||||
|
EFI_GUID FormSetGuid;
|
||||||
|
LIST_ENTRY *DefaultListEntry;
|
||||||
|
FORMSET_DEFAULTSTORE *DefaultStore;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
ASSERT (UefiDefaults != NULL);
|
||||||
|
|
||||||
|
FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));
|
||||||
|
ASSERT (FormSet != NULL);
|
||||||
|
|
||||||
|
CopyGuid (&FormSetGuid, &gZeroGuid);
|
||||||
|
Status = InitializeFormSet (UefiHiiHandle, &FormSetGuid, FormSet);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
*UefiDefaults = AllocateZeroPool (sizeof (LIST_ENTRY));
|
||||||
|
ASSERT (UefiDefaults != NULL);
|
||||||
|
InitializeListHead (*UefiDefaults);
|
||||||
|
|
||||||
|
DefaultListEntry = GetFirstNode (&FormSet->DefaultStoreListHead);
|
||||||
|
while (!IsNull (&FormSet->DefaultStoreListHead, DefaultListEntry)) {
|
||||||
|
DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultListEntry);
|
||||||
|
|
||||||
|
Status = GetBufferTypeDefaultId (DefaultStore, FormSet, *UefiDefaults);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
DefaultListEntry = GetNextNode (&FormSet->DefaultStoreListHead, DefaultListEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyFormSet (FormSet);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert the UEFI Buffer Type default values to a Framework HII default
|
||||||
|
values specified by a EFI_HII_VARIABLE_PACK_LIST structure.
|
||||||
|
|
||||||
|
@param ListHead The link list of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
which contains the default values retrived from
|
||||||
|
a UEFI form set.
|
||||||
|
@param DefaultMask The default mask.
|
||||||
|
The valid values are FRAMEWORK_EFI_IFR_FLAG_DEFAULT
|
||||||
|
and FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
UEFI spec only map FRAMEWORK_EFI_IFR_FLAG_DEFAULT and FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING
|
||||||
|
from specification to valid default class.
|
||||||
|
@param VariablePackList The output default value in a format defined in Framework.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
@retval EFI_INVALID_PARAMETER The default mask is not FRAMEWORK_EFI_IFR_FLAG_DEFAULT or
|
||||||
|
FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
UefiDefaultsToFrameworkDefaults (
|
||||||
|
IN LIST_ENTRY *ListHead,
|
||||||
|
IN UINTN DefaultMask,
|
||||||
|
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LIST_ENTRY *List;
|
||||||
|
UEFI_IFR_BUFFER_STORAGE_NODE *Node;
|
||||||
|
UINTN Size;
|
||||||
|
UINTN Count;
|
||||||
|
UINT16 DefaultId;
|
||||||
|
EFI_HII_VARIABLE_PACK *Pack;
|
||||||
|
EFI_HII_VARIABLE_PACK_LIST *PackList;
|
||||||
|
|
||||||
|
if (DefaultMask == FRAMEWORK_EFI_IFR_FLAG_DEFAULT) {
|
||||||
|
DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
|
||||||
|
} else if (DefaultMask == FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING) {
|
||||||
|
DefaultId = EFI_HII_DEFAULT_CLASS_MANUFACTURING;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// UEFI spec only map FRAMEWORK_EFI_IFR_FLAG_DEFAULT and FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING
|
||||||
|
// from specification to valid default class.
|
||||||
|
//
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate the size of the output EFI_HII_VARIABLE_PACK_LIST structure
|
||||||
|
//
|
||||||
|
Size = 0;
|
||||||
|
Count = 0;
|
||||||
|
List = GetFirstNode (ListHead);
|
||||||
|
while (!IsNull (ListHead, List)) {
|
||||||
|
Node = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(List);
|
||||||
|
|
||||||
|
if (Node->DefaultId == DefaultId) {
|
||||||
|
Size += Node->Size;
|
||||||
|
Size += StrSize (Node->Name);
|
||||||
|
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
List = GetNextNode (ListHead, List);
|
||||||
|
}
|
||||||
|
|
||||||
|
Size = Size + Count * (sizeof (EFI_HII_VARIABLE_PACK_LIST) + sizeof (EFI_HII_VARIABLE_PACK));
|
||||||
|
|
||||||
|
*VariablePackList = AllocateZeroPool (Size);
|
||||||
|
ASSERT (*VariablePackList != NULL);
|
||||||
|
|
||||||
|
List = GetFirstNode (ListHead);
|
||||||
|
|
||||||
|
PackList = (EFI_HII_VARIABLE_PACK_LIST *) *VariablePackList;
|
||||||
|
Pack = (EFI_HII_VARIABLE_PACK *) (PackList + 1);
|
||||||
|
while (!IsNull (ListHead, List)) {
|
||||||
|
Node = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(List);
|
||||||
|
|
||||||
|
Size = 0;
|
||||||
|
if (Node->DefaultId == DefaultId) {
|
||||||
|
Size += Node->Size;
|
||||||
|
Size += StrSize (Node->Name);
|
||||||
|
Size += sizeof (EFI_HII_VARIABLE_PACK);
|
||||||
|
|
||||||
|
//
|
||||||
|
// In UEFI, 0 is defined to be invalid for EFI_IFR_VARSTORE.VarStoreId.
|
||||||
|
// So the default storage of Var Store in VFR from a Framework module
|
||||||
|
// should be translated to 0xFFEE.
|
||||||
|
//
|
||||||
|
if (Node->StoreId == 0xFFEE) {
|
||||||
|
Pack->VariableId = 0;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize EFI_HII_VARIABLE_PACK
|
||||||
|
//
|
||||||
|
Pack->Header.Type = 0;
|
||||||
|
Pack->Header.Length = Size;
|
||||||
|
Pack->VariableId = Node->StoreId;
|
||||||
|
Pack->VariableNameLength = StrSize (Node->Name);
|
||||||
|
CopyMem (&Pack->VariableGuid, &Node->Guid, sizeof (EFI_GUID));
|
||||||
|
|
||||||
|
CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK), Node->Name, StrSize (Node->Name));
|
||||||
|
CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength, Node->Buffer, Node->Size);
|
||||||
|
|
||||||
|
Size += sizeof (EFI_HII_VARIABLE_PACK_LIST);
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize EFI_HII_VARIABLE_PACK_LIST
|
||||||
|
//
|
||||||
|
PackList->VariablePack = Pack;
|
||||||
|
PackList->NextVariablePack = (EFI_HII_VARIABLE_PACK_LIST *)((UINT8 *) PackList + Size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List = GetNextNode (ListHead, List);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Free up all buffer allocated for the link list of UEFI_IFR_BUFFER_STORAGE_NODE.
|
||||||
|
|
||||||
|
@param ListHead The link list of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
which contains the default values retrived from
|
||||||
|
a UEFI form set.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
@retval EFI_INVALID_PARAMETER The default mask is not FRAMEWORK_EFI_IFR_FLAG_DEFAULT or
|
||||||
|
FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
FreeDefaultList (
|
||||||
|
IN LIST_ENTRY *ListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LIST_ENTRY *Node;
|
||||||
|
UEFI_IFR_BUFFER_STORAGE_NODE *Default;
|
||||||
|
|
||||||
|
Node = GetFirstNode (ListHead);
|
||||||
|
|
||||||
|
while (!IsNull (ListHead, Node)) {
|
||||||
|
Default = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(Node);
|
||||||
|
|
||||||
|
RemoveEntryList (Node);
|
||||||
|
|
||||||
|
DestroyDefaultNode (Default);
|
||||||
|
|
||||||
|
Node = GetFirstNode (ListHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool (ListHead);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
/** @file
|
||||||
|
Header file for Function and Macro defintions for to extract default values from UEFI Form package.
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_DEFAULT_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_DEFAULT_
|
||||||
|
|
||||||
|
|
||||||
|
#define UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(a) CR(a, UEFI_IFR_BUFFER_STORAGE_NODE, List, UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE)
|
||||||
|
#define UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE EFI_SIGNATURE_32 ('I', 'b', 'S', 'n')
|
||||||
|
typedef struct {
|
||||||
|
LIST_ENTRY List;
|
||||||
|
UINT32 Signature;
|
||||||
|
|
||||||
|
EFI_GUID Guid;
|
||||||
|
CHAR16 *Name;
|
||||||
|
UINT16 DefaultId;
|
||||||
|
UINT16 StoreId;
|
||||||
|
UINTN Size;
|
||||||
|
UINT8 *Buffer;
|
||||||
|
|
||||||
|
} UEFI_IFR_BUFFER_STORAGE_NODE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the default value for Buffer Type storage from the first FormSet
|
||||||
|
in the Package List specified by a EFI_HII_HANDLE.
|
||||||
|
|
||||||
|
The results can be multiple instances of UEFI_IFR_BUFFER_STORAGE_NODE.
|
||||||
|
They are inserted to the link list.
|
||||||
|
|
||||||
|
@param UefiHiiHandle The handle for the package list.
|
||||||
|
@param UefiDefaultsListHead The head of link list for the output.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
UefiIfrGetBufferTypeDefaults (
|
||||||
|
EFI_HII_HANDLE UefiHiiHandle,
|
||||||
|
LIST_ENTRY **UefiDefaults
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert the UEFI Buffer Type default values to a Framework HII default
|
||||||
|
values specified by a EFI_HII_VARIABLE_PACK_LIST structure.
|
||||||
|
|
||||||
|
@param ListHead The link list of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
which contains the default values retrived from
|
||||||
|
a UEFI form set.
|
||||||
|
@param DefaultMask The default mask.
|
||||||
|
The valid values are FRAMEWORK_EFI_IFR_FLAG_DEFAULT
|
||||||
|
and FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
UEFI spec only map FRAMEWORK_EFI_IFR_FLAG_DEFAULT and FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING
|
||||||
|
from specification to valid default class.
|
||||||
|
@param VariablePackList The output default value in a format defined in Framework.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
@retval EFI_INVALID_PARAMETER The default mask is not FRAMEWORK_EFI_IFR_FLAG_DEFAULT or
|
||||||
|
FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
**/
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
UefiDefaultsToFrameworkDefaults (
|
||||||
|
IN LIST_ENTRY *UefiIfrDefaults,
|
||||||
|
IN UINTN DefaultMask,
|
||||||
|
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Free up all buffer allocated for the link list of UEFI_IFR_BUFFER_STORAGE_NODE.
|
||||||
|
|
||||||
|
@param ListHead The link list of UEFI_IFR_BUFFER_STORAGE_NODE
|
||||||
|
which contains the default values retrived from
|
||||||
|
a UEFI form set.
|
||||||
|
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Successful.
|
||||||
|
@retval EFI_INVALID_PARAMETER The default mask is not FRAMEWORK_EFI_IFR_FLAG_DEFAULT or
|
||||||
|
FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
FreeDefaultList (
|
||||||
|
IN LIST_ENTRY *UefiIfrDefaults
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,316 @@
|
||||||
|
/** @file
|
||||||
|
Function and Macro defintions for IFR parsing. To get the default value from IFR package, the IFR
|
||||||
|
opcode needs to be parsed. Most of code is taken from MdeModulePkg\Universal\SetupBrowserDxe\IfrParse.c.
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_PARSER_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_PARSER_
|
||||||
|
|
||||||
|
#include <PiDxe.h>
|
||||||
|
|
||||||
|
#include <Protocol/Print.h>
|
||||||
|
//#include <Protocol/SimpleTextOut.h>
|
||||||
|
//#include <Protocol/SimpleTextIn.h>
|
||||||
|
//#include <Protocol/FormBrowser2.h>
|
||||||
|
//#include <Protocol/DevicePath.h>
|
||||||
|
#include <Protocol/HiiConfigAccess.h>
|
||||||
|
#include <Protocol/HiiConfigRouting.h>
|
||||||
|
#include <Protocol/HiiDatabase.h>
|
||||||
|
#include <Protocol/HiiString.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// IFR relative definition
|
||||||
|
//
|
||||||
|
#define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
|
||||||
|
#define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
|
||||||
|
#define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
|
||||||
|
#define EFI_HII_EXPRESSION_SUPPRESS_IF 3
|
||||||
|
#define EFI_HII_EXPRESSION_DISABLE_IF 4
|
||||||
|
#define EFI_HII_EXPRESSION_VALUE 5
|
||||||
|
#define EFI_HII_EXPRESSION_RULE 6
|
||||||
|
|
||||||
|
#define EFI_HII_VARSTORE_BUFFER 0
|
||||||
|
#define EFI_HII_VARSTORE_NAME_VALUE 1
|
||||||
|
#define EFI_HII_VARSTORE_EFI_VARIABLE 2
|
||||||
|
|
||||||
|
#define FORM_INCONSISTENT_VALIDATION 0
|
||||||
|
#define FORM_NO_SUBMIT_VALIDATION 1
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT8 Type;
|
||||||
|
EFI_IFR_TYPE_VALUE Value;
|
||||||
|
} EFI_HII_VALUE;
|
||||||
|
|
||||||
|
#define NAME_VALUE_NODE_SIGNATURE EFI_SIGNATURE_32 ('N', 'V', 'S', 'T')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
CHAR16 *Name;
|
||||||
|
CHAR16 *Value;
|
||||||
|
CHAR16 *EditValue;
|
||||||
|
} NAME_VALUE_NODE;
|
||||||
|
|
||||||
|
#define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
|
||||||
|
|
||||||
|
#define FORMSET_STORAGE_SIGNATURE EFI_SIGNATURE_32 ('F', 'S', 'T', 'G')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT8 Type; // Storage type
|
||||||
|
|
||||||
|
UINT16 VarStoreId;
|
||||||
|
EFI_GUID Guid;
|
||||||
|
|
||||||
|
CHAR16 *Name; // For EFI_IFR_VARSTORE
|
||||||
|
UINT16 Size;
|
||||||
|
UINT8 *Buffer;
|
||||||
|
UINT8 *EditBuffer; // Edit copy for Buffer Storage
|
||||||
|
|
||||||
|
LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE
|
||||||
|
|
||||||
|
UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
|
||||||
|
|
||||||
|
CHAR16 *ConfigHdr; // <ConfigHdr>
|
||||||
|
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
|
||||||
|
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
|
||||||
|
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
|
||||||
|
} FORMSET_STORAGE;
|
||||||
|
|
||||||
|
#define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
|
||||||
|
|
||||||
|
#define EXPRESSION_OPCODE_SIGNATURE EFI_SIGNATURE_32 ('E', 'X', 'O', 'P')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT8 Operand;
|
||||||
|
|
||||||
|
UINT8 Format; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
|
||||||
|
UINT8 Flags; // For EFI_IFR_SPAN
|
||||||
|
UINT8 RuleId; // For EFI_IFR_RULE_REF
|
||||||
|
|
||||||
|
EFI_HII_VALUE Value; // For EFI_IFR_EQ_ID_VAL, EFI_IFR_UINT64, EFI_IFR_UINT32, EFI_IFR_UINT16, EFI_IFR_UINT8, EFI_IFR_STRING_REF1
|
||||||
|
|
||||||
|
EFI_QUESTION_ID QuestionId; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_LIST, EFI_IFR_QUESTION_REF1
|
||||||
|
EFI_QUESTION_ID QuestionId2;
|
||||||
|
|
||||||
|
UINT16 ListLength; // For EFI_IFR_EQ_ID_LIST
|
||||||
|
UINT16 *ValueList;
|
||||||
|
|
||||||
|
EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
|
||||||
|
EFI_GUID Guid;
|
||||||
|
} EXPRESSION_OPCODE;
|
||||||
|
|
||||||
|
#define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
|
||||||
|
|
||||||
|
#define FORM_EXPRESSION_SIGNATURE EFI_SIGNATURE_32 ('F', 'E', 'X', 'P')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT8 Type; // Type for this expression
|
||||||
|
|
||||||
|
UINT8 RuleId; // For EFI_IFR_RULE only
|
||||||
|
EFI_STRING_ID Error; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
|
||||||
|
|
||||||
|
EFI_HII_VALUE Result; // Expression evaluation result
|
||||||
|
|
||||||
|
LIST_ENTRY OpCodeListHead; // OpCodes consist of this expression (EXPRESSION_OPCODE)
|
||||||
|
} FORM_EXPRESSION;
|
||||||
|
|
||||||
|
#define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
|
||||||
|
|
||||||
|
#define QUESTION_DEFAULT_SIGNATURE EFI_SIGNATURE_32 ('Q', 'D', 'F', 'T')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT16 DefaultId;
|
||||||
|
EFI_HII_VALUE Value; // Default value
|
||||||
|
|
||||||
|
FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
|
||||||
|
} QUESTION_DEFAULT;
|
||||||
|
|
||||||
|
#define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
|
||||||
|
|
||||||
|
#define QUESTION_OPTION_SIGNATURE EFI_SIGNATURE_32 ('Q', 'O', 'P', 'T')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
EFI_STRING_ID Text;
|
||||||
|
UINT8 Flags;
|
||||||
|
EFI_HII_VALUE Value;
|
||||||
|
EFI_IMAGE_ID ImageId;
|
||||||
|
|
||||||
|
FORM_EXPRESSION *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
|
||||||
|
} QUESTION_OPTION;
|
||||||
|
|
||||||
|
#define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
|
||||||
|
|
||||||
|
#define FORM_BROWSER_STATEMENT_SIGNATURE EFI_SIGNATURE_32 ('F', 'S', 'T', 'A')
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT8 Operand; // The operand (first byte) of this Statement or Question
|
||||||
|
|
||||||
|
//
|
||||||
|
// Statement Header
|
||||||
|
//
|
||||||
|
EFI_STRING_ID Prompt;
|
||||||
|
EFI_STRING_ID Help;
|
||||||
|
EFI_STRING_ID TextTwo; // For EFI_IFR_TEXT
|
||||||
|
|
||||||
|
//
|
||||||
|
// Question Header
|
||||||
|
//
|
||||||
|
EFI_QUESTION_ID QuestionId; // The value of zero is reserved
|
||||||
|
EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
|
||||||
|
FORMSET_STORAGE *Storage;
|
||||||
|
union {
|
||||||
|
EFI_STRING_ID VarName;
|
||||||
|
UINT16 VarOffset;
|
||||||
|
} VarStoreInfo;
|
||||||
|
UINT16 StorageWidth;
|
||||||
|
UINT8 QuestionFlags;
|
||||||
|
CHAR16 *VariableName; // Name/Value or EFI Variable name
|
||||||
|
CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
|
||||||
|
|
||||||
|
EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
|
||||||
|
UINT8 *BufferValue; // Edit copy for string, password, orderedlist
|
||||||
|
|
||||||
|
//
|
||||||
|
// OpCode specific members
|
||||||
|
//
|
||||||
|
UINT8 Flags; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
|
||||||
|
// EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
|
||||||
|
UINT8 MaxContainers; // for EFI_IFR_ORDERED_LIST
|
||||||
|
|
||||||
|
UINT16 BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number
|
||||||
|
EFI_STRING_ID QuestionConfig; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
|
||||||
|
|
||||||
|
UINT64 Minimum; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
|
||||||
|
UINT64 Maximum; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
|
||||||
|
UINT64 Step;
|
||||||
|
|
||||||
|
EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON
|
||||||
|
EFI_FORM_ID RefFormId; // for EFI_IFR_REF
|
||||||
|
EFI_QUESTION_ID RefQuestionId; // for EFI_IFR_REF2
|
||||||
|
EFI_GUID RefFormSetId; // for EFI_IFR_REF3
|
||||||
|
EFI_STRING_ID RefDevicePath; // for EFI_IFR_REF4
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get from IFR parsing
|
||||||
|
//
|
||||||
|
FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
|
||||||
|
LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
|
||||||
|
LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
|
||||||
|
|
||||||
|
EFI_IMAGE_ID ImageId; // nested EFI_IFR_IMAGE
|
||||||
|
UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
|
||||||
|
BOOLEAN InSubtitle; // nesting inside of EFI_IFR_SUBTITLE
|
||||||
|
|
||||||
|
LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
|
||||||
|
LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)
|
||||||
|
FORM_EXPRESSION *GrayOutExpression; // nesting inside of GrayOutIf
|
||||||
|
FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
|
||||||
|
|
||||||
|
} FORM_BROWSER_STATEMENT;
|
||||||
|
|
||||||
|
#define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
|
||||||
|
|
||||||
|
#define FORM_BROWSER_FORM_SIGNATURE EFI_SIGNATURE_32 ('F', 'F', 'R', 'M')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT16 FormId;
|
||||||
|
EFI_STRING_ID FormTitle;
|
||||||
|
|
||||||
|
EFI_IMAGE_ID ImageId;
|
||||||
|
|
||||||
|
LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
|
||||||
|
LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
|
||||||
|
} FORM_BROWSER_FORM;
|
||||||
|
|
||||||
|
#define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
|
||||||
|
|
||||||
|
#define FORMSET_DEFAULTSTORE_SIGNATURE EFI_SIGNATURE_32 ('F', 'D', 'F', 'S')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
|
UINT16 DefaultId;
|
||||||
|
EFI_STRING_ID DefaultName;
|
||||||
|
} FORMSET_DEFAULTSTORE;
|
||||||
|
|
||||||
|
#define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EFI_HII_HANDLE HiiHandle;
|
||||||
|
EFI_HANDLE DriverHandle;
|
||||||
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
|
|
||||||
|
UINTN IfrBinaryLength;
|
||||||
|
UINT8 *IfrBinaryData;
|
||||||
|
|
||||||
|
EFI_GUID Guid;
|
||||||
|
EFI_STRING_ID FormSetTitle;
|
||||||
|
EFI_STRING_ID Help;
|
||||||
|
UINT16 Class;
|
||||||
|
UINT16 SubClass;
|
||||||
|
EFI_IMAGE_ID ImageId;
|
||||||
|
|
||||||
|
FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
|
||||||
|
EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
|
||||||
|
|
||||||
|
LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
|
||||||
|
LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
|
||||||
|
LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
|
||||||
|
} FORM_BROWSER_FORMSET;
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EvaluateExpression (
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
IN FORM_BROWSER_FORM *Form,
|
||||||
|
IN OUT FORM_EXPRESSION *Expression
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
ParseOpCodes (
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DestroyFormSet (
|
||||||
|
IN OUT FORM_BROWSER_FORMSET *FormSet
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HiiLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
CHAR16 *gEmptyString = L" ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the string based on the StringId and HII Package List Handle.
|
||||||
|
|
||||||
|
@param Token The String's ID.
|
||||||
|
@param HiiHandle The package list in the HII database to search for
|
||||||
|
the specified string.
|
||||||
|
|
||||||
|
@return The output string.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CHAR16 *
|
||||||
|
GetToken (
|
||||||
|
IN EFI_STRING_ID Token,
|
||||||
|
IN EFI_HII_HANDLE HiiHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
CHAR16 *String;
|
||||||
|
UINTN BufferLength;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set default string size assumption at no more than 256 bytes
|
||||||
|
//
|
||||||
|
BufferLength = 0x100;
|
||||||
|
String = AllocateZeroPool (BufferLength);
|
||||||
|
ASSERT (String != NULL);
|
||||||
|
|
||||||
|
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
|
||||||
|
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
gBS->FreePool (String);
|
||||||
|
String = AllocateZeroPool (BufferLength);
|
||||||
|
ASSERT (String != NULL);
|
||||||
|
|
||||||
|
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
|
||||||
|
}
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return String;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new string in HII Package List.
|
||||||
|
|
||||||
|
@param String The String to be added
|
||||||
|
@param HiiHandle The package list in the HII database to insert the
|
||||||
|
specified string.
|
||||||
|
|
||||||
|
@return The output string.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STRING_ID
|
||||||
|
NewString (
|
||||||
|
IN CHAR16 *String,
|
||||||
|
IN EFI_HII_HANDLE HiiHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STRING_ID StringId;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
StringId = 0;
|
||||||
|
Status = HiiLibNewString (HiiHandle, &StringId, String);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return StringId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/** @file
|
||||||
|
Common Function and Macro defintions used for both for IFR Parser and Expression evaluation.
|
||||||
|
This header file should only be included by UefiIfrParserExpression.c and UefiIfrParser.c
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_PARSER_COMMON_INTERNAL_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_PARSER_COMMON_INTERNAL_
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/PrintLib.h>
|
||||||
|
#include <Protocol/UnicodeCollation.h>
|
||||||
|
|
||||||
|
extern CHAR16 *gEmptyString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the string based on the StringId and HII Package List Handle.
|
||||||
|
|
||||||
|
@param Token The String's ID.
|
||||||
|
@param HiiHandle The package list in the HII database to search for
|
||||||
|
the specified string.
|
||||||
|
|
||||||
|
@return The output string.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CHAR16 *
|
||||||
|
GetToken (
|
||||||
|
IN EFI_STRING_ID Token,
|
||||||
|
IN EFI_HII_HANDLE HiiHandle
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new string in HII Package List.
|
||||||
|
|
||||||
|
@param String The String to be added
|
||||||
|
@param HiiHandle The package list in the HII database to insert the
|
||||||
|
specified string.
|
||||||
|
|
||||||
|
@return The output string.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STRING_ID
|
||||||
|
NewString (
|
||||||
|
IN CHAR16 *String,
|
||||||
|
IN EFI_HII_HANDLE HiiHandle
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,101 @@
|
||||||
|
/** @file
|
||||||
|
Internal Function and Macro defintions for IFR Expression evaluation used in Ifr Parsing. This header file should only
|
||||||
|
be included by UefiIfrParserExpression.c and UefiIfrParser.c
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_PARSER_EXPRESSION_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_PARSER_EXPRESSION_
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset stack pointer to begin of the stack.
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
@return None.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ResetScopeStack (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Push an Operand onto the Stack
|
||||||
|
|
||||||
|
@param Operand Operand to push.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The value was pushed onto the stack.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
|
||||||
|
stack.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
PushScope (
|
||||||
|
IN UINT8 Operand
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Pop an Operand from the Stack
|
||||||
|
|
||||||
|
@param Operand Operand to pop.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The value was pushed onto the stack.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
|
||||||
|
stack.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
PopScope (
|
||||||
|
OUT UINT8 *Operand
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Zero extend integer/boolean/date/time to UINT64 for comparing.
|
||||||
|
|
||||||
|
@param Value HII Value to be converted.
|
||||||
|
|
||||||
|
@return None.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ExtendValueToU64 (
|
||||||
|
IN EFI_HII_VALUE *Value
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compare two Hii value.
|
||||||
|
|
||||||
|
@param Value1 Expression value to compare on left-hand
|
||||||
|
@param Value2 Expression value to compare on right-hand
|
||||||
|
@param HiiHandle Only required for string compare
|
||||||
|
|
||||||
|
@retval EFI_INVALID_PARAMETER Could not perform comparation on two values
|
||||||
|
@retval 0 Two operators equeal
|
||||||
|
@retval 0 Value1 is greater than Value2
|
||||||
|
@retval 0 Value1 is less than Value2
|
||||||
|
|
||||||
|
**/
|
||||||
|
INTN
|
||||||
|
CompareHiiValue (
|
||||||
|
IN EFI_HII_VALUE *Value1,
|
||||||
|
IN EFI_HII_VALUE *Value2,
|
||||||
|
IN EFI_HII_HANDLE HiiHandle OPTIONAL
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,42 @@
|
||||||
|
/** @file
|
||||||
|
Internal Function and Macro defintions for IFR Expression evaluation used in Ifr Parsing. This header file should only
|
||||||
|
be included by UefiIfrParserExpression.c
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_PARSER_EXPRESSION_INTERNAL_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_PARSER_EXPRESSION_INTERNAL_
|
||||||
|
|
||||||
|
//
|
||||||
|
// Incremental size of stack for expression
|
||||||
|
//
|
||||||
|
#define EXPRESSION_STACK_SIZE_INCREMENT 0x100
|
||||||
|
|
||||||
|
|
||||||
|
FORM_BROWSER_STATEMENT *
|
||||||
|
IdToQuestion (
|
||||||
|
IN FORM_BROWSER_FORMSET *FormSet,
|
||||||
|
IN FORM_BROWSER_FORM *Form,
|
||||||
|
IN UINT16 QuestionId
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
FORM_EXPRESSION *
|
||||||
|
IdToExpression (
|
||||||
|
IN FORM_BROWSER_FORM *Form,
|
||||||
|
IN UINT8 RuleId
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,56 @@
|
||||||
|
/** @file
|
||||||
|
Internal Function and Macro defintions for IFR parsing. This header file should only
|
||||||
|
be included by UefiIfrParser.c
|
||||||
|
|
||||||
|
Copyright (c) 2008, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HII_THUNK_UEFI_IFR_PARSER_INTERNAL_
|
||||||
|
#define _HII_THUNK_UEFI_IFR_PARSER_INTERNAL_
|
||||||
|
|
||||||
|
#include <Protocol/UnicodeCollation.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HiiLib.h>
|
||||||
|
#include <Library/IfrSupportLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/PrintLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
|
||||||
|
#include <MdeModuleHii.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extern Variables
|
||||||
|
//
|
||||||
|
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
|
||||||
|
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
|
||||||
|
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
|
||||||
|
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
|
||||||
|
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Incremental string lenght of ConfigRequest
|
||||||
|
//
|
||||||
|
#define CONFIG_REQUEST_STRING_INCREMENTAL 1024
|
||||||
|
|
||||||
|
|
||||||
|
#define EFI_SPECIFICATION_ERRATA_VERSION 0
|
||||||
|
|
||||||
|
#define EFI_IFR_SPECIFICATION_VERSION \
|
||||||
|
((((EFI_SPECIFICATION_VERSION) >> 8) & 0xff00) | \
|
||||||
|
(((EFI_SPECIFICATION_VERSION) & 0xf) << 4) | \
|
||||||
|
((EFI_SPECIFICATION_ERRATA_VERSION) & 0xf))
|
||||||
|
|
||||||
|
extern EFI_GUID gZeroGuid;
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue