From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DEACD202E5E64 for ; Thu, 2 Nov 2017 23:00:27 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 02 Nov 2017 23:04:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,337,1505804400"; d="scan'208";a="171430922" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 02 Nov 2017 23:04:21 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 23:04:21 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 23:04:20 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 3 Nov 2017 14:04:17 +0800 From: "Zeng, Star" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Gao, Liming" , "Zeng, Star" Thread-Topic: [patch] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check Thread-Index: AQHTTvTfbjD7pW6wfkO7SjRRL/Yy/6MCMxGQ Date: Fri, 3 Nov 2017 06:04:16 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B1385@shsmsx102.ccr.corp.intel.com> References: <1509089122-135376-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1509089122-135376-1-git-send-email-dandan.bi@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Nov 2017 06:00:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Dandan, 1. Could we reuse VarOffset/StorageWidth to store bit level info when BitFi= eldStore =3D TRUE? Then we can avoid adding VarOffsetBitLevel/StorageWidthB= itLevel to reduce the final VarCheckBinSize, and it can be also aligned wit= h HiiDatabase that is using VarOffset to store bit level info when gEdkiiIf= rBitVarstoreGuid guid opcode is present, right? 2. Please increase VAR_CHECK_HII_REVISION since we will update the structur= e definitions. 3. How about to update "Bit VarStoreInfo (bit level)" to be "VarStoreInfo (bit level)"? "Bit VarOffset(Bit level)" to be "VarOffset(Bit level)"? "Bit StorageWidth(Bit level) " to be "StorageWidth(Bit level)"? 4. How about to update "oneof", "checkbox", "numeric" and "orderedlist" in= comments to be consistent with "OneOf", "CheckBox", "Numeric" and "Ordered= List"? Thanks, Star -----Original Message----- From: Bi, Dandan=20 Sent: Friday, October 27, 2017 3:25 PM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric ; Gao= , Liming Subject: [patch] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to suppor= t bit check VarCheckHiiLib check the value set to storage based on the possible value l= isted 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 ch= eck. Cc: Star Zeng Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../VarCheckHiiLib/InternalVarCheckStructure.h | 17 +- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 259 +++++++++++++++--= ---- .../Library/VarCheckHiiLib/VarCheckHiiLib.inf | 5 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 92 ++++++-- 5 files changed, 291 insertions(+), 86 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.= h b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h index a9faed4..b32dd4e 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h @@ -1,9 +1,9 @@ /** @file Internal structure for Var Check Hii. =20 -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at http://opens= ource.org/licenses/bsd-license.php =20 @@ -40,41 +40,56 @@ typedef struct { typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + UINT16 VarOffsetBitLevel; + UINT8 StorageWidthBitLevel; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field } VAR_CHECK_HII_QUESTION_HEADER; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + UINT16 VarOffsetBitLevel; + UINT8 StorageWidthBitLevel; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field //UINTx Data[]; // x =3D UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ONEOF; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + UINT16 VarOffsetBitLevel; + UINT8 StorageWidthBitLevel; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field } VAR_CHECK_HII_QUESTION_CHECKBOX; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + UINT16 VarOffsetBitLevel; + UINT8 StorageWidthBitLevel; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field //UINTx Minimum; // x =3D UINT8/UINT16/UINT32/UINT64; //UINTx Maximum; // x =3D UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_NUMERIC; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + UINT16 VarOffsetBitLevel; + UINT8 StorageWidthBitLevel; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field UINT8 MaxContainers; //UINTx Data[]; // x =3D UINT8/UINT16/UINT32/UINT64; } VAR_CHECK_HII_QUESTION_ORDEREDLIST; =20 #pragma pack () diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h b/MdeModuleP= kg/Library/VarCheckHiiLib/VarCheckHii.h index a54b867..7363edf 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h @@ -1,9 +1,9 @@ /** @file Include file for Var Check Hii handler and bin. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at http://opens= ource.org/licenses/bsd-license.php =20 @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include #include =20 +#include + #include #include #include =20 #include "InternalVarCheckStructure.h" diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModu= lePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index f018c87..f4b646c 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -1,9 +1,9 @@ /** @file Var Check Hii bin generation. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at http://opens= ource.org/licenses/bsd-license.php =20 @@ -118,12 +118,14 @@ DumpHiiPackage ( { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; EFI_IFR_VARSTORE *IfrVarStore; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; + BOOLEAN QuestionStoredInBitField; =20 HiiPackageHeader =3D (EFI_HII_PACKAGE_HEADER *) HiiPackage; + QuestionStoredInBitField =3D FALSE; =20 DEBUG ((EFI_D_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPac= kageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); DEBUG ((EFI_D_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageH= eader->Length)); =20 switch (HiiPackageHeader->Type) { @@ -155,83 +157,116 @@ DumpHiiPackage ( DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", IfrEfiVar= Store->Attributes)); DEBUG ((EFI_D_INFO, " Name - %a\n", IfrEfiVarStor= e->Name)); } break; =20 + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof = (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField =3D TRUE; + } + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: + if (QuestionStoredInBitField) { + DEBUG ((EFI_D_INFO, "----DumpHiiPackage-The Question is stor= ed in bit field----\n")); + } else { + DEBUG ((EFI_D_INFO, "----DumpHiiPackage-The Question is stor= ed in byte field----\n")); + } DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)= \n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode))); DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Length - 0x02%x\n", = IfrOpCodeHeader->Length)); DEBUG ((EFI_D_INFO, " IfrOpCodeHeader->Scope - 0x02%x\n", = IfrOpCodeHeader->Scope)); DEBUG ((EFI_D_INFO, " Prompt - 0x%04x\n", ((EFI_IFR= _ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt)); DEBUG ((EFI_D_INFO, " Help - 0x%04x\n", ((EFI_IFR= _ONE_OF *) IfrOpCodeHeader)->Question.Header.Help)); DEBUG ((EFI_D_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR= _ONE_OF *) IfrOpCodeHeader)->Question.QuestionId)); DEBUG ((EFI_D_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR= _ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId)); - DEBUG ((EFI_D_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR= _ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + if (QuestionStoredInBitField) { + DEBUG ((EFI_D_INFO, " Bit VarStoreInfo (bit level) - 0x%0= 4x\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffse= t)); + } else { + DEBUG ((EFI_D_INFO, " VarStoreInfo - 0x%04x\n", ((EFI_IFR= _ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset)); + } { EFI_IFR_ONE_OF *IfrOneOf; EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_NUMERIC *IfrNumeric; EFI_IFR_ORDERED_LIST *IfrOrderedList; =20 switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: IfrOneOf =3D (EFI_IFR_ONE_OF *) IfrOpCodeHeader; DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", If= rOneOf->Flags)); - switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", = IfrOneOf->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", = IfrOneOf->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", = IfrOneOf->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", = IfrOneOf->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", = IfrOneOf->data.u16.MaxValue)); - DEBUG ((EFI_D_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 ((EFI_D_INFO, " MinValue - 0x%08x\n", = IfrOneOf->data.u32.MinValue)); DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", = IfrOneOf->data.u32.MaxValue)); DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", = IfrOneOf->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n"= , IfrOneOf->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n"= , IfrOneOf->data.u64.MaxValue)); - DEBUG ((EFI_D_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 ((EFI_D_INFO, " MinValue - 0x%02x\n"= , IfrOneOf->data.u8.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n"= , IfrOneOf->data.u8.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%02x\n"= , IfrOneOf->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n"= , IfrOneOf->data.u16.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n"= , IfrOneOf->data.u16.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%04x\n"= , IfrOneOf->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n"= , IfrOneOf->data.u32.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n"= , IfrOneOf->data.u32.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%08x\n"= , IfrOneOf->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\= n", IfrOneOf->data.u64.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\= n", IfrOneOf->data.u64.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%016lx\= n", IfrOneOf->data.u64.Step)); + break; + } } break; case EFI_IFR_CHECKBOX_OP: IfrCheckBox =3D (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", If= rCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric =3D (EFI_IFR_NUMERIC *) IfrOpCodeHeader; DEBUG ((EFI_D_INFO, " Flags - 0x%02x\n", If= rNumeric->Flags)); - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DEBUG ((EFI_D_INFO, " MinValue - 0x%02x\n", = IfrNumeric->data.u8.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n", = IfrNumeric->data.u8.MaxValue)); - DEBUG ((EFI_D_INFO, " Step - 0x%02x\n", = IfrNumeric->data.u8.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_2: - DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n", = IfrNumeric->data.u16.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n", = IfrNumeric->data.u16.MaxValue)); - DEBUG ((EFI_D_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,MaxVa= lue and Step are saved as UINT32 type. + // DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n", = IfrNumeric->data.u32.MinValue)); DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n", = IfrNumeric->data.u32.MaxValue)); DEBUG ((EFI_D_INFO, " Step - 0x%08x\n", = IfrNumeric->data.u32.Step)); - break; - case EFI_IFR_NUMERIC_SIZE_8: - DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\n"= , IfrNumeric->data.u64.MinValue)); - DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\n"= , IfrNumeric->data.u64.MaxValue)); - DEBUG ((EFI_D_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 ((EFI_D_INFO, " MinValue - 0x%02x\n"= , IfrNumeric->data.u8.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%02x\n"= , IfrNumeric->data.u8.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%02x\n"= , IfrNumeric->data.u8.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_2: + DEBUG ((EFI_D_INFO, " MinValue - 0x%04x\n"= , IfrNumeric->data.u16.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%04x\n"= , IfrNumeric->data.u16.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%04x\n"= , IfrNumeric->data.u16.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_4: + DEBUG ((EFI_D_INFO, " MinValue - 0x%08x\n"= , IfrNumeric->data.u32.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%08x\n"= , IfrNumeric->data.u32.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%08x\n"= , IfrNumeric->data.u32.Step)); + break; + case EFI_IFR_NUMERIC_SIZE_8: + DEBUG ((EFI_D_INFO, " MinValue - 0x%016lx\= n", IfrNumeric->data.u64.MinValue)); + DEBUG ((EFI_D_INFO, " MaxValue - 0x%016lx\= n", IfrNumeric->data.u64.MaxValue)); + DEBUG ((EFI_D_INFO, " Step - 0x%016lx\= n", IfrNumeric->data.u64.Step)); + break; + } } break; case EFI_IFR_ORDERED_LIST_OP: IfrOrderedList =3D (EFI_IFR_ORDERED_LIST *) IfrOpCodeHea= der; DEBUG ((EFI_D_INFO, " MaxContainers - 0x%02x\n", If= rOrderedList->MaxContainers)); @@ -277,10 +312,11 @@ DumpHiiPackage ( } break; } =20 if (IfrOpCodeHeader->OpCode =3D=3D EFI_IFR_END_OP) { + QuestionStoredInBitField =3D FALSE; ASSERT (Scope > 0); Scope--; if (Scope =3D=3D 0) { break; } @@ -496,11 +532,11 @@ MergeHiiQuestion ( if (FromFv) { InternalVarCheckFreePool (HiiQuestion); return; } =20 - HiiQuestion1 =3D HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffse= t]; + HiiQuestion1 =3D=20 + HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffsetBitLevel]; HiiQuestion2 =3D HiiQuestion; =20 ASSERT ((HiiQuestion1->OpCode =3D=3D HiiQuestion2->OpCode) && (HiiQuesti= on1->StorageWidth =3D=3D HiiQuestion2->StorageWidth)); =20 switch (HiiQuestion1->OpCode) { @@ -578,11 +614,11 @@ MergeHiiQuestion ( Ptr +=3D HiiQuestion1->StorageWidth; } Ptr2 +=3D HiiQuestion2->StorageWidth; } =20 - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] =3D New= HiiQuestion; + =20 + HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffsetBitLevel] =3D=20 + NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; =20 case EFI_IFR_CHECKBOX_OP: @@ -703,11 +739,11 @@ MergeHiiQuestion ( Ptr +=3D HiiQuestion1->StorageWidth; } Ptr2 +=3D HiiQuestion2->StorageWidth; } =20 - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] =3D New= HiiQuestion; + =20 + HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffsetBitLevel] =3D=20 + NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; =20 default: @@ -829,103 +865,167 @@ GetOneOfOption ( =20 /** Parse Hii Question Oneof. =20 @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the Oneof is stored in bit field S= torage. =20 return Pointer to Hii Question. =20 **/ 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; VAR_CHECK_HII_QUESTION_ONEOF *OneOf; UINTN Length; UINT8 Width; UINTN OptionCount; UINT8 OptionWidth; + UINT8 BitWidth; + UINT8 TotalBits; =20 IfrOneOf =3D (EFI_IFR_ONE_OF *) IfrOpCodeHeader; + BitWidth =3D 0; =20 - Width =3D (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 =3D IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width =3D sizeof (UINT32); + } else { + Width =3D (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); } =20 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL); ASSERT (Width =3D=3D OptionWidth); =20 Length =3D sizeof (*OneOf) + OptionCount * Width; =20 OneOf =3D InternalVarCheckAllocateZeroPool (Length); ASSERT (OneOf !=3D NULL); OneOf->OpCode =3D EFI_IFR_ONE_OF_OP; OneOf->Length =3D (UINT8) Length; - OneOf->VarOffset =3D IfrOneOf->Question.VarStoreInfo.VarOffset; - OneOf->StorageWidth =3D Width; + OneOf->BitFieldStore =3D StoredInBitField; if (StoredInBitField) { + OneOf->VarOffsetBitLevel =3D IfrOneOf->Question.VarStoreInfo.VarOff= set; + OneOf->VarOffset =3D OneOf->VarOffsetBitLevel / 8; + OneOf->StorageWidthBitLevel =3D BitWidth; + TotalBits =3D OneOf->VarOffsetBitLevel % 8 + BitWidt= h; + OneOf->StorageWidth =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / = 8: TotalBits / 8 + 1); + } else { + OneOf->VarOffset =3D IfrOneOf->Question.VarStoreInfo.VarOff= set; + OneOf->VarOffsetBitLevel =3D OneOf->VarOffset * 8; + OneOf->StorageWidth =3D Width; + OneOf->StorageWidthBitLevel =3D Width * 8; } =20 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1); =20 return (VAR_CHECK_HII_QUESTION_HEADER *) OneOf; } =20 /** Parse Hii Question CheckBox. =20 @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the Checkbox is stored in bit fiel= d Storage. =20 return Pointer to Hii Question. =20 **/ 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; VAR_CHECK_HII_QUESTION_CHECKBOX *CheckBox; + UINT8 TotalBits; =20 IfrCheckBox =3D (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; =20 CheckBox =3D InternalVarCheckAllocateZeroPool (sizeof (*CheckBox)); ASSERT (CheckBox !=3D NULL); CheckBox->OpCode =3D EFI_IFR_CHECKBOX_OP; - CheckBox->Length =3D (UINT8) sizeof (*CheckBox);; - CheckBox->VarOffset =3D IfrCheckBox->Question.VarStoreInfo.VarOffset; - CheckBox->StorageWidth =3D (UINT8) sizeof (BOOLEAN); + CheckBox->Length =3D (UINT8) sizeof (*CheckBox); + CheckBox->BitFieldStore =3D StoredInBitField; if (StoredInBitField) { + CheckBox->VarOffsetBitLevel =3D IfrCheckBox->Question.VarStoreInfo.= VarOffset; + CheckBox->VarOffset =3D CheckBox->VarOffsetBitLevel / 8; + CheckBox->StorageWidthBitLevel =3D 1; + TotalBits =3D CheckBox->VarOffsetBitLevel % 8 + 1= ; + CheckBox->StorageWidth =3D (TotalBits % 8 =3D=3D 0 ? TotalBits= / 8: TotalBits / 8 + 1); + } else { + CheckBox->VarOffset =3D IfrCheckBox->Question.VarStoreInfo.= VarOffset; + CheckBox->VarOffsetBitLevel =3D CheckBox->VarOffset * 8; + CheckBox->StorageWidth =3D (UINT8) sizeof (BOOLEAN); + CheckBox->StorageWidthBitLevel =3D CheckBox->StorageWidth * 8; } =20 return (VAR_CHECK_HII_QUESTION_HEADER *) CheckBox; } =20 /** Parse Hii Question Numeric. =20 @param[in] IfrOpCodeHeader Pointer to Ifr OpCode header. + @param[in] StoredInBitField Whether the numeric is stored in bit field= Storage. =20 return Pointer to Hii Question. =20 **/ 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; + UINT8 TotalBits; =20 IfrNumeric =3D (EFI_IFR_NUMERIC *) IfrOpCodeHeader; + BitWidth =3D 0; =20 Numeric =3D InternalVarCheckAllocateZeroPool (sizeof (VAR_CHECK_HII_QUES= TION_NUMERIC) + 2 * sizeof (UINT64)); ASSERT (Numeric !=3D NULL); =20 - Width =3D (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); + if (StoredInBitField) { + // + // When numeric stored in bit field, the bit field width is saved in t= he lower six bits of the flag. + // And the Minimum Maximum of numeric is saved as UINT32 type. + // + BitWidth =3D IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; + Width =3D sizeof (UINT32); + } else { + Width =3D (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); = =20 + } =20 Numeric->OpCode =3D EFI_IFR_NUMERIC_OP; Numeric->Length =3D (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERI= C) + 2 * Width); - Numeric->VarOffset =3D IfrNumeric->Question.VarStoreInfo.VarOffset; - Numeric->StorageWidth =3D Width; + Numeric->BitFieldStore =3D StoredInBitField; if (StoredInBitField) { + Numeric->VarOffsetBitLevel =3D IfrNumeric->Question.VarStoreInfo.Va= rOffset; + Numeric->VarOffset =3D Numeric->VarOffsetBitLevel / 8; + Numeric->StorageWidthBitLevel =3D BitWidth; + TotalBits =3D Numeric->VarOffsetBitLevel % 8 + Bit= Width; + Numeric->StorageWidth =3D (TotalBits % 8 =3D=3D 0 ? TotalBits = / 8: TotalBits / 8 + 1); + } else { + Numeric->VarOffset =3D IfrNumeric->Question.VarStoreInfo.Va= rOffset; + Numeric->VarOffsetBitLevel =3D Numeric->VarOffset * 8; + Numeric->StorageWidth =3D Width; + Numeric->StorageWidthBitLevel =3D Width * 8; } =20 CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2); =20 return (VAR_CHECK_HII_QUESTION_HEADER *) Numeric; } @@ -955,15 +1055,18= @@ ParseHiiQuestionOrderedList ( =20 Length =3D sizeof (*OrderedList) + OptionCount * OptionWidth; =20 OrderedList =3D InternalVarCheckAllocateZeroPool (Length); ASSERT (OrderedList !=3D NULL); - OrderedList->OpCode =3D EFI_IFR_ORDERED_LIST_OP; - OrderedList->Length =3D (UINT8) Length; - OrderedList->VarOffset =3D IfrOrderedList->Question.VarStoreInfo.Var= Offset; - OrderedList->StorageWidth =3D OptionWidth; - OrderedList->MaxContainers =3D IfrOrderedList->MaxContainers; + OrderedList->BitFieldStore =3D FALSE; + OrderedList->OpCode =3D EFI_IFR_ORDERED_LIST_OP; + OrderedList->Length =3D (UINT8) Length; + OrderedList->VarOffset =3D IfrOrderedList->Question.VarStoreI= nfo.VarOffset; + OrderedList->StorageWidth =3D OptionWidth; + OrderedList->MaxContainers =3D IfrOrderedList->MaxContainers; + OrderedList->VarOffsetBitLevel =3D IfrOrderedList->Question.VarStoreI= nfo.VarOffset * 8; + OrderedList->StorageWidthBitLevel =3D OptionWidth * 8; =20 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList= + 1); =20 return (VAR_CHECK_HII_QUESTION_HEADER *) OrderedList; } @@ -972,32 +107= 5,37 @@ ParseHiiQuestionOrderedList ( Parse and create Hii Question node. =20 @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 fiel= d Storage. =20 **/ 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; =20 + // + // Currently only Oneof, Checkbox and numeric can be stored in bit field= . + // switch (IfrOpCodeHeader->OpCode) { case EFI_IFR_ONE_OF_OP: - HiiQuestion =3D ParseHiiQuestionOneOf (IfrOpCodeHeader); + HiiQuestion =3D ParseHiiQuestionOneOf (IfrOpCodeHeader,=20 + StoredInBitField); break; =20 case EFI_IFR_CHECKBOX_OP: - HiiQuestion =3D ParseHiiQuestionCheckBox (IfrOpCodeHeader); + HiiQuestion =3D ParseHiiQuestionCheckBox (IfrOpCodeHeader,=20 + StoredInBitField); break; =20 case EFI_IFR_NUMERIC_OP: - HiiQuestion =3D ParseHiiQuestionNumeric (IfrOpCodeHeader); + HiiQuestion =3D ParseHiiQuestionNumeric (IfrOpCodeHeader,=20 + StoredInBitField); break; =20 case EFI_IFR_ORDERED_LIST_OP: HiiQuestion =3D ParseHiiQuestionOrderedList (IfrOpCodeHeader); break; @@ -1006,14 +1114,14 @@ ParseHiiQuestion ( ASSERT (FALSE); return; break; } =20 - if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] !=3D NULL)= { + if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffsetBitLevel]=20 + !=3D NULL) { MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv); } else { - HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] =3D HiiQuest= ion; + HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffsetBitLevel] =3D= =20 + HiiQuestion; } } =20 /** Find Hii variable node by name and GUID. @@ -1164,11 +1272,11 @@ CreateHiiVariableNode ( HiiVariableNode->HiiVariable =3D HiiVariable; // // The variable store identifier, which is unique within the current f= orm set. // HiiVariableNode->VarStoreId =3D IfrEfiVarStore->VarStoreId; - HiiVariableNode->HiiQuestionArray =3D InternalVarCheckAllocateZeroPool= (IfrEfiVarStore->Size * sizeof (VAR_CHECK_HII_QUESTION_HEADER *)); + HiiVariableNode->HiiQuestionArray =3D=20 + InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * 8 * sizeof=20 + (VAR_CHECK_HII_QUESTION_HEADER *)); =20 InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link); } else { HiiVariableNode->VarStoreId =3D IfrEfiVarStore->VarStoreId; } @@ -1237,24 +1345,37 @@ VarCheckParseHiiPackage ( ) { EFI_HII_PACKAGE_HEADER *HiiPackageHeader; EFI_IFR_OP_HEADER *IfrOpCodeHeader; VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode; + BOOLEAN QuestionStoredInBitField; =20 // // Parse and create Hii Variable node list for this Hii Package. // ParseHiiVariable (HiiPackage); =20 HiiPackageHeader =3D (EFI_HII_PACKAGE_HEADER *) HiiPackage; =20 + QuestionStoredInBitField =3D FALSE; + switch (HiiPackageHeader->Type) { case EFI_HII_PACKAGE_FORMS: IfrOpCodeHeader =3D (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1); =20 while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPacka= geHeader->Length) { switch (IfrOpCodeHeader->OpCode) { + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof = (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { + QuestionStoredInBitField =3D TRUE; + } + break; + + case EFI_IFR_END_OP: + QuestionStoredInBitField =3D FALSE; + break; + case EFI_IFR_ONE_OF_OP: case EFI_IFR_CHECKBOX_OP: case EFI_IFR_NUMERIC_OP: case EFI_IFR_ORDERED_LIST_OP: HiiVariableNode =3D FindHiiVariableNodeByVarStoreId (((EFI_IFR= _ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId); @@ -1268,11 +1389,11 @@ VarCheckParseHiiPackage ( // } else { // // Normal IFR // - ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv); + ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader,=20 + FromFv, QuestionStoredInBitField); } default: break; } IfrOpCodeHeader =3D (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader= + IfrOpCodeHeader->Length); @@ -1339,11 +1460,11 @@ DestroyHiiVariableNode= ( RemoveEntryList (&HiiVariableNode->Link); =20 // // Free the allocated buffer. // - for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size; Index++)= { + for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size *=20 + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]= ); } } InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray); @@ -1387,11 +1508,11 @@ BuildVarCheckHiiBin ( BinSize =3D (UINT32) HEADER_ALIGN (BinSize); =20 HiiVariableNode =3D VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink)= ; HiiVariableLength =3D HiiVariableNode->HiiVariable->HeaderLength; =20 - for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size; Index++)= { + for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size *=20 + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { // // For Hii Question header align. // HiiVariableLength =3D (UINT32) HEADER_ALIGN (HiiVariableLength); @= @ -1432,11 +1553,11 @@ BuildVarCheckHiiBin ( =20 HiiVariableNode =3D VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink)= ; CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariab= le->HeaderLength); Ptr +=3D HiiVariableNode->HiiVariable->HeaderLength; =20 - for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size; Index++)= { + for (Index =3D 0; Index < HiiVariableNode->HiiVariable->Size *=20 + (UINTN) 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { // // For Hii Question header align. // Ptr =3D (UINT8 *) HEADER_ALIGN (Ptr); diff --git a/MdeModulePkg/Li= brary/VarCheckHiiLib/VarCheckHiiLib.inf b/MdeModulePkg/Library/VarCheckHiiL= ib/VarCheckHiiLib.inf index 98e6983..aeca3ef 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf @@ -1,9 +1,9 @@ ## @file # NULL class library to register var check HII handler. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2017, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials # are licensed and made a= vailable under the terms and conditions # of the BSD License which accomp= anies this distribution. The # full text of the license may be found at = @@ -44,10 +44,13 @@ UefiBootServicesTableLib MemoryAllocationLib PcdLib VarCheckLib =20 +[Guids] + gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID + [Protocols] gEfiFirmwareVolume2ProtocolGuid ## SOMETIMES_CONSUMES gEfiFirmwareVolumeBlock2ProtocolGuid ## SOMETIMES_CONSUMES gEfiHiiDatabaseProtocolGuid ## SOMETIMES_CONSUMES =20 diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c = b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 93ff934..1f96712 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -91,32 +91,53 @@ VarCheckHiiQuestion ( UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; + UINTN StartBit; + UINTN EndBit; =20 if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > Data= Size) { DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + St= orageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->S= torageWidth, DataSize)); return FALSE; } =20 OneData =3D 0; CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion-= >StorageWidth); + if (HiiQuestion->BitFieldStore) { + // + // Get the value form the bit field. + // + StartBit =3D HiiQuestion->VarOffsetBitLevel % 8; + EndBit =3D StartBit + HiiQuestion->StorageWidthBitLevel - 1; + OneData =3D BitFieldRead64 (OneData, StartBit, EndBit); } =20 switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr =3D (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1)= ; while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) { OneValue =3D 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 =3D=3D OneValue) { // // Match // break; } - Ptr +=3D HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + Ptr +=3D sizeof (UINT32); + } else { + Ptr +=3D HiiQuestion->StorageWidth; + } } if ((UINTN) Ptr >=3D ((UINTN) HiiQuestion + HiiQuestion->Length)) { // // No match // @@ -136,14 +157,24 @@ VarCheckHiiQuestion ( =20 case EFI_IFR_NUMERIC_OP: Minimum =3D 0; Maximum =3D 0; Ptr =3D (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + = 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr +=3D HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr +=3D HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum a= re saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr +=3D sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr +=3D sizeof (UINT32); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D HiiQuestion->StorageWidth; + } =20 // // No need to check Step, because it is ONLY for UI. // if ((OneData < Minimum) || (OneData > Maximum)) { @@ -341,22 +372,41= @@ DumpHiiQuestion ( UINT64 Minimum; UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; =20 + if (HiiQuestion->BitFieldStore) { + DEBUG ((EFI_D_INFO, "----DumpHiiQuestion-The Question is stored in=20 + bit field----\n")); } else { + DEBUG ((EFI_D_INFO, "----DumpHiiQuestion-The Question is stored in=20 + byte field----\n")); } + DEBUG ((EFI_D_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); DEBUG ((EFI_D_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->Op= Code, HiiOpCodeToStr (HiiQuestion->OpCode))); DEBUG ((EFI_D_INFO, " Length - 0x%02x\n", HiiQuestion->Length)= ); - DEBUG ((EFI_D_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffs= et)); - DEBUG ((EFI_D_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->Storage= Width)); + + if (HiiQuestion->BitFieldStore) { + DEBUG ((EFI_D_INFO, " Bit VarOffset(Bit level) - 0x%04x\n", HiiQu= estion->VarOffsetBitLevel)); + DEBUG ((EFI_D_INFO, " Bit StorageWidth(Bit level) - 0x%02x\n",=20 + HiiQuestion->StorageWidthBitLevel)); + } else { + DEBUG ((EFI_D_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOf= fset)); + DEBUG ((EFI_D_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->Stora= geWidth)); + } =20 switch (HiiQuestion->OpCode) { case EFI_IFR_ONE_OF_OP: Ptr =3D (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1)= ; while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) { OneValue =3D 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); + } switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): DEBUG ((EFI_D_INFO, " OneOfOption - 0x%02x\n", OneValue))= ; break; case sizeof (UINT16): @@ -370,25 +420,39 @@ DumpHiiQuestion ( break; default: ASSERT (FALSE); break; } - Ptr +=3D HiiQuestion->StorageWidth; + if (HiiQuestion->BitFieldStore) { + Ptr +=3D sizeof (UINT32); + } else { + Ptr +=3D HiiQuestion->StorageWidth; + } } break; =20 case EFI_IFR_CHECKBOX_OP: break; =20 case EFI_IFR_NUMERIC_OP: Minimum =3D 0; Maximum =3D 0; Ptr =3D (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + = 1); - CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); - Ptr +=3D HiiQuestion->StorageWidth; - CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); - Ptr +=3D HiiQuestion->StorageWidth; + if(HiiQuestion->BitFieldStore) { + // + // For Numeric stored in bit field, the value of Maximum/Minimum a= re saved as UINT32 type. + // + CopyMem (&Minimum, Ptr, sizeof (UINT32)); + Ptr +=3D sizeof (UINT32); + CopyMem (&Maximum, Ptr, sizeof (UINT32)); + Ptr +=3D sizeof (UINT32); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D HiiQuestion->StorageWidth; + } =20 switch (HiiQuestion->StorageWidth) { case sizeof (UINT8): DEBUG ((EFI_D_INFO, " Minimum - 0x%02x\n", Minimum)); DEBUG ((EFI_D_INFO, " Maximum - 0x%02x\n", Maximum)); -- 1.9.5.msysgit.1