MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check
V3: (1) Reset QuestionStoredInBitField to FALSE at end opcode(EFI_IFR_END_OP) (2) Fix typo and format issues(line alignment for debug print message and value assignment...) V2: (1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final VarCheckBinSize and update the implementation accordingly. (2)Update the VAR_CHECK_HII_REVISION (3)Refine the Debug message and function comments,like update oneof", "checkbox", "numeric" to "OneOf", "CheckBox", "Numeric". VarCheckHiiLib check the value set to storage based on the possible value listed in the vfr file. Since we have enhanced vfr to support Question value stored in bit field, so now enhance VarCheckHiiLib to support bit field check. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Var Check Hii bin generation.
|
||||
|
||||
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
@@ -120,8 +120,10 @@ DumpHiiPackage (
|
||||
EFI_IFR_OP_HEADER *IfrOpCodeHeader;
|
||||
EFI_IFR_VARSTORE *IfrVarStore;
|
||||
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
|
||||
BOOLEAN QuestionStoredInBitField;
|
||||
|
||||
HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage;
|
||||
QuestionStoredInBitField = FALSE;
|
||||
|
||||
DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type)));
|
||||
DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length));
|
||||
@@ -157,18 +159,24 @@ DumpHiiPackage (
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_IFR_GUID_OP:
|
||||
if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
|
||||
QuestionStoredInBitField = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_IFR_ONE_OF_OP:
|
||||
case EFI_IFR_CHECKBOX_OP:
|
||||
case EFI_IFR_NUMERIC_OP:
|
||||
case EFI_IFR_ORDERED_LIST_OP:
|
||||
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
|
||||
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a) (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode), (QuestionStoredInBitField? "bit level": "byte level")));
|
||||
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
|
||||
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
|
||||
DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt));
|
||||
DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help));
|
||||
DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId));
|
||||
DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId));
|
||||
DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset));
|
||||
DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x (%a)\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset, (QuestionStoredInBitField? "bit level": "byte level")));
|
||||
{
|
||||
EFI_IFR_ONE_OF *IfrOneOf;
|
||||
EFI_IFR_CHECKBOX *IfrCheckBox;
|
||||
@@ -179,27 +187,36 @@ DumpHiiPackage (
|
||||
case EFI_IFR_ONE_OF_OP:
|
||||
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader;
|
||||
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags));
|
||||
switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
|
||||
case EFI_IFR_NUMERIC_SIZE_1:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_2:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_4:
|
||||
if (QuestionStoredInBitField) {
|
||||
//
|
||||
// For OneOf stored in bit field, the option value are saved as UINT32 type.
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_8:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step));
|
||||
break;
|
||||
} else {
|
||||
switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
|
||||
case EFI_IFR_NUMERIC_SIZE_1:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_2:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_4:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_8:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFI_IFR_CHECKBOX_OP:
|
||||
@@ -209,27 +226,36 @@ DumpHiiPackage (
|
||||
case EFI_IFR_NUMERIC_OP:
|
||||
IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader;
|
||||
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags));
|
||||
switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
|
||||
case EFI_IFR_NUMERIC_SIZE_1:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_2:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_4:
|
||||
if (QuestionStoredInBitField) {
|
||||
//
|
||||
// For Numeric stored in bit field, the MinValue,MaxValue and Step are saved as UINT32 type.
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_8:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step));
|
||||
break;
|
||||
} else {
|
||||
switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
|
||||
case EFI_IFR_NUMERIC_SIZE_1:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_2:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_4:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step));
|
||||
break;
|
||||
case EFI_IFR_NUMERIC_SIZE_8:
|
||||
DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue));
|
||||
DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue));
|
||||
DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFI_IFR_ORDERED_LIST_OP:
|
||||
@@ -279,6 +305,7 @@ DumpHiiPackage (
|
||||
}
|
||||
|
||||
if (IfrOpCodeHeader->OpCode == EFI_IFR_END_OP) {
|
||||
QuestionStoredInBitField = FALSE;
|
||||
ASSERT (Scope > 0);
|
||||
Scope--;
|
||||
if (Scope == 0) {
|
||||
@@ -488,6 +515,7 @@ MergeHiiQuestion (
|
||||
UINT8 *Ptr;
|
||||
UINT8 *Ptr1;
|
||||
UINT8 *Ptr2;
|
||||
UINT16 ArrayIndex;
|
||||
|
||||
//
|
||||
// Hii Question from Hii Database has high priority.
|
||||
@@ -498,14 +526,20 @@ MergeHiiQuestion (
|
||||
return;
|
||||
}
|
||||
|
||||
HiiQuestion1 = HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset];
|
||||
if (HiiQuestion->BitFieldStore) {
|
||||
ArrayIndex = HiiQuestion->VarOffset;
|
||||
} else {
|
||||
ArrayIndex = HiiQuestion->VarOffset * 8;
|
||||
}
|
||||
|
||||
HiiQuestion1 = HiiVariableNode->HiiQuestionArray[ArrayIndex];
|
||||
HiiQuestion2 = HiiQuestion;
|
||||
|
||||
ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth));
|
||||
|
||||
switch (HiiQuestion1->OpCode) {
|
||||
case EFI_IFR_ONE_OF_OP:
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset));
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
|
||||
//
|
||||
// Get the length of Hii Question 1.
|
||||
//
|
||||
@@ -580,17 +614,17 @@ MergeHiiQuestion (
|
||||
Ptr2 += HiiQuestion2->StorageWidth;
|
||||
}
|
||||
|
||||
HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion;
|
||||
HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
|
||||
InternalVarCheckFreePool (HiiQuestion1);
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_IFR_CHECKBOX_OP:
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset));
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
|
||||
break;
|
||||
|
||||
case EFI_IFR_NUMERIC_OP:
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset));
|
||||
DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
|
||||
//
|
||||
// Get minimum and maximum of Hii Question 1.
|
||||
//
|
||||
@@ -705,7 +739,7 @@ MergeHiiQuestion (
|
||||
Ptr2 += HiiQuestion2->StorageWidth;
|
||||
}
|
||||
|
||||
HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] = NewHiiQuestion;
|
||||
HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
|
||||
InternalVarCheckFreePool (HiiQuestion1);
|
||||
}
|
||||
break;
|
||||
@@ -831,13 +865,15 @@ GetOneOfOption (
|
||||
Parse Hii Question Oneof.
|
||||
|
||||
@param[in] IfrOpCodeHeader Pointer to Ifr OpCode header.
|
||||
@param[in] StoredInBitField Whether the OneOf is stored in bit field Storage.
|
||||
|
||||
return Pointer to Hii Question.
|
||||
|
||||
**/
|
||||
VAR_CHECK_HII_QUESTION_HEADER *
|
||||
ParseHiiQuestionOneOf (
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
|
||||
IN BOOLEAN StoredInBitField
|
||||
)
|
||||
{
|
||||
EFI_IFR_ONE_OF *IfrOneOf;
|
||||
@@ -846,10 +882,21 @@ ParseHiiQuestionOneOf (
|
||||
UINT8 Width;
|
||||
UINTN OptionCount;
|
||||
UINT8 OptionWidth;
|
||||
UINT8 BitWidth;
|
||||
|
||||
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader;
|
||||
BitWidth = 0;
|
||||
|
||||
Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
|
||||
if (StoredInBitField) {
|
||||
//
|
||||
// When OneOf stored in bit field, the bit width is saved in the lower six bits of the flag.
|
||||
// And the options in the OneOf is saved as UINT32 type.
|
||||
//
|
||||
BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
|
||||
Width = sizeof (UINT32);
|
||||
} else {
|
||||
Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
|
||||
}
|
||||
|
||||
GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL);
|
||||
ASSERT (Width == OptionWidth);
|
||||
@@ -858,10 +905,15 @@ ParseHiiQuestionOneOf (
|
||||
|
||||
OneOf = InternalVarCheckAllocateZeroPool (Length);
|
||||
ASSERT (OneOf != NULL);
|
||||
OneOf->OpCode = EFI_IFR_ONE_OF_OP;
|
||||
OneOf->Length = (UINT8) Length;
|
||||
OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
|
||||
OneOf->StorageWidth = Width;
|
||||
OneOf->OpCode = EFI_IFR_ONE_OF_OP;
|
||||
OneOf->Length = (UINT8) Length;
|
||||
OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
|
||||
OneOf->BitFieldStore = StoredInBitField;
|
||||
if (StoredInBitField) {
|
||||
OneOf->StorageWidth = BitWidth;
|
||||
} else {
|
||||
OneOf->StorageWidth = Width;
|
||||
}
|
||||
|
||||
GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1);
|
||||
|
||||
@@ -872,13 +924,15 @@ ParseHiiQuestionOneOf (
|
||||
Parse Hii Question CheckBox.
|
||||
|
||||
@param[in] IfrOpCodeHeader Pointer to Ifr OpCode header.
|
||||
@param[in] StoredInBitField Whether the CheckBox is stored in bit field Storage.
|
||||
|
||||
return Pointer to Hii Question.
|
||||
|
||||
**/
|
||||
VAR_CHECK_HII_QUESTION_HEADER *
|
||||
ParseHiiQuestionCheckBox (
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
|
||||
IN BOOLEAN StoredInBitField
|
||||
)
|
||||
{
|
||||
EFI_IFR_CHECKBOX *IfrCheckBox;
|
||||
@@ -888,10 +942,15 @@ ParseHiiQuestionCheckBox (
|
||||
|
||||
CheckBox = InternalVarCheckAllocateZeroPool (sizeof (*CheckBox));
|
||||
ASSERT (CheckBox != NULL);
|
||||
CheckBox->OpCode = EFI_IFR_CHECKBOX_OP;
|
||||
CheckBox->Length = (UINT8) sizeof (*CheckBox);;
|
||||
CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
|
||||
CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN);
|
||||
CheckBox->OpCode = EFI_IFR_CHECKBOX_OP;
|
||||
CheckBox->Length = (UINT8) sizeof (*CheckBox);;
|
||||
CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
|
||||
CheckBox->BitFieldStore = StoredInBitField;
|
||||
if (StoredInBitField) {
|
||||
CheckBox->StorageWidth = 1;
|
||||
} else {
|
||||
CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN);
|
||||
}
|
||||
|
||||
return (VAR_CHECK_HII_QUESTION_HEADER *) CheckBox;
|
||||
}
|
||||
@@ -900,30 +959,48 @@ ParseHiiQuestionCheckBox (
|
||||
Parse Hii Question Numeric.
|
||||
|
||||
@param[in] IfrOpCodeHeader Pointer to Ifr OpCode header.
|
||||
@param[in] StoredInBitField Whether the Numeric is stored in bit field Storage.
|
||||
|
||||
return Pointer to Hii Question.
|
||||
|
||||
**/
|
||||
VAR_CHECK_HII_QUESTION_HEADER *
|
||||
ParseHiiQuestionNumeric (
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
|
||||
IN BOOLEAN StoredInBitField
|
||||
)
|
||||
{
|
||||
EFI_IFR_NUMERIC *IfrNumeric;
|
||||
VAR_CHECK_HII_QUESTION_NUMERIC *Numeric;
|
||||
UINT8 Width;
|
||||
UINT8 BitWidth;
|
||||
|
||||
IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader;
|
||||
BitWidth = 0;
|
||||
|
||||
Numeric = InternalVarCheckAllocateZeroPool (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * sizeof (UINT64));
|
||||
ASSERT (Numeric != NULL);
|
||||
|
||||
Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
|
||||
if (StoredInBitField) {
|
||||
//
|
||||
// When Numeric stored in bit field, the bit field width is saved in the lower six bits of the flag.
|
||||
// And the Minimum Maximum of Numeric is saved as UINT32 type.
|
||||
//
|
||||
BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
|
||||
Width = sizeof (UINT32);
|
||||
} else {
|
||||
Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
|
||||
}
|
||||
|
||||
Numeric->OpCode = EFI_IFR_NUMERIC_OP;
|
||||
Numeric->Length = (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width);
|
||||
Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
|
||||
Numeric->StorageWidth = Width;
|
||||
Numeric->OpCode = EFI_IFR_NUMERIC_OP;
|
||||
Numeric->Length = (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width);
|
||||
Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
|
||||
Numeric->BitFieldStore = StoredInBitField;
|
||||
if (StoredInBitField) {
|
||||
Numeric->StorageWidth = BitWidth;
|
||||
} else {
|
||||
Numeric->StorageWidth = Width;
|
||||
}
|
||||
|
||||
CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2);
|
||||
|
||||
@@ -962,6 +1039,7 @@ ParseHiiQuestionOrderedList (
|
||||
OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset;
|
||||
OrderedList->StorageWidth = OptionWidth;
|
||||
OrderedList->MaxContainers = IfrOrderedList->MaxContainers;
|
||||
OrderedList->BitFieldStore = FALSE;
|
||||
|
||||
GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList + 1);
|
||||
|
||||
@@ -974,28 +1052,34 @@ ParseHiiQuestionOrderedList (
|
||||
@param[in] HiiVariableNode Pointer to Hii Variable node.
|
||||
@param[in] IfrOpCodeHeader Pointer to Ifr OpCode header.
|
||||
@param[in] FromFv Hii Question from FV.
|
||||
@param[in] StoredInBitField Whether the Question is stored in bit field Storage.
|
||||
|
||||
**/
|
||||
VOID
|
||||
ParseHiiQuestion (
|
||||
IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode,
|
||||
IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
|
||||
IN BOOLEAN FromFv
|
||||
IN BOOLEAN FromFv,
|
||||
IN BOOLEAN StoredInBitField
|
||||
)
|
||||
{
|
||||
VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
|
||||
UINT16 ArrayIndex;
|
||||
|
||||
//
|
||||
// Currently only OneOf, CheckBox and Numeric can be stored in bit field.
|
||||
//
|
||||
switch (IfrOpCodeHeader->OpCode) {
|
||||
case EFI_IFR_ONE_OF_OP:
|
||||
HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader);
|
||||
HiiQuestion = ParseHiiQuestionOneOf (IfrOpCodeHeader, StoredInBitField);
|
||||
break;
|
||||
|
||||
case EFI_IFR_CHECKBOX_OP:
|
||||
HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader);
|
||||
HiiQuestion = ParseHiiQuestionCheckBox (IfrOpCodeHeader, StoredInBitField);
|
||||
break;
|
||||
|
||||
case EFI_IFR_NUMERIC_OP:
|
||||
HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader);
|
||||
HiiQuestion = ParseHiiQuestionNumeric (IfrOpCodeHeader, StoredInBitField);
|
||||
break;
|
||||
|
||||
case EFI_IFR_ORDERED_LIST_OP:
|
||||
@@ -1008,10 +1092,15 @@ ParseHiiQuestion (
|
||||
break;
|
||||
}
|
||||
|
||||
if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] != NULL) {
|
||||
if (StoredInBitField) {
|
||||
ArrayIndex = HiiQuestion->VarOffset;
|
||||
} else {
|
||||
ArrayIndex = HiiQuestion->VarOffset * 8;
|
||||
}
|
||||
if (HiiVariableNode->HiiQuestionArray[ArrayIndex] != NULL) {
|
||||
MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv);
|
||||
} else {
|
||||
HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] = HiiQuestion;
|
||||
HiiVariableNode->HiiQuestionArray[ArrayIndex] = HiiQuestion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,7 +1255,7 @@ CreateHiiVariableNode (
|
||||
// The variable store identifier, which is unique within the current form set.
|
||||
//
|
||||
HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId;
|
||||
HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * sizeof (VAR_CHECK_HII_QUESTION_HEADER *));
|
||||
HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * 8 * sizeof (VAR_CHECK_HII_QUESTION_HEADER *));
|
||||
|
||||
InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link);
|
||||
} else {
|
||||
@@ -1239,6 +1328,7 @@ VarCheckParseHiiPackage (
|
||||
EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
|
||||
EFI_IFR_OP_HEADER *IfrOpCodeHeader;
|
||||
VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
|
||||
BOOLEAN QuestionStoredInBitField;
|
||||
|
||||
//
|
||||
// Parse and create Hii Variable node list for this Hii Package.
|
||||
@@ -1247,12 +1337,24 @@ VarCheckParseHiiPackage (
|
||||
|
||||
HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage;
|
||||
|
||||
QuestionStoredInBitField = FALSE;
|
||||
|
||||
switch (HiiPackageHeader->Type) {
|
||||
case EFI_HII_PACKAGE_FORMS:
|
||||
IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1);
|
||||
|
||||
while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPackageHeader->Length) {
|
||||
switch (IfrOpCodeHeader->OpCode) {
|
||||
case EFI_IFR_GUID_OP:
|
||||
if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
|
||||
QuestionStoredInBitField = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_IFR_END_OP:
|
||||
QuestionStoredInBitField = FALSE;
|
||||
break;
|
||||
|
||||
case EFI_IFR_ONE_OF_OP:
|
||||
case EFI_IFR_CHECKBOX_OP:
|
||||
case EFI_IFR_NUMERIC_OP:
|
||||
@@ -1270,7 +1372,7 @@ VarCheckParseHiiPackage (
|
||||
//
|
||||
// Normal IFR
|
||||
//
|
||||
ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv);
|
||||
ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv, QuestionStoredInBitField);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -1341,7 +1443,7 @@ DestroyHiiVariableNode (
|
||||
//
|
||||
// Free the allocated buffer.
|
||||
//
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) {
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
|
||||
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
|
||||
InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]);
|
||||
}
|
||||
@@ -1389,7 +1491,7 @@ BuildVarCheckHiiBin (
|
||||
HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
|
||||
HiiVariableLength = HiiVariableNode->HiiVariable->HeaderLength;
|
||||
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) {
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
|
||||
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
|
||||
//
|
||||
// For Hii Question header align.
|
||||
@@ -1434,7 +1536,7 @@ BuildVarCheckHiiBin (
|
||||
CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariable->HeaderLength);
|
||||
Ptr += HiiVariableNode->HiiVariable->HeaderLength;
|
||||
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size; Index++) {
|
||||
for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
|
||||
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
|
||||
//
|
||||
// For Hii Question header align.
|
||||
|
Reference in New Issue
Block a user