Enable two form packages share one hii handle.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14790 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong
2013-10-21 05:22:01 +00:00
committed by ydong10
parent 76edfba6d4
commit 22031c4f6b
2 changed files with 80 additions and 29 deletions

View File

@ -1109,6 +1109,7 @@ GetVarStoreType (
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN IfrOffset; UINTN IfrOffset;
UINTN PackageOffset;
EFI_IFR_OP_HEADER *IfrOpHdr; EFI_IFR_OP_HEADER *IfrOpHdr;
CHAR16 *VarStoreName; CHAR16 *VarStoreName;
EFI_STRING GuidStr; EFI_STRING GuidStr;
@ -1118,6 +1119,7 @@ GetVarStoreType (
UINT8 *HiiFormPackage; UINT8 *HiiFormPackage;
UINTN PackageSize; UINTN PackageSize;
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
EFI_HII_PACKAGE_HEADER *PackageHeader;
HiiFormPackage = NULL; HiiFormPackage = NULL;
LengthString = 0; LengthString = 0;
@ -1132,10 +1134,26 @@ GetVarStoreType (
return Status; return Status;
} }
IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);
PackageOffset = IfrOffset;
PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage;
while (IfrOffset < PackageSize) { while (IfrOffset < PackageSize) {
IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); //
// More than one form packages exist.
//
if (PackageOffset >= PackageHeader->Length) {
//
// Process the new form package.
//
PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
IfrOffset += PackageOffset;
PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset);
}
IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);
IfrOffset += IfrOpHdr->Length; IfrOffset += IfrOpHdr->Length;
PackageOffset += IfrOpHdr->Length;
if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) { if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) {
IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;
@ -1190,6 +1208,13 @@ GetVarStoreType (
FreePool (GuidStr); FreePool (GuidStr);
FreePool (NameStr); FreePool (NameStr);
FreePool (TempStr); FreePool (TempStr);
//
// Already found the varstore, break;
//
if (*IsEfiVarstore) {
break;
}
} }
} }
Done: Done:
@ -1415,6 +1440,7 @@ ParseIfrData (
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN IfrOffset; UINTN IfrOffset;
UINTN PackageOffset;
EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE *IfrVarStore;
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
EFI_IFR_OP_HEADER *IfrOpHdr; EFI_IFR_OP_HEADER *IfrOpHdr;
@ -1438,25 +1464,50 @@ ParseIfrData (
LIST_ENTRY *LinkData; LIST_ENTRY *LinkData;
LIST_ENTRY *LinkDefault; LIST_ENTRY *LinkDefault;
EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;
EFI_HII_PACKAGE_HEADER *PackageHeader;
EFI_VARSTORE_ID VarStoreId;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
BlockData = NULL; BlockData = NULL;
DefaultDataPtr = NULL; DefaultDataPtr = NULL;
FirstOneOfOption = FALSE; FirstOneOfOption = FALSE;
VarStoreId = 0;
ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));
// //
// Go through the form package to parse OpCode one by one. // Go through the form package to parse OpCode one by one.
// //
IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
PackageHeader = (EFI_HII_PACKAGE_HEADER *) Package;
IfrOffset = PackageOffset;
while (IfrOffset < PackageLength) { while (IfrOffset < PackageLength) {
//
// More than one form package found.
//
if (PackageOffset >= PackageHeader->Length) {
//
// Already found varstore for this request, break;
//
if (VarStoreId != 0) {
VarStoreId = 0;
}
//
// Get next package header info.
//
IfrOffset += sizeof (EFI_HII_PACKAGE_HEADER);
PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
PackageHeader = (EFI_HII_PACKAGE_HEADER *) (Package + IfrOffset);
}
IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset); IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset);
switch (IfrOpHdr->OpCode) { switch (IfrOpHdr->OpCode) {
case EFI_IFR_VARSTORE_OP: case EFI_IFR_VARSTORE_OP:
// //
// VarStore is found. Don't need to search any more. // VarStore is found. Don't need to search any more.
// //
if (VarStorageData->VarStoreId != 0) { if (VarStoreId != 0) {
break; break;
} }
@ -1474,10 +1525,10 @@ ParseIfrData (
// Find the matched VarStore // Find the matched VarStore
// //
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid); CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid);
VarStorageData->VarStoreId = IfrVarStore->VarStoreId;
VarStorageData->Size = IfrVarStore->Size; VarStorageData->Size = IfrVarStore->Size;
VarStorageData->Name = VarStoreName; VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_BUFFER; VarStorageData->Type = EFI_HII_VARSTORE_BUFFER;
VarStoreId = IfrVarStore->VarStoreId;
} }
break; break;
@ -1485,7 +1536,7 @@ ParseIfrData (
// //
// VarStore is found. Don't need to search any more. // VarStore is found. Don't need to search any more.
// //
if (VarStorageData->VarStoreId != 0) { if (VarStoreId != 0) {
break; break;
} }
@ -1512,10 +1563,10 @@ ParseIfrData (
// Find the matched VarStore // Find the matched VarStore
// //
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid); CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid);
VarStorageData->VarStoreId = IfrEfiVarStore->VarStoreId;
VarStorageData->Size = IfrEfiVarStore->Size; VarStorageData->Size = IfrEfiVarStore->Size;
VarStorageData->Name = VarStoreName; VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER; VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
VarStoreId = IfrEfiVarStore->VarStoreId;
} }
break; break;
@ -1523,7 +1574,7 @@ ParseIfrData (
// //
// VarStore is found. Don't need to search any more. // VarStore is found. Don't need to search any more.
// //
if (VarStorageData->VarStoreId != 0) { if (VarStoreId != 0) {
break; break;
} }
@ -1534,8 +1585,8 @@ ParseIfrData (
// Find the matched VarStore // Find the matched VarStore
// //
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid); CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid);
VarStorageData->VarStoreId = IfrNameValueVarStore->VarStoreId;
VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE; VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE;
VarStoreId = IfrNameValueVarStore->VarStoreId;
} }
break; break;
@ -1558,7 +1609,7 @@ ParseIfrData (
// //
// No matched varstore is found and directly return. // No matched varstore is found and directly return.
// //
if (VarStorageData->VarStoreId == 0) { if ( VarStoreId == 0) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto Done; goto Done;
} }
@ -1568,7 +1619,7 @@ ParseIfrData (
// //
// Ref question is not in IFR Form. This IFR form is not valid. // Ref question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if ( VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1576,7 +1627,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrRef = (EFI_IFR_REF4 *) IfrOpHdr; IfrRef = (EFI_IFR_REF4 *) IfrOpHdr;
if (IfrRef->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrRef->Question.VarStoreId != VarStoreId) {
break; break;
} }
VarWidth = (UINT16) (sizeof (EFI_HII_REF)); VarWidth = (UINT16) (sizeof (EFI_HII_REF));
@ -1596,7 +1647,7 @@ ParseIfrData (
// //
// Numeric and OneOf question is not in IFR Form. This IFR form is not valid. // Numeric and OneOf question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1604,7 +1655,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr; IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
if (IfrOneOf->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrOneOf->Question.VarStoreId != VarStoreId) {
break; break;
} }
VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
@ -1673,7 +1724,7 @@ ParseIfrData (
// //
// OrderedList question is not in IFR Form. This IFR form is not valid. // OrderedList question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1681,7 +1732,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr; IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr;
if (IfrOrderedList->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrOrderedList->Question.VarStoreId != VarStoreId) {
BlockData = NULL; BlockData = NULL;
break; break;
} }
@ -1705,7 +1756,7 @@ ParseIfrData (
// //
// CheckBox question is not in IFR Form. This IFR form is not valid. // CheckBox question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1713,7 +1764,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr; IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;
if (IfrCheckBox->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrCheckBox->Question.VarStoreId != VarStoreId) {
break; break;
} }
VarWidth = (UINT16) sizeof (BOOLEAN); VarWidth = (UINT16) sizeof (BOOLEAN);
@ -1792,7 +1843,7 @@ ParseIfrData (
// //
// Date question is not in IFR Form. This IFR form is not valid. // Date question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1800,7 +1851,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrDate = (EFI_IFR_DATE *) IfrOpHdr; IfrDate = (EFI_IFR_DATE *) IfrOpHdr;
if (IfrDate->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrDate->Question.VarStoreId != VarStoreId) {
break; break;
} }
@ -1821,7 +1872,7 @@ ParseIfrData (
// //
// Time question is not in IFR Form. This IFR form is not valid. // Time question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1829,7 +1880,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrTime = (EFI_IFR_TIME *) IfrOpHdr; IfrTime = (EFI_IFR_TIME *) IfrOpHdr;
if (IfrTime->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrTime->Question.VarStoreId != VarStoreId) {
break; break;
} }
@ -1850,7 +1901,7 @@ ParseIfrData (
// //
// String question is not in IFR Form. This IFR form is not valid. // String question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1858,7 +1909,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrString = (EFI_IFR_STRING *) IfrOpHdr; IfrString = (EFI_IFR_STRING *) IfrOpHdr;
if (IfrString->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrString->Question.VarStoreId != VarStoreId) {
break; break;
} }
@ -1884,7 +1935,7 @@ ParseIfrData (
// //
// Password question is not in IFR Form. This IFR form is not valid. // Password question is not in IFR Form. This IFR form is not valid.
// //
if (VarStorageData->VarStoreId == 0) { if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
@ -1892,7 +1943,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore. // Check whether this question is for the requested varstore.
// //
IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr; IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr;
if (IfrPassword->Question.VarStoreId != VarStorageData->VarStoreId) { if (IfrPassword->Question.VarStoreId != VarStoreId) {
break; break;
} }
@ -2089,7 +2140,8 @@ ParseIfrData (
break; break;
} }
IfrOffset += IfrOpHdr->Length; IfrOffset += IfrOpHdr->Length;
PackageOffset += IfrOpHdr->Length;
} }
Done: Done:
@ -2990,7 +3042,7 @@ GetFullStringFromHiiFormPackages (
// //
// No requested varstore in IFR data and directly return // No requested varstore in IFR data and directly return
// //
if (VarStorageData->VarStoreId == 0) { if (VarStorageData->Type == 0 && VarStorageData->Name == NULL) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto Done; goto Done;
} }

View File

@ -65,7 +65,6 @@ typedef struct {
LIST_ENTRY Entry; // Link to VarStorage LIST_ENTRY Entry; // Link to VarStorage
EFI_GUID Guid; EFI_GUID Guid;
CHAR16 *Name; CHAR16 *Name;
EFI_VARSTORE_ID VarStoreId;
UINT16 Size; UINT16 Size;
UINT8 Type; UINT8 Type;
LIST_ENTRY BlockEntry; // Link to its Block array LIST_ENTRY BlockEntry; // Link to its Block array