From nobody Wed Dec 25 01:26:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1509954446215835.8362504779941; Sun, 5 Nov 2017 23:47:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E665120355601; Sun, 5 Nov 2017 23:43:22 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 1183E203555FE for ; Sun, 5 Nov 2017 23:43:19 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2017 23:47:17 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga004.jf.intel.com with ESMTP; 05 Nov 2017 23:47:16 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,351,1505804400"; d="scan'208";a="146371344" From: Dandan Bi To: edk2-devel@lists.01.org Date: Mon, 6 Nov 2017 15:47:02 +0800 Message-Id: <1509954422-39164-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [PATCH v3] 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: , Cc: Liming Gao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Star Zeng --- .../VarCheckHiiLib/InternalVarCheckStructure.h | 9 +- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 248 +++++++++++++++--= ---- .../Library/VarCheckHiiLib/VarCheckHiiLib.inf | 5 +- .../VarCheckHiiLib/VarCheckHiiLibNullClass.c | 174 ++++++++++----- 5 files changed, 310 insertions(+), 130 deletions(-) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.= h b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h index a9faed4..8878e4a 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 available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php =20 @@ -21,11 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #define HEADER_ALIGNMENT 4 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) &= (~(HEADER_ALIGNMENT - 1))) =20 #pragma pack (1) =20 -#define VAR_CHECK_HII_REVISION 0x0001 +#define VAR_CHECK_HII_REVISION 0x0002 =20 typedef struct { UINT16 Revision; UINT16 HeaderLength; UINT32 Length; // Length include this header @@ -40,41 +40,46 @@ typedef struct { typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, ot= herwise in byte level. } VAR_CHECK_HII_QUESTION_HEADER; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, ot= herwise in byte level. //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; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, ot= herwise in byte level. } VAR_CHECK_HII_QUESTION_CHECKBOX; =20 typedef struct { UINT8 OpCode; UINT8 Length; // Length include this header UINT16 VarOffset; UINT8 StorageWidth; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, ot= herwise in byte level. //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; + BOOLEAN BitFieldStore; // Whether the Question is stored in bi= t field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, ot= herwise in byte level. 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 available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.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 a334a6f..9611ba0 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 available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.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 ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPac= kageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type))); DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageH= eader->Length)); =20 switch (HiiPackageHeader->Type) { @@ -155,83 +157,107 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVar= Store->Attributes)); DEBUG ((DEBUG_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: - 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 - 0x02%x\n", = IfrOpCodeHeader->Length)); DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x02%x\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", ((EF= I_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset, (Questio= nStoredInBitField? "bit level": "byte level"))); { 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 ((DEBUG_INFO, " Flags - 0x%02x\n", If= rOneOf->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: IfrCheckBox =3D (EFI_IFR_CHECKBOX *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", If= rCheckBox->Flags)); break; case EFI_IFR_NUMERIC_OP: IfrNumeric =3D (EFI_IFR_NUMERIC *) IfrOpCodeHeader; DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", If= rNumeric->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,MaxVa= lue 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: IfrOrderedList =3D (EFI_IFR_ORDERED_LIST *) IfrOpCodeHea= der; DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", If= rOrderedList->MaxContainers)); @@ -277,10 +303,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; } @@ -486,28 +513,35 @@ MergeHiiQuestion ( UINT64 Maximum2; UINT64 OneValue2; UINT8 *Ptr; UINT8 *Ptr1; UINT8 *Ptr2; + UINT16 ArrayIndex; =20 // // Hii Question from Hii Database has high priority. // Do not to merge Hii Question from Fv to Hii Question from Hii Databas= e. // if (FromFv) { InternalVarCheckFreePool (HiiQuestion); return; } =20 - HiiQuestion1 =3D HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffse= t]; + if (HiiQuestion->BitFieldStore) { + ArrayIndex =3D HiiQuestion->VarOffset; + } else { + ArrayIndex =3D HiiQuestion->VarOffset * 8; + } + + HiiQuestion1 =3D HiiVariableNode->HiiQuestionArray[ArrayIndex]; HiiQuestion2 =3D HiiQuestion; =20 ASSERT ((HiiQuestion1->OpCode =3D=3D HiiQuestion2->OpCode) && (HiiQuesti= on1->StorageWidth =3D=3D HiiQuestion2->StorageWidth)); =20 switch (HiiQuestion1->OpCode) { case EFI_IFR_ONE_OF_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = =3D 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = =3D 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? = "bit level": "byte level"))); // // Get the length of Hii Question 1. // NewLength =3D HiiQuestion1->Length; =20 @@ -578,21 +612,21 @@ MergeHiiQuestion ( Ptr +=3D HiiQuestion1->StorageWidth; } Ptr2 +=3D HiiQuestion2->StorageWidth; } =20 - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] =3D New= HiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] =3D NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; =20 case EFI_IFR_CHECKBOX_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffse= t =3D 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffse= t =3D 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore= ? "bit level": "byte level"))); break; =20 case EFI_IFR_NUMERIC_OP: - DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset= =3D 0x%04x\n", HiiQuestion1->VarOffset)); + DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset= =3D 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore?= "bit level": "byte level"))); // // Get minimum and maximum of Hii Question 1. // Minimum1 =3D 0; Maximum1 =3D 0; @@ -703,11 +737,11 @@ MergeHiiQuestion ( Ptr +=3D HiiQuestion1->StorageWidth; } Ptr2 +=3D HiiQuestion2->StorageWidth; } =20 - HiiVariableNode->HiiQuestionArray[HiiQuestion1->VarOffset] =3D New= HiiQuestion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] =3D NewHiiQuestion; InternalVarCheckFreePool (HiiQuestion1); } break; =20 default: @@ -829,103 +863,146 @@ 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; =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->OpCode =3D EFI_IFR_ONE_OF_OP; + OneOf->Length =3D (UINT8) Length; + OneOf->VarOffset =3D IfrOneOf->Question.VarStoreInfo.VarOffset; + OneOf->BitFieldStore =3D StoredInBitField; + if (StoredInBitField) { + OneOf->StorageWidth =3D BitWidth; + } else { + OneOf->StorageWidth =3D Width; + } =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; =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->OpCode =3D EFI_IFR_CHECKBOX_OP; + CheckBox->Length =3D (UINT8) sizeof (*CheckBox);; + CheckBox->VarOffset =3D IfrCheckBox->Question.VarStoreInfo.VarOffse= t; + CheckBox->BitFieldStore =3D StoredInBitField; + if (StoredInBitField) { + CheckBox->StorageWidth =3D 1; + } else { + CheckBox->StorageWidth =3D (UINT8) sizeof (BOOLEAN); + } =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; =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 - 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->OpCode =3D EFI_IFR_NUMERIC_OP; + Numeric->Length =3D (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUME= RIC) + 2 * Width); + Numeric->VarOffset =3D IfrNumeric->Question.VarStoreInfo.VarOffset; + Numeric->BitFieldStore =3D StoredInBitField; + if (StoredInBitField) { + Numeric->StorageWidth =3D BitWidth; + } else { + Numeric->StorageWidth =3D Width; + } =20 CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2); =20 return (VAR_CHECK_HII_QUESTION_HEADER *) Numeric; } @@ -960,10 +1037,11 @@ ParseHiiQuestionOrderedList ( 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; =20 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList= + 1); =20 return (VAR_CHECK_HII_QUESTION_HEADER *) OrderedList; } @@ -972,32 +1050,38 @@ 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; + UINT16 ArrayIndex; =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, StoredInBitF= ield); break; =20 case EFI_IFR_CHECKBOX_OP: - HiiQuestion =3D ParseHiiQuestionCheckBox (IfrOpCodeHeader); + HiiQuestion =3D ParseHiiQuestionCheckBox (IfrOpCodeHeader, StoredInB= itField); break; =20 case EFI_IFR_NUMERIC_OP: - HiiQuestion =3D ParseHiiQuestionNumeric (IfrOpCodeHeader); + HiiQuestion =3D ParseHiiQuestionNumeric (IfrOpCodeHeader, StoredInBi= tField); break; =20 case EFI_IFR_ORDERED_LIST_OP: HiiQuestion =3D ParseHiiQuestionOrderedList (IfrOpCodeHeader); break; @@ -1006,14 +1090,19 @@ ParseHiiQuestion ( ASSERT (FALSE); return; break; } =20 - if (HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] !=3D NULL)= { + if (StoredInBitField) { + ArrayIndex =3D HiiQuestion->VarOffset; + } else { + ArrayIndex =3D HiiQuestion->VarOffset * 8; + } + if (HiiVariableNode->HiiQuestionArray[ArrayIndex] !=3D NULL) { MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv); } else { - HiiVariableNode->HiiQuestionArray[HiiQuestion->VarOffset] =3D HiiQuest= ion; + HiiVariableNode->HiiQuestionArray[ArrayIndex] =3D HiiQuestion; } } =20 /** Find Hii variable node by name and GUID. @@ -1164,11 +1253,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 InternalVarCheckAllocateZeroPool= (IfrEfiVarStore->Size * 8 * sizeof (VAR_CHECK_HII_QUESTION_HEADER *)); =20 InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link); } else { HiiVariableNode->VarStoreId =3D IfrEfiVarStore->VarStoreId; } @@ -1237,24 +1326,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 +1370,11 @@ VarCheckParseHiiPackage ( // } else { // // Normal IFR // - ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv); + ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv, = QuestionStoredInBitField); } default: break; } IfrOpCodeHeader =3D (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader= + IfrOpCodeHeader->Length); @@ -1339,11 +1441,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 * (UINTN)= 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]= ); } } InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray); @@ -1387,11 +1489,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 * (UINTN)= 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { // // For Hii Question header align. // HiiVariableLength =3D (UINT32) HEADER_ALIGN (HiiVariableLength); @@ -1432,11 +1534,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 * (UINTN)= 8; Index++) { if (HiiVariableNode->HiiQuestionArray[Index] !=3D NULL) { // // For Hii Question header align. // Ptr =3D (UINT8 *) HEADER_ALIGN (Ptr); diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf b/MdeMo= dulePkg/Library/VarCheckHiiLib/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 reserved.
# # 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 @@ -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 46a93bd..c693ac5 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -91,32 +91,65 @@ VarCheckHiiQuestion ( UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; UINT8 Index; UINT8 MaxContainers; + UINT8 StartBit; + UINT8 EndBit; + UINT8 TotalBits; + UINT16 VarOffsetByteLevel; + UINT8 StorageWidthByteLevel; + + if (HiiQuestion->BitFieldStore) { + VarOffsetByteLevel =3D HiiQuestion->VarOffset / 8; + TotalBits =3D HiiQuestion->VarOffset % 8 + HiiQuestion->St= orageWidth; + StorageWidthByteLevel =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: Tot= alBits / 8 + 1); + } else { + VarOffsetByteLevel =3D HiiQuestion->VarOffset; + StorageWidthByteLevel =3D HiiQuestion->StorageWidth; + } =20 - if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > Data= Size) { - DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + S= torageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->= StorageWidth, DataSize)); + if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) { + DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + S= torageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteL= evel, DataSize)); return FALSE; } =20 OneData =3D 0; - CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset, HiiQuestion-= >StorageWidth); + CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByte= Level); + if (HiiQuestion->BitFieldStore) { + // + // Get the value from the bit field. + // + StartBit =3D HiiQuestion->VarOffset % 8; + EndBit =3D StartBit + HiiQuestion->StorageWidth - 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 +169,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)) { @@ -342,74 +385,99 @@ DumpHiiQuestion ( UINT64 Maximum; UINT64 OneValue; UINT8 *Ptr; =20 DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n")); - DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiQuestion->Op= Code, HiiOpCodeToStr (HiiQuestion->OpCode))); + DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestio= n->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStor= e? "bit level": "byte level"))); DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length)= ); - DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", HiiQuestion->VarOffs= et)); - DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", HiiQuestion->Storage= Width)); + DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->Va= rOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level"))); + DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->St= orageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level"))); =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)); + 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", OneVal= ue)); + break; + default: + ASSERT (FALSE); + break; + } + } + if (HiiQuestion->BitFieldStore) { + Ptr +=3D sizeof (UINT32); + } else { + Ptr +=3D HiiQuestion->StorageWidth; + } + } + break; + + case EFI_IFR_CHECKBOX_OP: + break; + + case EFI_IFR_NUMERIC_OP: + Minimum =3D 0; + Maximum =3D 0; + Ptr =3D (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + = 1); + 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); + + DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); + DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); + } else { + CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D HiiQuestion->StorageWidth; + CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth); + Ptr +=3D 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 +=3D HiiQuestion->StorageWidth; - } - break; - - case EFI_IFR_CHECKBOX_OP: - break; - - 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; - - 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; =20 case EFI_IFR_ORDERED_LIST_OP: DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_= QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers)); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel