From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 1505456672647849.5464041630632; Thu, 14 Sep 2017 23:24:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A14D721E97817; Thu, 14 Sep 2017 23:21:31 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 2C02921E8799E for ; Thu, 14 Sep 2017 23:21:30 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:29 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:27 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617228" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:38 +0800 Message-Id: <1505456623-414328-2-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 1/6] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore 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: Eric Dong , Liming Gao 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" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 Enhance VfrCompiler to parse following case: 1. EFI/Buffer VarStore can contain bit fields in their structure. 2. For question Oneof/Checkbox/numeric, their storage can be bit fields of an EFI VarStore/Buffer VarStore. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong for this series. --- BaseTools/Source/C/Include/Common/MdeModuleHii.h | 13 +- BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 +- BaseTools/Source/C/VfrCompile/VfrError.h | 3 +- BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 105 +- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 52 +- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 1238 ++++++++++++++----= ---- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 241 ++++- BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 23 +- 8 files changed, 1188 insertions(+), 490 deletions(-) diff --git a/BaseTools/Source/C/Include/Common/MdeModuleHii.h b/BaseTools/S= ource/C/Include/Common/MdeModuleHii.h index 21c8387..8f4e81b 100644 --- a/BaseTools/Source/C/Include/Common/MdeModuleHii.h +++ b/BaseTools/Source/C/Include/Common/MdeModuleHii.h @@ -1,9 +1,9 @@ /** @file EDK II specific HII relative definition. =20 - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble 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 @@ -210,10 +210,21 @@ typedef struct _EFI_IFR_GUID_VAREQNAME { /// The the Unicode String will be used as a EFI Variable Name. /// UINT16 NameId; } EFI_IFR_GUID_VAREQNAME; =20 +/// +/// EDKII implementation extension flags, used to indaicate the disply sty= le and bit width for bit filed storage. +/// Two high bits for display style and the low six bits for bit width. +/// +#define EFI_IFR_DISPLAY_BIT 0xC0 +#define EFI_IFR_DISPLAY_INT_DEC_BIT 0x00 +#define EFI_IFR_DISPLAY_UINT_DEC_BIT 0x40 +#define EFI_IFR_DISPLAY_UINT_HEX_BIT 0x80 + +#define EFI_IFR_NUMERIC_SIZE_BIT 0x3F + #pragma pack() =20 extern EFI_GUID gEfiIfrTianoGuid; extern EFI_GUID gEfiIfrFrameworkGuid; =20 diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/= C/VfrCompile/VfrError.cpp index 285e175..0f8f7dd 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -1,10 +1,10 @@ /** @file =20 VfrCompiler error handler. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -44,10 +44,11 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] =3D { { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error, the valid value is= in (0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr= " }, { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not suppor= t"}, { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with d= ifferent value"}, { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expressio= n"}, { VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR, ": Varstore name is defined = by more than one varstores, it can't be referred as varstore, only varstore= strucure name could be used."}, + { VFR_RETURN_BIT_WIDTH_ERROR, ": bit width must be <=3D sizeof (type) * = 8 and the max width can not > 32" }, { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" } }; =20 static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] =3D { { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with = different value"}, diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/= VfrCompile/VfrError.h index 4dbc54c..8bae049 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.h +++ b/BaseTools/Source/C/VfrCompile/VfrError.h @@ -1,10 +1,10 @@ /** @file =20 VfrCompiler Error definition =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -42,10 +42,11 @@ typedef enum { VFR_RETURN_ERROR_ARRARY_NUM, VFR_RETURN_DATA_STRING_ERROR, VFR_RETURN_DEFAULT_VALUE_REDEFINED, VFR_RETURN_CONSTANT_ONLY, VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR, + VFR_RETURN_BIT_WIDTH_ERROR, VFR_RETURN_CODEUNDEFINED } EFI_VFR_RETURN_CODE; =20 typedef enum { VFR_WARNING_DEFAULT_VALUE_REDEFINED =3D 0, diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Sourc= e/C/VfrCompile/VfrFormPkg.cpp index 2be0c38..c0a3894 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -1,10 +1,10 @@ /** @file =20 The definition of CFormPkg's member function =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -827,10 +827,13 @@ CFormPkg::DeclarePendingQuestion ( CHAR8 *SName; CHAR8 *NewStr; UINT32 ShrinkSize =3D 0; EFI_VFR_RETURN_CODE ReturnCode; EFI_VFR_VARSTORE_TYPE VarStoreType =3D EFI_VFR_VARSTORE_INVALID; + UINT8 LFlags; + UINT32 MaxValue; + CIfrGuid *GuidObj =3D NULL; =20 // // Declare all questions as Numeric in DisableIf True // // DisableIf @@ -842,18 +845,12 @@ CFormPkg::DeclarePendingQuestion ( CIfrTrue TObj (LineNo); =20 // Declare Numeric qeustion for each undefined question. for (pNode =3D PendingAssignList; pNode !=3D NULL; pNode =3D pNode->mNex= t) { if (pNode->mFlag =3D=3D PENDING) { - CIfrNumeric CNObj; EFI_VARSTORE_INFO Info;=20 EFI_QUESTION_ID QId =3D EFI_QUESTION_ID_INVALID; - - CNObj.SetLineNo (LineNo); - CNObj.SetPrompt (0x0); - CNObj.SetHelp (0x0); - // // Register this question, assume it is normal question, not date or= time question // VarStr =3D pNode->mKey; ReturnCode =3D lCVfrQuestionDB.RegisterQuestion (NULL, VarStr, QId); @@ -886,63 +883,87 @@ CFormPkg::DeclarePendingQuestion ( if (*VarStr =3D=3D '\0' && ArrayIdx !=3D INVALID_ARRAY_INDEX) { ReturnCode =3D lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayI= dx); } else { if (VarStoreType =3D=3D EFI_VFR_VARSTORE_EFI) { ReturnCode =3D lCVfrDataStorage.GetEfiVarStoreInfo (&Info); - } else if (VarStoreType =3D=3D EFI_VFR_VARSTORE_BUFFER) { + } else if (VarStoreType =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStore= Type =3D=3D EFI_VFR_VARSTORE_BUFFER_BITS) { VarStr =3D pNode->mKey; //convert VarStr with store name to VarStr with structure name ReturnCode =3D lCVfrDataStorage.GetBufferVarStoreDataTypeName (I= nfo.mVarStoreId, &SName); if (ReturnCode =3D=3D VFR_RETURN_SUCCESS) { NewStr =3D new CHAR8[strlen (VarStr) + strlen (SName) + 1]; NewStr[0] =3D '\0'; strcpy (NewStr, SName); strcat (NewStr, VarStr + strlen (FName)); - ReturnCode =3D lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, In= fo.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize); + ReturnCode =3D lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, In= fo.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize, Info.mIsBitVar); delete[] NewStr; } } else { ReturnCode =3D VFR_RETURN_UNSUPPORTED; } } if (ReturnCode !=3D VFR_RETURN_SUCCESS) { gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->m= Key); return ReturnCode; } - - CNObj.SetQuestionId (QId); - CNObj.SetVarStoreInfo (&Info); // - // Numeric doesn't support BOOLEAN data type.=20 - // BOOLEAN type has the same data size to UINT8.=20 + // If the storage is bit fields, create Guid opcode to wrap the nume= ric opcode. // - if (Info.mVarType =3D=3D EFI_IFR_TYPE_BOOLEAN) { - Info.mVarType =3D EFI_IFR_TYPE_NUM_SIZE_8; + if (Info.mIsBitVar) { + GuidObj =3D new CIfrGuid(0); + GuidObj->SetGuid (&gEfiIfrBitvarstoreGuid); + GuidObj->SetLineNo(LineNo); } - CNObj.SetFlags (0, Info.mVarType); + + CIfrNumeric CNObj; + CNObj.SetLineNo (LineNo); + CNObj.SetPrompt (0x0); + CNObj.SetHelp (0x0); + CNObj.SetQuestionId (QId); + CNObj.SetVarStoreInfo (&Info); + // - // Use maximum value not to limit the vaild value for the undefined = question. + // Set Min/Max/Step Data and flags for the question with bit fields.= Min/Max/Step Data are saved as UINT32 type for bit question. // - switch (Info.mVarType) { - case EFI_IFR_TYPE_NUM_SIZE_64: - CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0); - ShrinkSize =3D 0; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0); + if (Info.mIsBitVar) { + MaxValue =3D (1 << Info.mVarTotalSize) -1; + CNObj.SetMinMaxStepData ((UINT32) 0, MaxValue, (UINT32) 0); ShrinkSize =3D 12; - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0); - ShrinkSize =3D 18; - break; - case EFI_IFR_TYPE_NUM_SIZE_8: - CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0); - ShrinkSize =3D 21; - break; - default: - break; + LFlags =3D (EFI_IFR_NUMERIC_SIZE_BIT & Info.mVarTotalSize); + CNObj.SetFlagsForBitField (0, LFlags); + } else { + // + // Numeric doesn't support BOOLEAN data type. + // BOOLEAN type has the same data size to UINT8. + // + if (Info.mVarType =3D=3D EFI_IFR_TYPE_BOOLEAN) { + Info.mVarType =3D EFI_IFR_TYPE_NUM_SIZE_8; + } + CNObj.SetFlags (0, Info.mVarType); + // + // Use maximum value not to limit the vaild value for the undefine= d question. + // + switch (Info.mVarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0); + ShrinkSize =3D 0; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0); + ShrinkSize =3D 12; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0); + ShrinkSize =3D 18; + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0); + ShrinkSize =3D 21; + break; + default: + break; + } } CNObj.ShrinkBinSize (ShrinkSize); =20 // // For undefined Efi VarStore type question @@ -954,12 +975,22 @@ CFormPkg::DeclarePendingQuestion ( } =20 // // End for Numeric // - CIfrEnd CEObj;=20 + CIfrEnd CEObj; CEObj.SetLineNo (LineNo); + // + // End for Guided opcode + // + CIfrEnd CEObjGuid; + CEObjGuid.SetLineNo (LineNo); + if (GuidObj !=3D NULL) { + GuidObj->SetScope(1); + delete GuidObj; + GuidObj =3D NULL; + } } } =20 // // End for DisableIf diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/= C/VfrCompile/VfrFormPkg.h index 17ab14c..fec3743 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -1,10 +1,10 @@ /** @file =20 The definition of CFormPkg's member function =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -565,12 +565,16 @@ public: } } mMinMaxStepData->u8.Step =3D Step; } =20 - UINT64 GetMinData (UINT8 VarType) { + UINT64 GetMinData (UINT8 VarType, BOOLEAN IsBitVar) { UINT64 MinValue =3D 0; + if (IsBitVar) { + MinValue =3D mMinMaxStepData->u32.MinValue; + return MinValue; + } switch (VarType) { case EFI_IFR_TYPE_NUM_SIZE_64: MinValue =3D mMinMaxStepData->u64.MinValue; break; case EFI_IFR_TYPE_NUM_SIZE_32: @@ -586,12 +590,16 @@ public: break; } return MinValue; } =20 - UINT64 GetMaxData (UINT8 VarType) { + UINT64 GetMaxData (UINT8 VarType, BOOLEAN IsBitVar) { UINT64 MaxValue =3D 0; + if (IsBitVar) { + MaxValue =3D mMinMaxStepData->u32.MaxValue; + return MaxValue; + } switch (VarType) { case EFI_IFR_TYPE_NUM_SIZE_64: MaxValue =3D mMinMaxStepData->u64.MaxValue; break; case EFI_IFR_TYPE_NUM_SIZE_32: @@ -607,12 +615,16 @@ public: break; } return MaxValue; } =20 - UINT64 GetStepData (UINT8 VarType) { + UINT64 GetStepData (UINT8 VarType, BOOLEAN IsBitVar) { UINT64 MaxValue =3D 0; + if (IsBitVar) { + MaxValue =3D mMinMaxStepData->u32.Step; + return MaxValue; + } switch (VarType) { case EFI_IFR_TYPE_NUM_SIZE_64: MaxValue =3D mMinMaxStepData->u64.Step; break; case EFI_IFR_TYPE_NUM_SIZE_32: @@ -1405,10 +1417,26 @@ public: mNumeric->Flags =3D LFlags; } return VFR_RETURN_SUCCESS; } =20 + EFI_VFR_RETURN_CODE SetFlagsForBitField (IN UINT8 HFlags, IN UINT8 LFlag= s, BOOLEAN DisplaySettingsSpecified =3D FALSE) { + EFI_VFR_RETURN_CODE Ret; + + Ret =3D CIfrQuestionHeader::SetFlags (HFlags); + if (Ret !=3D VFR_RETURN_SUCCESS) { + return Ret; + } + + if (DisplaySettingsSpecified =3D=3D FALSE) { + mNumeric->Flags =3D LFlags | EFI_IFR_DISPLAY_UINT_DEC_BIT; + } else { + mNumeric->Flags =3D LFlags; + } + return VFR_RETURN_SUCCESS; + } + UINT8 GetNumericFlags () { return mNumeric->Flags; } }; =20 @@ -1445,10 +1473,26 @@ public: mOneOf->Flags =3D LFlags | EFI_IFR_DISPLAY_UINT_DEC; } return VFR_RETURN_SUCCESS; } =20 + EFI_VFR_RETURN_CODE SetFlagsForBitField (IN UINT8 HFlags, IN UINT8 LFlag= s) { + EFI_VFR_RETURN_CODE Ret; + + Ret =3D CIfrQuestionHeader::SetFlags (HFlags); + if (Ret !=3D VFR_RETURN_SUCCESS) { + return Ret; + } + + if (LFlags & EFI_IFR_DISPLAY) { + mOneOf->Flags =3D LFlags; + } else { + mOneOf->Flags =3D LFlags | EFI_IFR_DISPLAY_UINT_DEC_BIT; + } + return VFR_RETURN_SUCCESS; + } + VOID ShrinkBinSize (IN UINT16 Size) { // // Update the buffer size which is truly be used later. // ShrinkObjBin(Size); diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C= /VfrCompile/VfrSyntax.g index 24e0538..4647f64 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -361,11 +361,15 @@ vfrDataStructFields [BOOLEAN FieldInUnion]: dataStructFieldBool [FieldInUnion] | dataStructFieldString [FieldInUnion]| dataStructFieldDate [FieldInUnion] | dataStructFieldTime [FieldInUnion] | dataStructFieldRef [FieldInUnion] | - dataStructFieldUser [FieldInUnion] + dataStructFieldUser [FieldInUnion] | + dataStructBitField64 [FieldInUnion] | + dataStructBitField32 [FieldInUnion] | + dataStructBitField16 [FieldInUnion] | + dataStructBitField8 [FieldInUnion] )* ; =20 dataStructField64 [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> @@ -467,10 +471,87 @@ dataStructFieldUser [BOOLEAN FieldInUnion]: OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum, FieldInUnio= n), T); >> ; =20 +dataStructBitField64[BOOLEAN FieldInUnion]: + << + UINT32 Width =3D 0; + BOOLEAN HasBitFieldName =3D FALSE; + >> + D:"UINT64" + { + N:StringIdentifier << HasBitFieldName =3D TRUE;>> + } + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLine(= ));>> + + ";" << if (HasBitFieldName) { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width, FieldInUnion), N); + } else { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (" ", D->getText(), Width, FieldInUnion), D); + } + >> + ; + +dataStructBitField32[BOOLEAN FieldInUnion]: + << + UINT32 Width =3D 0; + BOOLEAN HasBitFieldName =3D FALSE; + >> + D:"UINT32" + { + N:StringIdentifier << HasBitFieldName =3D TRUE;>> + } + + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLine(= ));>> + + ";" << if (HasBitFieldName) { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width, FieldInUnion), N); + } else { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (" ", D->getText(), Width, FieldInUnion), D); + } + >> + ; + +dataStructBitField16[BOOLEAN FieldInUnion]: + << + UINT32 Width =3D 0; + BOOLEAN HasBitFieldName =3D FALSE; + >> + D:"UINT16" + { + N:StringIdentifier << HasBitFieldName =3D TRUE;>> + } + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLine(= ));>> + + ";" << if (HasBitFieldName) { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width, FieldInUnion), N); + } else { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (" ", D->getText(), Width, FieldInUnion), D); + } + >> + ; + +dataStructBitField8[BOOLEAN FieldInUnion]: + << + UINT32 Width =3D 0; + BOOLEAN HasBitFieldName =3D FALSE; + >> + D:"UINT8" + { + N:StringIdentifier << HasBitFieldName =3D TRUE;>> + } + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLine(= ));>> + + ";" << if (HasBitFieldName) { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width, FieldInUnion), N); + } else { + _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (" ", D->getText(), Width, FieldInUnion), D); + } + >> + ; + //************************************************************************= ***** // // the syntax of GUID definition // guidSubDefinition [EFI_GUID &Guid] : @@ -749,10 +830,15 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 = *TypeName, UINT32 TypeSize, UINT8 Data_U8 =3D 0; BOOLEAN Data_BL =3D 0; EFI_STRING_ID Data_SID =3D 0; BOOLEAN IsArray =3D FALSE; UINT8 *ByteOffset =3D NULL; + BOOLEAN BitField =3D FALSE; + UINT64 Value; + UINT64 Mask; + UINT16 Offset; + UINT8 PreBits; >> ( ("," "data" {OpenBracket IDX1:Number CloseBracket <>} << ArrayIdx =3D 0; @@ -805,27 +891,73 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 = *TypeName, UINT32 TypeSize, }else if (strcmp ("EFI_STRING_ID", TypeName) =3D=3D 0) { Data_SID =3D _STOSID(RD->getText(), RD->getLine()); memcpy (ByteOffset, &Data_SID, TypeSize); = =20 } } else { - gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, Fie= ldType, FieldSize); + gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, Fie= ldType, FieldSize, BitField); + if (BitField) { + Mask =3D (1 << FieldSize) - 1; + Offset =3D FieldOffset / 8; + PreBits =3D FieldOffset % 8; + Mask <<=3D PreBits; + } switch (FieldType) { case EFI_IFR_TYPE_NUM_SIZE_8: Data_U8 =3D _STOU8(RD->getText(), RD->getLine()); - memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize); + if (BitField) { + // + // Set the value to the bit fileds. + // + Value =3D *(UINT8*) (ByteOffset + Offset); + Data_U8 <<=3D PreBits; + Value =3D (Value & (~Mask)) | Data_U8; + memcpy (ByteOffset + Offset, &Value, sizeof (UINT8)); + } else { + memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize); + } break; case EFI_IFR_TYPE_NUM_SIZE_16: Data_U16 =3D _STOU16(RD->getText(), RD->getLine()); - memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize); + if (BitField) { + // + // Set the value to the bit fileds. + // + Value =3D *(UINT16*) (ByteOffset + Offset); + Data_U16 <<=3D PreBits; + Value =3D (Value & (~Mask)) | Data_U16; + memcpy (ByteOffset + Offset, &Value, sizeof (UINT16)); + } else { + memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize); + } break; case EFI_IFR_TYPE_NUM_SIZE_32: Data_U32 =3D _STOU32(RD->getText(), RD->getLine()); - memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize); + if (BitField) { + // + // Set the value to the bit fileds. + // + Value =3D *(UINT32*) (ByteOffset + Offset); + Data_U32 <<=3D PreBits; + Value =3D (Value & (~Mask)) | Data_U32; + memcpy (ByteOffset + Offset, &Value, sizeof (UINT32)); + } else { + memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize); + } break; case EFI_IFR_TYPE_NUM_SIZE_64: Data_U64 =3D _STOU64(RD->getText(), RD->getLine()); - memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize); + if (BitField) { + // + // Set the value to the bit fileds. + // + Value =3D *(UINT64*) (ByteOffset + Offset); + Data_U64 <<=3D PreBits; + Value =3D (Value & (~Mask)) | Data_U64; + memcpy (ByteOffset + Offset, &Value, sizeof (UINT64)); + } else { + memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize); + } break; case EFI_IFR_TYPE_BOOLEAN: Data_BL =3D _STOU8(RD->getText(), RD->getLine()); memcpy (ByteOffset + FieldOffset, &Data_BL, FieldSize); break; @@ -872,14 +1004,15 @@ vfrStatementVarStoreLinear : CHAR8 *TypeName; CHAR8 *StoreName; UINT32 LineNum; EFI_VARSTORE_ID VarStoreId =3D EFI_VARSTORE_ID_INVALID; UINT32 Size; + BOOLEAN IsBitVarStore =3D FALSE; >> V:Varstore << VSObj.SetLineNo(V->= getLine()); >> ( - TN:StringIdentifier "," << TypeName =3D TN->ge= tText(); LineNum =3D TN->getLine(); >> + TN:StringIdentifier "," << TypeName =3D TN->ge= tText(); LineNum =3D TN->getLine(); IsBitVarStore =3D gCVfrVarDataTypeDB.Da= taTypeHasBitField (TN->getText());>> | U8:"UINT8" "," << TypeName =3D U8->ge= tText(); LineNum =3D U8->getLine(); >> | U16:"UINT16" "," << TypeName =3D U16->g= etText(); LineNum =3D U16->getLine(); >> | C16:"CHAR16" "," << TypeName =3D (CHAR8= *) "UINT16"; LineNum =3D C16->getLine(); >> | U32:"UINT32" "," << TypeName =3D U32->g= etText(); LineNum =3D U32->getLine(); >> | U64:"UINT64" "," << TypeName =3D U64->g= etText(); LineNum =3D U64->getLine(); >> @@ -910,16 +1043,17 @@ vfrStatementVarStoreLinear : StoreName =3D Typ= eName; } else { StoreName =3D SN-= >getText(); } _PCATCH(gCVfrDataSt= orage.DeclareBufferVarStore ( - = StoreName, - = &Guid, - = &gCVfrVarDataTypeDB, - = TypeName, - = VarStoreId - = ), LineNum); + = StoreName, + = &Guid, + = &gCVfrVarDataTypeDB, + = TypeName, + = VarStoreId, + = IsBitVarStore + = ), LineNum); VSObj.SetGuid (&Gui= d); _PCATCH(gCVfrDataSt= orage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN); VSObj.SetVarStoreId= (VarStoreId); _PCATCH(gCVfrVarDat= aTypeDB.GetDataTypeSize(TypeName, &Size), LineNum); VSObj.SetSize ((UIN= T16) Size); @@ -938,14 +1072,15 @@ vfrStatementVarStoreEfi : UINT32 Size; CHAR8 *TypeName; UINT32 LineNum; CHAR8 *StoreName =3D NULL; BOOLEAN CustomizedName =3D FALSE; + BOOLEAN IsBitVarStore =3D FALSE; >> E:Efivarstore << VSEObj.SetLineNo(E-= >getLine()); >> ( - TN:StringIdentifier "," << TypeName =3D TN->ge= tText(); LineNum =3D TN->getLine(); CustomizedName =3D TRUE; >> + TN:StringIdentifier "," << TypeName =3D TN->ge= tText(); LineNum =3D TN->getLine(); CustomizedName =3D TRUE; IsBitVarStore = =3D gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText());>> | U8:"UINT8" "," << TypeName =3D U8->ge= tText(); LineNum =3D U8->getLine(); >> | U16:"UINT16" "," << TypeName =3D U16->g= etText(); LineNum =3D U16->getLine(); >> | C16:"CHAR16" "," << TypeName =3D (CHAR8= *) "UINT16"; LineNum =3D C16->getLine(); >> | U32:"UINT32" "," << TypeName =3D U32->g= etText(); LineNum =3D U32->getLine(); >> | U64:"UINT64" "," << TypeName =3D U64->g= etText(); LineNum =3D U64->getLine(); >> @@ -1002,30 +1137,32 @@ vfrStatementVarStoreEfi : ) =20 Uuid "=3D" guidDefinition[Guid] <<=20 if (IsUEFI23EfiVars= tore) { _PCATCH(gCVfrDataSt= orage.DeclareBufferVarStore ( - = StoreName, - = &Guid, - = &gCVfrVarDataTypeDB, - = TypeName, - = VarStoreId - = ), LineNum); =20 + = StoreName, + = &Guid, + = &gCVfrVarDataTypeDB, + = TypeName, + = VarStoreId, + = IsBitVarStore + = ), LineNum); _PCATCH(gCVfrData= Storage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN); _PCATCH(gCVfrVarD= ataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum); } else { - _PCATCH(gCVfrDataS= torage.DeclareBufferVarStore ( + _PCATCH(gCVfrDataSt= orage.DeclareBufferVarStore ( = TN->getText(), = &Guid, = &gCVfrVarDataTypeDB, = TypeName, - = VarStoreId - = ), LineNum); =20 + = VarStoreId, + = FALSE + = ), LineNum); _PCATCH(gCVfrData= Storage.GetVarStoreId(TN->getText(), &VarStoreId, &Guid), VN); _PCATCH(gCVfrVarD= ataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine()); } - VSEObj.SetGuid (&Gu= id); =20 + VSEObj.SetGuid (&Gu= id); VSEObj.SetVarStoreI= d (VarStoreId); =20 VSEObj.SetSize ((UI= NT16) Size); VSEObj.SetName (Sto= reName); if (IsUEFI23EfiVars= tore =3D=3D FALSE && StoreName !=3D NULL) { @@ -1139,71 +1276,79 @@ vfrStatementSuppressIfFormSet : vfrStatementHeader[CIfrStatementHeader *SHObj] : Prompt "=3D" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt= (_STOSID(S1->getText(), S1->getLine())); >> Help "=3D" "STRING_TOKEN" "\(" S2:Number "\)" << $SHObj->SetHelp (= _STOSID(S2->getText(), S2->getLine())); >> ; =20 +vfrQuestionBaseInfo[EFI_VARSTORE_INFO & Info, EFI_QUESTION_ID & QId, EFI_Q= UESION_TYPE QType =3D QUESTION_NORMAL]: + << + CHAR8 *QName =3D NULL; + CHAR8 *VarIdStr =3D NULL; + mUsedDefaultCount =3D 0; + >> + { + Name "=3D" QN:StringIdentifier "," << + QName =3D QN->getTex= t(); + _PCATCH(mCVfrQuestio= nDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used = please used anther name"); + >> + } + { V:VarId "=3D" vfrStorageVarId[Info, VarIdStr] "," } + { + QuestionId "=3D" ID:Number "," << + QId =3D _STOQID(ID->= getText(), ID->getLine()); + _PCATCH(mCVfrQuestio= nDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used pl= ease assign another number"); + >> + } + << + switch (QType) { + case QUESTION_NORMAL: + mCVfrQuestionDB.Re= gisterQuestion (QName, VarIdStr, QId); + break; + case QUESTION_DATE: + mCVfrQuestionDB.Re= gisterNewDateQuestion (QName, VarIdStr, QId); + break; + case QUESTION_TIME: + mCVfrQuestionDB.Re= gisterNewTimeQuestion (QName, VarIdStr, QId); + break; + case QUESTION_REF: + // + // VarIdStr !=3D N= ULL stand for question with storagae. + // + if (VarIdStr !=3D = NULL) { + mCVfrQuestionDB.= RegisterRefQuestion (QName, VarIdStr, QId); + } else { + mCVfrQuestionDB.= RegisterQuestion (QName, NULL, QId); + } + break; + default: + _PCATCH(VFR_RETURN_F= ATAL_ERROR); + } + >> + << + if (VarIdStr !=3D NU= LL) { + delete VarIdStr; + } + _SAVE_CURRQEST_VARIN= FO (Info); + >> + ; + vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType =3D Q= UESTION_NORMAL]: << EFI_VARSTORE_INFO Info; Info.mVarType =3D EFI_IFR_TYPE_OTHER; Info.mVarTotalSize =3D 0; Info.mInfo.mVarOffset =3D EFI_VAROFFSET_INVALID; Info.mVarStoreId =3D EFI_VARSTORE_ID_INVALID; + Info.mIsBitVar =3D FALSE; EFI_QUESTION_ID QId =3D EFI_QUESTION_ID_INVALID; - CHAR8 *QName =3D NULL; - CHAR8 *VarIdStr =3D NULL; - mUsedDefaultCount =3D 0; >> - { - Name "=3D" QN:StringIdentifier "," << - QName =3D QN->getTe= xt(); - _PCATCH(mCVfrQuesti= onDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used= please used anther name"); - >> - } - { V:VarId "=3D" vfrStorageVarId[Info, VarIdStr] "," } - { - QuestionId "=3D" ID:Number "," << - QId =3D _STOQID(ID-= >getText(), ID->getLine()); - _PCATCH(mCVfrQuesti= onDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used p= lease assign another number"); - >> - } - << - switch (QType) { - case QUESTION_NORMA= L: - mCVfrQuestionDB.R= egisterQuestion (QName, VarIdStr, QId); - break; - case QUESTION_DATE: - mCVfrQuestionDB.R= egisterNewDateQuestion (QName, VarIdStr, QId); - break; - case QUESTION_TIME: - mCVfrQuestionDB.R= egisterNewTimeQuestion (QName, VarIdStr, QId); - break; - case QUESTION_REF: - // - // VarIdStr !=3D = NULL stand for question with storagae. - // - if (VarIdStr !=3D= NULL) { - mCVfrQuestionDB= .RegisterRefQuestion (QName, VarIdStr, QId); - } else { - mCVfrQuestionDB= .RegisterQuestion (QName, NULL, QId); - } - break; - default: - _PCATCH(VFR_RETURN_= FATAL_ERROR); - } - $QHObj.SetQuestionI= d (QId); - if (VarIdStr !=3D N= ULL) { - $QHObj.SetVarStore= Info (&Info); - } + vfrQuestionBaseInfo[Info, QId, QType] + << $QHObj.SetQuestionI= d (QId); + if (Info.mVarStore= Id !=3D EFI_VARSTORE_ID_INVALID) { + $QHObj.SetVarSto= reInfo (&Info); + } >> vfrStatementHeader[&$QHObj] - <<=20 - if (VarIdStr !=3D N= ULL) { - delete VarIdStr;=20 - } - _SAVE_CURRQEST_VARI= NFO (Info); - >> ; =20 questionheaderFlagsField[UINT8 & Flags] : ReadOnlyFlag << $Flags |=3D 0x01; >> | InteractiveFlag << $Flags |=3D 0x04; >> @@ -1268,10 +1413,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&Q= uestVarIdStr, BOOLEAN CheckFl = SName, = &mFormsetGuid, = &gCVfrVarDataTypeDB, = SName, = EFI_VARSTORE_ID_INVALID, + = FALSE, = FALSE = ); VfrReturnCode = =3D gCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid= ); } if (CheckFlag || Vf= rReturnCode =3D=3D VFR_RETURN_SUCCESS) { @@ -1299,21 +1445,21 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&Q= uestVarIdStr, BOOLEAN CheckFl VfrReturnCode = =3D gCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid= ); } if (CheckFlag || Vf= rReturnCode =3D=3D VFR_RETURN_SUCCESS) { _PCATCH(VfrReturn= Code, SN2); VarStoreType =3D = gCVfrDataStorage.GetVarStoreType ($Info.mVarStoreId); - if (VarStoreType = =3D=3D EFI_VFR_VARSTORE_BUFFER) { + if (VarStoreType = =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStoreType =3D=3D EFI_VFR_VARSTORE_BUFF= ER_BITS) { _PCATCH(gCVfrDa= taStorage.GetBufferVarStoreDataTypeName(Info.mVarStoreId, &TName), SN2); _STRCAT(&VarStr= , TName); } } >> =20 ( "." << if (CheckFlag || Vf= rReturnCode =3D=3D VFR_RETURN_SUCCESS) { - _PCATCH(((VarStor= eType !=3D EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VF= R_RETURN_SUCCESS), SN2); + _PCATCH((((VarSto= reType !=3D EFI_VFR_VARSTORE_BUFFER) && (VarStoreType !=3D EFI_VFR_VARSTORE= _BUFFER_BITS))? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2= ); } _STRCAT(&VarIdStr, = "."); _STRCAT(&VarStr, "."); >> SF:StringIdentifier << _STRCAT(&VarIdStr, = SF->getText()); _STRCAT(&VarStr, SF->getText()); >> { @@ -1338,11 +1484,12 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&Q= uestVarIdStr, BOOLEAN CheckFl switch (VarStoreTyp= e) { case EFI_VFR_VARSTO= RE_EFI: _PCATCH(gCVfrData= Storage.GetEfiVarStoreInfo (&$Info), SN2); break; case EFI_VFR_VARSTO= RE_BUFFER: - _PCATCH(gCVfrVarD= ataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType,= $Info.mVarTotalSize), SN2->getLine(), VarStr); + case EFI_VFR_VARSTO= RE_BUFFER_BITS: + _PCATCH(gCVfrVarD= ataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType,= $Info.mVarTotalSize, $Info.mIsBitVar), SN2->getLine(), VarStr); VarGuid =3D gCVfr= DataStorage.GetVarStoreGuid($Info.mVarStoreId); _PCATCH((EFI_VFR_= RETURN_CODE)gCVfrBufferConfig.Register ( SName, VarGui= d, NULL), @@ -1436,90 +1583,97 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALU= E &Value, BOOLEAN &ListType] >> { "\-" << Negative =3D TRUE; = >> } N1:Number << - switch ($Type) { - case EFI_IFR_TYPE_N= UM_SIZE_8 : - $Value.u8 =3D _ST= OU8(N1->getText(), N1->getLine()); - if (IntDecStyle) { - if (Negative) { - if ($Value.u8= > 0x80) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, = small than -0x80"); - } - } else { - if ($Value.u8= > 0x7F) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F, = small than -0x80"); + // + // The value stored= in bit fields is always set to UINT32 type. + // + if (_GET_CURRQEST_V= ARTINFO().mIsBitVar) { + $Value.u32 =3D _S= TOU32(N1->getText(), N1->getLine()); + } else { + switch ($Type) { + case EFI_IFR_TYPE= _NUM_SIZE_8 : + $Value.u8 =3D _= STOU8(N1->getText(), N1->getLine()); + if (IntDecStyle= ) { + if (Negative)= { + if ($Value.= u8 > 0x80) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F= , small than -0x80"); + } + } else { + if ($Value.= u8 > 0x7F) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT8 type can't big than 0x7F= , small than -0x80"); + } } } - } - if (Negative) { - $Value.u8 =3D ~= $Value.u8 + 1; - } - break; - case EFI_IFR_TYPE_N= UM_SIZE_16 : - $Value.u16 =3D _S= TOU16(N1->getText(), N1->getLine()); - if (IntDecStyle) { if (Negative) { - if ($Value.u1= 6 > 0x8000) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FF= F, small than -0x8000"); - } - } else { - if ($Value.u1= 6 > 0x7FFF) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7FF= F, small than -0x8000"); + $Value.u8 =3D= ~$Value.u8 + 1; + } + break; + case EFI_IFR_TYPE= _NUM_SIZE_16 : + $Value.u16 =3D = _STOU16(N1->getText(), N1->getLine()); + if (IntDecStyle= ) { + if (Negative)= { + if ($Value.= u16 > 0x8000) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7= FFF, small than -0x8000"); + } + } else { + if ($Value.= u16 > 0x7FFF) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT16 type can't big than 0x7= FFF, small than -0x8000"); + } } } - } - if (Negative) { - $Value.u16 =3D = ~$Value.u16 + 1; - } - break; - case EFI_IFR_TYPE_N= UM_SIZE_32 : - $Value.u32 =3D= _STOU32(N1->getText(), N1->getLine()); - if (IntDecStyle) { if (Negative) { - if ($Value.u3= 2 > 0x80000000) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FF= FFFFF, small than -0x80000000"); - } - } else { - if ($Value.u3= 2 > 0X7FFFFFFF) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7FF= FFFFF, small than -0x80000000"); + $Value.u16 = =3D ~$Value.u16 + 1; + } + break; + case EFI_IFR_TYPE= _NUM_SIZE_32 : + $Value.u32 = =3D _STOU32(N1->getText(), N1->getLine()); + if (IntDecStyle= ) { + if (Negative)= { + if ($Value.= u32 > 0x80000000) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7= FFFFFFF, small than -0x80000000"); + } + } else { + if ($Value.= u32 > 0X7FFFFFFF) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT32 type can't big than 0x7= FFFFFFF, small than -0x80000000"); + } } } - } - if (Negative) { - $Value.u32 =3D = ~$Value.u32 + 1; - } - break; - case EFI_IFR_TYPE_N= UM_SIZE_64 : - $Value.u64 =3D= _STOU64(N1->getText(), N1->getLine()); - if (IntDecStyle) { if (Negative) { - if ($Value.u6= 4 > 0x8000000000000000) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FF= FFFFFFFFFFFFF, small than -0x8000000000000000"); - } - } else { - if ($Value.u6= 4 > 0x7FFFFFFFFFFFFFFF) { - _PCATCH (VF= R_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7FF= FFFFFFFFFFFFF, small than -0x8000000000000000"); + $Value.u32 = =3D ~$Value.u32 + 1; + } + break; + case EFI_IFR_TYPE= _NUM_SIZE_64 : + $Value.u64 = =3D _STOU64(N1->getText(), N1->getLine()); + if (IntDecStyle= ) { + if (Negative)= { + if ($Value.= u64 > 0x8000000000000000) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7= FFFFFFFFFFFFFFF, small than -0x8000000000000000"); + } + } else { + if ($Value.= u64 > 0x7FFFFFFFFFFFFFFF) { + _PCATCH (= VFR_RETURN_INVALID_PARAMETER, N1->getLine(), "INT64 type can't big than 0x7= FFFFFFFFFFFFFFF, small than -0x8000000000000000"); + } } } + if (Negative) { + $Value.u64 = =3D ~$Value.u64 + 1; + } + break; + case EFI_IFR_TYPE= _BOOLEAN : + $Value.b = =3D _STOU8(N1->getText(), N1->getLine()); + break; + case EFI_IFR_TYPE= _STRING : + $Value.string = =3D _STOU16(N1->getText(), N1->getLine()); + break; + case EFI_IFR_TYPE= _TIME : + case EFI_IFR_TYPE= _DATE : + case EFI_IFR_TYPE= _REF : + default : + break; } - if (Negative) { - $Value.u64 =3D = ~$Value.u64 + 1; - } - break; - case EFI_IFR_TYPE_B= OOLEAN : - $Value.b =3D= _STOU8(N1->getText(), N1->getLine()); - break; - case EFI_IFR_TYPE_S= TRING : - $Value.string =3D= _STOU16(N1->getText(), N1->getLine()); - break; - case EFI_IFR_TYPE_T= IME : - case EFI_IFR_TYPE_D= ATE : - case EFI_IFR_TYPE_R= EF : - default : - break; } >> | B1:True << $Value.b =3D T= RUE; >> | B2:False << $Value.b =3D F= ALSE; >> | O1:One << $Value.u8 =3D _= STOU8(O1->getText(), O1->getLine()); >> @@ -1689,42 +1843,51 @@ vfrStatementDefault : "=3D" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayTyp= e] "," =20 <<=20 if (gCurrentMinMax= Data !=3D NULL && gCurrentMinMaxData->IsNumericOpcode()) { //check default = value is valid for Numeric Opcode NumericQst =3D (= CIfrNumeric *) gCurrentQuestion; - if ((NumericQst-= >GetNumericFlags() & EFI_IFR_DISPLAY) =3D=3D 0) { + if ((NumericQst-= >GetNumericFlags() & EFI_IFR_DISPLAY) =3D=3D 0 && !(_GET_CURRQEST_VARTINFO(= ).mIsBitVar)) { switch (_GET_C= URRQEST_DATATYPE()) { case EFI_IFR_T= YPE_NUM_SIZE_8: - if (((INT8) = Val->u8 < (INT8) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE())) = ||=20 - ((INT8) = Val->u8 > (INT8) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())))= { + if (((INT8) = Val->u8 < (INT8) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), F= ALSE)) || + ((INT8) = Val->u8 > (INT8) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), F= ALSE))) { _PCATCH (V= FR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be b= etween MinValue and MaxValue."); } break; case EFI_IFR_T= YPE_NUM_SIZE_16: - if (((INT16)= Val->u16 < (INT16) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= )) ||=20 - ((INT16)= Val->u16 > (INT16) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= ))) { + if (((INT16)= Val->u16 < (INT16) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= , FALSE)) || + ((INT16)= Val->u16 > (INT16) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= , FALSE))) { _PCATCH (V= FR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be b= etween MinValue and MaxValue."); } break; case EFI_IFR_T= YPE_NUM_SIZE_32: - if (((INT32)= Val->u32 < (INT32) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= )) ||=20 - ((INT32)= Val->u32 > (INT32) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= ))) { + if (((INT32)= Val->u32 < (INT32) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= , FALSE)) || + ((INT32)= Val->u32 > (INT32) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= , FALSE))) { _PCATCH (V= FR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be b= etween MinValue and MaxValue."); } break; case EFI_IFR_T= YPE_NUM_SIZE_64: - if (((INT64)= Val->u64 < (INT64) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= )) ||=20 - ((INT64)= Val->u64 > (INT64) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= ))) { + if (((INT64)= Val->u64 < (INT64) gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()= , FALSE)) || + ((INT64)= Val->u64 > (INT64) gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE()= , FALSE))) { _PCATCH (V= FR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be b= etween MinValue and MaxValue."); } break; default: break; } } else { - if (Val->u64 <= gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val->u64 > gCu= rrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) { + // + // Value for q= uestion stored in bit fields is always set to UINT32 type. + // + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + if (Val->u32= < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), TRUE) || Val->u= 32 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), TRUE)) { _PCATCH (VFR= _RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be bet= ween MinValue and MaxValue."); + } + } else { + if (Val->u64= < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE(), FALSE) || Val->= u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE(), FALSE)) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be b= etween MinValue and MaxValue."); + } } } } if (_GET_CURRQEST_= DATATYPE() =3D=3D EFI_IFR_TYPE_OTHER) { _PCATCH (VFR_RET= URN_FATAL_ERROR, D->getLine(), "Default data type error."); @@ -1759,21 +1922,29 @@ vfrStatementDefault : =20 default: break; } } else { - _PCATCH (gCVfrVa= rDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size), D->getLine()= ); + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + Size =3D sizeo= f (UINT32); + } else { + _PCATCH (gCVfr= VarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size), D->getLine= ()); + } } Size +=3D OFFSET_O= F (EFI_IFR_DEFAULT, Value); DObj =3D new CIfrD= efault ((UINT8)Size); DObj->SetLineNo(D-= >getLine()); if (ArrayType) { DObj->SetType (E= FI_IFR_TYPE_BUFFER); } else if (gIsStri= ngOp) { DObj->SetType (E= FI_IFR_TYPE_STRING); } else { - DObj->SetType (_= GET_CURRQEST_DATATYPE()); + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + DObj->SetType = (EFI_IFR_TYPE_NUM_SIZE_32); + } else { + DObj->SetType = (_GET_CURRQEST_DATATYPE()); + } } DObj->SetValue(*Va= l); >> | << IsExp =3D TRUE; DOb= j2 =3D new CIfrDefault2; DObj2->SetLineNo(D->getLine()); DObj2->SetScope (1= ); >> vfrStatementValue "," << CIfrEnd EndObj1; En= dObj1.SetLineNo(D->getLine()); >> @@ -2176,39 +2347,72 @@ vfrStatementBooleanType : // default value =3D TRUE, defaultstore =3D MyDefaultStore, // endcheckbox; // vfrStatementCheckBox : << - CIfrCheckBox CBObj; + CIfrCheckBox *CBObj =3D NULL; EFI_IFR_TYPE_VALUE Val =3D gZeroEfiIfrTypeValue; CHAR8 *VarStoreName =3D NULL; UINT32 DataTypeSize; EFI_GUID *VarStoreGuid =3D NULL; + CIfrGuid *GuidObj =3D NULL; + EFI_QUESTION_ID QId =3D EFI_QUESTION_ID_INVALID;; + EFI_VARSTORE_INFO Info; + Info.mVarType =3D EFI_IFR_TYPE_OTHER; + Info.mVarTotalSize =3D 0; + Info.mInfo.mVarOffset =3D EFI_VAROFFSET_INVALID; + Info.mVarStoreId =3D EFI_VARSTORE_ID_INVALID; + Info.mIsBitVar =3D FALSE; >> - L:CheckBox << CBObj.SetLineNo(= L->getLine()); >> - vfrQuestionHeader[CBObj] "," << //check data type + L:CheckBox + vfrQuestionBaseInfo[Info, QId] << + // + // Create a GUID = opcode to wrap the checkbox opcode, if it refer to bit varstore. + // + if (_GET_CURRQEST= _VARTINFO().mIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gEfiIfrBitvarstoreGuid); + GuidObj->SetLin= eNo(L->getLine()); + } + CBObj =3D new CIf= rCheckBox; + CBObj->SetLineNo(= L->getLine()); + CBObj->SetQuestio= nId (QId); + CBObj->SetVarStor= eInfo (&Info); + >> + vfrStatementHeader[CBObj]"," << //check data t= ype if (_GET_CURRQES= T_DATATYPE() =3D=3D EFI_IFR_TYPE_OTHER) { _GET_CURRQEST_= VARTINFO().mVarType =3D EFI_IFR_TYPE_BOOLEAN; } if (_GET_CURRQES= T_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { - _PCATCH (gCVfr= VarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L-= >getLine(), "CheckBox varid is not the valid data type"); - if (DataTypeSi= ze !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { - _PCATCH (VFR= _RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support ar= ray"); - } else if ((gC= VfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) =3D= =3D EFI_VFR_VARSTORE_BUFFER) && - (_GE= T_CURRQEST_VARSIZE() !=3D sizeof (BOOLEAN))) { - _PCATCH (VFR= _RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLE= AN data type"); + // + // Check wheth= er the question refers to a bit field, if yes. create a Guid to indicate th= e question refers to a bit field. + // + if (_GET_CURRQ= EST_VARTINFO ().mIsBitVar) { + _PCATCH (gCV= frVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), = L->getLine(), "CheckBox varid is not the valid data type"); + if ((gCVfrDa= taStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) =3D=3D EFI= _VFR_VARSTORE_BUFFER_BITS) && + (_GET_CU= RRQEST_VARSIZE() !=3D 1)) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only occupy 1 bi= t in Bit Varstore"); + } + } else { + _PCATCH (gCV= frVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), = L->getLine(), "CheckBox varid is not the valid data type"); + if (DataType= Size !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support = array"); + } else if ((= gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) =3D= =3D EFI_VFR_VARSTORE_BUFFER) && + (_= GET_CURRQEST_VARSIZE() !=3D sizeof (BOOLEAN))) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOO= LEAN data type"); + } } } >> { - F:FLAGS "=3D" vfrCheckBoxFlags[CBObj, F->getLine()] "," + F:FLAGS "=3D" vfrCheckBoxFlags[*CBObj, F->getLine()] "," << if (_GET_CURRQEST= _VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { _PCATCH(gCVfrD= ataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStore= Name), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name"); VarStoreGuid = =3D gCVfrDataStorage.GetVarStoreGuid(_GET_CURRQEST_VARTINFO().mVarStoreId); Val.b =3D TRUE; - if (CBObj.GetF= lags () & 0x01) { + if (CBObj->Get= Flags () & 0x01) { CheckDuplica= teDefaultValue (EFI_HII_DEFAULT_CLASS_STANDARD, F); _PCATCH( gCVfrDefau= ltStore.BufferVarStoreAltConfigAdd ( = EFI_HII_DEFAULT_CLASS_STANDARD, = _GET_CURRQEST_VARTINFO(), @@ -2220,11 +2424,11 @@ vfrStatementCheckBox : VFR_RETURN= _SUCCESS, L, "No standa= rd default storage found" ); } - if (CBObj.GetF= lags () & 0x02) { + if (CBObj->Get= Flags () & 0x02) { CheckDuplica= teDefaultValue (EFI_HII_DEFAULT_CLASS_MANUFACTURING, F); _PCATCH( gCVfrDefau= ltStore.BufferVarStoreAltConfigAdd ( = EFI_HII_DEFAULT_CLASS_MANUFACTURING, = _GET_CURRQEST_VARTINFO(), @@ -2240,14 +2444,21 @@ vfrStatementCheckBox : } } >> } { - Key "=3D" KN:Number "," << AssignQuestion= Key (CBObj, KN); >> + Key "=3D" KN:Number "," << AssignQuestion= Key (*CBObj, KN); >> } vfrStatementQuestionOptionList - E:EndCheckBox << CRT_END_OP (E); = >> + E:EndCheckBox << CRT_END_OP (E); + if (GuidObj !=3D= NULL) { + GuidObj->SetSc= ope(1); + CRT_END_OP (E); + delete GuidObj; + } + if (CBObj !=3D N= ULL) delete CBObj; + >> ";" ; =20 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] : << @@ -2439,11 +2650,12 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] : UINT32 MaxU4 =3D 0, MinU4 =3D 0, StepU4 =3D 0; UINT16 MaxU2 =3D 0, MinU2 =3D 0, StepU2 =3D 0; UINT8 MaxU1 =3D 0, MinU1 =3D 0, StepU1 =3D 0; BOOLEAN IntDecStyle =3D FALSE; CIfrNumeric *NObj =3D (CIfrNumeric *) (&MMSDObj); - if ((NObj->GetOpCode() =3D=3D EFI_IFR_NUMERIC_OP) && ((NObj->GetNumer= icFlags() & EFI_IFR_DISPLAY) =3D=3D 0)) { + if (((_GET_CURRQEST_VARTINFO().mIsBitVar) && (NObj->GetOpCode() =3D= =3D EFI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY_BIT)= =3D=3D 0)) || + (!(_GET_CURRQEST_VARTINFO().mIsBitVar) && (NObj->GetOpCode() =3D=3D E= FI_IFR_NUMERIC_OP) && ((NObj->GetNumericFlags() & EFI_IFR_DISPLAY) =3D=3D 0= ))) { IntDecStyle =3D TRUE; } BOOLEAN MinNegative =3D FALSE; BOOLEAN MaxNegative =3D FALSE; >> @@ -2453,383 +2665,539 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] : } I:Number "," << if (!IntDecStyle= && MinNegative) { _PCATCH (VFR_R= ETURN_INVALID_PARAMETER, I->getLine(), "\"-\" can't be used when not in int= decimal type. "); } - switch (_GET_CUR= RQEST_DATATYPE()) { - case EFI_IFR_TYP= E_NUM_SIZE_64 : - MinU8 =3D _STO= U64(I->getText(), I->getLine()); - if (IntDecStyl= e) { - if (MinNegat= ive) {=20 - if (MinU8 = > 0x8000000000000000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't smal= l than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); - } - } else { - if (MinU8 = > 0x7FFFFFFFFFFFFFFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't smal= l than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); - } - } - } - if (MinNegativ= e) { - MinU8 =3D ~M= inU8 + 1; - } - break; - case EFI_IFR_TYP= E_NUM_SIZE_32 : + // + // Value for que= stion stored in bit fields is always set to UINT32 type. + // + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { MinU4 =3D _STO= U32(I->getText(), I->getLine()); - if (IntDecStyl= e) { - if (MinNegat= ive) {=20 - if (MinU4 = > 0x80000000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't smal= l than -0x80000000, big than 0x7FFFFFFF"); - } - } else { - if (MinU4 = > 0x7FFFFFFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't smal= l than -0x80000000, big than 0x7FFFFFFF"); - } - } - } - if (MinNegativ= e) { - MinU4 =3D ~M= inU4 + 1; + if (!IntDecSty= le && MinU4 > (1<< _GET_CURRQEST_VARTINFO().mVarTotalSize) -1) { + _PCATCH (VFR= _RETURN_INVALID_PARAMETER, I->getLine(), "BIT type minimum can't small than= 0, bigger than 2^BitWidth -1"); } - break; - case EFI_IFR_TYP= E_NUM_SIZE_16 : - MinU2 =3D _STO= U16(I->getText(), I->getLine()); - if (IntDecStyl= e) { - if (MinNegat= ive) {=20 - if (MinU2 = > 0x8000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't smal= l than -0x8000, big than 0x7FFF"); + } else { + switch (_GET_C= URRQEST_DATATYPE()) { + case EFI_IFR_T= YPE_NUM_SIZE_64 : + MinU8 =3D _S= TOU64(I->getText(), I->getLine()); + if (IntDecSt= yle) { + if (MinNeg= ative) { + if (MinU= 8 > 0x8000000000000000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't sm= all than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + } + } else { + if (MinU= 8 > 0x7FFFFFFFFFFFFFFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT64 type minimum can't sm= all than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + } } - } else { - if (MinU2 = > 0x7FFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't smal= l than -0x8000, big than 0x7FFF"); + } + if (MinNegat= ive) { + MinU8 =3D = ~MinU8 + 1; + } + break; + case EFI_IFR_T= YPE_NUM_SIZE_32 : + MinU4 =3D _S= TOU32(I->getText(), I->getLine()); + if (IntDecSt= yle) { + if (MinNeg= ative) { + if (MinU= 4 > 0x80000000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't sm= all than -0x80000000, big than 0x7FFFFFFF"); + } + } else { + if (MinU= 4 > 0x7FFFFFFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT32 type minimum can't sm= all than -0x80000000, big than 0x7FFFFFFF"); + } } } - } - if (MinNegativ= e) { - MinU2 =3D ~M= inU2 + 1; - } - break; - case EFI_IFR_TYP= E_NUM_SIZE_8 : - MinU1 =3D _STO= U8(I->getText(), I->getLine()); - if (IntDecStyl= e) { - if (MinNegat= ive) {=20 - if (MinU1 = > 0x80) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small= than -0x80, big than 0x7F"); + if (MinNegat= ive) { + MinU4 =3D = ~MinU4 + 1; + } + break; + case EFI_IFR_T= YPE_NUM_SIZE_16 : + MinU2 =3D _S= TOU16(I->getText(), I->getLine()); + if (IntDecSt= yle) { + if (MinNeg= ative) { + if (MinU= 2 > 0x8000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't sm= all than -0x8000, big than 0x7FFF"); + } + } else { + if (MinU= 2 > 0x7FFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT16 type minimum can't sm= all than -0x8000, big than 0x7FFF"); + } } - } else { - if (MinU1 = > 0x7F) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't small= than -0x80, big than 0x7F"); + } + if (MinNegat= ive) { + MinU2 =3D = ~MinU2 + 1; + } + break; + case EFI_IFR_T= YPE_NUM_SIZE_8 : + MinU1 =3D _S= TOU8(I->getText(), I->getLine()); + if (IntDecSt= yle) { + if (MinNeg= ative) { + if (MinU= 1 > 0x80) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't sma= ll than -0x80, big than 0x7F"); + } + } else { + if (MinU= 1 > 0x7F) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, I->getLine(), "INT8 type minimum can't sma= ll than -0x80, big than 0x7F"); + } } } + if (MinNegat= ive) { + MinU1 =3D = ~MinU1 + 1; + } + break; } - if (MinNegativ= e) { - MinU1 =3D ~M= inU1 + 1; - } - break; } >> Maximum "=3D"=20 {=20 "\-" << MaxNegative =3D = TRUE; >> } A:Number "," << if (!IntDecStyle= && MaxNegative) { _PCATCH (VFR_R= ETURN_INVALID_PARAMETER, A->getLine(), "\"-\" can't be used when not in int= decimal type. "); } - - switch (_GET_CUR= RQEST_DATATYPE()) { - case EFI_IFR_TYP= E_NUM_SIZE_64 :=20 - MaxU8 =3D _STO= U64(A->getText(), A->getLine());=20 - if (IntDecStyl= e) { + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + MaxU4 =3D _STO= U32(A->getText(), A->getLine()); + if (!IntDecSty= le && MaxU4 > (1<< _GET_CURRQEST_VARTINFO().mVarTotalSize) -1) { + _PCATCH (VFR= _RETURN_INVALID_PARAMETER, A->getLine(), "BIT type maximum can't bigger tha= n 2^BitWidth -1"); + } + } else { + switch (_GET_C= URRQEST_DATATYPE()) { + case EFI_IFR_T= YPE_NUM_SIZE_64 : + MaxU8 =3D _S= TOU64(A->getText(), A->getLine()); + if (IntDecSt= yle) { + if (MaxNeg= ative) { + if (MaxU= 8 > 0x8000000000000000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't sm= all than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + } + } else { + if (MaxU= 8 > 0x7FFFFFFFFFFFFFFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't sm= all than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + } + } + } if (MaxNegat= ive) { - if (MaxU8 = > 0x8000000000000000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't smal= l than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + MaxU8 =3D = ~MaxU8 + 1; + } + if (IntDecSt= yle) { + if ((INT64= ) MaxU8 < (INT64) MinU8) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } else { - if (MaxU8 = > 0x7FFFFFFFFFFFFFFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT64 type maximum can't smal= l than -0x8000000000000000, big than 0x7FFFFFFFFFFFFFFF"); + if (MaxU8 = < MinU8) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } - } - if (MaxNegativ= e) { - MaxU8 =3D ~M= axU8 + 1; - } - if (IntDecStyl= e) { - if ((INT64) = MaxU8 < (INT64) MinU8) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); - } - } else { - if (MaxU8 < = MinU8) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); + break; + case EFI_IFR_T= YPE_NUM_SIZE_32 : + MaxU4 =3D _S= TOU32(A->getText(), A->getLine()); + if (IntDecSt= yle) { + if (MaxNeg= ative) { + if (MaxU= 4 > 0x80000000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't sm= all than -0x80000000, big than 0x7FFFFFFF"); + } + } else { + if (MaxU= 4 > 0x7FFFFFFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't sm= all than -0x80000000, big than 0x7FFFFFFF"); + } + } } - } - break; - case EFI_IFR_TYP= E_NUM_SIZE_32 :=20 - MaxU4 =3D _STO= U32(A->getText(), A->getLine()); - if (IntDecStyl= e) { if (MaxNegat= ive) { - if (MaxU4 = > 0x80000000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't smal= l than -0x80000000, big than 0x7FFFFFFF"); + MaxU4 =3D = ~MaxU4 + 1; + } + if (IntDecSt= yle) { + if ((INT32= ) MaxU4 < (INT32) MinU4) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } else { - if (MaxU4 = > 0x7FFFFFFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT32 type maximum can't smal= l than -0x80000000, big than 0x7FFFFFFF"); + if (MaxU4 = < MinU4) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } - } - if (MaxNegativ= e) { - MaxU4 =3D ~M= axU4 + 1; - } - if (IntDecStyl= e) { - if ((INT32) = MaxU4 < (INT32) MinU4) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); - } - } else { - if (MaxU4 < = MinU4) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); + break; + case EFI_IFR_T= YPE_NUM_SIZE_16 : + MaxU2 =3D _S= TOU16(A->getText(), A->getLine()); + if (IntDecSt= yle) { + if (MaxNeg= ative) { + if (MaxU= 2 > 0x8000) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't sm= all than -0x8000, big than 0x7FFF"); + } + } else { + if (MaxU= 2 > 0x7FFF) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't sm= all than -0x8000, big than 0x7FFF"); + } + } } - } - break; - case EFI_IFR_TYP= E_NUM_SIZE_16 :=20 - MaxU2 =3D _STO= U16(A->getText(), A->getLine());=20 - if (IntDecStyl= e) { if (MaxNegat= ive) { - if (MaxU2 = > 0x8000) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't smal= l than -0x8000, big than 0x7FFF"); + MaxU2 =3D = ~MaxU2 + 1; + } + if (IntDecSt= yle) { + if ((INT16= ) MaxU2 < (INT16) MinU2) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } else { - if (MaxU2 = > 0x7FFF) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT16 type maximum can't smal= l than -0x8000, big than 0x7FFF"); + if (MaxU2 = < MinU2) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } - } - if (MaxNegativ= e) { - MaxU2 =3D ~M= axU2 + 1; - } - if (IntDecStyl= e) { - if ((INT16) = MaxU2 < (INT16) MinU2) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); - } - } else { - if (MaxU2 < = MinU2) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); + break; + case EFI_IFR_T= YPE_NUM_SIZE_8 : + MaxU1 =3D _S= TOU8(A->getText(), A->getLine()); + if (IntDecSt= yle) { + if (MaxNeg= ative) { + if (MaxU= 1 > 0x80) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't sma= ll than -0x80, big than 0x7F"); + } + } else { + if (MaxU= 1 > 0x7F) { + _PCATC= H (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't sma= ll than -0x80, big than 0x7F"); + } + } } - } - break; - case EFI_IFR_TYP= E_NUM_SIZE_8 : =20 - MaxU1 =3D _STO= U8(A->getText(), A->getLine()); - if (IntDecStyl= e) { if (MaxNegat= ive) { - if (MaxU1 = > 0x80) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small= than -0x80, big than 0x7F"); + MaxU1 =3D = ~MaxU1 + 1; + } + if (IntDecSt= yle) { + if ((INT8)= MaxU1 < (INT8) MinU1) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } else { - if (MaxU1 = > 0x7F) { - _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "INT8 type maximum can't small= than -0x80, big than 0x7F"); + if (MaxU1 = < MinU1) { + _PCATCH = (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mi= nimum"); } } + break; } - if (MaxNegativ= e) { - MaxU1 =3D ~M= axU1 + 1; - } - if (IntDecStyl= e) { - if ((INT8) M= axU1 < (INT8) MinU1) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); - } - } else { - if (MaxU1 < = MinU1) { - _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); - } - } - break; } >> { STEP "=3D" S:Number "," << - switch (_GET_CUR= RQEST_DATATYPE()) { - case EFI_IFR_TYP= E_NUM_SIZE_64 : StepU8 =3D _STOU64(S->getText(), S->getLine()); break; - case EFI_IFR_TYP= E_NUM_SIZE_32 : StepU4 =3D _STOU32(S->getText(), S->getLine()); break; - case EFI_IFR_TYP= E_NUM_SIZE_16 : StepU2 =3D _STOU16(S->getText(), S->getLine()); break; - case EFI_IFR_TYP= E_NUM_SIZE_8 : StepU1 =3D _STOU8(S->getText(), S->getLine()); break; + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + StepU4 =3D _ST= OU32(S->getText(), S->getLine()); + } else { + switch (_GET_C= URRQEST_DATATYPE()) { + case EFI_IFR_T= YPE_NUM_SIZE_64 : StepU8 =3D _STOU64(S->getText(), S->getLine()); break; + case EFI_IFR_T= YPE_NUM_SIZE_32 : StepU4 =3D _STOU32(S->getText(), S->getLine()); break; + case EFI_IFR_T= YPE_NUM_SIZE_16 : StepU2 =3D _STOU16(S->getText(), S->getLine()); break; + case EFI_IFR_T= YPE_NUM_SIZE_8 : StepU1 =3D _STOU8(S->getText(), S->getLine()); break; + } } >> } << - switch (_GET_CUR= RQEST_DATATYPE()) { - case EFI_IFR_TYP= E_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break; - case EFI_IFR_TYP= E_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break; - case EFI_IFR_TYP= E_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break; - case EFI_IFR_TYP= E_NUM_SIZE_8 : $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1); break; + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + $MMSDObj.SetMi= nMaxStepData (MinU4, MaxU4, StepU4); + } else { + switch (_GET_C= URRQEST_DATATYPE()) { + case EFI_IFR_T= YPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break; + case EFI_IFR_T= YPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break; + case EFI_IFR_T= YPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break; + case EFI_IFR_T= YPE_NUM_SIZE_8 : $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1); break; + } } >> ; =20 vfrStatementNumeric : << - CIfrNumeric NObj; + CIfrNumeric *NObj =3D NULL; UINT32 DataTypeSize; BOOLEAN IsSupported =3D TRUE; UINT8 ShrinkSize =3D 0; + CIfrGuid *GuidObj =3D NULL; + UINT8 LFlags =3D _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZ= E; + EFI_QUESTION_ID QId =3D EFI_QUESTION_ID_INVALID; + EFI_VARSTORE_INFO Info; + Info.mVarType =3D EFI_IFR_TYPE_OTHER; + Info.mVarTotalSize =3D 0; + Info.mInfo.mVarOffset =3D EFI_VAROFFSET_INVALID; + Info.mVarStoreId =3D EFI_VARSTORE_ID_INVALID; + Info.mIsBitVar =3D FALSE; >> - L:Numeric << NObj.SetLineNo(L= ->getLine()); >> - vfrQuestionHeader[NObj] "," << // check data ty= pe + L:Numeric + vfrQuestionBaseInfo[Info, QId] << + // + // Create a GUID = opcode to wrap the numeric opcode, if it refer to bit varstore. + // + if (_GET_CURRQEST= _VARTINFO().mIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gEfiIfrBitvarstoreGuid); + GuidObj->SetLin= eNo(L->getLine()); + } + NObj =3D new CIfr= Numeric; + NObj->SetLineNo(L= ->getLine()); + NObj->SetQuestion= Id (QId); + NObj->SetVarStore= Info (&Info); + >> + vfrStatementHeader[NObj]"," + << + // check data ty= pe if (_GET_CURRQES= T_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { - _PCATCH (gCVfr= VarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L-= >getLine(), "Numeric varid is not the valid data type"); - if (DataTypeSi= ze !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { - _PCATCH (VFR= _RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support arr= ay"); + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + LFlags =3D = (EFI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE())); + _PCATCH(NObj= ->SetFlagsForBitField (NObj->FLAGS(), LFlags), L->getLine()); + } else { + _PCATCH (gCV= frVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), = L->getLine(), "Numeric varid is not the valid data type"); + if (DataType= Size !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support a= rray"); + } + _PCATCH(NObj= ->SetFlags (NObj->FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); } - _PCATCH(NObj.S= etFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); } >> - { F:FLAGS "=3D" vfrNumericFlags[NObj, F->getLine()] "," } + { F:FLAGS "=3D" vfrNumericFlags[*NObj, F->getLine()] "," } { - Key "=3D" KN:Number "," << AssignQuestion= Key (NObj, KN); >> + Key "=3D" KN:Number "," << AssignQuestion= Key (*NObj, KN); >> } - vfrSetMinMaxStep[NObj] << - switch (_GET_CUR= RQEST_DATATYPE()) { + vfrSetMinMaxStep[*NObj] << + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + switch (_GET_C= URRQEST_DATATYPE()) { + // + // Base on t= he type to know the actual used size,shrink the buffer + // size allo= cate before. + // + case EFI_IFR= _TYPE_NUM_SIZE_8: ShrinkSize =3D 21;break; + case EFI_IFR= _TYPE_NUM_SIZE_16:ShrinkSize =3D 18;break; + case EFI_IFR= _TYPE_NUM_SIZE_32:ShrinkSize =3D 12;break; + case EFI_IFR= _TYPE_NUM_SIZE_64:break; + default: + IsSupporte= d =3D FALSE; + break; + } + } else { // - // Base on the= type to know the actual used size,shrink the buffer=20 - // size alloca= te before. + // Question st= ored in bit fields saved as UINT32 type, so the ShrinkSize same as EFI_IFR_= TYPE_NUM_SIZE_32. // - case EFI_IFR_T= YPE_NUM_SIZE_8: ShrinkSize =3D 21;break; - case EFI_IFR_T= YPE_NUM_SIZE_16:ShrinkSize =3D 18;break; - case EFI_IFR_T= YPE_NUM_SIZE_32:ShrinkSize =3D 12;break; - case EFI_IFR_T= YPE_NUM_SIZE_64:break; - default:=20 - IsSupported = =3D FALSE; - break; + ShrinkSize =3D= 12; } - NObj.ShrinkBinSi= ze (ShrinkSize); + NObj->ShrinkBinS= ize (ShrinkSize); + if (!IsSupported= ) { _PCATCH (VFR_R= ETURN_INVALID_PARAMETER, L->getLine(), "Numeric question only support UINT8= , UINT16, UINT32 and UINT64 data type."); } >> vfrStatementQuestionOptionList E:EndNumeric <<=20 - CRT_END_OP (E);=20 + CRT_END_OP (E); + if (GuidObj !=3D= NULL) { + GuidObj->SetSc= ope(1); + CRT_END_OP (E); + delete GuidObj; + } + if (NObj !=3D NU= LL) delete NObj; >> ";" ; =20 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] : << UINT8 LFlags =3D _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE; UINT8 HFlags =3D 0; - EFI_VFR_VARSTORE_TYPE VarStoreType =3D EFI_VFR_VARSTORE_INVALID; BOOLEAN IsSetType =3D FALSE; BOOLEAN IsDisplaySpecified =3D FALSE; + EFI_VFR_VARSTORE_TYPE VarStoreType =3D gCVfrDataStorage.GetVarStoreTy= pe (_GET_CURRQEST_VARTINFO().mVarStoreId); >> - numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" = numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified ] )* + numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum= ] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, L= ineNum] )* << //check data typ= e flag - if (_GET_CURRQES= T_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { - VarStoreType = =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); - if (VarStoreTy= pe =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStoreType =3D=3D EFI_VFR_VARSTORE_E= FI) { - if (_GET_CUR= RQEST_DATATYPE() !=3D (LFlags & EFI_IFR_NUMERIC_SIZE)) { - _PCATCH(VF= R_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric V= arData type"); + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + if (VarStore= Type =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStoreType =3D=3D EFI_VFR_VARSTORE= _EFI) { + if (_GET_C= URRQEST_DATATYPE() !=3D (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(= VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric= VarData type"); + } + } else { + // update = data type for name/value store + UINT32 Dat= aTypeSize; + _GET_CURRQ= EST_VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; + gCVfrVarDa= taTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQ= EST_VARTINFO().mVarTotalSize =3D DataTypeSize; } - } else { - // update da= ta type for name/value store - UINT32 DataT= ypeSize; + } else if (IsS= etType){ _GET_CURRQES= T_VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; - gCVfrVarData= TypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); - _GET_CURRQES= T_VARTINFO().mVarTotalSize =3D DataTypeSize; } - } else if (IsSet= Type){ - _GET_CURRQEST_= VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; + _PCATCH(NObj.S= etFlags (HFlags, LFlags, IsDisplaySpecified), LineNum); + } else if ((_GET= _CURRQEST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) && (_GET_CUR= RQEST_VARTINFO().mIsBitVar)) { + LFlags |=3D (E= FI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE())); + _PCATCH(NObj.S= etFlagsForBitField (HFlags, LFlags, IsDisplaySpecified), LineNum); } - _PCATCH(NObj.Set= Flags (HFlags, LFlags, IsDisplaySpecified), LineNum); >> ; =20 -numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, BOOLEAN & IsSetType, BO= OLEAN & IsDisplaySpecified] : +numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, BOOLEAN & IsSetType, BO= OLEAN & IsDisplaySpecified, UINT32 LineNum] : N:Number << _PCATCH(_STOU8(N= ->getText(), N->getLine()) =3D=3D 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUP= PORTED, N->getLine()); >> - | "NUMERIC_SIZE_1" << $LFlags =3D ($LF= lags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; IsSetType =3D TRUE;= >> - | "NUMERIC_SIZE_2" << $LFlags =3D ($LF= lags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; IsSetType =3D TRUE;= >> - | "NUMERIC_SIZE_4" << $LFlags =3D ($LF= lags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; IsSetType =3D TRUE;= >> - | "NUMERIC_SIZE_8" << $LFlags =3D ($LF= lags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; IsSetType =3D TRUE;= >> - | "DISPLAY_INT_DEC" << $LFlags =3D ($LF= lags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; IsDisplaySpecified =3D = TRUE;>> - | "DISPLAY_UINT_DEC" << $LFlags =3D ($LF= lags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; IsDisplaySpecified =3D= TRUE;>> - | "DISPLAY_UINT_HEX" << $LFlags =3D ($LF= lags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; IsDisplaySpecified =3D= TRUE;>> + | "NUMERIC_SIZE_1" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1;IsSetType =3D TRUE; + } else { + _PCATCH(VFR_RE= TURN_INVALID_PARAMETER, LineNum, "Can not specify the size of the numeric v= alue for BIT field"); + } + >> + | "NUMERIC_SIZE_2" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2;IsSetType =3D TRUE; + } else { + _PCATCH(VFR_RE= TURN_INVALID_PARAMETER, LineNum, "Can not specify the size of the numeric v= alue for BIT field"); + } + >> + | "NUMERIC_SIZE_4" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; IsSetType =3D TRU= E; + } else { + _PCATCH(VFR_RE= TURN_INVALID_PARAMETER, LineNum, "Can not specify the size of the numeric v= alue for BIT field"); + } + >> + | "NUMERIC_SIZE_8" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; IsSetType =3D TRU= E; + } else { + _PCATCH(VFR_RE= TURN_INVALID_PARAMETER, LineNum, "Can not specify the size of the numeric v= alue for BIT field"); + } + >> + | "DISPLAY_INT_DEC" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; + } else { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_INT_DEC_BIT; + } + IsDisplaySpecifi= ed =3D TRUE; + >> + | "DISPLAY_UINT_DEC" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; + } else { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_UINT_DEC_BIT; + } + IsDisplaySpecifi= ed =3D TRUE; + >> + | "DISPLAY_UINT_HEX" << if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; + } else { + $LFlags =3D ($= LFlags & ~EFI_IFR_DISPLAY_BIT) | EFI_IFR_DISPLAY_UINT_HEX_BIT; + } + IsDisplaySpecifi= ed =3D TRUE; + >> | questionheaderFlagsField[HFlags] ; =20 vfrStatementOneOf : << - CIfrOneOf OObj; + CIfrOneOf *OObj =3D NULL; UINT32 DataTypeSize; BOOLEAN IsSupported =3D TRUE; UINT8 ShrinkSize =3D 0; + CIfrGuid *GuidObj =3D NULL; + UINT8 LFlags =3D _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE; + EFI_QUESTION_ID QId =3D EFI_QUESTION_ID_INVALID;; + EFI_VARSTORE_INFO Info; + Info.mVarType =3D EFI_IFR_TYPE_OTHER; + Info.mVarTotalSize =3D 0; + Info.mInfo.mVarOffset =3D EFI_VAROFFSET_INVALID; + Info.mVarStoreId =3D EFI_VARSTORE_ID_INVALID; + Info.mIsBitVar =3D FALSE; >> - L:OneOf << OObj.SetLineNo(L= ->getLine()); >> - vfrQuestionHeader[OObj] "," << //check data type + L:OneOf + vfrQuestionBaseInfo[Info, QId] << + // + // Create a GUID = opcode to wrap the oneof opcode, if it refer to bit varstore. + // + if (_GET_CURRQEST= _VARTINFO().mIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gEfiIfrBitvarstoreGuid); + GuidObj->SetLin= eNo(L->getLine()); + } + OObj =3D new CIfr= OneOf; + OObj->SetLineNo(L= ->getLine()); + OObj->SetQuestion= Id (QId); + OObj->SetVarStore= Info (&Info); + >> + vfrStatementHeader[OObj]"," + << //check data ty= pe if (_GET_CURRQES= T_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { - _PCATCH (gCVfr= VarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L-= >getLine(), "OneOf varid is not the valid data type"); - if (DataTypeSi= ze !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { - _PCATCH (VFR= _RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array= "); + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + LFlags =3D = (EFI_IFR_NUMERIC_SIZE_BIT & (_GET_CURRQEST_VARSIZE())); + _PCATCH(OObj= ->SetFlagsForBitField (OObj->FLAGS(), LFlags), L->getLine()); + } else { + _PCATCH (gCV= frVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), = L->getLine(), "OneOf varid is not the valid data type"); + if (DataType= Size !=3D 0 && DataTypeSize !=3D _GET_CURRQEST_VARSIZE()) { + _PCATCH (V= FR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support arr= ay"); + } + _PCATCH(OObj= ->SetFlags (OObj->FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); } - _PCATCH(OObj.S= etFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); } >> - { F:FLAGS "=3D" vfrOneofFlagsField[OObj, F->getLine()] "," } + { F:FLAGS "=3D" vfrOneofFlagsField[*OObj, F->getLine()] "," } { - vfrSetMinMaxStep[OObj] + vfrSetMinMaxStep[*OObj] } << - switch (_GET_CUR= RQEST_DATATYPE()) { + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + switch (_GET_C= URRQEST_DATATYPE()) { + // + // Base on t= he type to know the actual used size,shrink the buffer + // size allo= cate before. + // + case EFI_IFR= _TYPE_NUM_SIZE_8: ShrinkSize =3D 21;break; + case EFI_IFR= _TYPE_NUM_SIZE_16:ShrinkSize =3D 18;break; + case EFI_IFR= _TYPE_NUM_SIZE_32:ShrinkSize =3D 12;break; + case EFI_IFR= _TYPE_NUM_SIZE_64:break; + default: + IsSupporte= d =3D FALSE; + break; + } + } else { // - // Base on the= type to know the actual used size,shrink the buffer=20 - // size alloca= te before. + // Question st= ored in bit fields saved as UINT32 type, so the ShrinkSize same as EFI_IFR_= TYPE_NUM_SIZE_32. // - case EFI_IFR_T= YPE_NUM_SIZE_8: ShrinkSize =3D 21;break; - case EFI_IFR_T= YPE_NUM_SIZE_16:ShrinkSize =3D 18;break; - case EFI_IFR_T= YPE_NUM_SIZE_32:ShrinkSize =3D 12;break; - case EFI_IFR_T= YPE_NUM_SIZE_64:break; - default: - IsSupported = =3D FALSE; - break; + ShrinkSize =3D= 12; } - OObj.ShrinkBinSi= ze (ShrinkSize); + OObj->ShrinkBinS= ize (ShrinkSize); + if (!IsSupported= ) { _PCATCH (VFR_R= ETURN_INVALID_PARAMETER, L->getLine(), "OneOf question only support UINT8, = UINT16, UINT32 and UINT64 data type."); } >> vfrStatementQuestionOptionList E:EndOneOf << - CRT_END_OP (E);=20 + CRT_END_OP (E); + if (GuidObj !=3D= NULL) { + GuidObj->SetSc= ope(1); + CRT_END_OP (E); + delete GuidObj; + } + if (OObj !=3D NU= LL) delete OObj; >> ";" ; =20 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] : << UINT8 LFlags =3D _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE; UINT8 HFlags =3D 0; - EFI_VFR_VARSTORE_TYPE VarStoreType =3D EFI_VFR_VARSTORE_INVALID; BOOLEAN IsSetType =3D FALSE; BOOLEAN IsDisplaySpecified =3D FALSE; + EFI_VFR_VARSTORE_TYPE VarStoreType =3D gCVfrDataStorage.GetVarStoreTy= pe (_GET_CURRQEST_VARTINFO().mVarStoreId); >> - numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" = numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] )* + numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, LineNum= ] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified, L= ineNum] )* << //check data typ= e flag - if (_GET_CURRQES= T_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { - VarStoreType = =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); - if (VarStoreTy= pe =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStoreType =3D=3D EFI_VFR_VARSTORE_E= FI) { - if (_GET_CUR= RQEST_DATATYPE() !=3D (LFlags & EFI_IFR_NUMERIC_SIZE)) { - _PCATCH(VF= R_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric V= arData type"); + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar) { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + if (VarStore= Type =3D=3D EFI_VFR_VARSTORE_BUFFER || VarStoreType =3D=3D EFI_VFR_VARSTORE= _EFI) { + if (_GET_C= URRQEST_DATATYPE() !=3D (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(V= FR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric = VarData type"); + } + } else { + // update = data type for Name/Value store + UINT32 Dat= aTypeSize; + _GET_CURRQ= EST_VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; + gCVfrVarDa= taTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQ= EST_VARTINFO().mVarTotalSize =3D DataTypeSize; } - } else { - // update da= ta type for Name/Value store - UINT32 DataT= ypeSize; + } else if (IsS= etType){ _GET_CURRQES= T_VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; - gCVfrVarData= TypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); - _GET_CURRQES= T_VARTINFO().mVarTotalSize =3D DataTypeSize; } - } else if (IsSet= Type){ - _GET_CURRQEST_= VARTINFO().mVarType =3D LFlags & EFI_IFR_NUMERIC_SIZE; + _PCATCH(OObj.S= etFlags (HFlags, LFlags), LineNum); + } else if (_GET_= CURRQEST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + _PCATCH(OObj.S= etFlagsForBitField (HFlags, LFlags), LineNum); } - _PCATCH(OObj.Set= Flags (HFlags, LFlags), LineNum); >> ; =20 vfrStatementStringType : vfrStatementString | @@ -3379,26 +3747,30 @@ vfrStatementOneOfOption : Text "=3D" "STRING_TOKEN" "\(" S:Number "\)" "," =20 Value "=3D" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayT= ype] "," <<=20 if (gCurrentMinM= axData !=3D NULL) { //set min/max = value for oneof opcode - UINT64 Step = =3D gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE()); - switch (_GET_C= URRQEST_DATATYPE()) { - case EFI_IFR_T= YPE_NUM_SIZE_64: - gCurrentMinM= axData->SetMinMaxStepData(Val->u64, Val->u64, Step); - break; - case EFI_IFR_T= YPE_NUM_SIZE_32: + UINT64 Step = =3D gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE(), _GET_CURRQEST= _VARTINFO().mIsBitVar); + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { gCurrentMinM= axData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step); - break; - case EFI_IFR_T= YPE_NUM_SIZE_16: - gCurrentMinM= axData->SetMinMaxStepData(Val->u16, Val->u16, (UINT16) Step); - break; - case EFI_IFR_T= YPE_NUM_SIZE_8: - gCurrentMinM= axData->SetMinMaxStepData(Val->u8, Val->u8, (UINT8) Step); - break; - default: - break; + } else { + switch (_GET= _CURRQEST_DATATYPE()) { + case EFI_IFR= _TYPE_NUM_SIZE_64: + gCurrentMi= nMaxData->SetMinMaxStepData(Val->u64, Val->u64, Step); + break; + case EFI_IFR= _TYPE_NUM_SIZE_32: + gCurrentMi= nMaxData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step); + break; + case EFI_IFR= _TYPE_NUM_SIZE_16: + gCurrentMi= nMaxData->SetMinMaxStepData(Val->u16, Val->u16, (UINT16) Step); + break; + case EFI_IFR= _TYPE_NUM_SIZE_8: + gCurrentMi= nMaxData->SetMinMaxStepData(Val->u8, Val->u8, (UINT8) Step); + break; + default: + break; + } } } if (_GET_CURRQES= T_DATATYPE() =3D=3D EFI_IFR_TYPE_OTHER) { Size =3D sizeo= f (EFI_IFR_TYPE_VALUE); } else if (Array= Type) { @@ -3428,24 +3800,35 @@ vfrStatementOneOfOption : break; default: break; } } else { - ReturnCode =3D= gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size); + // + // For the one= of stored in bit fields, set the option type as UINT32. + // + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + Size =3D siz= eof (UINT32); + } else { + ReturnCode = =3D gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size); + } } if (ReturnCode != =3D VFR_RETURN_SUCCESS) { _PCATCH (Retur= nCode, L->getLine()); } =20 Size +=3D OFFSET= _OF (EFI_IFR_ONE_OF_OPTION, Value); OOOObj =3D new C= IfrOneOfOption((UINT8)Size); OOOObj->SetLineN= o(L->getLine()); OOOObj->SetOptio= n (_STOSID(S->getText(), S->getLine()));=20 if (ArrayType) { - OOOObj->SetTyp= e (EFI_IFR_TYPE_BUFFER);=20 + OOOObj->SetTyp= e (EFI_IFR_TYPE_BUFFER); } else { - OOOObj->SetTyp= e (_GET_CURRQEST_DATATYPE());=20 + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + OOOObj->SetT= ype ( EFI_IFR_TYPE_NUM_SIZE_32); + } else { + OOOObj->SetT= ype (_GET_CURRQEST_DATATYPE()); + } } OOOObj->SetValue= (*Val);=20 >> F:FLAGS "=3D" vfrOneOfOptionFlags[*OOOObj, F->getLine()] << @@ -5220,11 +5603,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( gCVfrDataStorage.DeclareBufferVarStore ( TypeNameList[Index], &mFormsetGuid, &gCVfrVarDataTypeDB, TypeNameList[Index], - EFI_VARSTORE_ID_INVALID + EFI_VARSTORE_ID_INVALID, + FALSE ); gCVfrDataStorage.GetVarStoreId(TypeNameList[Index], &VarStoreId, &mFor= msetGuid); VSObj.SetVarStoreId (VarStoreId); gCVfrVarDataTypeDB.GetDataTypeSize(TypeNameList[Index], &Size); VSObj.SetSize ((UINT16) Size); @@ -5245,11 +5629,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( gCVfrDataStorage.DeclareBufferVarStore ( (CHAR8 *) DateName, &mFormsetGuid, &gCVfrVarDataTypeDB, (CHAR8 *) DateType, - EFI_VARSTORE_ID_INVALID + EFI_VARSTORE_ID_INVALID, + FALSE ); gCVfrDataStorage.GetVarStoreId((CHAR8 *) DateName, &VarStoreId, &mForm= setGuid); VSObj.SetVarStoreId (VarStoreId); gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) DateType, &Size); VSObj.SetSize ((UINT16) Size); @@ -5266,11 +5651,12 @@ EfiVfrParser::_DeclareDefaultLinearVarStore ( gCVfrDataStorage.DeclareBufferVarStore ( (CHAR8 *) TimeName, &mFormsetGuid, &gCVfrVarDataTypeDB, (CHAR8 *) TimeType, - EFI_VARSTORE_ID_INVALID + EFI_VARSTORE_ID_INVALID, + FALSE ); gCVfrDataStorage.GetVarStoreId((CHAR8 *) TimeName, &VarStoreId, &mForm= setGuid); VSObj.SetVarStoreId (VarStoreId); gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) TimeType, &Size); VSObj.SetSize ((UINT16) Size); diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/So= urce/C/VfrCompile/VfrUtilityLib.cpp index 37b58e2..23fffa1 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -598,10 +598,65 @@ CVfrVarDataTypeDB::ExtractStructTypeName ( } =20 return VFR_RETURN_SUCCESS; } =20 +/** + Check whether the DataType contain bit field. + + @param TypeName The name of the type. + +**/ +BOOLEAN +CVfrVarDataTypeDB::DataTypeHasBitField ( + IN CHAR8 *TypeName + ) +{ + SVfrDataType *pType =3D NULL; + SVfrDataField *pTmp; + + GetDataType (TypeName, &pType); + for (pTmp =3D pType->mMembers; pTmp!=3D NULL; pTmp =3D pTmp->mNext) { + if (pTmp->mIsBitField) { + return TRUE; + } + } + return FALSE; +} + +/** + Check whether the field is bit field or not. + + @param VarStr Point to the field name which may contain the structu= re name. + +**/ +BOOLEAN +CVfrVarDataTypeDB::IsThisBitField ( + IN CHAR8 *VarStr + ) +{ + CHAR8 FName[MAX_NAME_LEN]; + CHAR8 TName[MAX_NAME_LEN]; + UINT32 ArrayIdx; + SVfrDataType *pType =3D NULL; + SVfrDataField *pField =3D NULL; + + CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SU= CCESS); + CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS); + + while (*VarStr !=3D '\0') { + CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx),= VFR_RETURN_SUCCESS); + CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUC= CESS); + pType =3D pField->mFieldType; + } + if (pField->mIsBitField) { + return TRUE; + } else { + return FALSE; + } +} + EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::ExtractFieldNameAndArrary ( IN CHAR8 *&VarStr, IN CHAR8 *FName, OUT UINT32 &ArrayIdx @@ -695,11 +750,12 @@ CVfrVarDataTypeDB::GetTypeField ( =20 EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::GetFieldOffset ( IN SVfrDataField *Field, IN UINT32 ArrayIdx, - OUT UINT32 &Offset + OUT UINT32 &Offset, + IN BOOLEAN IsBitField ) { if (Field =3D=3D NULL) { return VFR_RETURN_FATAL_ERROR; } @@ -727,12 +783,15 @@ CVfrVarDataTypeDB::GetFieldOffset ( // // if ((ArrayIdx =3D=3D INVALID_ARRAY_INDEX) && (Field->mArrayNum > 0)) { // return VFR_RETURN_ERROR_ARRARY_NUM; // } // - - Offset =3D Field->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx = =3D=3D INVALID_ARRAY_INDEX) ? 0 : ArrayIdx); + if (IsBitField) { + Offset =3D Field->mBitOffset + Field->mFieldType->mTotalSize * ((Array= Idx =3D=3D INVALID_ARRAY_INDEX) ? 0 : ArrayIdx) * 8; + } else { + Offset =3D Field->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx= =3D=3D INVALID_ARRAY_INDEX) ? 0 : ArrayIdx); + } return VFR_RETURN_SUCCESS; } =20 UINT8 CVfrVarDataTypeDB::GetFieldWidth ( @@ -747,21 +806,26 @@ CVfrVarDataTypeDB::GetFieldWidth ( } =20 UINT32 CVfrVarDataTypeDB::GetFieldSize ( IN SVfrDataField *Field, - IN UINT32 ArrayIdx + IN UINT32 ArrayIdx, + IN BOOLEAN BitField ) { if (Field =3D=3D NULL) { return VFR_RETURN_FATAL_ERROR; } =20 if ((ArrayIdx =3D=3D INVALID_ARRAY_INDEX) && (Field->mArrayNum !=3D 0)) { - return Field->mFieldType->mTotalSize * Field->mArrayNum; + return Field->mFieldType->mTotalSize * Field->mArrayNum; } else { - return Field->mFieldType->mTotalSize; + if (BitField) { + return Field->mBitWidth; + } else { + return Field->mFieldType->mTotalSize; + } } } =20 VOID CVfrVarDataTypeDB::InternalTypesListInit ( @@ -786,22 +850,25 @@ CVfrVarDataTypeDB::InternalTypesListInit ( strcpy (pYearField->mFieldName, "Year"); GetDataType ((CHAR8 *)"UINT16", &pYearField->mFieldType); pYearField->mOffset =3D 0; pYearField->mNext =3D pMonthField; pYearField->mArrayNum =3D 0; + pYearField->mIsBitField =3D FALSE; =20 strcpy (pMonthField->mFieldName, "Month"); GetDataType ((CHAR8 *)"UINT8", &pMonthField->mFieldType); pMonthField->mOffset =3D 2; pMonthField->mNext =3D pDayField; pMonthField->mArrayNum =3D 0; + pMonthField->mIsBitField =3D FALSE; =20 strcpy (pDayField->mFieldName, "Day"); GetDataType ((CHAR8 *)"UINT8", &pDayField->mFieldType); pDayField->mOffset =3D 3; pDayField->mNext =3D NULL; pDayField->mArrayNum =3D 0; + pDayField->mIsBitField =3D FALSE; =20 New->mMembers =3D pYearField; } else if (strcmp (gInternalTypesTable[Index].mTypeName, "EFI_HII_TI= ME") =3D=3D 0) { SVfrDataField *pHoursField =3D new SVfrDataField; SVfrDataField *pMinutesField =3D new SVfrDataField; @@ -810,22 +877,25 @@ CVfrVarDataTypeDB::InternalTypesListInit ( strcpy (pHoursField->mFieldName, "Hours"); GetDataType ((CHAR8 *)"UINT8", &pHoursField->mFieldType); pHoursField->mOffset =3D 0; pHoursField->mNext =3D pMinutesField; pHoursField->mArrayNum =3D 0; + pHoursField->mIsBitField =3D FALSE; =20 strcpy (pMinutesField->mFieldName, "Minutes"); GetDataType ((CHAR8 *)"UINT8", &pMinutesField->mFieldType); pMinutesField->mOffset =3D 1; pMinutesField->mNext =3D pSecondsField; pMinutesField->mArrayNum =3D 0; + pMinutesField->mIsBitField =3D FALSE; =20 strcpy (pSecondsField->mFieldName, "Seconds"); GetDataType ((CHAR8 *)"UINT8", &pSecondsField->mFieldType); pSecondsField->mOffset =3D 2; pSecondsField->mNext =3D NULL; pSecondsField->mArrayNum =3D 0; + pSecondsField->mIsBitField =3D FALSE; =20 New->mMembers =3D pHoursField; } else if (strcmp (gInternalTypesTable[Index].mTypeName, "EFI_HII_RE= F") =3D=3D 0) { SVfrDataField *pQuestionIdField =3D new SVfrDataField; SVfrDataField *pFormIdField =3D new SVfrDataField; @@ -835,28 +905,32 @@ CVfrVarDataTypeDB::InternalTypesListInit ( strcpy (pQuestionIdField->mFieldName, "QuestionId"); GetDataType ((CHAR8 *)"UINT16", &pQuestionIdField->mFieldType); pQuestionIdField->mOffset =3D 0; pQuestionIdField->mNext =3D pFormIdField; pQuestionIdField->mArrayNum =3D 0; + pQuestionIdField->mIsBitField =3D FALSE; =20 strcpy (pFormIdField->mFieldName, "FormId"); GetDataType ((CHAR8 *)"UINT16", &pFormIdField->mFieldType); pFormIdField->mOffset =3D 2; pFormIdField->mNext =3D pFormSetGuidField; pFormIdField->mArrayNum =3D 0; + pFormIdField->mIsBitField =3D FALSE; =20 strcpy (pFormSetGuidField->mFieldName, "FormSetGuid"); GetDataType ((CHAR8 *)"EFI_GUID", &pFormSetGuidField->mFieldType); pFormSetGuidField->mOffset =3D 4; pFormSetGuidField->mNext =3D pDevicePathField; pFormSetGuidField->mArrayNum =3D 0; + pFormSetGuidField->mIsBitField =3D FALSE; =20 strcpy (pDevicePathField->mFieldName, "DevicePath"); GetDataType ((CHAR8 *)"EFI_STRING_ID", &pDevicePathField->mFieldTy= pe); pDevicePathField->mOffset =3D 20; pDevicePathField->mNext =3D NULL; pDevicePathField->mArrayNum =3D 0; + pDevicePathField->mIsBitField =3D FALSE; =20 New->mMembers =3D pQuestionIdField; } else { New->mMembers =3D NULL; } @@ -976,10 +1050,11 @@ CVfrVarDataTypeDB::DeclareDataTypeBegin ( pNewType->mType =3D EFI_IFR_TYPE_OTHER; pNewType->mAlign =3D DEFAULT_ALIGN; pNewType->mTotalSize =3D 0; pNewType->mMembers =3D NULL; pNewType->mNext =3D NULL; + pNewType->mHasBitField =3D FALSE; =20 mNewDataType =3D pNewType; } =20 EFI_VFR_RETURN_CODE @@ -1007,10 +1082,127 @@ CVfrVarDataTypeDB::SetNewTypeName ( =20 strcpy(mNewDataType->mTypeName, TypeName); return VFR_RETURN_SUCCESS; } =20 +/** + Record the bit field info in the data type. + + @param FieldName Point to the field name. + @param TypeName Point to the type name. + @param Width The bit widthS. + @param FieldInUnion The filed is in Union type or Structure type. + +**/ +EFI_VFR_RETURN_CODE +CVfrVarDataTypeDB::DataTypeAddBitField ( + IN CHAR8 *FieldName, + IN CHAR8 *TypeName, + IN UINT32 Width, + IN BOOLEAN FieldInUnion + ) +{ + SVfrDataField *pNewField =3D NULL; + SVfrDataType *pFieldType =3D NULL; + SVfrDataField *pTmp; + UINT32 Align; + UINT32 MaxDataTypeSize; + BOOLEAN UpdateTotalSize; + + CHECK_ERROR_RETURN (GetDataType (TypeName, &pFieldType), VFR_RETURN_SUCC= ESS); + + if (Width > MAX_BIT_WIDTH) { + return VFR_RETURN_BIT_WIDTH_ERROR; + } + + if (Width > pFieldType->mTotalSize * 8) { + return VFR_RETURN_BIT_WIDTH_ERROR; + } + + if (strlen (FieldName) >=3D MAX_NAME_LEN) { + return VFR_RETURN_INVALID_PARAMETER; + } + + if (Width =3D=3D 0 && strcmp (" ", FieldName) !=3D 0) { + return VFR_RETURN_INVALID_PARAMETER; + } + + for (pTmp =3D mNewDataType->mMembers; pTmp !=3D NULL; pTmp =3D pTmp->mNe= xt) { + if (strcmp (pTmp->mFieldName, FieldName) =3D=3D 0 && strcmp (" ", Fiel= dName) !=3D 0) { + return VFR_RETURN_REDEFINED; + } + } + + Align =3D MIN (mPackAlign, pFieldType->mAlign); + UpdateTotalSize =3D FALSE; + + if ((pNewField =3D new SVfrDataField) =3D=3D NULL) { + return VFR_RETURN_OUT_FOR_RESOURCES; + } + + MaxDataTypeSize =3D mNewDataType->mTotalSize; + strcpy (pNewField->mFieldName, FieldName); + pNewField->mFieldType =3D pFieldType; + pNewField->mIsBitField =3D TRUE; + pNewField->mBitWidth =3D Width; + pNewField->mArrayNum =3D 0; + pNewField->mBitOffset =3D 0; + pNewField->mOffset =3D 0; + + if (mNewDataType->mMembers =3D=3D NULL) { + mNewDataType->mMembers =3D pNewField; + pNewField->mNext =3D NULL; + } else { + for (pTmp =3D mNewDataType->mMembers; pTmp->mNext !=3D NULL; pTmp =3D = pTmp->mNext) + ; + pTmp->mNext =3D pNewField; + pNewField->mNext =3D NULL; + } + + if (FieldInUnion) { + pNewField->mOffset =3D 0; + if (MaxDataTypeSize < pNewField->mFieldType->mTotalSize) { + mNewDataType->mTotalSize =3D pNewField->mFieldType->mTotalSize; + } + } else { + // + // Check whether the bit fileds can be contained within one FieldType. + // + if (pTmp !=3D NULL && pTmp->mIsBitField && strcmp (pTmp->mFieldType->m= TypeName, pNewField->mFieldType->mTypeName) =3D=3D 0 && + (pTmp->mBitOffset - pTmp->mOffset * 8) + pTmp->mBitWidth + pNewFiel= d->mBitWidth <=3D pNewField->mFieldType->mTotalSize * 8) { + pNewField->mBitOffset =3D pTmp->mBitOffset + pTmp->mBitWidth; + pNewField->mOffset =3D pTmp->mOffset; + // + // If BitWidth=3D0,used to force alignment at the next word boundary. + // So make this bit field occupy the remaing bit width of current fi= eld type. + // + if (pNewField->mBitWidth =3D=3D 0) { + pNewField->mBitWidth =3D pNewField->mFieldType->mTotalSize * 8 - (= pNewField->mBitOffset - pTmp->mOffset * 8); + } + } else { + // + // The bit filed start a new memory + // + pNewField->mBitOffset =3D mNewDataType->mTotalSize * 8; + UpdateTotalSize =3D TRUE; + } + } + + if (UpdateTotalSize){ + if ((mNewDataType->mTotalSize % Align) =3D=3D 0) { + pNewField->mOffset =3D mNewDataType->mTotalSize; + } else { + pNewField->mOffset =3D mNewDataType->mTotalSize + ALIGN_STUFF(mN= ewDataType->mTotalSize, Align); + } + mNewDataType->mTotalSize =3D pNewField->mOffset + (pNewField->mFieldTy= pe->mTotalSize); + } + + mNewDataType->mAlign =3D MIN (mPackAlign, MAX (pFieldType->mAlign, m= NewDataType->mAlign)); + mNewDataType->mHasBitField =3D TRUE; + return VFR_RETURN_SUCCESS; +} + EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::DataTypeAddField ( IN CHAR8 *FieldName, IN CHAR8 *TypeName, IN UINT32 ArrayNum, @@ -1042,10 +1234,11 @@ CVfrVarDataTypeDB::DataTypeAddField ( return VFR_RETURN_OUT_FOR_RESOURCES; } strcpy (pNewField->mFieldName, FieldName); pNewField->mFieldType =3D pFieldType; pNewField->mArrayNum =3D ArrayNum; + pNewField->mIsBitField =3D FALSE; if ((mNewDataType->mTotalSize % Align) =3D=3D 0) { pNewField->mOffset =3D mNewDataType->mTotalSize; } else { pNewField->mOffset =3D mNewDataType->mTotalSize + ALIGN_STUFF(mNew= DataType->mTotalSize, Align); } @@ -1181,39 +1374,48 @@ CVfrVarDataTypeDB::GetDataTypeSize ( EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::GetDataFieldInfo ( IN CHAR8 *VarStr, OUT UINT16 &Offset, OUT UINT8 &Type, - OUT UINT32 &Size + OUT UINT32 &Size, + OUT BOOLEAN &BitField ) { CHAR8 TName[MAX_NAME_LEN], FName[MAX_NAME_LEN]; UINT32 ArrayIdx, Tmp; SVfrDataType *pType =3D NULL; SVfrDataField *pField =3D NULL; + CHAR8 *VarStrName; =20 Offset =3D 0; Type =3D EFI_IFR_TYPE_OTHER; Size =3D 0; + VarStrName =3D VarStr; =20 CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SU= CCESS); CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS); =20 + BitField =3D IsThisBitField (VarStrName); + // // if it is not struct data type // Type =3D pType->mType; Size =3D pType->mTotalSize; =20 while (*VarStr !=3D '\0') { - CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), = VFR_RETURN_SUCCESS); + CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx),= VFR_RETURN_SUCCESS); CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUC= CESS); pType =3D pField->mFieldType; - CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp), VFR_RETURN_= SUCCESS); - Offset =3D (UINT16) (Offset + Tmp); + CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, pField->mIsB= itField), VFR_RETURN_SUCCESS); + if (BitField && !pField->mIsBitField) { + Offset =3D (UINT16) (Offset + Tmp * 8); + } else { + Offset =3D (UINT16) (Offset + Tmp); + } Type =3D GetFieldWidth (pField); - Size =3D GetFieldSize (pField, ArrayIdx); + Size =3D GetFieldSize (pField, ArrayIdx, BitField); } return VFR_RETURN_SUCCESS; } =20 EFI_VFR_RETURN_CODE @@ -1358,10 +1560,11 @@ SVfrVarStorageNode::SVfrVarStorageNode ( SVfrVarStorageNode::SVfrVarStorageNode ( IN EFI_GUID *Guid, IN CHAR8 *StoreName, IN EFI_VARSTORE_ID VarStoreId, IN SVfrDataType *DataType, + IN BOOLEAN BitsVarstore, IN BOOLEAN Flag ) { if (Guid !=3D NULL) { mGuid =3D *Guid; @@ -1374,11 +1577,15 @@ SVfrVarStorageNode::SVfrVarStorageNode ( } else { mVarStoreName =3D NULL; } mNext =3D NULL; mVarStoreId =3D VarStoreId; - mVarStoreType =3D EFI_VFR_VARSTORE_BUFFER; + if (BitsVarstore) { + mVarStoreType =3D EFI_VFR_VARSTORE_BUFFER_BITS; + } else { + mVarStoreType =3D EFI_VFR_VARSTORE_BUFFER; + } mStorageInfo.mDataType =3D DataType; mAssignedFlag =3D Flag; } =20 SVfrVarStorageNode::SVfrVarStorageNode ( @@ -1646,10 +1853,11 @@ CVfrDataStorage::DeclareBufferVarStore ( IN CHAR8 *StoreName,=20 IN EFI_GUID *Guid,=20 IN CVfrVarDataTypeDB *DataTypeDB, IN CHAR8 *TypeName, IN EFI_VARSTORE_ID VarStoreId, + IN BOOLEAN IsBitVarStore, IN BOOLEAN Flag ) { SVfrVarStorageNode *pNew =3D NULL; SVfrDataType *pDataType =3D NULL; @@ -1672,11 +1880,11 @@ CVfrDataStorage::DeclareBufferVarStore ( return VFR_RETURN_VARSTOREID_REDEFINED; } MarkVarStoreIdUsed (VarStoreId); } =20 - if ((pNew =3D new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pData= Type, Flag)) =3D=3D NULL) { + if ((pNew =3D new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pData= Type, IsBitVarStore, Flag)) =3D=3D NULL) { return VFR_RETURN_OUT_FOR_RESOURCES; } =20 pNew->mNext =3D mBufferVarStoreList; mBufferVarStoreList =3D pNew; @@ -2386,10 +2594,11 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO ( mVarStoreId =3D EFI_VARSTORE_ID_INVALID; mInfo.mVarName =3D EFI_STRING_ID_INVALID; mInfo.mVarOffset =3D EFI_VAROFFSET_INVALID; mVarType =3D EFI_IFR_TYPE_OTHER; mVarTotalSize =3D 0; + mIsBitVar =3D FALSE; } =20 EFI_VARSTORE_INFO::EFI_VARSTORE_INFO ( IN EFI_VARSTORE_INFO &Info ) @@ -2397,10 +2606,11 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO ( mVarStoreId =3D Info.mVarStoreId; mInfo.mVarName =3D Info.mInfo.mVarName; mInfo.mVarOffset =3D Info.mInfo.mVarOffset; mVarType =3D Info.mVarType; mVarTotalSize =3D Info.mVarTotalSize; + mIsBitVar =3D Info.mIsBitVar; } =20 EFI_VARSTORE_INFO& EFI_VARSTORE_INFO::operator=3D ( IN CONST EFI_VARSTORE_INFO &Info @@ -2410,10 +2620,11 @@ EFI_VARSTORE_INFO::operator=3D ( mVarStoreId =3D Info.mVarStoreId; mInfo.mVarName =3D Info.mInfo.mVarName; mInfo.mVarOffset =3D Info.mInfo.mVarOffset; mVarType =3D Info.mVarType; mVarTotalSize =3D Info.mVarTotalSize; + mIsBitVar =3D Info.mIsBitVar; } =20 return *this; } =20 @@ -2424,11 +2635,12 @@ EFI_VARSTORE_INFO::operator =3D=3D ( { if ((mVarStoreId =3D=3D Info->mVarStoreId) && (mInfo.mVarName =3D=3D Info->mInfo.mVarName) && (mInfo.mVarOffset =3D=3D Info->mInfo.mVarOffset) && (mVarType =3D=3D Info->mVarType) && - (mVarTotalSize =3D=3D Info->mVarTotalSize)) { + (mVarTotalSize =3D=3D Info->mVarTotalSize) && + (mIsBitVar =3D=3D Info->mIsBitVar)) { return TRUE; } =20 return FALSE; } @@ -3727,10 +3939,11 @@ CVfrStringDB::GetUnicodeStringTextSize ( =20 return StringSize; } =20 BOOLEAN VfrCompatibleMode =3D FALSE; +EFI_GUID gEfiIfrBitvarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x= 27, 0x20, 0xA8, 0xFD, 0x60 ,0xA7 , 0x1D}}; =20 CVfrVarDataTypeDB gCVfrVarDataTypeDB; CVfrDefaultStore gCVfrDefaultStore; CVfrDataStorage gCVfrDataStorage; =20 diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Sour= ce/C/VfrCompile/VfrUtilityLib.h index 0c67d73..c1d124f 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h @@ -20,11 +20,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include "Common/UefiBaseTypes.h" #include "EfiVfr.h" #include "VfrError.h" =20 extern BOOLEAN VfrCompatibleMode; +extern EFI_GUID gEfiIfrBitvarstoreGuid; =20 +#define MAX_BIT_WIDTH 32 #define MAX_NAME_LEN 64 #define MAX_STRING_LEN 0x100 #define DEFAULT_ALIGN 1 #define DEFAULT_PACK_ALIGN 0x8 #define DEFAULT_NAME_TABLE_ITEMS 1024 @@ -114,18 +116,22 @@ struct SVfrDataType; struct SVfrDataField { CHAR8 mFieldName[MAX_NAME_LEN]; SVfrDataType *mFieldType; UINT32 mOffset; UINT32 mArrayNum; + BOOLEAN mIsBitField; + UINT8 mBitWidth; + UINT32 mBitOffset; SVfrDataField *mNext; }; =20 struct SVfrDataType { CHAR8 mTypeName[MAX_NAME_LEN]; UINT8 mType; UINT32 mAlign; UINT32 mTotalSize; + BOOLEAN mHasBitField; SVfrDataField *mMembers; SVfrDataType *mNext; }; =20 #define VFR_PACK_ASSIGN 0x01 @@ -193,30 +199,33 @@ private: VOID InternalTypesListInit (VOID); VOID RegisterNewType (IN SVfrDataType *); =20 EFI_VFR_RETURN_CODE ExtractStructTypeName (IN CHAR8 *&, OUT CHAR8 *); EFI_VFR_RETURN_CODE GetTypeField (IN CONST CHAR8 *, IN SVfrDataType *, I= N SVfrDataField *&); - EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT U= INT32 &); + EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT U= INT32 &, IN BOOLEAN); UINT8 GetFieldWidth (IN SVfrDataField *); - UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32); + UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32, IN BOOL= EAN); =20 public: CVfrVarDataTypeDB (VOID); ~CVfrVarDataTypeDB (VOID); =20 VOID DeclareDataTypeBegin (VOID); EFI_VFR_RETURN_CODE SetNewTypeName (IN CHAR8 *); EFI_VFR_RETURN_CODE DataTypeAddField (IN CHAR8 *, IN CHAR8 *, IN UINT32,= IN BOOLEAN); + EFI_VFR_RETURN_CODE DataTypeAddBitField (IN CHAR8 *, IN CHAR8 *, IN UINT= 32, IN BOOLEAN); VOID DeclareDataTypeEnd (VOID); =20 EFI_VFR_RETURN_CODE GetDataType (IN CHAR8 *, OUT SVfrDataType **); EFI_VFR_RETURN_CODE GetDataTypeSize (IN CHAR8 *, OUT UINT32 *); EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *); - EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT= 8 &, OUT UINT32 &); + EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT= 8 &, OUT UINT32 &, OUT BOOLEAN &); =20 EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT CHAR8 ***, OUT UINT3= 2 *); EFI_VFR_RETURN_CODE ExtractFieldNameAndArrary (IN CHAR8 *&, OUT CHAR8 *,= OUT UINT32 &); + BOOLEAN DataTypeHasBitField (IN CHAR8 *); + BOOLEAN IsThisBitField (IN CHAR8 *); =20 BOOLEAN IsTypeNameDefined (IN CHAR8 *); =20 VOID Dump(IN FILE *); // @@ -236,11 +245,12 @@ extern CVfrVarDataTypeDB gCVfrVarDataTypeDB; =20 typedef enum { EFI_VFR_VARSTORE_INVALID, EFI_VFR_VARSTORE_BUFFER, EFI_VFR_VARSTORE_EFI, - EFI_VFR_VARSTORE_NAME + EFI_VFR_VARSTORE_NAME, + EFI_VFR_VARSTORE_BUFFER_BITS } EFI_VFR_VARSTORE_TYPE; =20 struct SVfrVarStorageNode { EFI_GUID mGuid; CHAR8 *mVarStoreName; @@ -266,11 +276,11 @@ struct SVfrVarStorageNode { } mNameSpace; } mStorageInfo; =20 public: SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN EF= I_STRING_ID, IN UINT32, IN BOOLEAN Flag =3D TRUE); - SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SV= frDataType *, IN BOOLEAN Flag =3D TRUE); + SVfrVarStorageNode (IN EFI_GUID *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN SV= frDataType *,IN BOOLEAN, IN BOOLEAN Flag =3D TRUE); SVfrVarStorageNode (IN CHAR8 *, IN EFI_VARSTORE_ID); ~SVfrVarStorageNode (VOID); =20 private: SVfrVarStorageNode (IN CONST SVfrVarStorageNode&); // Preven= t copy-construction @@ -283,10 +293,11 @@ struct EFI_VARSTORE_INFO { EFI_STRING_ID mVarName; UINT16 mVarOffset; } mInfo; UINT8 mVarType; UINT32 mVarTotalSize; + BOOLEAN mIsBitVar; =20 EFI_VARSTORE_INFO (VOID); EFI_VARSTORE_INFO (IN EFI_VARSTORE_INFO &); EFI_VARSTORE_INFO& operator=3D(IN CONST EFI_VARSTORE_INFO &); BOOLEAN operator =3D=3D (IN EFI_VARSTORE_INFO *); @@ -341,11 +352,11 @@ public: EFI_VFR_RETURN_CODE NameTableAddItem (EFI_STRING_ID); EFI_VFR_RETURN_CODE DeclareNameVarStoreEnd (EFI_GUID *); =20 EFI_VFR_RETURN_CODE DeclareEfiVarStore (IN CHAR8 *, IN EFI_GUID *, IN EF= I_STRING_ID, IN UINT32, IN BOOLEAN Flag =3D TRUE); =20 - EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN= CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN Flag =3D T= RUE); + EFI_VFR_RETURN_CODE DeclareBufferVarStore (IN CHAR8 *, IN EFI_GUID *, IN= CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN, IN BOOLEA= N Flag =3D TRUE); =20 EFI_VFR_RETURN_CODE GetVarStoreId (IN CHAR8 *, OUT EFI_VARSTORE_ID *, IN= EFI_GUID *VarGuid =3D NULL); EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID); EFI_GUID * GetVarStoreGuid (IN EFI_VARSTORE_ID); EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT CHAR8 **); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 1505456674366810.1486317506095; Thu, 14 Sep 2017 23:24:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E674421E9781A; Thu, 14 Sep 2017 23:21:32 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 B0B9121E97819 for ; Thu, 14 Sep 2017 23:21:31 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:31 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:30 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617239" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:39 +0800 Message-Id: <1505456623-414328-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 2/6] MdeModulePkg: Add GUID/flags to implement BitField support 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: Eric Dong , Liming Gao 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" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Include/Guid/MdeModuleHii.h | 20 +++++++++++++++++++- MdeModulePkg/MdeModulePkg.dec | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Include/Guid/MdeModuleHii.h b/MdeModulePkg/Includ= e/Guid/MdeModuleHii.h index 81821da..4ef4db8 100644 --- a/MdeModulePkg/Include/Guid/MdeModuleHii.h +++ b/MdeModulePkg/Include/Guid/MdeModuleHii.h @@ -1,9 +1,9 @@ /** @file EDKII extented HII IFR guid opcodes. =20 -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availabl= e under=20 the terms and conditions of the BSD License that accompanies this distribu= tion. =20 The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. = =20 =20 @@ -209,12 +209,30 @@ typedef struct _EFI_IFR_GUID_VAREQNAME { /// The the Unicode String will be used as a EFI Variable Name. /// UINT16 NameId; } EFI_IFR_GUID_VAREQNAME; =20 +/// +/// EDKII implementation extension GUID, used to indaicate there are bit f= ields in the varstore. +/// +#define EFI_IFR_BITVARSTORE_GUID \ + {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 0xA8, 0xFD, 0x60,0xA7, 0= x1D}} + +/// +/// EDKII implementation extension flags, used to indaicate the disply sty= le and bit width for bit filed storage. +/// Two high bits for display style and the low six bits for bit width. +/// +#define EFI_IFR_DISPLAY_BIT 0xC0 +#define EFI_IFR_DISPLAY_INT_DEC_BIT 0x00 +#define EFI_IFR_DISPLAY_UINT_DEC_BIT 0x40 +#define EFI_IFR_DISPLAY_UINT_HEX_BIT 0x80 + +#define EFI_IFR_NUMERIC_SIZE_BIT 0x3F + #pragma pack() =20 extern EFI_GUID gEfiIfrTianoGuid; extern EFI_GUID gEfiIfrFrameworkGuid; +extern EFI_GUID gEfiIfrBitvarstoreGuid; =20 #endif =20 diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 593bff3..8c8d76e 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -182,10 +182,14 @@ =20 ## Guid for EDKII implementation GUIDed opcodes # Include/Guid/MdeModuleHii.h gEfiIfrTianoGuid =3D { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53= , 0x8c, 0x38, 0xaf, 0x48, 0xce }} =20 + ## Guid for EDKII implementation extension, used to indaicate there are = bit fields in the varstore. + # Include/Guid/MdeModuleHii.h + gEfiIfrBitvarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x= 20, 0xA8, 0xFD, 0x60,0xA7, 0x1D}} + ## Guid for Framework vfr GUIDed opcodes. # Include/Guid/MdeModuleHii.h gEfiIfrFrameworkGuid =3D { 0x31ca5d1a, 0xd511, 0x4931, { 0xb7, 0x82, 0x= ae, 0x6b, 0x2b, 0x17, 0x8c, 0xd7 }} =20 ## Guid to specify the System Non Volatile FV --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 150545667744944.50199148776164; Thu, 14 Sep 2017 23:24:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3131321E97819; Thu, 14 Sep 2017 23:21:36 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 391C221E8799E for ; Thu, 14 Sep 2017 23:21:35 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:35 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:33 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617257" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:40 +0800 Message-Id: <1505456623-414328-4-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 3/6] MdeModulePkg/UefiHiiLib: Add codes to validate question with bit fields 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: Eric Dong , Liming Gao 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: Use API BitFieldRead/Write to replace the same logic in the codes. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 In UefiHiiLib, there are codes to validate the current setting of questions, now update the logic to handle question with bit storage. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 246 ++++++++++++++++---= ---- MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h | 4 +- MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf | 5 +- 3 files changed, 178 insertions(+), 77 deletions(-) diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Librar= y/UefiHiiLib/HiiLib.c index cd0cd35..d24be7c 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -1167,10 +1167,16 @@ ValidateQuestionFromVfr ( EFI_IFR_STRING *IfrString; CHAR8 *VarStoreName; UINTN Index; CHAR16 *QuestionName; CHAR16 *StringPtr; + UINT16 BitOffset; + UINT16 BitWidth; + UINT16 TotalBits; + UINTN StartBit; + UINTN EndBit; + BOOLEAN QuestionReferBitField; =20 // // Initialize the local variables. // Index =3D 0; @@ -1180,10 +1186,13 @@ ValidateQuestionFromVfr ( IfrVarStore =3D NULL; IfrNameValueStore =3D NULL; IfrEfiVarStore =3D NULL; ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA)); ZeroMem (&VarBlockData, sizeof (VarBlockData)); + BitOffset =3D 0; + BitWidth =3D 0; + QuestionReferBitField =3D FALSE; =20 // // Check IFR value is in block data, then Validate Value // PackageOffset =3D sizeof (EFI_HII_PACKAGE_LIST_HEADER); @@ -1343,12 +1352,23 @@ ValidateQuestionFromVfr ( } } else { // // Get Offset by Question header and Width by DataType Flags // - Offset =3D IfrOneOf->Question.VarStoreInfo.VarOffset; - Width =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_S= IZE)); + if (QuestionReferBitField) { + // + // Get the byte offset/width for bit field. + // + BitOffset =3D IfrOneOf->Question.VarStoreInfo.VarOffset; + BitWidth =3D IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE_BIT; + Offset =3D BitOffset / 8; + TotalBits =3D BitOffset % 8 + BitWidth; + Width =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: TotalBits= / 8 + 1); + } else { + Offset =3D IfrOneOf->Question.VarStoreInfo.VarOffset; + Width =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC= _SIZE)); + } // // Check whether this question is in current block array. // if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { // @@ -1368,11 +1388,20 @@ ValidateQuestionFromVfr ( =20 // // Get the current value for oneof opcode // VarValue =3D 0; - CopyMem (&VarValue, VarBuffer + Offset, Width); + if (QuestionReferBitField) { + // + // Get the value in bit fields. + // + StartBit =3D BitOffset % 8; + EndBit =3D StartBit + BitWidth - 1; + VarValue =3D BitFieldRead32 (*(UINT32*)(VarBuffer + Offset),= StartBit, EndBit); + } else { + CopyMem (&VarValue, VarBuffer + Offset, Width); + } } // // Set Block Data, to be checked in the following Oneof option o= pcode. // VarBlockData.OpCode =3D IfrOpHdr->OpCode; @@ -1414,12 +1443,23 @@ ValidateQuestionFromVfr ( } } else { // // Get Offset by Question header and Width by DataType Flags // - Offset =3D IfrNumeric->Question.VarStoreInfo.VarOffset; - Width =3D (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC= _SIZE)); + if (QuestionReferBitField) { + // + // Get the byte offset/width for bit field. + // + BitOffset =3D IfrNumeric->Question.VarStoreInfo.VarOffset; + BitWidth =3D IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE_BIT; + Offset =3D BitOffset / 8; + TotalBits =3D BitOffset % 8 + BitWidth; + Width =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: TotalBit= s / 8 + 1); + } else { + Offset =3D IfrNumeric->Question.VarStoreInfo.VarOffset; + Width =3D (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMER= IC_SIZE)); + } // // Check whether this question is in current block array. // if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { // @@ -1439,81 +1479,111 @@ ValidateQuestionFromVfr ( =20 // // Check the current value is in the numeric range. // VarValue =3D 0; - CopyMem (&VarValue, VarBuffer + Offset, Width); - } - if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) =3D=3D 0) { - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue ||= (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; - case EFI_IFR_NUMERIC_SIZE_2: - if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue= || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; - case EFI_IFR_NUMERIC_SIZE_4: - if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue= || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; - case EFI_IFR_NUMERIC_SIZE_8: - if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue= || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; + if (QuestionReferBitField) { + // + // Get the value in the bit fields. + // + StartBit =3D BitOffset % 8; + EndBit =3D StartBit + BitWidth - 1; + VarValue =3D BitFieldRead32 (*(UINT32*)(VarBuffer + Offset),= StartBit, EndBit); + } else { + CopyMem (&VarValue, VarBuffer + Offset, Width); } + } + if ( QuestionReferBitField) { + // + // Value in bit fields was stored as UINt32 type. + // + if ((IfrNumeric->Flags & EFI_IFR_DISPLAY_BIT) =3D=3D 0) { + if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValu= e || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + } else { + if (VarValue < IfrNumeric->data.u32.MinValue || VarValue > = IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + } } else { - switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT= 8) VarValue > IfrNumeric->data.u8.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; - case EFI_IFR_NUMERIC_SIZE_2: - if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UI= NT16) VarValue > IfrNumeric->data.u16.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; - } - break; - case EFI_IFR_NUMERIC_SIZE_4: - if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UI= NT32) VarValue > IfrNumeric->data.u32.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; + if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) =3D=3D 0) { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue = || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_2: + if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinVal= ue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_4: + if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinVal= ue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_8: + if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinVal= ue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; } - break; - case EFI_IFR_NUMERIC_SIZE_8: - if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UI= NT64) VarValue > IfrNumeric->data.u64.MaxValue) { - // - // Not in the valid range. - // - return EFI_INVALID_PARAMETER; + } else { + switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UI= NT8) VarValue > IfrNumeric->data.u8.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_2: + if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (= UINT16) VarValue > IfrNumeric->data.u16.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_4: + if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (= UINT32) VarValue > IfrNumeric->data.u32.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; + case EFI_IFR_NUMERIC_SIZE_8: + if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (= UINT64) VarValue > IfrNumeric->data.u64.MaxValue) { + // + // Not in the valid range. + // + return EFI_INVALID_PARAMETER; + } + break; } - break; } } break; case EFI_IFR_CHECKBOX_OP: // @@ -1552,12 +1622,23 @@ ValidateQuestionFromVfr ( } } else { // // Get Offset by Question header // - Offset =3D IfrCheckBox->Question.VarStoreInfo.VarOffset; - Width =3D (UINT16) sizeof (BOOLEAN); + if (QuestionReferBitField) { + // + // Get the byte offset/width for bit field. + // + BitOffset =3D IfrCheckBox->Question.VarStoreInfo.VarOffset; + BitWidth =3D 1; + Offset =3D BitOffset / 8; + TotalBits =3D BitOffset % 8 + BitWidth; + Width =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: TotalBits= / 8 + 1); + } else { + Offset =3D IfrCheckBox->Question.VarStoreInfo.VarOffset; + Width =3D (UINT16) sizeof (BOOLEAN); + } // // Check whether this question is in current block array. // if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) { // @@ -1576,11 +1657,20 @@ ValidateQuestionFromVfr ( } // // Check the current value is in the numeric range. // VarValue =3D 0; - CopyMem (&VarValue, VarBuffer + Offset, Width); + if (QuestionReferBitField) { + // + // Get the value in bit fields. + // + StartBit =3D BitOffset % 8; + EndBit =3D StartBit + BitWidth - 1; + VarValue =3D BitFieldRead32 (*(UINT32*)(VarBuffer + Offset),= StartBit, EndBit); + } else { + CopyMem (&VarValue, VarBuffer + Offset, Width); + } } // // Boolean type, only 1 and 0 is valid. // if (VarValue > 1) { @@ -1692,10 +1782,11 @@ ValidateQuestionFromVfr ( VarBlockData.OpCode =3D 0; } } break; case EFI_IFR_END_OP: + QuestionReferBitField =3D FALSE; // // Decrease opcode scope for the validated opcode // if (VarBlockData.Scope > 0) { VarBlockData.Scope --; @@ -1706,10 +1797,15 @@ ValidateQuestionFromVfr ( // if ((VarBlockData.Scope =3D=3D 0) && (VarBlockData.OpCode =3D=3D= EFI_IFR_ONE_OF_OP)) { return EFI_INVALID_PARAMETER; } break; + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR= _OP_HEADER)), &gEfiIfrBitvarstoreGuid)) { + QuestionReferBitField =3D TRUE; + } + break; default: // // Increase Scope for the validated opcode // if (VarBlockData.Scope > 0) { diff --git a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h b/MdeModulePk= g/Library/UefiHiiLib/InternalHiiLib.h index 9bf7696..293c226 100644 --- a/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h +++ b/MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h @@ -1,9 +1,9 @@ /** @file Internal include file for the HII Library instance. =20 - Copyright (c) 2007, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BS= D License =20 which accompanies this distribution. The full text of the license may b= e found at =20 http://opensource.org/licenses/bsd-license.php = =20 =20 @@ -18,10 +18,12 @@ #include =20 #include #include =20 +#include + #include #include #include #include #include diff --git a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf b/MdeModulePkg/= Library/UefiHiiLib/UefiHiiLib.inf index 62f435a..411c758 100644 --- a/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf +++ b/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf @@ -1,9 +1,9 @@ ## @file # HII Library implementation using UEFI HII protocols and services. # -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may b= e found at # http://opensource.org/licenses/bsd-license.php @@ -49,5 +49,8 @@ PrintLib =20 [Protocols] gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES + +[Guids] + gEfiIfrBitvarstoreGuid ## SOMETIMES_CONSUMES ## GUID --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 1505456682567116.78812555214085; Thu, 14 Sep 2017 23:24:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 95A1621EA35B1; Thu, 14 Sep 2017 23:21:38 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 0C75D21E8799E for ; Thu, 14 Sep 2017 23:21:37 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:36 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:35 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617267" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:41 +0800 Message-Id: <1505456623-414328-5-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 4/6] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore 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: Eric Dong , Liming Gao 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.Split function UpdateBlockDataArray into UpdateDefaultValue, MergeBlockDefaultValue,UpdateBlockDataArray three functions. 2 Use API BitFieldRead/Write to replace the same logic in the codes. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 For oneof/numeric/checkbox, their storage may be bit field. When generating string to get default value for these questions, we need to parse the Ifr data to get the bit Varstore info,and then generating the correct string. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 346 +++++++++++++++++= ++-- .../Universal/HiiDatabaseDxe/HiiDatabase.h | 6 +- .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf | 3 +- 3 files changed, 319 insertions(+), 36 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index c9ff1cf..9ea63b4 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1223,19 +1223,19 @@ InsertBlockData ( // Insert block data in its Offset and Width order. // for (Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Link= ->ForwardLink) { BlockArray =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); if (BlockArray->Offset =3D=3D BlockSingleData->Offset) { - if (BlockArray->Width > BlockSingleData->Width) { + if ((BlockArray->Width > BlockSingleData->Width) || (BlockSingleData= ->IsBitVar && BlockArray->Width =3D=3D BlockSingleData->Width)) { // // Insert this block data in the front of block array // InsertTailList (Link, &BlockSingleData->Entry); return; } =20 - if (BlockArray->Width =3D=3D BlockSingleData->Width) { + if ((!BlockSingleData->IsBitVar) && BlockArray->Width =3D=3D BlockSi= ngleData->Width) { // // The same block array has been added. // if (BlockSingleData !=3D BlockArray) { FreePool (BlockSingleData); @@ -1978,10 +1978,11 @@ Done: @param HiiHandle The hii handle for this form package. @param VarStorageData The varstore data structure. @param IfrOpHdr Ifr opcode header for this opcode. @param VarWidth The buffer width for this opcode. @param ReturnData The data block added for this opcode. + @param IsBitVar Whether the the opcode refers to bit stor= age. =20 @retval EFI_SUCCESS This opcode is required. @retval EFI_NOT_FOUND This opcode is not required. @retval Others Contain some error. =20 @@ -1991,20 +1992,26 @@ IsThisOpcodeRequired ( IN IFR_BLOCK_DATA *RequestBlockArray, IN EFI_HII_HANDLE HiiHandle, IN OUT IFR_VARSTORAGE_DATA *VarStorageData, IN EFI_IFR_OP_HEADER *IfrOpHdr, IN UINT16 VarWidth, - OUT IFR_BLOCK_DATA **ReturnData + OUT IFR_BLOCK_DATA **ReturnData, + IN BOOLEAN IsBitVar ) { IFR_BLOCK_DATA *BlockData; UINT16 VarOffset; EFI_STRING_ID NameId; EFI_IFR_QUESTION_HEADER *IfrQuestionHdr; + UINT16 BitOffset; + UINT16 BitWidth; + UINT16 TotalBits; =20 NameId =3D 0; VarOffset =3D 0; + BitOffset =3D 0; + BitWidth =3D 0; IfrQuestionHdr =3D (EFI_IFR_QUESTION_HEADER *)((CHAR8 *) IfrOpHdr + siz= eof (EFI_IFR_OP_HEADER)); =20 if (VarStorageData->Type =3D=3D EFI_HII_VARSTORE_NAME_VALUE) { NameId =3D IfrQuestionHdr->VarStoreInfo.VarName; =20 @@ -2016,11 +2023,27 @@ IsThisOpcodeRequired ( // This question is not in the requested string. Skip it. // return EFI_NOT_FOUND; } } else { - VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + // + // Get the byte offset/with and bit offset/width + // + if (IsBitVar) { + BitOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + BitWidth =3D VarWidth; + VarOffset =3D BitOffset / 8; + // + // Use current bit width and the bit width before current bit (with = same byte offset) to calculate the byte width. + // + TotalBits =3D BitOffset % 8 + BitWidth; + VarWidth =3D (TotalBits % 8 =3D=3D 0 ? TotalBits / 8: TotalBits / 8 = + 1); + } else { + VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + BitWidth =3D VarWidth; + BitOffset =3D VarOffset * 8; + } =20 // // Check whether this question is in requested block array. // if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, H= iiHandle)) { @@ -2051,10 +2074,13 @@ IsThisOpcodeRequired ( =20 BlockData->Width =3D VarWidth; BlockData->QuestionId =3D IfrQuestionHdr->QuestionId; BlockData->OpCode =3D IfrOpHdr->OpCode; BlockData->Scope =3D IfrOpHdr->Scope; + BlockData->IsBitVar =3D IsBitVar; + BlockData->BitOffset =3D BitOffset; + BlockData->BitWidth =3D BitWidth; InitializeListHead (&BlockData->DefaultValueEntry); // // Add Block Data into VarStorageData BlockEntry // InsertBlockData (&VarStorageData->BlockEntry, &BlockData); @@ -2124,10 +2150,11 @@ ParseIfrData ( EFI_HII_PACKAGE_HEADER *PackageHeader; EFI_VARSTORE_ID VarStoreId; UINT16 SmallestDefaultId; BOOLEAN SmallestIdFromFlag; BOOLEAN FromOtherDefaultOpcode; + BOOLEAN QuestionReferBitField; =20 Status =3D EFI_SUCCESS; BlockData =3D NULL; DefaultDataPtr =3D NULL; FirstOneOfOption =3D FALSE; @@ -2135,10 +2162,11 @@ ParseIfrData ( FirstOrderedList =3D FALSE; VarStoreName =3D NULL; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); SmallestDefaultId =3D 0xFFFF; FromOtherDefaultOpcode =3D FALSE; + QuestionReferBitField =3D FALSE; =20 // // Go through the form package to parse OpCode one by one. // PackageOffset =3D sizeof (EFI_HII_PACKAGE_HEADER); @@ -2309,11 +2337,11 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2341,20 +2369,25 @@ ParseIfrData ( // IfrOneOf =3D (EFI_IFR_ONE_OF *) IfrOpHdr; if (IfrOneOf->Question.VarStoreId !=3D VarStoreId) { break; } - VarWidth =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE= )); + + if (QuestionReferBitField) { + VarWidth =3D IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE_BIT; + } else { + VarWidth =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SI= ZE)); + } =20 // // The BlockData may allocate by other opcode,need to clean. // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, QuestionReferBitField); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2376,30 +2409,37 @@ ParseIfrData ( } else if (IfrOpHdr->OpCode =3D=3D EFI_IFR_NUMERIC_OP) { // // Numeric minimum value will be used as default value when no def= ault is specified.=20 // DefaultData.Type =3D DefaultValueFromDefault; - switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - DefaultData.Value.u8 =3D IfrOneOf->data.u8.MinValue; - break; + if (QuestionReferBitField) { + // + // Since default value in bit field was stored as UINT32 type. + // + CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, s= izeof (UINT32)); + } else { + switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + DefaultData.Value.u8 =3D IfrOneOf->data.u8.MinValue; + break; =20 - case EFI_IFR_NUMERIC_SIZE_2: - CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, s= izeof (UINT16)); - break; + case EFI_IFR_NUMERIC_SIZE_2: + CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, = sizeof (UINT16)); + break; =20 - case EFI_IFR_NUMERIC_SIZE_4: - CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, s= izeof (UINT32)); - break; + case EFI_IFR_NUMERIC_SIZE_4: + CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue,= sizeof (UINT32)); + break; =20 - case EFI_IFR_NUMERIC_SIZE_8: - CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue, s= izeof (UINT64)); - break; + case EFI_IFR_NUMERIC_SIZE_8: + CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue,= sizeof (UINT64)); + break; =20 - default: - Status =3D EFI_INVALID_PARAMETER; - goto Done; + default: + Status =3D EFI_INVALID_PARAMETER; + goto Done; + } } // // Set default value base on the DefaultId list get from IFR data. // =20 for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { @@ -2439,11 +2479,11 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2484,11 +2524,14 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + if (QuestionReferBitField) { + VarWidth =3D 1; + } + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, QuestionReferBitField); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2515,11 +2558,15 @@ ParseIfrData ( if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT) =3D=3D EFI_IFR_C= HECKBOX_DEFAULT) { // // When flag is set, default value is TRUE. // DefaultData.Type =3D DefaultValueFromFlag; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } InsertDefaultValue (BlockData, &DefaultData); =20 if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_STANDARD) { // // Record the SmallestDefaultId and update the SmallestIdFromFla= g. @@ -2540,11 +2587,15 @@ ParseIfrData ( if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) =3D=3D EFI_I= FR_CHECKBOX_DEFAULT_MFG) { // // When flag is set, default value is TRUE. // DefaultData.Type =3D DefaultValueFromFlag; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } InsertDefaultValue (BlockData, &DefaultData); =20 if (SmallestDefaultId > EFI_HII_DEFAULT_CLASS_MANUFACTURING) { // // Record the SmallestDefaultId and update the SmallestIdFromFla= g. @@ -2556,11 +2607,15 @@ ParseIfrData ( if (SmallestIdFromFlag) { // // When smallest default Id is given by the flag of CheckBox, set= default value with TRUE for other default Id in the DefaultId list. // DefaultData.Type =3D DefaultValueFromOtherDefault; - DefaultData.Value.b =3D TRUE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D TRUE; + } else { + DefaultData.Value.b =3D TRUE; + } // // Set default value for all the default id in the DefaultId list. // for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); @@ -2570,11 +2625,15 @@ ParseIfrData ( } else { // // When flag is not set, default value is FASLE. // DefaultData.Type =3D DefaultValueFromDefault; - DefaultData.Value.b =3D FALSE; + if (QuestionReferBitField) { + DefaultData.Value.u32 =3D FALSE; + } else { + DefaultData.Value.b =3D FALSE; + } // // Set default value for all the default id in the DefaultId list. // for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData !=3D= &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); @@ -2612,11 +2671,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) sizeof (EFI_HII_DATE); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2654,11 +2713,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) sizeof (EFI_HII_TIME); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2696,11 +2755,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) (IfrString->MaxSize * sizeof (UINT16)); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2738,11 +2797,11 @@ ParseIfrData ( if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 VarWidth =3D (UINT16) (IfrPassword->MaxSize * sizeof (UINT16)); - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, FALSE); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2930,11 +2989,15 @@ ParseIfrData ( // // Prepare new DefaultValue // DefaultData.Type =3D DefaultValueFromOpcode; DefaultData.DefaultId =3D VarDefaultId; - CopyMem (&DefaultData.Value, &IfrDefault->Value, IfrDefault->Header.= Length - OFFSET_OF (EFI_IFR_DEFAULT, Value)); + if (QuestionReferBitField) { + CopyMem (&DefaultData.Value.u32, &IfrDefault->Value.u32, sizeof (U= INT32)); + } else { + CopyMem (&DefaultData.Value, &IfrDefault->Value, IfrDefault->Heade= r.Length - OFFSET_OF (EFI_IFR_DEFAULT, Value)); + } =20 // If the value field is expression, set the cleaned flag. if (IfrDefault->Type =3D=3D EFI_IFR_TYPE_OTHER) { DefaultData.Cleaned =3D TRUE; } @@ -2972,10 +3035,11 @@ ParseIfrData ( =20 case EFI_IFR_END_OP: // // End Opcode is for Var question. // + QuestionReferBitField =3D FALSE; if (BlockData !=3D NULL) { if (BlockData->Scope > 0) { BlockData->Scope--; } if (BlockData->Scope =3D=3D 0) { @@ -2988,10 +3052,16 @@ ParseIfrData ( } } =20 break; =20 + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_= HEADER)), &gEfiIfrBitvarstoreGuid)) { + QuestionReferBitField =3D TRUE; + } + break; + default: if (BlockData !=3D NULL) { if (BlockData->Scope > 0) { BlockData->Scope =3D (UINT8) (BlockData->Scope + IfrOpHdr->Scope= ); } @@ -3567,10 +3637,216 @@ GetStorageWidth ( =20 return StorageWidth; } =20 /** + Update the default value in the block data which is used as bit var stor= e. + + For example: + A question value saved in a bit fied: bitoffset =3D 1; bitwidth =3D 2;de= fault value =3D 1. + And corresponding block data info: offset=3D=3D0; width=3D=3D1;currently= the default value + is saved as 1.Actually the default value 1 need to be set to bit field 1= , so the + default value of this block data shuold be:2. + + typedef struct { + UINN8 Bit1 : 1; // + UINT8 Bit2 : 2; // Question saved in Bit2,so originalBlock info: offs= et =3D 0; width =3D 1;(byte level) defaul =3D 1. + // (default value record for the bit field) + ...... + }ExampleData; + + After function UpdateDefaultValue,the Block info is: offset =3D 0; width= =3D 1;(byte level) default =3D 2. + (default value reco= rd for the Block) + + UpdateDefaultValue function update default value of bit var block based = on the bit field info in the block. + + @param BlockLink The Link of the block data. + +**/ +VOID +UpdateDefaultValue ( + IN LIST_ENTRY *BlockLink +) +{ + LIST_ENTRY *Link; + LIST_ENTRY *ListEntry; + LIST_ENTRY *LinkDefault; + IFR_BLOCK_DATA *BlockData; + IFR_DEFAULT_DATA *DefaultValueData; + UINTN StartBit; + UINTN EndBit; + UINT32 *BitFieldDefaultValue; + UINT32 *ByteBlockDefaultValue; + + for ( Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Lin= k->ForwardLink) { + BlockData =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); + if (!BlockData ->IsBitVar) { + continue; + } + ListEntry =3D &BlockData->DefaultValueEntry; + // + // Update the default value in the block data with all existing defaul= t id. + // + for (LinkDefault =3D ListEntry->ForwardLink; LinkDefault !=3D ListEntr= y; LinkDefault =3D LinkDefault->ForwardLink) { + // + // Get the default data, and the value of the default data is for so= me field in the block. + // + DefaultValueData =3D BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry); + BitFieldDefaultValue =3D (UINT32*)&DefaultValueData->Value; + ByteBlockDefaultValue =3D (UINT32*)&DefaultValueData->Value; + + StartBit =3D BlockData->BitOffset % 8; + EndBit =3D StartBit + BlockData->BitWidth - 1; + + // + // Set the bit field default value to related bit filed, then we wil= l got the new default vaule for the block data. + // + *ByteBlockDefaultValue =3D BitFieldWrite32 (0, StartBit, EndBit, *Bi= tFieldDefaultValue); + } + } +} + +/** +Merge the default value in two block datas which have overlap region. + +For bit fields, their related block data may have overlap region, such as: + +typedef struct { + UINN16 Bit1 : 6; // Question1 refer Bit1, Block1: offset =3D 0; width = =3D 1;(byte level) default =3D 1 + UINT16 Bit2 : 5; // Question2 refer Bit2, Block2: offset =3D 0; width = =3D 2;(byte level) default =3D 5 + // (default value record for the bit field) + ...... +}ExampleData; + +After function UpdateDefaultValue: +Block1: offset =3D 0; width =3D 1;(byte level) default =3D 1 +Block2: offset =3D 0; width =3D 2;(byte level) default =3D 320 (5 * (2 << = 6)) +(default value record for block) + +After function MergeBlockDefaultValue: +Block1: offset =3D 0; width =3D 1;(byte level) default =3D 65 +Block2: offset =3D 0; width =3D 2;(byte level) default =3D 321 +(Block1 and Block2 has overlap region, merge the overlap value to Block1 a= nd Blcok2) + +Block1 and Block2 have overlap byte region, but currntly the default value= of Block1 only contains +value of Bit1 (low 6 bits),the default value of Block2 only contains the v= alue of Bit2 (middle 5 bits). + +This fuction merge the default value of these two blocks, and make the def= ault value of block1 +also contain the value of lower 2 bits of the Bit2. And make the default v= alue of Block2 also +contain the default value of Bit1. + +We can get the total value of the whole block that just cover these two bl= ocks(in this case is: +block: offset =3D0; width =3D2;) then the value of block2 is same as block= , the value of block1 is +the first byte value of block. + +@param FirstBlock Point to the block date whose default value need to= be merged. +@param SecondBlock Point to the block date whose default value need to= be merged. + +**/ +VOID +MergeBlockDefaultValue ( + IN OUT IFR_BLOCK_DATA *FirstBlock, + IN OUT IFR_BLOCK_DATA *SecondBlock +) +{ + LIST_ENTRY *FirstListEntry; + LIST_ENTRY *SecondListEntry; + LIST_ENTRY *FirstDefaultLink; + LIST_ENTRY *SecondDefaultLink; + IFR_DEFAULT_DATA *FirstDefaultValueData; + IFR_DEFAULT_DATA *SecondDefaultValueData; + UINT32 *FirstDefaultValue; + UINT32 *SecondDefaultValue; + UINT64 TotalValue; + UINT64 ShiftedValue; + UINT16 OffsetShift; + + FirstListEntry =3D &FirstBlock->DefaultValueEntry; + for (FirstDefaultLink =3D FirstListEntry->ForwardLink; FirstDefaultLink = !=3D FirstListEntry; FirstDefaultLink =3D FirstDefaultLink->ForwardLink) { + FirstDefaultValueData =3D BASE_CR (FirstDefaultLink, IFR_DEFAULT_DATA,= Entry); + SecondListEntry =3D &SecondBlock->DefaultValueEntry; + for (SecondDefaultLink =3D SecondListEntry->ForwardLink; SecondDefault= Link !=3D SecondListEntry; SecondDefaultLink =3D SecondDefaultLink->Forward= Link) { + SecondDefaultValueData =3D BASE_CR (SecondDefaultLink, IFR_DEFAULT_D= ATA, Entry); + if (FirstDefaultValueData->DefaultId !=3D SecondDefaultValueData->De= faultId) { + continue; + } + // + // Find default value with same default id in the two blocks. + // + FirstDefaultValue =3D (UINT32*)&(FirstDefaultValueData->Value); + SecondDefaultValue =3D (UINT32*)&(SecondDefaultValueData->Value); + // + // 1. Get the default value of the whole blcok that can just cover F= irstBlock and SecondBlock. + // 2. Get the default value of FirstBlock and SecondBlock form the v= alue of whole block based + // on the offset and width of FirstBlock and SecondBlock. + // + if (FirstBlock->Offset > SecondBlock->Offset) { + OffsetShift =3D FirstBlock->Offset - SecondBlock->Offset; + ShiftedValue =3D LShiftU64 ((UINT64)*FirstDefaultValue, OffsetShif= t * 8); + TotalValue =3D ShiftedValue | (UINT64)(*SecondDefaultValue); + *SecondDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, 0, Se= condBlock->Width * 8 -1); + *FirstDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, Offset= Shift * 8, OffsetShift * 8 + FirstBlock->Width *8 -1); + } else { + OffsetShift =3D SecondBlock->Offset -FirstBlock->Offset; + ShiftedValue =3D LShiftU64 ((UINT64)*SecondDefaultValue, OffsetShi= ft * 8); + TotalValue =3D ShiftedValue | (UINT64)(*FirstDefaultValue); + *FirstDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, 0, Fir= stBlock->Width * 8 -1); + *SecondDefaultValue =3D (UINT32) BitFieldRead64 (TotalValue, Offse= tShift * 8, OffsetShift * 8 + SecondBlock->Width *8 -1); + } + } + } +} + +/** + +Update the default value in the block data which used as Bit VarStore + +@param BlockLink The Link of the block data. + +**/ +VOID +UpdateBlockDataArray ( + IN LIST_ENTRY *BlockLink +) +{ + LIST_ENTRY *Link; + LIST_ENTRY *TempLink; + IFR_BLOCK_DATA *BlockData; + IFR_BLOCK_DATA *NextBlockData; + + // + // 1. Update default value in BitVar block data. + // Sine some block datas are used as BitVarStore, then the default value= recored in the block + // is for related bit field in the block. so we need to set the default = value to the related bit + // fields in the block data if the block data is used as bit varstore, t= hen the default value of + // the block will be updated. + // + UpdateDefaultValue (BlockLink); + + // + // 2.Update default value for overlap BitVar blcok datas. + // For block datas have overlap region, we need to merge the default val= ue in different blocks. + // + for (Link =3D BlockLink->ForwardLink; Link !=3D BlockLink; Link =3D Link= ->ForwardLink) { + BlockData =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); + if (!BlockData ->IsBitVar) { + continue; + } + for (TempLink =3D Link->ForwardLink; TempLink !=3D BlockLink; TempLink= =3D TempLink->ForwardLink) { + NextBlockData =3D BASE_CR (TempLink, IFR_BLOCK_DATA, Entry); + if (!NextBlockData->IsBitVar || NextBlockData->Offset >=3D BlockData= ->Offset + BlockData->Width || BlockData->Offset >=3D NextBlockData->Offset= + NextBlockData->Width) { + continue; + } + // + // Find two blocks are used as bit VarStore and have overlap region,= so need to merge default value of these two blocks. + // + MergeBlockDefaultValue (BlockData, NextBlockData); + } + } +} + +/** Generate ConfigAltResp string base on the varstore info. =20 @param HiiHandle Hii Handle for this hii package. @param ConfigHdr The config header for this varstore. @param VarStorageData The varstore info. @@ -3610,10 +3886,12 @@ GenerateAltConfigResp ( // // Add length for + '\0' // Length =3D StrLen (ConfigHdr) + 1; =20 + UpdateBlockDataArray (&VarStorageData->BlockEntry); + for (Link =3D DefaultIdArray->Entry.ForwardLink; Link !=3D &DefaultIdArr= ay->Entry; Link =3D Link->ForwardLink) { DefaultId =3D BASE_CR (Link, IFR_DEFAULT_DATA, Entry); // // Add length for "&&ALTCFG=3DXXXX" // |1| StrLen (ConfigHdr) | 8 | 4 | diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModul= ePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index e6760c3..320754c 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -1,9 +1,9 @@ /** @file Private structures definitions in HiiDatabase. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 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 @@ -29,10 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include =20 #include #include +#include =20 =20 #include #include #include @@ -75,15 +76,18 @@ typedef struct { =20 typedef struct { LIST_ENTRY Entry; // Link to Block array UINT16 Offset; UINT16 Width; + UINT16 BitOffset; + UINT16 BitWidth; EFI_QUESTION_ID QuestionId; UINT8 OpCode; UINT8 Scope; LIST_ENTRY DefaultValueEntry; // Link to its default value array CHAR16 *Name; + BOOLEAN IsBitVar; } IFR_BLOCK_DATA; =20 // // Get default value from IFR data. // diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/Mde= ModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf index 6bb1d03..9f99c2c 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -2,11 +2,11 @@ # The DXE driver produces HII protocols defined in UEFI specification. # # This driver produces all required HII serivces that includes HiiDataBase= , HiiString, # HiiFont, HiiConfigRouting. To support UEFI HII, this driver is required. # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials =20 # are licensed and made available under the terms and conditions of the B= SD License =20 # which accompanies this distribution. The full text of the license may b= e found at =20 # http://opensource.org/licenses/bsd-license.php =20 @@ -88,10 +88,11 @@ ## CONSUMES ## Event ## PRODUCES ## Event gEfiHiiKeyBoardLayoutGuid gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSuppo= rtHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSuppo= rtHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID + gEfiIfrBitvarstoreGuid = ## SOMETIMES_CONSUMES ## GUID =20 [Depex] TRUE =20 [UserExtensions.TianoCore."ExtraFiles"] --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 15054566871621011.4912258674688; Thu, 14 Sep 2017 23:24:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D267921EA35BC; Thu, 14 Sep 2017 23:21:39 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 D4C7721EA35AB for ; Thu, 14 Sep 2017 23:21:38 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:38 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:37 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617275" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:42 +0800 Message-Id: <1505456623-414328-6-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 5/6] MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore 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: Eric Dong , Liming Gao 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: Use API BitFieldRead/Write to replace the same logic in the codes. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 For oneof/numeric/CheckBox(storage can be Bit VarStore) If the question value can be updated and shown correctly in UI page, we need do enhancements in following cases: 1. Parse the Ifr data to get the bit VarStore info correctly. 2. Set/get value to/from bit VarStore correctly. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 138 ++++++++++++++++-= ---- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 110 ++++++++++++++-- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 + .../Universal/SetupBrowserDxe/SetupBrowserDxe.inf | 3 +- 4 files changed, 212 insertions(+), 42 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModuleP= kg/Universal/SetupBrowserDxe/IfrParse.c index 6b3e5e0..821e282 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -57,10 +57,11 @@ CreateStatement ( =20 Statement->Signature =3D FORM_BROWSER_STATEMENT_SIGNATURE; =20 Statement->Operand =3D ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode; Statement->OpCode =3D (EFI_IFR_OP_HEADER *) OpCodeData; + Statement->QuestionReferToBitField =3D FALSE; =20 StatementHdr =3D (EFI_IFR_STATEMENT_HEADER *) (OpCodeData + sizeof (EFI_= IFR_OP_HEADER)); CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_I= D)); CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID)); =20 @@ -1312,10 +1313,12 @@ ParseOpCodes ( BOOLEAN InUnknownScope; UINT8 UnknownDepth; FORMSET_DEFAULTSTORE *PreDefaultStore; LIST_ENTRY *DefaultLink; BOOLEAN HaveInserted; + UINT16 TotalBits; + BOOLEAN QuestionReferBitField; =20 SuppressForQuestion =3D FALSE; SuppressForOption =3D FALSE; InScopeDisable =3D FALSE; DepthOfDisable =3D 0; @@ -1333,10 +1336,11 @@ ParseOpCodes ( MapExpressionList =3D NULL; TempVarstoreId =3D 0; ConditionalExprCount =3D 0; InUnknownScope =3D FALSE; UnknownDepth =3D 0; + QuestionReferBitField =3D FALSE; =20 // // Get the number of Statements and Expressions // CountOpCodes (FormSet, &NumberOfStatement, &NumberOfExpression); @@ -1978,47 +1982,98 @@ ParseOpCodes ( ASSERT(CurrentStatement !=3D NULL); =20 CurrentStatement->Flags =3D ((EFI_IFR_ONE_OF *) OpCodeData)->Flags; Value =3D &CurrentStatement->HiiValue; =20 - switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) { - case EFI_IFR_NUMERIC_SIZE_1: - CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.MinValue; - CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.MaxValue; - CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u8.Step; - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT8); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; - break; + if (QuestionReferBitField) { + // + // Get the bit var store info (bit/byte offset, bit/byte offset) + // + CurrentStatement->QuestionReferToBitField =3D TRUE; + CurrentStatement->BitStorageWidth =3D CurrentStatement->Flags & EF= I_IFR_NUMERIC_SIZE_BIT; + CurrentStatement->BitVarOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Bit= VarOffset / 8; + TotalBits =3D CurrentStatement->BitVarOffset % 8 + CurrentStatemen= t->BitStorageWidth; + CurrentStatement->StorageWidth =3D (TotalBits % 8 =3D=3D 0? TotalB= its / 8: TotalBits / 8 + 1); =20 - case EFI_IFR_NUMERIC_SIZE_2: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.MinValue, sizeof (UINT16)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.MaxValue, sizeof (UINT16)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u16.Step, sizeof (UINT16)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT16); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; - break; + // + // Get the Minimum/Maximum/Step value(Note: bit field type has bee= n stored as UINT32 type) + // + CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.MinValue; + CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.MaxValue; + CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->da= ta.u32.Step; =20 - case EFI_IFR_NUMERIC_SIZE_4: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.MinValue, sizeof (UINT32)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.MaxValue, sizeof (UINT32)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u32.Step, sizeof (UINT32)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT32); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; - break; + // + // Update the Flag and type of Minimum/Maximum/Step according to t= he actual width of bit field, + // in order to make Browser handle these question with bit varstor= e correctly. + // + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D EFI_IFR_DISPLAY_BIT; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags >>=3D 2; + switch (CurrentStatement->StorageWidth) { + case 1: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NUM_SI= ZE_8; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue =3D (UINT8)Cu= rrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue =3D (UINT8)Cu= rrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step =3D (UINT8)Curren= tStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; + break; + case 2: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NUM_SI= ZE_16; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue =3D (UINT16)= CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue =3D (UINT16)= CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step =3D (UINT16)Curr= entStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; + break; + case 3: + case 4: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NUM_SI= ZE_32; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue =3D (UINT32)= CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue =3D (UINT32)= CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step =3D (UINT32)Curr= entStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + default: + break; + } + } else { + switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + CurrentStatement->Minimum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.MinValue; + CurrentStatement->Maximum =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.MaxValue; + CurrentStatement->Step =3D ((EFI_IFR_NUMERIC *) OpCodeData)->= data.u8.Step; + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT8); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; + break; =20 - case EFI_IFR_NUMERIC_SIZE_8: - CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.MinValue, sizeof (UINT64)); - CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.MaxValue, sizeof (UINT64)); - CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeD= ata)->data.u64.Step, sizeof (UINT64)); - CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT64); - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64; - break; + case EFI_IFR_NUMERIC_SIZE_2: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.MinValue, sizeof (UINT16)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.MaxValue, sizeof (UINT16)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u16.Step, sizeof (UINT16)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT16); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; + break; =20 - default: - break; - } + case EFI_IFR_NUMERIC_SIZE_4: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.MinValue, sizeof (UINT32)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.MaxValue, sizeof (UINT32)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u32.Step, sizeof (UINT32)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT32); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + + case EFI_IFR_NUMERIC_SIZE_8: + CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.MinValue, sizeof (UINT64)); + CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.MaxValue, sizeof (UINT64)); + CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCod= eData)->data.u64.Step, sizeof (UINT64)); + CurrentStatement->StorageWidth =3D (UINT16) sizeof (UINT64); + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64; + break; =20 + default: + break; + } + } InitializeRequestElement (FormSet, CurrentStatement, CurrentForm); =20 if ((Operand =3D=3D EFI_IFR_ONE_OF_OP) && Scope !=3D 0) { SuppressForOption =3D TRUE; } @@ -2045,10 +2100,22 @@ ParseOpCodes ( =20 CurrentStatement->Flags =3D ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags; CurrentStatement->StorageWidth =3D (UINT16) sizeof (BOOLEAN); CurrentStatement->HiiValue.Type =3D EFI_IFR_TYPE_BOOLEAN; =20 + if (QuestionReferBitField) { + // + // Get the bit var store info (bit/byte offset, bit/byte offset) + // + CurrentStatement->QuestionReferToBitField =3D TRUE; + CurrentStatement->BitStorageWidth =3D 1; + CurrentStatement->BitVarOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Bit= VarOffset / 8; + TotalBits =3D CurrentStatement->BitVarOffset % 8 + CurrentStatemen= t->BitStorageWidth; + CurrentStatement->StorageWidth =3D (TotalBits % 8 =3D=3D 0? TotalB= its / 8: TotalBits / 8 + 1); + } + InitializeRequestElement (FormSet, CurrentStatement, CurrentForm); =20 break; =20 case EFI_IFR_STRING_OP: @@ -2592,18 +2659,23 @@ ParseOpCodes ( break; =20 // // Vendor specific // - case EFI_IFR_GUID_OP: =20 + case EFI_IFR_GUID_OP: CurrentStatement =3D CreateStatement (OpCodeData, FormSet, CurrentFo= rm); + if (CompareGuid ((EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER= )), &gEfiIfrBitvarstoreGuid)) { + Scope =3D 0; + QuestionReferBitField =3D TRUE; + } break; =20 // // Scope End // case EFI_IFR_END_OP: + QuestionReferBitField =3D FALSE; Status =3D PopScope (&ScopeOpCode); if (EFI_ERROR (Status)) { ResetScopeStack (); return Status; } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.c index 89e06de..e95e543 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1367,10 +1367,68 @@ ConfigRespToStorage ( =20 return Status; } =20 /** + Get bit field value from the buffer and then set the value for the quest= ion. + Note: Data type UINT32 can cover all the bit field value. + + @param Question The question refer to bit field. + @param Buffer Point to the buffer which the question value get= from. + +**/ +VOID +GetBitsQuestionValue ( + IN FORM_BROWSER_STATEMENT *Question, + IN UINT32 *Buffer + ) +{ + UINTN StartBit; + UINTN EndBit; + UINT32 Value; + + StartBit =3D Question->BitVarOffset % 8; + EndBit =3D StartBit + Question->BitStorageWidth - 1; + + Value =3D BitFieldRead32 (*Buffer, StartBit, EndBit); + + // + // Set question value. + // Note: Since Question with BufferValue (orderedlist, password, string)= are not supported to refer bit field. + // Only oneof/checkbox/oneof can support bit field.So we can copy the va= lue to the Hiivalue of Question directly. + // + CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8*)&Value, Question->= StorageWidth); +} + +/** + Set bit field value to the buffer. + Note: Data type UINT32 can cover all the bit field value. + + @param Question The question refer to bit field. + @param Buffer Point to the buffer which the question value set= to. + @param Value The bit field value need to set. + +**/ +VOID +SetBitsQuestionValue ( + IN FORM_BROWSER_STATEMENT *Question, + IN OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + UINT32 Operand; + UINTN StartBit; + UINTN EndBit; + + StartBit =3D Question->BitVarOffset % 8; + EndBit =3D StartBit + Question->BitStorageWidth - 1; + Operand =3D *Buffer; + + *Buffer =3D BitFieldWrite32 (Operand, StartBit, EndBit, Value); +} + +/** Convert the buffer value to HiiValue. =20 @param Question The question. @param Value Unicode buffer save the question value. =20 @@ -1393,10 +1451,13 @@ BufferToValue ( UINTN Index; UINT8 DigitUint8; BOOLEAN IsString; UINTN Length; EFI_STATUS Status; + UINT8 *Buffer; + + Buffer =3D NULL; =20 IsString =3D (BOOLEAN) ((Question->HiiValue.Type =3D=3D EFI_IFR_TYPE_STR= ING) ? TRUE : FALSE); if (Question->Storage->Type =3D=3D EFI_HII_VARSTORE_BUFFER ||=20 Question->Storage->Type =3D=3D EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)= { IsBufferStorage =3D TRUE; @@ -1414,11 +1475,17 @@ BufferToValue ( Dst =3D Question->BufferValue; } else { // // Other type of Questions // - Dst =3D (UINT8 *) &Question->HiiValue.Value; + if (Question->QuestionReferToBitField) { + Buffer =3D (UINT8 *)AllocateZeroPool (Question->StorageWidth); + ASSERT (Buffer !=3D NULL); + Dst =3D Buffer; + } else { + Dst =3D (UINT8 *) &Question->HiiValue.Value; + } } =20 // // Temp cut at the end of this section, end with '\0' or '&'. // @@ -1472,10 +1539,17 @@ BufferToValue ( } } =20 *StringPtr =3D TempChar; =20 + if (Question->QuestionReferToBitField) { + GetBitsQuestionValue (Question, (UINT32*) Buffer); + if (Buffer !=3D NULL) { + FreePool (Buffer); + } + } + return Status; } =20 /** Get Question's current Value. @@ -1676,17 +1750,27 @@ GetQuestionValue ( if (GetValueFrom =3D=3D GetSetValueWithEditBuffer || GetValueFrom =3D=3D= GetSetValueWithBuffer ) { if (IsBufferStorage) { if (GetValueFrom =3D=3D GetSetValueWithEditBuffer) { // // Copy from storage Edit buffer + // If the Question refer to bit filed, get the value in the relate= d bit filed. // - CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffs= et, StorageWidth); + if (Question->QuestionReferToBitField) { + GetBitsQuestionValue (Question, (UINT32*)(Storage->EditBuffer + = Question->VarStoreInfo.VarOffset)); + } else { + CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset, StorageWidth); + } } else { // // Copy from storage Edit buffer + // If the Question refer to bit filed, get the value in the relate= d bit filed. // - CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, = StorageWidth); + if (Question->QuestionReferToBitField) { + GetBitsQuestionValue (Question, (UINT32*)(Storage->Buffer + Ques= tion->VarStoreInfo.VarOffset)); + } else { + CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset= , StorageWidth); + } } } else { Value =3D NULL; Status =3D GetValueByName (Storage, Question->VariableName, &Value, = GetValueFrom); if (EFI_ERROR (Status)) { @@ -1948,17 +2032,27 @@ SetQuestionValue ( if (SetValueTo =3D=3D GetSetValueWithEditBuffer || SetValueTo =3D=3D Get= SetValueWithBuffer) { if (IsBufferStorage) { if (SetValueTo =3D=3D GetSetValueWithEditBuffer) { // // Copy to storage edit buffer - // =20 - CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, S= rc, StorageWidth); + // If the Question refer to bit filed, copy the value in related b= it filed to storage edit buffer. + // + if (Question->QuestionReferToBitField) { + SetBitsQuestionValue (Question, (UINT32*)(Storage->EditBuffer + = Question->VarStoreInfo.VarOffset), (UINT32)(*Src)); + } else { + CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset,= Src, StorageWidth); + } } else if (SetValueTo =3D=3D GetSetValueWithBuffer) { // - // Copy to storage edit buffer - // =20 - CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, = StorageWidth); + // Copy to storage buffer + // If the Question refer to bit filed, copy the value in related b= it filed to storage buffer. + // + if (Question->QuestionReferToBitField) { + SetBitsQuestionValue (Question, (UINT32*)(Storage->Buffer + Ques= tion->VarStoreInfo.VarOffset), (UINT32)(*Src)); + } else { + CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src= , StorageWidth); + } } } else { if (IsString) { // // Allocate enough string buffer. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.h index de140e9..09e0be7 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -327,11 +327,14 @@ struct _FORM_BROWSER_STATEMENT{ EFI_QUESTION_ID QuestionId; // The value of zero is reserved EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no = variable storage BROWSER_STORAGE *Storage; VAR_STORE_INFO VarStoreInfo; UINT16 StorageWidth; + UINT16 BitStorageWidth; + UINT16 BitVarOffset; UINT8 QuestionFlags; + BOOLEAN QuestionReferToBitField;// Whether the question is= stored in a bit field. CHAR16 *VariableName; // Name/Value or EFI Variable na= me CHAR16 *BlockName; // Buffer storage block name: "O= FFSET=3D...WIDTH=3D..." =20 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numbe= ric, oneof UINT8 *BufferValue; // Edit copy for string, passwor= d, orderedlist diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf b/M= deModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf index 012a39b..f979a2f 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf +++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf @@ -1,11 +1,11 @@ ## @file # The DXE driver produces FORM BROWSER2 protocol defined in UEFI specifica= tion. # # It also produces FormBrowserEx(2) protocol to let user register the diff= erent Hot key service.=20 # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may b= e found at # http://opensource.org/licenses/bsd-license.php @@ -60,10 +60,11 @@ [Guids] gEfiIfrFrameworkGuid ## SOMETIMES_CONSUMES ## = GUID gEfiHiiPlatformSetupFormsetGuid ## SOMETIMES_CONSUMES ## = GUID gEfiHiiStandardFormGuid ## SOMETIMES_CONSUMES ## = GUID gZeroGuid ## SOMETIMES_CONSUMES ## = GUID + gEfiIfrBitvarstoreGuid ## SOMETIMES_CONSUMES ## = GUID =20 [Protocols] gEfiHiiConfigAccessProtocolGuid ## SOMETIMES_CONSUMES gEfiFormBrowser2ProtocolGuid ## PRODUCES gEdkiiFormBrowserEx2ProtocolGuid ## PRODUCES --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 18:13:13 2024 Delivered-To: importer@patchew.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; 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 1505456690833560.0198354011759; Thu, 14 Sep 2017 23:24:50 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1AA8621EA35AF; Thu, 14 Sep 2017 23:21:42 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 1515C21EA35A9 for ; Thu, 14 Sep 2017 23:21:41 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 14 Sep 2017 23:24:40 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2017 23:24:39 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,396,1500966000"; d="scan'208";a="135617283" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 15 Sep 2017 14:23:43 +0800 Message-Id: <1505456623-414328-7-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> References: <1505456623-414328-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [PATCH v3 6/6] MdeModulePkg/DriverSample: Add sample questions with bit/union VarStore 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: Eric Dong , Liming Gao 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" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D545 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Universal/DriverSampleDxe/DriverSample.c | 120 ++++++++++++++ .../Universal/DriverSampleDxe/DriverSample.h | 2 + .../Universal/DriverSampleDxe/NVDataStruc.h | 34 +++- MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 172 +++++++++++++++++= ++++ .../Universal/DriverSampleDxe/VfrStrings.uni | 63 ++++++++ 5 files changed, 390 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.c index bbd9713..af31615 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -18,10 +18,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 #define DISPLAY_ONLY_MY_ITEM 0x0002 =20 CHAR16 VariableName[] =3D L"MyIfrNVData"; CHAR16 MyEfiVar[] =3D L"MyEfiVar"; +CHAR16 MyEfiBitVar[] =3D L"MyEfiBitVar"; +CHAR16 MyEfiUnionVar[] =3D L"MyEfiUnionVar"; + EFI_HANDLE DriverHandle[2] =3D {NULL, NULL}; DRIVER_SAMPLE_PRIVATE_DATA *mPrivateData =3D NULL; EFI_EVENT mEvent; =20 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 =3D { @@ -662,10 +665,17 @@ ExtractConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiVar))= { return EFI_UNSUPPORTED; } + if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiBitVa= r)) { + return EFI_UNSUPPORTED; + } + if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiUnion= Var)) { + return EFI_UNSUPPORTED; + } + // // Set Request to the unified request string. // ConfigRequest =3D Request; // @@ -883,10 +893,16 @@ RouteConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiV= ar)) { return EFI_UNSUPPORTED; } + if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiB= itVar)) { + return EFI_UNSUPPORTED; + } + if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiU= nionVar)) { + return EFI_UNSUPPORTED; + } =20 // // Get Buffer Storage data from EFI variable // BufferSize =3D sizeof (DRIVER_SAMPLE_CONFIGURATION); @@ -1295,10 +1311,14 @@ DriverCallback ( for (Index =3D 0; Index < 3; Index ++) { SetArrayData (Value, EFI_IFR_TYPE_NUM_SIZE_8, Index, BufferValue= --); } break; =20 + case 0x6666: + Value->u8 =3D 12; + break; + default: Status =3D EFI_UNSUPPORTED; break; } } @@ -1309,10 +1329,14 @@ DriverCallback ( switch (QuestionId) { case 0x1240: Value->u8 =3D DEFAULT_CLASS_MANUFACTURING_VALUE; break; =20 + case 0x6666: + Value->u8 =3D 13; + break; + default: Status =3D EFI_UNSUPPORTED; =20 break; } } @@ -1703,10 +1727,12 @@ DriverSampleInit ( DRIVER_SAMPLE_CONFIGURATION *Configuration; BOOLEAN ActionFlag; EFI_STRING ConfigRequestHdr; EFI_STRING NameRequestHdr; MY_EFI_VARSTORE_DATA *VarStoreConfig; + MY_EFI_BITS_VARSTORE_DATA *BitsVarStoreConfig; + MY_EFI_UNION_DATA *UnionConfig; EFI_INPUT_KEY HotKey; EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx; =20 // // Initialize the local variables. @@ -1991,10 +2017,104 @@ DriverSampleInit ( return EFI_INVALID_PARAMETER; } } FreePool (ConfigRequestHdr); =20 + // + // Initialize Bits efi varstore configuration data + // + BitsVarStoreConfig =3D &mPrivateData->BitsVarStoreConfig; + ZeroMem (BitsVarStoreConfig, sizeof (MY_EFI_BITS_VARSTORE_DATA)); + + ConfigRequestHdr =3D HiiConstructConfigHdr (&gDriverSampleFormSetGuid, M= yEfiBitVar, DriverHandle[0]); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (MY_EFI_BITS_VARSTORE_DATA); + Status =3D gRT->GetVariable (MyEfiBitVar, &gDriverSampleFormSetGuid, NUL= L, &BufferSize, BitsVarStoreConfig); + if (EFI_ERROR (Status)) { + // + // Store zero data to EFI variable Storage. + // + Status =3D gRT->SetVariable( + MyEfiBitVar, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (MY_EFI_BITS_VARSTORE_DATA), + BitsVarStoreConfig + ); + if (EFI_ERROR (Status)) { + DriverSampleUnload (ImageHandle); + return Status; + } + // + // EFI variable for NV config doesn't exit, we should build this varia= ble + // based on default values stored in IFR + // + ActionFlag =3D HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLA= SS_STANDARD); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } else { + // + // EFI variable does exist and Validate Current Setting + // + ActionFlag =3D HiiValidateSettings (ConfigRequestHdr); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } + FreePool (ConfigRequestHdr); + + // + // Initialize Union efi varstore configuration data + // + UnionConfig =3D &mPrivateData->UnionConfig; + ZeroMem (UnionConfig, sizeof (MY_EFI_UNION_DATA)); + + ConfigRequestHdr =3D HiiConstructConfigHdr (&gDriverSampleFormSetGuid, M= yEfiUnionVar, DriverHandle[0]); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (MY_EFI_UNION_DATA); + Status =3D gRT->GetVariable (MyEfiUnionVar, &gDriverSampleFormSetGuid, N= ULL, &BufferSize, UnionConfig); + if (EFI_ERROR (Status)) { + // + // Store zero data to EFI variable Storage. + // + Status =3D gRT->SetVariable( + MyEfiUnionVar, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (MY_EFI_UNION_DATA), + UnionConfig + ); + if (EFI_ERROR (Status)) { + DriverSampleUnload (ImageHandle); + return Status; + } + // + // EFI variable for NV config doesn't exit, we should build this varia= ble + // based on default values stored in IFR + // + ActionFlag =3D HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLA= SS_STANDARD); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } else { + // + // EFI variable does exist and Validate Current Setting + // + ActionFlag =3D HiiValidateSettings (ConfigRequestHdr); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } + FreePool (ConfigRequestHdr); + Status =3D gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL,=20 TPL_NOTIFY, EfiEventEmptyFunction, NULL, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.h index 507cff6..00752bf 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -83,10 +83,12 @@ typedef struct { =20 EFI_HANDLE DriverHandle[2]; EFI_HII_HANDLE HiiHandle[2]; DRIVER_SAMPLE_CONFIGURATION Configuration; MY_EFI_VARSTORE_DATA VarStoreConfig; + MY_EFI_BITS_VARSTORE_DATA BitsVarStoreConfig; + MY_EFI_UNION_DATA UnionConfig; =20 // // Name/Value storage Name list // EFI_STRING_ID NameStringId[NAME_VALUE_NAME_NUMBER]; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModu= lePkg/Universal/DriverSampleDxe/NVDataStruc.h index 195cc8a..40fb3d0 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -1,8 +1,8 @@ /** @file =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 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 @@ -29,12 +29,28 @@ Revision History: #include #include #include =20 #define CONFIGURATION_VARSTORE_ID 0x1234 +#define BITS_VARSTORE_ID 0x2345 =20 #pragma pack(1) + +typedef struct { + UINT16 NestByteField; + UINT8 : 1; // unamed field can be used for padding + UINT8 NestBitCheckbox : 1; + UINT8 NestBitOneof : 2; + UINT8 : 0; // Special width 0 can be used to force a= lignment at the next word boundary + UINT8 NestBitNumeric : 4; +} MY_BITS_DATA; + +typedef union { + UINT16 BitField : 10; + UINT8 ByteField; +} MY_EFI_UNION_DATA; + typedef struct { UINT16 MyStringData[40]; UINT16 SomethingHiddenForHtml; UINT8 HowOldAreYouInYearsManual; UINT16 HowTallAreYouManual; @@ -65,10 +81,15 @@ typedef struct { UINT8 GetDefaultValueFromAccess; EFI_HII_TIME Time; UINT8 RefreshGuidCount; UINT8 Match2; UINT8 GetDefaultValueFromCallBackForOrderedList[3]; + UINT8 BitCheckbox : 1; + UINT16 BitOneof : 6; + UINT16 BitNumeric : 12; + MY_BITS_DATA MyBitData; + MY_EFI_UNION_DATA MyUnionData; } DRIVER_SAMPLE_CONFIGURATION; =20 // // 2nd NV data structure definition // @@ -78,10 +99,21 @@ typedef struct { UINT8 OrderedList[3]; UINT16 SubmittedCallback; } MY_EFI_VARSTORE_DATA; =20 // +// 3rd NV data structure definition +// +typedef struct { + MY_BITS_DATA BitsData; + UINT32 EfiBitGrayoutTest : 5; + UINT32 EfiBitNumeric : 4; + UINT32 EfiBitOneof : 10; + UINT32 EfiBitCheckbox : 1; +} MY_EFI_BITS_VARSTORE_DATA; + +// // Labels definition // #define LABEL_UPDATE1 0x1234 #define LABEL_UPDATE2 0x2234 #define LABEL_UPDATE3 0x3234 diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/= Universal/DriverSampleDxe/Vfr.vfr index d547ec8..c168291 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -86,10 +86,23 @@ formset attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures =20 name =3D MyEfiVar, guid =3D DRIVER_SAMPLE_FORMSET_GUID; =20 // + // Define a Buffer Storage (EFI_IFR_VARSTORE) + // + efivarstore MY_EFI_BITS_VARSTORE_DATA, = // This is the data structure type + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures + name =3D MyEfiBitVar, = // Define referenced name in vfr + guid =3D DRIVER_SAMPLE_FORMSET_GUID; = // GUID of this buffer storage + + efivarstore MY_EFI_UNION_DATA, + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures + name =3D MyEfiUnionVar, + guid =3D DRIVER_SAMPLE_FORMSET_GUID; + + // // Define a Name/Value Storage (EFI_IFR_VARSTORE_NAME_VALUE) // namevaluevarstore MyNameValueVar, // Define storage refer= ence name in vfr name =3D STRING_TOKEN(STR_NAME_VALUE_VAR_NAME0), // Define Name list o= f this storage, refer it by MyNameValueVar[0] name =3D STRING_TOKEN(STR_NAME_VALUE_VAR_NAME1), // Define Name list o= f this storage, refer it by MyNameValueVar[1] @@ -516,10 +529,13 @@ formset data.Field8 =3D 0x21,=20 data.Field16 =3D 0x2121, data.OrderedList[0] =3D 0x21, =20 endguidop; =20 + goto 7, + prompt =3D STRING_TOKEN(STR_GOTO_FORM7), + help =3D STRING_TOKEN(STR_GOTO_FORM7_HELP); =20 endform; =20 suppressif ideqval MyIfrNVData.BootOrderLarge =3D=3D 0; form formid =3D 2, // SecondSetupPage, @@ -778,6 +794,162 @@ formset // label LABEL_END; =20 endform; =20 + + form formid =3D 7, // Form to show the question= refer to union and bit Varstore + title =3D STRING_TOKEN(STR_FORM7_TITLE); + + subtitle text =3D STRING_TOKEN(STR_NEST_BIT_EFI_VARSTORE); + + checkbox varid =3D MyEfiBitVar.BitsData.NestBitCheckbox, + prompt =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyEfiBitVar.BitsData.NestBitOneof, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + numeric varid =3D MyEfiBitVar.BitsData.NestBitNumeric, + questionid =3D 0x6666, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_DEFAULT_HELP), + flags =3D DISPLAY_UINT_HEX | INTERACTIVE, + minimum =3D 2, + maximum =3D 15, + step =3D 1, + endnumeric; + + oneof varid =3D MyEfiBitVar.BitsData.NestByteField, + prompt =3D STRING_TOKEN(BYTE_QUESTION_NEST_BIT_PROMPT), + help =3D STRING_TOKEN(BYTE_QUESTION_NEST_BIT_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); + subtitle text =3D STRING_TOKEN(STR_BIT_EFI_VARSTORE); + + checkbox varid =3D MyEfiBitVar.EfiBitCheckbox, + prompt =3D STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_BIT_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + grayoutif ideqval MyEfiBitVar.EfiBitGrayoutTest =3D=3D 0; + numeric varid =3D MyEfiBitVar.EfiBitNumeric, + prompt =3D STRING_TOKEN(STR_BIT_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_BIT_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 4, defaultstore =3D MyStandardDefault, + default =3D 5, defaultstore =3D MyManufactureDefault, + endnumeric; + endif; + + oneof varid =3D MyEfiBitVar.EfiBitOneof, + questionid =3D 0x9999, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_BIT_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0x0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 0x1, flags = =3D DEFAULT; + endoneof; + + subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); + subtitle text =3D STRING_TOKEN(STR_NEST_BIT_VARSTORE); + checkbox varid =3D MyIfrNVData.MyBitData.NestBitCheckbox, + prompt =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyIfrNVData.MyBitData.NestBitOneof, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + numeric varid =3D MyIfrNVData.MyBitData.NestBitNumeric, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 6, defaultstore =3D MyStandardDefault, + default =3D 7, defaultstore =3D MyManufactureDefault, + endnumeric; + + oneof varid =3D MyIfrNVData.MyBitData.NestByteField, + prompt =3D STRING_TOKEN(BYTE_QUESTION_NEST_BIT_PROMPT), + help =3D STRING_TOKEN(BYTE_QUESTION_NEST_BIT_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); + subtitle text =3D STRING_TOKEN(STR_BIT_VARSTORE); + + oneof varid =3D MyIfrNVData.BitOneof, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_BIT_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + checkbox varid =3D MyIfrNVData.BitCheckbox, + prompt =3D STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_BIT_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + numeric varid =3D MyIfrNVData.BitNumeric, + prompt =3D STRING_TOKEN(STR_BIT_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_BUFFER_BIT_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 20, + step =3D 0, + default =3D 16, defaultstore =3D MyStandardDefault, + default =3D 17, defaultstore =3D MyManufactureDefault, + endnumeric; + + subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); + subtitle text =3D STRING_TOKEN(STR_UNION_EFI_VARSTORE); + + numeric varid =3D MyEfiUnionVar.ByteField, + prompt =3D STRING_TOKEN(STR_UNION_BYTE_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_UNION_BYTE_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 20, + step =3D 0, + default =3D 7, defaultstore =3D MyStandardDefault, + default =3D 8, defaultstore =3D MyManufactureDefault, + endnumeric; + + numeric varid =3D MyEfiUnionVar.BitField, + prompt =3D STRING_TOKEN(STR_UNION_BIT_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_UNION_BIT_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 20, + step =3D 0, + default =3D 7, defaultstore =3D MyStandardDefault, + default =3D 8, defaultstore =3D MyManufactureDefault, + endnumeric; + + guidop + guid =3D DRIVER_SAMPLE_FORMSET_GUID, + datatype =3D MY_EFI_BITS_VARSTORE_DATA, + data.EfiBitNumeric =3D 1, + data.EfiBitOneof =3D 1, + data.EfiBitCheckbox =3D 1, + endguidop; + + endform; + endformset; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeMod= ulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 6a268d1..7cc6a19 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -271,10 +271,73 @@ #language fr-FR "Sele= ct it to invoke Hii Popup Protocol" #string STR_POPUP_TEST_HELP #language en-US "Sele= ct this question will pop up a message box, then user can decide whether ex= it curret form or not" #language fr-FR "Sele= ct this question will pop up a message box, then user can decide whether ex= it curret form or not" #string STR_POPUP_STRING #language en-US "Are = you sure to exit current form?" #language fr-FR "Are = you sure to exit current form?" +// +// Form 7 to show Questions which refer to Union Bit varstore +// +#string STR_FORM7_TITLE #language en-US "Form to Show Quest= ions with union and bit VarStore" + #language fr-FR "Form to Show Quest= ions with union and bit VarStore" +#string STR_GOTO_FORM7 #language en-US "Enter Page 7" + #language fr-FR "Enter Page 7" +#string STR_GOTO_FORM7_HELP #language en-US "This Form is to Sh= ow Questions with union and bit VarStore" + #language fr-FR "This Form is to Sh= ow Questions with union and bit VarStore" +#string STR_NEST_BIT_EFI_VARSTORE #language en-US "Nested BIT fields = in efivarstore" + #language fr-FR "Nested BIT fields = in efivarstore" +#string STR_BIT_EFI_VARSTORE #language en-US "BIT fields in efiv= arstore" + #language fr-FR "BIT fields in efiv= arstore" +#string STR_NEST_BIT_VARSTORE #language en-US "Nested BIT fields = in bufferstore" + #language fr-FR "Nested BIT fields = in bufferstore" +#string STR_BIT_VARSTORE #language en-US "BIT fields in buff= erstore" + #language fr-FR "BIT fields in buff= erstore" +#string STR_UNION_EFI_VARSTORE #language en-US "Union efivarstore" + #language fr-FR "Union efivarstore" +#string STR_BIT_NEST_CHECK_BOX_PROMPT #language en-US "NEST_BIT check box" + #language fr-FR "NEST_BIT check box" +#string STR_BIT_NEST_CHECK_BOX_HELP #language en-US "The check box refe= r to nested bit field, the default is checked" + #language fr-FR "The check box refe= r to nested bit field, the default is checked" +#string STR_ONE_OF_BIT_NEST_PROMPT #language en-US "NEST_BIT one-of" + #language fr-FR "NEST_BIT one-of" +#string STR_ONE_OF_BIT_NEST_HELP #language en-US "The oneof refer to= nested bit field" + #language fr-FR "The oneof refer to= nested bit field" +#string STR_BIT_NEST_NUMERIC_PROMPT #language en-US "NEST_BIT numeric" + #language fr-FR "NEST_BIT numeric" +#string STR_BIT_NEST_NUMERIC_HELP #language en-US "The numeric refer = to nested bit field, the Standard default is 6 Manufacture default is 7" + #language fr-FR "The numeric refer = to nested bit field, the Standard default is 6 Manufacture default is 7" +#string BYTE_QUESTION_NEST_BIT_PROMPT #language en-US "Use byte field in = NEST_BIT structure" + #language fr-FR "Use byte field in = NEST_BIT structure" +#string BYTE_QUESTION_NEST_BIT_HELP #language en-US "The Question refer= to byte field in NEST_BIT structure" + #language fr-FR "The Question refer= to byte field in NEST_BIT structure" +#string STR_BIT_NEST_NUMERIC_DEFAULT_HELP #language en-US "NEST_BIT nume= ric, default value form callback function, the Standard default is C Manufa= cture default is D" + #language fr-FR "NEST_BIT nume= ric, default value form callback function, the Standard default is C Manufa= cture default is D" +#string STR_BIT_CHECK_BOX_PROMPT #language en-US "BIT check box" + #language fr-FR "BIT check box" +#string STR_BIT_CHECK_BOX_HELP #language en-US "The check box refe= r to bit field, the default is checked" + #language fr-FR "The check box refe= r to bit field, the default is checked" +#string STR_ONE_OF_BIT_PROMPT #language en-US "BIT one-of" + #language fr-FR "BIT one-of" +#string STR_ONE_OF_BIT_HELP #language en-US "The one-of refer t= o bit field" + #language fr-FR "The one-of refer t= o bit field" +#string STR_BIT_NUMERIC_PROMPT #language en-US "BIT numeric" + #language fr-FR "BIT numeric" +#string STR_BIT_NUMERIC_HELP #language en-US "The numeric refer = to bit field, the Standard default is 4 Manufacture default is 5" + #language fr-FR "The numeric refer = to bit field the Standard default is 4 Manufacture default is 5" +#string STR_BUFFER_BIT_NUMERIC_HELP #language en-US "The numeric refer = to bit field, the Standard default is 16 Manufacture default is 17" + #language fr-FR "The numeric refer = to bit field, the Standard default is 16 Manufacture default is 17" +#string BYTE_QUESTION_BIT_PROMPT #language en-US "Use byte field in = BIT structure" + #language fr-FR "Use byte field in = BIT structure" +#string BYTE_QUESTION_BIT_HELP #language en-US "The question refer= to byte field in BIT structure" + #language fr-FR "The question refer= to byte field in BIT structure" +#string STR_UNION_BYTE_NUMERIC_PROMPT #language en-US "UNION EfiVarStore = byte numeric" + #language fr-FR "UNION EfiVarStore = byte numeric" +#string STR_UNION_BYTE_NUMERIC_HELP #language en-US "Question refer to = byte field in UNION type efivastore, the Standard default is 7 Manufacture = default is 8" + #language fr-FR "Question refer to = byte field in UNION type efivastore, the Standard default is 7 Manufacture = default is 8" +#string STR_UNION_BIT_NUMERIC_PROMPT #language en-US "UNION EfiVarStore = bit numeric" + #language fr-FR "UNION EfiVarStore = bit numeric" +#string STR_UNION_BIT_NUMERIC_HELP #language en-US "Question refer to = bit field in UNION type efivastore, the Standard default is 7 Manufacture d= efault is 8" + #language fr-FR "Question refer to = bit field in UNION type efivastore, the Standard default is 7 Manufacture d= efault is 8" // Boot Order #string STR_BOOT_TITLE #language en-US "Boot" #string STR_BOOT_OPTIONS #language en-US "Boot Order" #string STR_BOOT_OPTION1 #language en-US "IDE HDD" #string STR_BOOT_OPTION2 #language en-US "ATAPI CD" --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel