X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FVarCheckHiiLib%2FVarCheckHiiLibNullClass.c;h=93ac5ec8f1cc6e33ecdc7dae557ff58a93c27b19;hb=b4e96b82b4e2e47e95014b51787ba5b43abac784;hp=46a93bdb8a1b65e6112b5f25e4294a33cda74028;hpb=c9a7f34356c12c873d1737b7d3366fc7e1cadd50;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 46a93bdb8a..93ac5ec8f1 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -93,28 +93,61 @@ VarCheckHiiQuestion ( UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; + UINT8 StartBit; + UINT8 EndBit; + UINT8 TotalBits; + UINT16 VarOffsetByteLevel; + UINT8 StorageWidthByteLevel; + + if (HiiQuestion->BitFieldStore) { + VarOffsetByteLevel = HiiQuestion->VarOffset / 8; + TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth; + StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1); + } else { + VarOffsetByteLevel = HiiQuestion->VarOffset; + StorageWidthByteLevel = HiiQuestion->StorageWidth; + } - if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { - DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); + if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) { + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize)); return FALSE; } OneData = 0; - CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion->StorageWidth); + CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel); + if (HiiQuestion->BitFieldStore) { + // + // Get the value from the bit field. + // + StartBit = HiiQuestion->VarOffset % 8; + EndBit = StartBit + HiiQuestion->StorageWidth - 1; + OneData = BitFieldRead64 (OneData, StartBit, EndBit); + } switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + } if (OneData == OneValue) { // // Match // break; } - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } } if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) { // @@ -138,10 +171,20 @@ VarCheckHiiQuestion ( Minimum = 0; Maximum = 0; Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + } // // No need to check Step, because it is ONLY for UI. @@ -344,70 +387,95 @@ DumpHiiQuestion ( UINT8 *Ptr; DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); - DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode))); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore? "bit level": "byte level"))); DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)); - DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffset)); - DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->StorageWidth)); + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level"))); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level"))); switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1); while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue = 0; - CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // For OneOf stored in bit field, the value of options are saved as UINT32 type. + // + CopyMem (&OneValue, Ptr, sizeof (UINT32)); + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + } else { + CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth); + switch (HiiQuestion->StorageWidth) { + case sizeof (UINT8): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + break; + case sizeof (UINT16): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + break; + case sizeof (UINT32): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + break; + case sizeof (UINT64): + DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + break; + default: + ASSERT (FALSE); + break; + } + } + if (HiiQuestion->BitFieldStore) { + Ptr += sizeof (UINT32); + } else { + Ptr += HiiQuestion->StorageWidth; + } + } + break; + + case EFI_IFR_CHECKBOX_OP: + break; + + case EFI_IFR_NUMERIC_OP: + Minimum = 0; + Maximum = 0; + Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); + if(HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr += sizeof (UINT32); + + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr += HiiQuestion->StorageWidth; + switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); break; case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); break; case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); break; case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue)); + DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); break; default: ASSERT (FALSE); break; } - Ptr += HiiQuestion->StorageWidth; - } - break; - - case EFI_IFR_CHECKBOX_OP: - break; - - case EFI_IFR_NUMERIC_OP: - Minimum = 0; - Maximum = 0; - Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr += HiiQuestion->StorageWidth; - - switch (HiiQuestion->StorageWidth) { - case sizeof (UINT8): - DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); - break; - case sizeof (UINT16): - DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); - break; - case sizeof (UINT32): - DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); - break; - case sizeof (UINT64): - DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); - DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); - break; - default: - ASSERT (FALSE); - break; } break;