UINT8 *Ptr;\r
UINT8 Index;\r
UINT8 MaxContainers;\r
+ UINT8 StartBit;\r
+ UINT8 EndBit;\r
+ UINT8 TotalBits;\r
+ UINT16 VarOffsetByteLevel;\r
+ UINT8 StorageWidthByteLevel;\r
+\r
+ if (HiiQuestion->BitFieldStore) {\r
+ VarOffsetByteLevel = HiiQuestion->VarOffset / 8;\r
+ TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth;\r
+ StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);\r
+ } else {\r
+ VarOffsetByteLevel = HiiQuestion->VarOffset;\r
+ StorageWidthByteLevel = HiiQuestion->StorageWidth;\r
+ }\r
\r
- if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) {\r
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize));\r
+ if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {\r
+ DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));\r
return FALSE;\r
}\r
\r
OneData = 0;\r
- CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth);\r
+ CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel);\r
+ if (HiiQuestion->BitFieldStore) {\r
+ //\r
+ // Get the value from the bit field.\r
+ //\r
+ StartBit = HiiQuestion->VarOffset % 8;\r
+ EndBit = StartBit + HiiQuestion->StorageWidth - 1;\r
+ OneData = BitFieldRead64 (OneData, StartBit, EndBit);\r
+ }\r
\r
switch (HiiQuestion->OpCode) {\r
case EFI_IFR_ONE_OF_OP:\r
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);\r
while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) {\r
OneValue = 0;\r
- CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
+ if (HiiQuestion->BitFieldStore) {\r
+ //\r
+ // For OneOf stored in bit field, the value of options are saved as UINT32 type.\r
+ //\r
+ CopyMem (&OneValue, Ptr, sizeof (UINT32));\r
+ } else {\r
+ CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
+ }\r
if (OneData == OneValue) {\r
//\r
// Match\r
//\r
break;\r
}\r
- Ptr += HiiQuestion->StorageWidth;\r
+ if (HiiQuestion->BitFieldStore) {\r
+ Ptr += sizeof (UINT32);\r
+ } else {\r
+ Ptr += HiiQuestion->StorageWidth;\r
+ }\r
}\r
if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
//\r
Minimum = 0;\r
Maximum = 0;\r
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);\r
- CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
- Ptr += HiiQuestion->StorageWidth;\r
- CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
- Ptr += HiiQuestion->StorageWidth;\r
+ if (HiiQuestion->BitFieldStore) {\r
+ //\r
+ // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.\r
+ //\r
+ CopyMem (&Minimum, Ptr, sizeof (UINT32));\r
+ Ptr += sizeof (UINT32);\r
+ CopyMem (&Maximum, Ptr, sizeof (UINT32));\r
+ Ptr += sizeof (UINT32);\r
+ } else {\r
+ CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
+ Ptr += HiiQuestion->StorageWidth;\r
+ CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
+ Ptr += HiiQuestion->StorageWidth;\r
+ }\r
\r
//\r
// No need to check Step, because it is ONLY for UI.\r
UINT8 *Ptr;\r
\r
DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n"));\r
- DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode)));\r
+ DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length));\r
- DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset));\r
- DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth));\r
+ DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
+ DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
\r
switch (HiiQuestion->OpCode) {\r
case EFI_IFR_ONE_OF_OP:\r
Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);\r
while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
OneValue = 0;\r
- CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
+ if (HiiQuestion->BitFieldStore) {\r
+ //\r
+ // For OneOf stored in bit field, the value of options are saved as UINT32 type.\r
+ //\r
+ CopyMem (&OneValue, Ptr, sizeof (UINT32));\r
+ DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
+ } else {\r
+ CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
+ switch (HiiQuestion->StorageWidth) {\r
+ case sizeof (UINT8):\r
+ DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue));\r
+ break;\r
+ case sizeof (UINT16):\r
+ DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue));\r
+ break;\r
+ case sizeof (UINT32):\r
+ DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
+ break;\r
+ case sizeof (UINT64):\r
+ DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue));\r
+ break;\r
+ default:\r
+ ASSERT (FALSE);\r
+ break;\r
+ }\r
+ }\r
+ if (HiiQuestion->BitFieldStore) {\r
+ Ptr += sizeof (UINT32);\r
+ } else {\r
+ Ptr += HiiQuestion->StorageWidth;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EFI_IFR_CHECKBOX_OP:\r
+ break;\r
+\r
+ case EFI_IFR_NUMERIC_OP:\r
+ Minimum = 0;\r
+ Maximum = 0;\r
+ Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);\r
+ if(HiiQuestion->BitFieldStore) {\r
+ //\r
+ // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.\r
+ //\r
+ CopyMem (&Minimum, Ptr, sizeof (UINT32));\r
+ Ptr += sizeof (UINT32);\r
+ CopyMem (&Maximum, Ptr, sizeof (UINT32));\r
+ Ptr += sizeof (UINT32);\r
+\r
+ DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum));\r
+ DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum));\r
+ } else {\r
+ CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
+ Ptr += HiiQuestion->StorageWidth;\r
+ CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
+ Ptr += HiiQuestion->StorageWidth;\r
+\r
switch (HiiQuestion->StorageWidth) {\r
case sizeof (UINT8):\r
- DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue));\r
+ DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum));\r
+ DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum));\r
break;\r
case sizeof (UINT16):\r
- DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue));\r
+ DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum));\r
+ DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum));\r
break;\r
case sizeof (UINT32):\r
- DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
+ DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum));\r
+ DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum));\r
break;\r
case sizeof (UINT64):\r
- DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue));\r
+ DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum));\r
+ DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum));\r
break;\r
default:\r
ASSERT (FALSE);\r
break;\r
}\r
- Ptr += HiiQuestion->StorageWidth;\r
- }\r
- break;\r
-\r
- case EFI_IFR_CHECKBOX_OP:\r
- break;\r
-\r
- case EFI_IFR_NUMERIC_OP:\r
- Minimum = 0;\r
- Maximum = 0;\r
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);\r
- CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
- Ptr += HiiQuestion->StorageWidth;\r
- CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
- Ptr += HiiQuestion->StorageWidth;\r
-\r
- switch (HiiQuestion->StorageWidth) {\r
- case sizeof (UINT8):\r
- DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum));\r
- DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum));\r
- break;\r
- case sizeof (UINT16):\r
- DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum));\r
- DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum));\r
- break;\r
- case sizeof (UINT32):\r
- DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum));\r
- DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum));\r
- break;\r
- case sizeof (UINT64):\r
- DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum));\r
- DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum));\r
- break;\r
- default:\r
- ASSERT (FALSE);\r
- break;\r
}\r
break;\r
\r