From nobody Sun Dec 29 01:50:16 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.zoho.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 1492519616044937.0308544356403; Tue, 18 Apr 2017 05:46:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6B45621954060; Tue, 18 Apr 2017 05:46:54 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 E6BD921A18AAB for ; Tue, 18 Apr 2017 05:46:52 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:46:52 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:46:50 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823040" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:29 +0800 Message-Id: <1492519592-173060-2-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [RFC patch 1/4] BaseTool/VfrCompiler: Support bit fields in EFI Variable Storage 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" Enhance VfrCompiler to parse following case: 1. EFI VarStore can contain bit fields in their structure. 2. For question Oneof/Checkbox/numeric, their storage can be bit fields of an EFI VarStore. Cc: Eric Dong Cc: Liming Gao Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 14 +- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 505 +++++++++++++++++++-= ---- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 406 ++++++++++++++++++- BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 25 +- 4 files changed, 825 insertions(+), 125 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/= C/VfrCompile/VfrFormPkg.h index 17ab14c..18c2afb 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: diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C= /VfrCompile/VfrSyntax.g index 406dbc5..b13b6d0 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -344,11 +344,15 @@ vfrDataStructFields : dataStructFieldBool | dataStructFieldString | dataStructFieldDate | dataStructFieldTime | dataStructFieldRef | - dataStructFieldUser + dataStructFieldUser | + vfr64BitsStructField | + vfr32BitsStructField | + vfr16BitsStructField | + vfr8BitsStructField )* ; =20 dataStructField64 : << UINT32 ArrayNum =3D 0; >> @@ -450,10 +454,50 @@ dataStructFieldUser : OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >> ; =20 +vfr64BitsStructField: + << UINT32 Width =3D 0;>> + D:"UINT64" + N:StringIdentifier + { + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLin= e());>> + } + ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width), N); >> + ; + +vfr32BitsStructField: + << UINT32 Width =3D 0;>> + D:"UINT32" + N:StringIdentifier + { + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLin= e());>> + } + ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width), N); >> + ; + +vfr16BitsStructField: + << UINT32 Width =3D 0;>> + D:"UINT16" + N:StringIdentifier + { + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLin= e());>> + } + ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width), N); >> + ; + +vfr8BitsStructField: + << UINT32 Width =3D 0;>> + D:"UINT8" + N:StringIdentifier + { + ":" I:Number << Width =3D _STOU32(I->getText(), I->getLin= e());>> + } + ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddBit= Field (N->getText(), D->getText(), Width), N); >> + ; + //************************************************************************= ***** // // the syntax of GUID definition // guidSubDefinition [EFI_GUID &Guid] : @@ -921,10 +965,11 @@ 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; >> | U8:"UINT8" "," << TypeName =3D U8->ge= tText(); LineNum =3D U8->getLine(); >> @@ -934,10 +979,11 @@ vfrStatementVarStoreEfi : | U64:"UINT64" "," << TypeName =3D U64->g= etText(); LineNum =3D U64->getLine(); >> | D:"EFI_HII_DATE" "," << TypeName =3D D->get= Text(); LineNum =3D D->getLine(); >> | T:"EFI_HII_TIME" "," << TypeName =3D T->get= Text(); LineNum =3D T->getLine(); >> | R:"EFI_HII_REF" "," << TypeName =3D R->get= Text(); LineNum =3D R->getLine(); >> =20 ) + << IsBitVarStore =3D gCVfrVarDataTypeDB.DataTypeHasBitField (TN->getText= ());>> { VarId "=3D" ID:Number "," << _PCATCH( (INTN)(VarStoreId= =3D _STOU16(ID->getText(), ID->getLine())) !=3D 0, (INTN)TRUE, @@ -984,17 +1030,27 @@ vfrStatementVarStoreEfi : >> ) =20 Uuid "=3D" guidDefinition[Guid] <<=20 if (IsUEFI23EfiVars= tore) { - _PCATCH(gCVfrDataSt= orage.DeclareBufferVarStore ( - = StoreName, - = &Guid, - = &gCVfrVarDataTypeDB, - = TypeName, - = VarStoreId - = ), LineNum); =20 + if (IsBitVarStore)= { + _PCATCH(gCVfrDat= aStorage.DeclareBitsBufferVarStore ( + = StoreName, + = &Guid, + = &gCVfrVarDataTypeDB, + = TypeName, + = VarStoreId + = ), LineNum); + } else { + _PCATCH(gCVfrDat= aStorage.DeclareBufferVarStore ( + = StoreName, + = &Guid, + = &gCVfrVarDataTypeDB, + = TypeName, + = VarStoreId + = ), LineNum); + } _PCATCH(gCVfrData= Storage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN); _PCATCH(gCVfrVarD= ataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum); } else { _PCATCH(gCVfrDataS= torage.DeclareBufferVarStore ( = TN->getText(), @@ -1129,10 +1185,11 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_Q= UESION_TYPE QType =3D QUESTION_ 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; >> @@ -1185,10 +1242,62 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_Q= UESION_TYPE QType =3D QUESTION_ } _SAVE_CURRQEST_VARI= NFO (Info); >> ; =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->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); + } + >> + <<=20 + if (VarIdStr !=3D N= ULL) { + delete VarIdStr;=20 + } + _SAVE_CURRQEST_VARI= NFO (Info); + >> + ; + questionheaderFlagsField[UINT8 & Flags] : ReadOnlyFlag << $Flags |=3D 0x01; >> | InteractiveFlag << $Flags |=3D 0x04; >> | ResetRequiredFlag << $Flags |=3D 0x10; >> | ReconnectRequiredFlag << $Flags |=3D 0x40; >> @@ -1233,10 +1342,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&Q= uestVarIdStr, BOOLEAN CheckFl CHAR8 *SName =3D NULL; CHAR8 *TName =3D NULL; EFI_VFR_RETURN_CODE VfrReturnCode =3D VFR_RETURN_SUCCESS; EFI_IFR_TYPE_VALUE Dummy =3D gZeroEfiIfrTypeValue; EFI_GUID *VarGuid =3D NULL; + gNestStructureIsBitVar =3D FALSE; >> ( SN1:StringIdentifier << SName =3D SN1->getT= ext(); _STRCAT(&VarIdStr, SN1->getText()); >> OpenBracket I1:Number CloseBracket << Idx =3D _STOU32(I1-= >getText(), I1->getLine()); @@ -1282,21 +1392,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()); >> { @@ -1321,11 +1431,31 @@ 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); + _PCATCH(gCVfrVarD= ataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType,= $Info.mVarTotalSize, FALSE), SN2->getLine(), VarStr); + VarGuid =3D gCVfr= DataStorage.GetVarStoreGuid($Info.mVarStoreId); + _PCATCH((EFI_VFR_= RETURN_CODE)gCVfrBufferConfig.Register ( + SName, + VarGui= d, + NULL), + SN2->getL= ine()); + _PCATCH((EFI_VFR_= RETURN_CODE)gCVfrBufferConfig.Write ( + 'a', + SName, + VarGui= d, + NULL, + $Info.= mVarType, + $Info.= mInfo.mVarOffset, + $Info.= mVarTotalSize, + Dummy), + SN2->getL= ine()); + _PCATCH(gCVfrData= Storage.AddBufferVarStoreFieldInfo(&$Info),SN2->getLine()); + break; + case EFI_VFR_VARSTO= RE_BUFFER_BITS: + _PCATCH(gCVfrVarD= ataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType,= $Info.mVarTotalSize, TRUE), SN2->getLine(), VarStr); VarGuid =3D gCVfr= DataStorage.GetVarStoreGuid($Info.mVarStoreId); _PCATCH((EFI_VFR_= RETURN_CODE)gCVfrBufferConfig.Register ( SName, VarGui= d, NULL), @@ -1338,11 +1468,12 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&Q= uestVarIdStr, BOOLEAN CheckFl $Info.= mVarType, $Info.= mInfo.mVarOffset, $Info.= mVarTotalSize, Dummy), SN2->getL= ine()); - _PCATCH(gCVfrData= Storage.AddBufferVarStoreFieldInfo(&$Info ),SN2->getLine()); + _PCATCH(gCVfrData= Storage.AddBufferVarStoreFieldInfo(&$Info),SN2->getLine()); + Info.mIsBitVar = =3D TRUE; break; case EFI_VFR_VARSTO= RE_NAME: default: break; } =20 @@ -1419,10 +1550,13 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALU= E &Value, BOOLEAN &ListType] >> { "\-" << Negative =3D TRUE; = >> } N1:Number << + if (_GET_CURRQEST_V= ARTINFO().mIsBitVar) { + $Value.u32 =3D= _STOU32(N1->getText(), N1->getLine()); + } else { switch ($Type) { case EFI_IFR_TYPE_N= UM_SIZE_8 : $Value.u8 =3D _ST= OU8(N1->getText(), N1->getLine()); if (IntDecStyle) { if (Negative) { @@ -1500,10 +1634,11 @@ vfrConstantValueField[UINT8 Type, EFI_IFR_TYPE_VALU= E &Value, BOOLEAN &ListType] 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()); >> | O2:Ones << $Value.u64 =3D _= STOU64(O2->getText(), O2->getLine()); >> @@ -1672,42 +1807,48 @@ 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)) ||=20 + ((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)) ||=20 + ((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)) ||=20 + ((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)) ||=20 + ((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())) { + 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."); @@ -1742,21 +1883,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()); >> @@ -2159,39 +2308,70 @@ 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] << + if (_GET_CURRQEST= _VARTINFO().mIsBitVar || gNestStructureIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gBitVarstoreGuid); + 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 || gNestStructureIsBitVar) { + _PCATCH (gCV= frVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), = L->getLine(), "CheckBox varid is not the valid data type"); + if ((gCVfrD= ataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) =3D=3D EF= I_VFR_VARSTORE_BUFFER_BITS) && + (_= GET_CURRQEST_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(), @@ -2203,11 +2383,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(), @@ -2223,14 +2403,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] : << @@ -2436,10 +2623,13 @@ 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. "); } + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + MinU4 =3D _STO= U32(I->getText(), I->getLine()); + } else { 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 @@ -2506,20 +2696,23 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] : 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. "); } - + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + MaxU4 =3D _STO= U32(A->getText(), A->getLine()); + } else { 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 (MaxNegat= ive) { @@ -2622,75 +2815,122 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] : _PCATCH (V= FR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Mini= mum"); } } break; } + } >> { STEP "=3D" S:Number "," << + if (_GET_CURRQES= T_VARTINFO().mIsBitVar) { + StepU4 =3D _ST= OU32(S->getText(), S->getLine()); + } else { 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_CURRQEST= _VARTINFO().mIsBitVar) { + $MMSDObj.SetMi= nMaxStepData (MinU4, MaxU4, StepU4); + } else { 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; } + } >> ; =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] << + if (_GET_CURRQEST= _VARTINFO().mIsBitVar || gNestStructureIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gBitVarstoreGuid); + 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 || gNestStructureIsBitVar) { + LFlags|=3D = (0X0F & (_GET_CURRQEST_VARSIZE())); + _PCATCH(NObj= ->SetFlags (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()) { - // - // Base on the= type to know the actual used size,shrink the buffer=20 - // size alloca= te before. - // - 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; + vfrSetMinMaxStep[*NObj] << + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar && !gNestStructureIsBitVar) { + switch (_GET_C= URRQEST_DATATYPE()) { + // + // Base on t= he type to know the actual used size,shrink the buffer=20 + // 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:=20 + IsSupporte= d =3D FALSE; + break; + } + } else { + ShrinkSize =3D= 0; } - 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] : @@ -2702,25 +2942,34 @@ vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum= ] : BOOLEAN IsDisplaySpecified =3D FALSE; >> numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" = numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified ] )* << //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 && !gNestStructureIsBitVar) { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + VarStoreType= =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId= ); + 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; + } else { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + VarStoreType= =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId= ); + if (VarStore= Type =3D=3D EFI_VFR_VARSTORE_BUFFER_BITS) { + LFlags|=3D= (0X0F & (_GET_CURRQEST_VARSIZE())); + } + } } _PCATCH(NObj.Set= Flags (HFlags, LFlags, IsDisplaySpecified), LineNum); >> ; =20 @@ -2736,30 +2985,57 @@ numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, = BOOLEAN & IsSetType, BOOLEAN | 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] << + if (_GET_CURRQEST= _VARTINFO().mIsBitVar || gNestStructureIsBitVar) { + GuidObj =3D new= CIfrGuid(0); + GuidObj->SetGui= d (&gBitVarstoreGuid); + 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 || gNestStructureIsBitVar) { + LFlags|=3D = (0X0F & (_GET_CURRQEST_VARSIZE())); + _PCATCH(OObj= ->SetFlags (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] } << + if (!_GET_CURRQE= ST_VARTINFO().mIsBitVar && !gNestStructureIsBitVar) { switch (_GET_CUR= RQEST_DATATYPE()) { // // Base on the= type to know the actual used size,shrink the buffer=20 // size alloca= te before. // @@ -2769,18 +3045,28 @@ vfrStatementOneOf : case EFI_IFR_T= YPE_NUM_SIZE_64:break; default: IsSupported = =3D FALSE; break; } - OObj.ShrinkBinSi= ze (ShrinkSize); + } else { + ShrinkSize =3D 0; + } + 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 N= ULL) { + GuidObj->SetSc= ope(1); + CRT_END_OP (E); + delete GuidObj; + } + if (OObj !=3D NU= LL) delete OObj; >> ";" ; =20 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] : @@ -2792,25 +3078,34 @@ vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNu= m] : BOOLEAN IsDisplaySpecified =3D FALSE; >> numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] ( "\|" = numericFlagsField[HFlags, LFlags, IsSetType, IsDisplaySpecified] )* << //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 && !gNestStructureIsBitVar) { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + VarStoreTyp= e =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreI= d); + 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; + } else { + if (_GET_CURRQ= EST_VARTINFO().mVarStoreId !=3D EFI_VARSTORE_ID_INVALID) { + VarStoreType= =3D gCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId= ); + if (VarStore= Type =3D=3D EFI_VFR_VARSTORE_BUFFER_BITS) { + LFlags|=3D= (0X0F & (_GET_CURRQEST_VARSIZE())); + } + } } _PCATCH(OObj.Set= Flags (HFlags, LFlags), LineNum); >> ; =20 @@ -3363,10 +3658,13 @@ vfrStatementOneOfOption : 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()); + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + gCurrentMinM= axData->SetMinMaxStepData(Val->u32, Val->u32, (UINT32) Step); + } else { 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: @@ -3379,10 +3677,11 @@ vfrStatementOneOfOption : gCurrentMinM= axData->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) { switch (_GET_C= URRQEST_DATATYPE()) { @@ -3411,11 +3710,15 @@ vfrStatementOneOfOption : break; default: break; } } else { - ReturnCode =3D= gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size); + 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 @@ -3424,11 +3727,15 @@ vfrStatementOneOfOption : OOOObj->SetLineN= o(L->getLine()); OOOObj->SetOptio= n (_STOSID(S->getText(), S->getLine()));=20 if (ArrayType) { OOOObj->SetTyp= e (EFI_IFR_TYPE_BUFFER);=20 } else { + if (_GET_CURRQ= EST_VARTINFO().mIsBitVar) { + OOOObj->Set= Type ( EFI_IFR_TYPE_NUM_SIZE_32); + } else { OOOObj->SetTyp= e (_GET_CURRQEST_DATATYPE());=20 + } } OOOObj->SetValue= (*Val);=20 >> F:FLAGS "=3D" vfrOneOfOptionFlags[*OOOObj, F->getLine()] << diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/So= urce/C/VfrCompile/VfrUtilityLib.cpp index 2f97975..d0b7d6c 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -1,10 +1,10 @@ /** @file =20 Vfr common library functions. =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 @@ -575,10 +575,19 @@ CVfrVarDataTypeDB::RegisterNewType ( { New->mNext =3D mDataTypeList; mDataTypeList =3D New; } =20 +VOID +CVfrVarDataTypeDB::RegisterNewBitsType ( + IN SVfrDataType *New + ) +{ + New->mNext =3D mBitsTypeList; + mBitsTypeList =3D New; +} + EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::ExtractStructTypeName ( IN CHAR8 *&VarStr, OUT CHAR8 *TName ) @@ -598,10 +607,28 @@ CVfrVarDataTypeDB::ExtractStructTypeName ( } =20 return VFR_RETURN_SUCCESS; } =20 +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; +} + + EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::ExtractFieldNameAndArrary ( IN CHAR8 *&VarStr, IN CHAR8 *FName, OUT UINT32 &ArrayIdx @@ -695,11 +722,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 +755,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->mOffset + Field->mFieldType->mTotalSize * ((ArrayIdx= =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 +778,26 @@ CVfrVarDataTypeDB::GetFieldWidth ( } =20 UINT32 CVfrVarDataTypeDB::GetFieldSize ( IN SVfrDataField *Field, - IN UINT32 ArrayIdx + IN UINT32 ArrayIdx, + IN BOOLEAN IsBitField ) { 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 (IsBitField) { + return Field->mBitWidth; + } else { + return Field->mFieldType->mTotalSize; + } } } =20 VOID CVfrVarDataTypeDB::InternalTypesListInit ( @@ -786,22 +822,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 +849,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 +877,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; } @@ -870,10 +916,11 @@ CVfrVarDataTypeDB::InternalTypesListInit ( CVfrVarDataTypeDB::CVfrVarDataTypeDB ( VOID ) { mDataTypeList =3D NULL; + mBitsTypeList =3D NULL; mNewDataType =3D NULL; mCurrDataField =3D NULL; mPackAlign =3D DEFAULT_PACK_ALIGN; mPackStack =3D NULL; mFirstNewDataTypeName =3D NULL; @@ -899,11 +946,22 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB ( while(pType->mMembers !=3D NULL) { pField =3D pType->mMembers; pType->mMembers =3D pType->mMembers->mNext; delete pField; } - delete pType; + delete pType; + } + + while (mBitsTypeList !=3D NULL) { + pType =3D mBitsTypeList; + mBitsTypeList =3D mBitsTypeList->mNext; + while(pType->mMembers !=3D NULL) { + pField =3D pType->mMembers; + pType->mMembers =3D pType->mMembers->mNext; + delete pField; + } + delete pType; } =20 while (mPackStack !=3D NULL) { pPack =3D mPackStack; mPackStack =3D mPackStack->mNext; @@ -976,10 +1034,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 @@ -1008,10 +1067,61 @@ CVfrVarDataTypeDB::SetNewTypeName ( strcpy(mNewDataType->mTypeName, TypeName); return VFR_RETURN_SUCCESS; } =20 EFI_VFR_RETURN_CODE +CVfrVarDataTypeDB::DataTypeAddBitField ( + IN CHAR8 *FieldName, + IN CHAR8 *TypeName, + IN UINT8 Width + ) +{ + SVfrDataField *pNewField =3D NULL; + SVfrDataType *pFieldType =3D NULL; + SVfrDataField *pTmp; + UINT32 Align; + + CHECK_ERROR_RETURN (GetDataType (TypeName, &pFieldType), VFR_RETURN_SUCC= ESS); + + if (strlen (FieldName) >=3D MAX_NAME_LEN) { + 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) { + return VFR_RETURN_REDEFINED; + } + } + + if ((pNewField =3D new SVfrDataField) =3D=3D NULL) { + return VFR_RETURN_OUT_FOR_RESOURCES; + } + + strcpy (pNewField->mFieldName, FieldName); + pNewField->mFieldType =3D pFieldType; + pNewField->mIsBitField =3D TRUE; + pNewField->mBitWidth =3D Width; + + if (mNewDataType->mMembers =3D=3D NULL) { + mNewDataType->mMembers =3D pNewField; + pNewField->mNext =3D NULL; + pNewField->mOffset =3D 0; + } else { + for (pTmp =3D mNewDataType->mMembers; pTmp->mNext !=3D NULL; pTmp =3D = pTmp->mNext) + ; + pTmp->mNext =3D pNewField; + pNewField->mNext =3D NULL; + } + + 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 ) @@ -1039,10 +1149,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); } @@ -1061,20 +1172,117 @@ CVfrVarDataTypeDB::DataTypeAddField ( =20 return VFR_RETURN_SUCCESS; } =20 VOID +CVfrVarDataTypeDB::ChangeFieldToBitRepresentation( + IN SVfrDataType *DataType + ) +{ + =20 + SVfrDataField *pTmp; + SVfrDataField *pSTmp; + UINT32 Offset; + UINT8 Width; + UINT32 TotalSize; + + Offset =3D 0; + Width =3D 0; + TotalSize =3D 0; + + + for (pTmp =3D DataType->mMembers; pTmp!=3D NULL; pTmp =3D pTmp->mNext) { + pTmp->mOffset =3D 0; + } + + for (pTmp =3D DataType->mMembers; pTmp !=3D NULL; pTmp =3D pTmp->mNext) { + if (pTmp->mIsBitField) { + pSTmp =3D pTmp; + while (pSTmp !=3D NULL && pSTmp->mIsBitField) { + pSTmp->mOffset +=3D Offset; + pTmp =3D pSTmp; + if ((pSTmp->mNext !=3D NULL) &&!(pSTmp->mNext->mIsBitField)) { + // + // Currect field is bit field, but next field is not bit field + // + if (Width > 0){ + TotalSize +=3D pSTmp->mFieldType->mTotalSize; + Width +=3D pSTmp->mBitWidth; + if (Width > pSTmp->mFieldType->mTotalSize * 8) { + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + pSTmp->mOffset +=3D Offset; + } else { + pSTmp->mOffset +=3D (Width - pSTmp->mBitWidth); + } + Width =3D 0; + break; + } + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + TotalSize +=3D pSTmp->mFieldType->mTotalSize; + break; + } else if ((pSTmp->mNext !=3D NULL) && strcmp (pSTmp->mFieldType->= mTypeName,pSTmp->mNext->mFieldType->mTypeName) !=3D0) { + // + // Currect field is bit field, and next field is also bit field, + // but they have different type name. + // + if (Width > 0){ + Width +=3D pSTmp->mBitWidth; + if (Width > pSTmp->mFieldType->mTotalSize * 8) { + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + pSTmp->mOffset +=3D Offset; + } else { + pSTmp->mOffset +=3D (Width - pSTmp->mBitWidth); + } + Width =3D 0; + } + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + TotalSize +=3D pSTmp->mFieldType->mTotalSize; + break; + }else { + pSTmp->mOffset +=3D Width; + Width +=3D pSTmp->mBitWidth; + if (Width > pSTmp->mFieldType->mTotalSize * 8) { + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + TotalSize +=3D pSTmp->mFieldType->mTotalSize; + Width =3D 0; + break; + } + } + if (pSTmp->mNext =3D=3D NULL) { + Offset +=3D pSTmp->mFieldType->mTotalSize * 8; + TotalSize +=3D pSTmp->mFieldType->mTotalSize; + Width =3D 0; + break; + } + pSTmp =3D pSTmp->mNext; + } + } else { + pTmp->mOffset +=3D Offset; + pTmp->mBitWidth =3D pTmp->mFieldType->mTotalSize * 8; + Offset +=3D pTmp->mFieldType->mTotalSize * 8; + TotalSize +=3D pTmp->mFieldType->mTotalSize; + } + } + + DataType->mTotalSize =3D TotalSize; +} + +VOID CVfrVarDataTypeDB::DeclareDataTypeEnd ( VOID ) { if (mNewDataType->mTypeName[0] =3D=3D '\0') { return; } =20 - if ((mNewDataType->mTotalSize % mNewDataType->mAlign) !=3D0) { - mNewDataType->mTotalSize +=3D ALIGN_STUFF (mNewDataType->mTotalSize, m= NewDataType->mAlign); + if (mNewDataType->mHasBitField) { + ChangeFieldToBitRepresentation (mNewDataType); + } else { + if ((mNewDataType->mTotalSize % mNewDataType->mAlign) !=3D0) { + mNewDataType->mTotalSize +=3D ALIGN_STUFF (mNewDataType->mTotalSize,= mNewDataType->mAlign); + } } =20 RegisterNewType (mNewDataType); if (mFirstNewDataTypeName =3D=3D NULL) { mFirstNewDataTypeName =3D mNewDataType->mTypeName; @@ -1170,43 +1378,104 @@ CVfrVarDataTypeDB::GetDataTypeSize ( EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::GetDataFieldInfo ( IN CHAR8 *VarStr, OUT UINT16 &Offset, OUT UINT8 &Type, + OUT UINT32 &Size, + IN BOOLEAN IsBitField + ) +{ + CHAR8 TName[MAX_NAME_LEN], FName[MAX_NAME_LEN]; + UINT32 ArrayIdx, Tmp; + SVfrDataType *pType =3D NULL; + SVfrDataField *pField =3D NULL; + BOOLEAN IsNestBitField; + + Offset =3D 0; + Type =3D EFI_IFR_TYPE_OTHER; + Size =3D 0; + + CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SU= CCESS); + CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS); + + // + // if it is not struct data type + // + Type =3D pType->mType; + Size =3D pType->mTotalSize; + + 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; + IsNestBitField =3D pField->mIsBitField; + gNestStructureIsBitVar =3D IsNestBitField; + if (!IsBitField && IsNestBitField) { + CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsNestBitF= ield), VFR_RETURN_SUCCESS); + Offset =3D (UINT16) (Offset * 8 + Tmp); + Size =3D GetFieldSize (pField, ArrayIdx, IsNestBitField); + } else { + CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsBitField= ), VFR_RETURN_SUCCESS); + Offset =3D (UINT16) (Offset + Tmp); + Size =3D GetFieldSize (pField, ArrayIdx, IsBitField); + } + Type =3D GetFieldWidth (pField); + } + return VFR_RETURN_SUCCESS; +} + +EFI_VFR_RETURN_CODE +CVfrVarDataTypeDB::GetDataFieldInfo ( + IN CHAR8 *VarStr, + OUT UINT16 &Offset, + OUT UINT8 &Type, OUT UINT32 &Size ) { CHAR8 TName[MAX_NAME_LEN], FName[MAX_NAME_LEN]; UINT32 ArrayIdx, Tmp; SVfrDataType *pType =3D NULL; SVfrDataField *pField =3D NULL; + BOOLEAN IsNestBitField; + BOOLEAN IsBitField; =20 Offset =3D 0; Type =3D EFI_IFR_TYPE_OTHER; Size =3D 0; =20 CHECK_ERROR_RETURN (ExtractStructTypeName (VarStr, TName), VFR_RETURN_SU= CCESS); CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS); =20 + IsBitField =3D DataTypeHasBitField (TName); + // // 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); + IsNestBitField =3D pField->mIsBitField; + gNestStructureIsBitVar =3D IsNestBitField; + if (!IsBitField && IsNestBitField) { + CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsNestBitF= ield), VFR_RETURN_SUCCESS); + Offset =3D (UINT16) (Offset * 8 + Tmp); + Size =3D GetFieldSize (pField, ArrayIdx, IsNestBitField); + } else { + CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, IsBitField= ), VFR_RETURN_SUCCESS); + Offset =3D (UINT16) (Offset + Tmp); + Size =3D GetFieldSize (pField, ArrayIdx, IsBitField); + } Type =3D GetFieldWidth (pField); - Size =3D GetFieldSize (pField, ArrayIdx); } return VFR_RETURN_SUCCESS; } =20 + EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::GetUserDefinedTypeNameList ( OUT CHAR8 ***NameList, OUT UINT32 *ListSize ) @@ -1347,10 +1616,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; @@ -1363,11 +1633,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 ( @@ -1415,10 +1689,11 @@ CVfrDataStorage::CVfrDataStorage ( mFreeVarStoreIdBitMap[0] =3D 0x80000000; =20 mBufferVarStoreList =3D NULL; mEfiVarStoreList =3D NULL; mNameVarStoreList =3D NULL; + mBitsBufferStoreList =3D NULL; mCurrVarStorageNode =3D NULL; mNewVarStorageNode =3D NULL; mBufferFieldInfoListHead =3D NULL; mBufferFieldInfoListTail =3D NULL; } @@ -1442,10 +1717,15 @@ CVfrDataStorage::~CVfrDataStorage ( while (mNameVarStoreList !=3D NULL) { pNode =3D mNameVarStoreList; mNameVarStoreList =3D mNameVarStoreList->mNext; delete pNode; } + while ( mBitsBufferStoreList !=3D NULL) { + pNode =3D mBitsBufferStoreList; + mBitsBufferStoreList =3D mBitsBufferStoreList->mNext; + delete pNode; + } if (mNewVarStorageNode !=3D NULL) { delete mNewVarStorageNode; } } =20 @@ -1661,11 +1941,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, FALSE, Flag)) =3D=3D NULL) { return VFR_RETURN_OUT_FOR_RESOURCES; } =20 pNew->mNext =3D mBufferVarStoreList; mBufferVarStoreList =3D pNew; @@ -1676,10 +1956,57 @@ CVfrDataStorage::DeclareBufferVarStore ( =20 return VFR_RETURN_SUCCESS; } =20 EFI_VFR_RETURN_CODE=20 +CVfrDataStorage::DeclareBitsBufferVarStore ( + IN CHAR8 *StoreName,=20 + IN EFI_GUID *Guid,=20 + IN CVfrVarDataTypeDB *DataTypeDB, + IN CHAR8 *TypeName, + IN EFI_VARSTORE_ID VarStoreId, + IN BOOLEAN Flag + ) +{ + SVfrVarStorageNode *pNew =3D NULL; + SVfrDataType *pDataType =3D NULL; + EFI_VARSTORE_ID TempVarStoreId; + + if ((StoreName =3D=3D NULL) || (Guid =3D=3D NULL) || (DataTypeDB =3D=3D = NULL)) { + return VFR_RETURN_FATAL_ERROR; + } + + if (GetVarStoreId (StoreName, &TempVarStoreId, Guid) =3D=3D VFR_RETURN_S= UCCESS) { + return VFR_RETURN_REDEFINED; + } + + CHECK_ERROR_RETURN(DataTypeDB->GetDataType (TypeName, &pDataType), VFR_R= ETURN_SUCCESS); + + if (VarStoreId =3D=3D EFI_VARSTORE_ID_INVALID) { + VarStoreId =3D GetFreeVarStoreId (EFI_VFR_VARSTORE_BUFFER); + } else { + if (ChekVarStoreIdFree (VarStoreId) =3D=3D FALSE) { + return VFR_RETURN_VARSTOREID_REDEFINED; + } + MarkVarStoreIdUsed (VarStoreId); + } + + if ((pNew =3D new SVfrVarStorageNode (Guid, StoreName, VarStoreId, pData= Type, TRUE, Flag)) =3D=3D NULL) { + return VFR_RETURN_OUT_FOR_RESOURCES; + } + + pNew->mNext =3D mBitsBufferStoreList; + mBitsBufferStoreList =3D pNew; + + if (gCVfrBufferConfig.Register(StoreName, Guid) !=3D 0) { + return VFR_RETURN_FATAL_ERROR; + } + + return VFR_RETURN_SUCCESS; +} + +EFI_VFR_RETURN_CODE=20 CVfrDataStorage::GetVarStoreByDataType ( IN CHAR8 *DataTypeName, OUT SVfrVarStorageNode **VarNode, IN EFI_GUID *VarGuid ) @@ -1813,10 +2140,18 @@ CVfrDataStorage::GetVarStoreId ( *VarStoreId =3D mCurrVarStorageNode->mVarStoreId; return ReturnCode; } } } + for (pNode =3D mBitsBufferStoreList; pNode !=3D NULL; pNode =3D pNode->m= Next) { + if (strcmp (pNode->mVarStoreName, StoreName) =3D=3D 0) { + if (CheckGuidField(pNode, StoreGuid, &HasFoundOne, &ReturnCode)) { + *VarStoreId =3D mCurrVarStorageNode->mVarStoreId; + return ReturnCode; + } + } + } =20 if (HasFoundOne) { *VarStoreId =3D mCurrVarStorageNode->mVarStoreId; return VFR_RETURN_SUCCESS; } @@ -1852,10 +2187,17 @@ CVfrDataStorage::GetBufferVarStoreDataTypeName ( *DataTypeName =3D pNode->mStorageInfo.mDataType->mTypeName; return VFR_RETURN_SUCCESS; } } =20 + for (pNode =3D mBitsBufferStoreList; pNode !=3D NULL; pNode =3D pNode->m= Next) { + if (pNode->mVarStoreId =3D=3D VarStoreId) { + *DataTypeName =3D pNode->mStorageInfo.mDataType->mTypeName; + return VFR_RETURN_SUCCESS; + } + } + return VFR_RETURN_UNDEFINED; } =20 EFI_VFR_VARSTORE_TYPE CVfrDataStorage::GetVarStoreType ( @@ -1890,10 +2232,17 @@ CVfrDataStorage::GetVarStoreType ( VarStoreType =3D pNode->mVarStoreType; return VarStoreType; } } =20 + for (pNode =3D mBitsBufferStoreList; pNode !=3D NULL; pNode =3D pNode->m= Next) { + if (pNode->mVarStoreId =3D=3D VarStoreId) { + VarStoreType =3D pNode->mVarStoreType; + return VarStoreType; + } + } + return VarStoreType; } =20 EFI_GUID * CVfrDataStorage::GetVarStoreGuid ( @@ -1928,10 +2277,17 @@ CVfrDataStorage::GetVarStoreGuid ( VarGuid =3D &pNode->mGuid; return VarGuid; } } =20 + for (pNode =3D mBitsBufferStoreList; pNode !=3D NULL; pNode =3D pNode->m= Next) { + if (pNode->mVarStoreId =3D=3D VarStoreId) { + VarGuid =3D &pNode->mGuid; + return VarGuid; + } + } + return VarGuid; } =20 EFI_VFR_RETURN_CODE CVfrDataStorage::GetVarStoreName ( @@ -1964,10 +2320,18 @@ CVfrDataStorage::GetVarStoreName ( *VarStoreName =3D pNode->mVarStoreName; return VFR_RETURN_SUCCESS; } } =20 + for (pNode =3D mBitsBufferStoreList; pNode !=3D NULL; pNode =3D pNode->m= Next) { + if (pNode->mVarStoreId =3D=3D VarStoreId) { + *VarStoreName =3D pNode->mVarStoreName; + return VFR_RETURN_SUCCESS; + } + } + + *VarStoreName =3D NULL; return VFR_RETURN_UNDEFINED; } =20 EFI_VFR_RETURN_CODE @@ -2375,10 +2739,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 ) @@ -2386,10 +2751,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 @@ -2399,10 +2765,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 @@ -2413,11 +2780,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; } @@ -3715,11 +4083,13 @@ CVfrStringDB::GetUnicodeStringTextSize ( } =20 return StringSize; } =20 -BOOLEAN VfrCompatibleMode =3D FALSE; +BOOLEAN VfrCompatibleMode =3D FALSE; +BOOLEAN gNestStructureIsBitVar =3D FALSE; +EFI_GUID gBitVarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0= x20, 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 59509c3..2adfba7 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h @@ -1,10 +1,10 @@ /** @file =20 Vfr common library functions. =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 @@ -20,10 +20,12 @@ 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 gBitVarstoreGuid; +extern BOOLEAN gNestStructureIsBitVar; =20 #define MAX_NAME_LEN 64 #define MAX_STRING_LEN 0x100 #define DEFAULT_ALIGN 1 #define DEFAULT_PACK_ALIGN 0x8 @@ -114,18 +116,21 @@ struct SVfrDataType; struct SVfrDataField { CHAR8 mFieldName[MAX_NAME_LEN]; SVfrDataType *mFieldType; UINT32 mOffset; UINT32 mArrayNum; + BOOLEAN mIsBitField; + UINT8 mBitWidth; 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 @@ -183,40 +188,46 @@ private: public: EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN CHAR8 *Identifie= r =3D NULL, IN UINT32 Number =3D DEFAULT_PACK_ALIGN); =20 private: SVfrDataType *mDataTypeList; + SVfrDataType *mBitsTypeList; =20 SVfrDataType *mNewDataType; SVfrDataType *mCurrDataType; SVfrDataField *mCurrDataField; =20 VOID InternalTypesListInit (VOID); VOID RegisterNewType (IN SVfrDataType *); + VOID RegisterNewBitsType (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); + EFI_VFR_RETURN_CODE DataTypeAddBitField (IN CHAR8 *, IN CHAR8 *, IN UINT= 8); VOID DeclareDataTypeEnd (VOID); + VOID ChangeFieldToBitRepresentation( IN SVfrDataType *); =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 &, IN BOOLEAN); EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT= 8 &, OUT UINT32 &); =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 *); =20 BOOLEAN IsTypeNameDefined (IN CHAR8 *); =20 VOID Dump(IN FILE *); // @@ -236,11 +247,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 +278,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 +295,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 *); @@ -308,10 +321,11 @@ private: UINT32 mFreeVarStoreIdBitMap[EFI_FREE_VARSTORE_ID_BIT= MAP_SIZE]; =20 struct SVfrVarStorageNode *mBufferVarStoreList; struct SVfrVarStorageNode *mEfiVarStoreList; struct SVfrVarStorageNode *mNameVarStoreList; + struct SVfrVarStorageNode *mBitsBufferStoreList; =20 struct SVfrVarStorageNode *mCurrVarStorageNode; struct SVfrVarStorageNode *mNewVarStorageNode; BufferVarStoreFieldInfoNode *mBufferFieldInfoListHead; BufferVarStoreFieldInfoNode *mBufferFieldInfoListTail; @@ -342,10 +356,11 @@ public: 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 DeclareBitsBufferVarStore (IN CHAR8 *, IN EFI_GUID *= , IN CVfrVarDataTypeDB *, IN CHAR8 *, IN EFI_VARSTORE_ID, IN BOOLEAN 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 Dec 29 01:50:16 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.zoho.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 149251961934859.644197051455194; Tue, 18 Apr 2017 05:46:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D5EC42195407B; Tue, 18 Apr 2017 05:46:56 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 7C8AB21954085 for ; Tue, 18 Apr 2017 05:46:55 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:46:55 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:46:54 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823051" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:30 +0800 Message-Id: <1492519592-173060-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [RFC patch 2/4] 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" For oneof/numeric/CheckBox(storage can be Bit EFI VarStore) If we want 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 EFI VarStore info correctly. 2. Set/get value to/from bit EFI VarStore correctly. Cc: Eric Dong Cc: Liming Gao Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 137 +++++++++++++++++-= ---- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 106 ++++++++++++++++- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 + 3 files changed, 208 insertions(+), 38 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModuleP= kg/Universal/SetupBrowserDxe/IfrParse.c index 6b3e5e0..ccd6790 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -15,10 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include "Setup.h" =20 UINT16 mStatementIndex; UINT16 mExpressionOpCodeIndex; EFI_QUESTION_ID mUsedQuestionId; +EFI_GUID mBitVarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B,= 0x27, 0x20, 0xA8, 0xFD, 0x60 ,0xA7 , 0x1D}}; +BOOLEAN mQuestionReferBitVar =3D FALSE; + extern LIST_ENTRY gBrowserStorageList; /** Initialize Statement header members. =20 @param OpCodeData Pointer of the raw OpCode data. @@ -559,10 +562,11 @@ CreateStorage ( } =20 BrowserStorage->HiiHandle =3D FormSet->HiiHandle; =20 BrowserStorage->Initialized =3D FALSE; + BrowserStorage->IsBitVarStore =3D FALSE; } =20 Storage->BrowserStorage =3D BrowserStorage; InitializeConfigHdr (FormSet, Storage); Storage->ConfigRequest =3D AllocateCopyPool (StrSize (Storage->ConfigHdr= ), Storage->ConfigHdr); @@ -1312,10 +1316,12 @@ ParseOpCodes ( BOOLEAN InUnknownScope; UINT8 UnknownDepth; FORMSET_DEFAULTSTORE *PreDefaultStore; LIST_ENTRY *DefaultLink; BOOLEAN HaveInserted; + UINT16 ByteWidth; + UINT16 BitWidth; =20 SuppressForQuestion =3D FALSE; SuppressForOption =3D FALSE; InScopeDisable =3D FALSE; DepthOfDisable =3D 0; @@ -1978,47 +1984,99 @@ 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 (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + CurrentStatement->StorageBitWidth =3D CurrentStatement->Flags & 0X= 0F; + CurrentStatement->Storage->IsBitVarStore =3D TRUE; + CurrentStatement->VarBitOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Var= BitOffset / 8; + BitWidth =3D CurrentStatement->VarBitOffset - (CurrentStatement->V= arStoreInfo.VarOffset * 8) + CurrentStatement->StorageBitWidth; + ByteWidth =3D BitWidth / 8; + CurrentStatement->StorageWidth =3D (BitWidth % 8 =3D=3D 0? ByteWid= th: ByteWidth + 1); + 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; + if (Operand =3D=3D EFI_IFR_NUMERIC_OP) { + switch (CurrentStatement->StorageWidth) { + case 1: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_8; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue =3D (UINT= 8)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue =3D (UINT= 8)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step =3D (UINT8)Cu= rrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_8; + break; + case 2: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NUM= _SIZE_16; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue =3D (UINT= 16)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue =3D (UINT= 16)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step =3D (UINT16)C= urrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_16; + break; + case 3: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_32; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue =3D (UIN= T32)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue =3D (UIN= T32)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step =3D (UINT32)= CurrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + case 4: + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &=3D 0x30; + ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |=3D EFI_IFR_TYPE_NU= M_SIZE_32; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue =3D (UIN= T32)CurrentStatement->Minimum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue =3D (UIN= T32)CurrentStatement->Maximum; + ((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step =3D (UINT32)= CurrentStatement->Step; + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_32; + break; + default: + break; + } + } + } else { =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; + 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_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; + 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 - 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_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; =20 - default: - 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 +2103,21 @@ 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 (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + CurrentStatement->StorageBitWidth =3D 1; + CurrentStatement->Storage->IsBitVarStore =3D TRUE; + CurrentStatement->VarBitOffset =3D CurrentStatement->VarStoreInfo.= VarOffset; + CurrentStatement->VarStoreInfo.VarOffset =3D CurrentStatement->Var= BitOffset / 8; + BitWidth =3D CurrentStatement->VarBitOffset - (CurrentStatement->V= arStoreInfo.VarOffset * 8) + CurrentStatement->StorageBitWidth; + ByteWidth =3D BitWidth / 8; + CurrentStatement->StorageWidth =3D (BitWidth % 8 =3D=3D 0? ByteWid= th: ByteWidth + 1); + } + InitializeRequestElement (FormSet, CurrentStatement, CurrentForm); =20 break; =20 case EFI_IFR_STRING_OP: @@ -2594,10 +2663,14 @@ ParseOpCodes ( // // Vendor specific // case EFI_IFR_GUID_OP: =20 CurrentStatement =3D CreateStatement (OpCodeData, FormSet, CurrentFo= rm); + if (CompareGuid ((EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER= )), &mBitVarstoreGuid)) { + Scope =3D 0; + mQuestionReferBitVar =3D TRUE; + } break; =20 // // Scope End // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.c index 83dc2b8..6b46581 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1392,10 +1392,14 @@ BufferToValue ( UINTN Index; UINT8 DigitUint8; BOOLEAN IsString; UINTN Length; EFI_STATUS Status; + UINT8 *Buffer; + UINT32 Mask; + UINT32 PreBits; + UINT32 BufferValue; =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; @@ -1413,11 +1417,17 @@ BufferToValue ( Dst =3D Question->BufferValue; } else { // // Other type of Questions // - Dst =3D (UINT8 *) &Question->HiiValue.Value; + if (Question->Storage->IsBitVarStore) { + 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 '&'. // @@ -1471,10 +1481,27 @@ BufferToValue ( } } =20 *StringPtr =3D TempChar; =20 + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarOffset = * 8; + Mask =3D (1 << Question->StorageBitWidth) - 1; + BufferValue =3D *(Buffer); + BufferValue |=3D *(Buffer + 1) << 8; + BufferValue |=3D *(Buffer + 2) << 16; + BufferValue |=3D *(Buffer + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + + CopyMem ((UINT8 *) &Question->HiiValue.Value, (UINT8*)&BufferValue, Qu= estion->StorageWidth); + + if (Buffer !=3D NULL) { + FreePool (Buffer); + } + } + return Status; } =20 /** Get Question's current Value. @@ -1509,10 +1536,13 @@ GetQuestionValue ( CHAR16 *Result; CHAR16 *Value; UINTN Length; BOOLEAN IsBufferStorage; UINTN MaxLen; + UINT32 PreBits; + UINT32 Mask; + UINT32 BufferValue; =20 Status =3D EFI_SUCCESS; Value =3D NULL; Result =3D NULL; =20 @@ -1676,16 +1706,40 @@ GetQuestionValue ( if (IsBufferStorage) { if (GetValueFrom =3D=3D GetSetValueWithEditBuffer) { // // Copy from storage Edit buffer // - CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffs= et, StorageWidth); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8;; + Mask =3D (1<< Question->StorageBitWidth) -1; + BufferValue =3D *(Storage->EditBuffer + Question->VarStoreInfo.V= arOffset); + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 1) << 8; + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 2) << 16; + BufferValue |=3D *(Storage->EditBuffer + Question->VarStoreInfo.= VarOffset + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth); + } else { + CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset, StorageWidth); + } } else { // // Copy from storage Edit buffer // - CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, = StorageWidth); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8;; + Mask =3D (1<< Question->StorageBitWidth) -1; + BufferValue =3D *(Storage->Buffer + Question->VarStoreInfo.VarOf= fset); + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 1) << 8; + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 2) << 16; + BufferValue |=3D *(Storage->Buffer + Question->VarStoreInfo.VarO= ffset + 3) << 24; + BufferValue >>=3D PreBits; + BufferValue &=3D Mask; + CopyMem (Dst, (UINT8*)&BufferValue, StorageWidth); + } 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)) { @@ -1825,10 +1879,14 @@ SetQuestionValue ( CHAR16 *TemName; CHAR16 *TemString; UINTN Index; NAME_VALUE_NODE *Node; UINTN MaxLen; + UINT32 PreBits; + UINT32 Mask; + UINT32 Buffer; + UINT32 SrcValue; =20 Status =3D EFI_SUCCESS; Node =3D NULL; =20 if (SetValueTo >=3D GetSetValueWithMax) { @@ -1947,17 +2005,53 @@ 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 (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8; + SrcValue =3D (UINT32)(*Src); + SrcValue <<=3D PreBits; + Mask =3D (1<< Question->StorageBitWidth) -1; + Mask <<=3D PreBits; + Buffer =3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOff= set); + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 1) << 8; + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 2) << 16; + Buffer |=3D *(Storage->EditBuffer + Question->VarStoreInfo.VarOf= fset + 3) << 24; + + Buffer =3D (Buffer & (~Mask)) | SrcValue; + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset) =3D (U= INT8) Buffer & 0xFF; + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 1) = =3D (UINT8) (Buffer >> 8); + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 2) = =3D (UINT8) (Buffer >> 16); + *(Storage->EditBuffer + Question->VarStoreInfo.VarOffset + 3) = =3D (UINT8) (Buffer >> 24); + } 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); + if (Question->Storage->IsBitVarStore) { + PreBits =3D Question->VarBitOffset - Question->VarStoreInfo.VarO= ffset * 8; + SrcValue =3D (UINT32)(*Src); + SrcValue <<=3D PreBits; + Mask =3D (1<< Question->StorageBitWidth) -1; + Mask <<=3D PreBits; + Buffer =3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset); + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 1) << 8; + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 2) << 16; + Buffer |=3D *(Storage->Buffer + Question->VarStoreInfo.VarOffset= + 3) << 24; + + Buffer =3D (Buffer & (~Mask)) | SrcValue; + *(Storage->Buffer + Question->VarStoreInfo.VarOffset) =3D (UINT8= ) Buffer & 0xFF; + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 1) =3D (U= INT8) (Buffer >> 8); + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 2) =3D (U= INT8) (Buffer >> 16); + *(Storage->Buffer + Question->VarStoreInfo.VarOffset + 3) =3D (U= INT8) (Buffer >> 24); + } 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 f1accdf..f919b76 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -137,10 +137,11 @@ typedef struct { LIST_ENTRY Link; =20 UINT8 Type; // Storage type =20 BOOLEAN Initialized; // Whether this varstore is initialized= , efi varstore not used. + BOOLEAN IsBitVarStore; // whether this is bit varstore. =20 EFI_HII_HANDLE HiiHandle; // HiiHandle for this varstore, efi var= store not used. EFI_GUID Guid; =20 CHAR16 *Name; // For EFI_IFR_VARSTORE @@ -327,10 +328,12 @@ 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 StorageBitWidth; + UINT16 VarBitOffset; UINT8 QuestionFlags; 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 --=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 Dec 29 01:50:16 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.zoho.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 149251962282912.456863831608189; Tue, 18 Apr 2017 05:47:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1CFDA2195408B; Tue, 18 Apr 2017 05:47:01 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 33CDC2195408B for ; Tue, 18 Apr 2017 05:47:00 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:47:00 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:46:59 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823085" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:31 +0800 Message-Id: <1492519592-173060-4-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [RFC patch 3/4] 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" 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 Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 197 +++++++++++++++++= ++-- .../Universal/HiiDatabaseDxe/HiiDatabase.h | 3 + 2 files changed, 186 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index c9ff1cf..5da0ba6 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -13,10 +13,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. **/ =20 =20 #include "HiiDatabase.h" extern HII_DATABASE_PRIVATE_DATA mPrivate; +EFI_GUID mBitVarstoreGuid =3D {0x82DDD68B, 0x9163, 0x4187, {0x9B,= 0x27, 0x20, 0xA8, 0xFD, 0x60 ,0xA7 , 0x1D}}; +BOOLEAN mNeedUpdateBlockData =3D FALSE; +BOOLEAN mQuestionReferBitVar =3D FALSE; =20 /** Calculate the number of Unicode characters of the incoming Configuration= string, not including NULL terminator. =20 @@ -1223,19 +1226,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); @@ -1991,17 +1994,21 @@ 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 BitVarWidth; =20 NameId =3D 0; VarOffset =3D 0; IfrQuestionHdr =3D (EFI_IFR_QUESTION_HEADER *)((CHAR8 *) IfrOpHdr + siz= eof (EFI_IFR_OP_HEADER)); =20 @@ -2016,11 +2023,19 @@ IsThisOpcodeRequired ( // This question is not in the requested string. Skip it. // return EFI_NOT_FOUND; } } else { - VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + if (IsBitVar) { + BitOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + VarOffset =3D BitOffset / 8; + BitVarWidth =3D VarWidth; + BitWidth =3D BitOffset - (VarOffset * 8) + BitVarWidth; + VarWidth =3D (BitWidth % 8 =3D=3D 0 ? BitWidth / 8: BitWidth / 8 += 1); + } else { + VarOffset =3D IfrQuestionHdr->VarStoreInfo.VarOffset; + } =20 // // Check whether this question is in requested block array. // if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, H= iiHandle)) { @@ -2051,10 +2066,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 IfrQuestionHdr->VarStoreInfo.VarOffset; + BlockData->BitWidth =3D BitVarWidth; InitializeListHead (&BlockData->DefaultValueEntry); // // Add Block Data into VarStorageData BlockEntry // InsertBlockData (&VarStorageData->BlockEntry, &BlockData); @@ -2124,10 +2142,11 @@ ParseIfrData ( EFI_HII_PACKAGE_HEADER *PackageHeader; EFI_VARSTORE_ID VarStoreId; UINT16 SmallestDefaultId; BOOLEAN SmallestIdFromFlag; BOOLEAN FromOtherDefaultOpcode; + BOOLEAN IsBitVar; =20 Status =3D EFI_SUCCESS; BlockData =3D NULL; DefaultDataPtr =3D NULL; FirstOneOfOption =3D FALSE; @@ -2135,10 +2154,11 @@ ParseIfrData ( FirstOrderedList =3D FALSE; VarStoreName =3D NULL; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); SmallestDefaultId =3D 0xFFFF; FromOtherDefaultOpcode =3D FALSE; + IsBitVar =3D FALSE; =20 // // Go through the form package to parse OpCode one by one. // PackageOffset =3D sizeof (EFI_HII_PACKAGE_HEADER); @@ -2309,11 +2329,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 +2361,28 @@ 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 (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + VarWidth =3D IfrOneOf->Flags & 0X0F; + IsBitVar =3D TRUE; + } else { + VarWidth =3D (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SI= ZE)); + IsBitVar =3D FALSE; + } =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, IsBitVar); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2439,11 +2467,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 +2512,19 @@ ParseIfrData ( // if (BlockData !=3D NULL){ BlockData =3D NULL; } =20 - Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData); + if (mQuestionReferBitVar) { + mQuestionReferBitVar =3D FALSE; + VarWidth =3D 1; + IsBitVar =3D TRUE; + } else { + IsBitVar =3D FALSE; + } + + Status =3D IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarSto= rageData, IfrOpHdr, VarWidth, &BlockData, IsBitVar); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND){ // //The opcode is not required,exit and parse other opcode. // @@ -2612,11 +2648,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 +2690,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 +2732,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 +2774,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. // @@ -2985,13 +3021,19 @@ ParseIfrData ( // SmallestDefaultId =3D 0xFFFF; FromOtherDefaultOpcode =3D FALSE; } } + mQuestionReferBitVar =3D FALSE; =20 break; =20 + case EFI_IFR_GUID_OP: + if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_= HEADER)), &mBitVarstoreGuid)) { + mQuestionReferBitVar =3D TRUE; + } + default: if (BlockData !=3D NULL) { if (BlockData->Scope > 0) { BlockData->Scope =3D (UINT8) (BlockData->Scope + IfrOpHdr->Scope= ); } @@ -3567,13 +3609,138 @@ GetStorageWidth ( =20 return StorageWidth; } =20 /** +For some question (oneof/numeric/checkbox),their storage may be bit filed, +their block data may have same OFFSET and WIDTH, this function merge the +same block data to one. + +@param BlockLink The Link of the block data. + +**/ +VOID +UpdateBlockDataArray( + IN LIST_ENTRY *BlockLink +) +{ + LIST_ENTRY *Link; + LIST_ENTRY *TempLink; + LIST_ENTRY *ListEntry; + LIST_ENTRY *NextListEntry; + LIST_ENTRY *LinkDefault; + LIST_ENTRY *NextLinkDefault; + IFR_BLOCK_DATA *BlockData; + IFR_BLOCK_DATA *NextBlockeData; + IFR_DEFAULT_DATA *DefaultValueData; + IFR_DEFAULT_DATA *NextDefaultValueData; + UINT32 Value; + UINT32 Mask; + UINT32 PreBits; + UINT32 *DefaultValue; + UINT8 *BufferValue; + BOOLEAN BlockDataChanged; + BOOLEAN DefaultIdChanged; + BOOLEAN NextBlockChanged; + + Value =3D 0; + Link =3D BlockLink->ForwardLink; + BlockDataChanged =3D TRUE; + DefaultIdChanged =3D FALSE; + NextBlockChanged =3D FALSE; + + while (Link !=3D BlockLink) { + BlockData =3D BASE_CR (Link, IFR_BLOCK_DATA, Entry); + TempLink =3D Link->ForwardLink; + if (!BlockData ->IsBitVar) { + Link =3D Link->ForwardLink; + continue; + } + + while (TempLink !=3D Link) { + NextBlockeData =3D BASE_CR (TempLink, IFR_BLOCK_DATA, Entry); + TempLink =3D TempLink->ForwardLink; + if (BlockData->Offset !=3D NextBlockeData->Offset || BlockData->Widt= h !=3D NextBlockeData->Width) { + continue; + } + // + // They are the same blocks, merge them to one, and update the defau= lt value. + // + ListEntry =3D &BlockData->DefaultValueEntry; + for (LinkDefault =3D ListEntry->ForwardLink; LinkDefault !=3D ListEn= try; LinkDefault =3D LinkDefault->ForwardLink) { + DefaultValueData =3D BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry= ); + NextListEntry =3D &NextBlockeData->DefaultValueEntry; + for (NextLinkDefault =3D NextListEntry->ForwardLink; NextLinkDefau= lt !=3D NextListEntry; NextLinkDefault =3D NextLinkDefault->ForwardLink) { + NextDefaultValueData =3D BASE_CR (NextLinkDefault, IFR_DEFAULT_D= ATA, Entry); + if (DefaultValueData->DefaultId !=3D NextDefaultValueData->Defau= ltId) { + continue; + } + // + // The default value with same default id. + // + if (BlockDataChanged) { + Mask =3D (1 << BlockData->BitWidth) - 1; + PreBits =3D BlockData->BitOffset - BlockData->Offset * 8; + DefaultValue =3D (UINT32*)&(DefaultValueData->Value); + *DefaultValue <<=3D PreBits; + Mask <<=3D PreBits; + Value =3D (Value & (~Mask)) | *DefaultValue; + BlockDataChanged =3D FALSE; + } else if (!BlockDataChanged && !NextBlockChanged && DefaultIdCh= anged){ + Mask =3D (1 << BlockData->BitWidth) - 1; + PreBits =3D BlockData->BitOffset - BlockData->Offset * 8; + DefaultValue =3D (UINT32*)&(DefaultValueData->Value); + *DefaultValue <<=3D PreBits; + Mask <<=3D PreBits; + Value =3D (Value & (~Mask)) | *DefaultValue; + DefaultIdChanged =3D FALSE; + } else if (!BlockDataChanged && NextBlockChanged) { + BufferValue =3D (UINT8*)&(DefaultValueData->Value); + Value =3D (UINTN)(*BufferValue); + } + + Mask =3D (1 << NextBlockeData->BitWidth) - 1; + PreBits =3D NextBlockeData->BitOffset - NextBlockeData->Offset *= 8; + DefaultValue =3D (UINT32*) & (NextDefaultValueData->Value); + *DefaultValue <<=3D PreBits; + Mask <<=3D PreBits; + Value =3D (Value & (~Mask)) | *DefaultValue; + + CopyMem (&DefaultValueData->Value, &Value, sizeof (EFI_IFR_TYPE_= VALUE)); + } + DefaultIdChanged =3D TRUE; + } + RemoveEntryList (&NextBlockeData->Entry); + if (NextBlockeData->Name !=3D NULL) { + FreePool (NextBlockeData->Name); + } + // + // Free default value link array + // + while (!IsListEmpty (&NextBlockeData->DefaultValueEntry)) { + DefaultValueData =3D BASE_CR (NextBlockeData->DefaultValueEntry.Fo= rwardLink, IFR_DEFAULT_DATA, Entry); + RemoveEntryList (&DefaultValueData->Entry); + FreePool (DefaultValueData); + } + FreePool (NextBlockeData); + + Link->ForwardLink =3D TempLink; + NextBlockChanged =3D TRUE; + } + + Link =3D Link->ForwardLink; + BlockDataChanged =3D TRUE; + NextBlockChanged =3D FALSE; + DefaultIdChanged =3D FALSE; + } +} + +/** Generate ConfigAltResp string base on the varstore info. =20 - @param HiiHandle Hii Handle for this hii package. + Contributed-under: TianoCore Contribution Agreement 1.0 +Signed-off-by: Dandan Bi Hii Handle for = this hii package. @param ConfigHdr The config header for this varstore. @param VarStorageData The varstore info. @param DefaultIdArray The Default id array. @param DefaultAltCfgResp The DefaultAltCfgResp info may be retu= rn. =20 @@ -3610,10 +3777,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..e9962be 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -75,15 +75,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. // --=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 Dec 29 01:50:16 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.zoho.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 14925196258791020.8788738131518; Tue, 18 Apr 2017 05:47:05 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 605CF2195408F; Tue, 18 Apr 2017 05:47:04 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 165DB21A18AAB for ; Tue, 18 Apr 2017 05:47:03 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:47:03 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:47:02 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823112" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:32 +0800 Message-Id: <1492519592-173060-5-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> MIME-Version: 1.0 Subject: [edk2] [RFC patch 4/4] MdeModulePkg/DriverSample: Add smaple 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 Content-Type: multipart/mixed; boundary="===============0048130975599519945==" Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 --===============0048130975599519945== Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 1.Construct the EFI VarStore with: (a) bit fields (b) nested structure( the nested structure contains bit fields). 2.Construct oneof/numeric/check to refer the bit fields of the EFI VarStore. Cc: Eric Dong Cc: Liming Gao Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/DriverSampleDxe/DriverSample.c | 56 +++++++++++++++++++ .../Universal/DriverSampleDxe/DriverSample.h | 1 + .../Universal/DriverSampleDxe/NVDataStruc.h | 19 +++++++ MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 65 ++++++++++++++++++= ++++ .../Universal/DriverSampleDxe/VfrStrings.uni | 12 ++++ 5 files changed, 153 insertions(+) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.c index f103b9c..b226a65 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -18,10 +18,11 @@ 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 MyBitVar[] =3D L"MyBitVar"; 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 +663,14 @@ ExtractConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiVar))= { return EFI_UNSUPPORTED; } + if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyBitVar))= { + return EFI_UNSUPPORTED; + } + // // Set Request to the unified request string. // ConfigRequest =3D Request; // @@ -883,10 +888,13 @@ RouteConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiV= ar)) { return EFI_UNSUPPORTED; } + if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyBitV= ar)) { + return EFI_UNSUPPORTED; + } =20 // // Get Buffer Storage data from EFI variable // BufferSize =3D sizeof (DRIVER_SAMPLE_CONFIGURATION); @@ -1683,10 +1691,11 @@ DriverSampleInit ( DRIVER_SAMPLE_CONFIGURATION *Configuration; BOOLEAN ActionFlag; EFI_STRING ConfigRequestHdr; EFI_STRING NameRequestHdr; MY_EFI_VARSTORE_DATA *VarStoreConfig; + MY_BITS_VARSTORE_DATA *BitsVarStoreConfig; EFI_INPUT_KEY HotKey; EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx; =20 // // Initialize the local variables. @@ -1962,10 +1971,57 @@ DriverSampleInit ( return EFI_INVALID_PARAMETER; } } FreePool (ConfigRequestHdr); =20 + // + // Initialize Bits efi varstore configuration data + // + BitsVarStoreConfig =3D &mPrivateData->BitsVarStoreConfig; + ZeroMem (BitsVarStoreConfig, sizeof (MY_BITS_VARSTORE_DATA)); + + ConfigRequestHdr =3D HiiConstructConfigHdr (&gDriverSampleFormSetGuid, M= yBitVar, DriverHandle[0]); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (MY_BITS_VARSTORE_DATA); + Status =3D gRT->GetVariable (MyBitVar, &gDriverSampleFormSetGuid, NULL, = &BufferSize, BitsVarStoreConfig); + if (EFI_ERROR (Status)) { + // + // Store zero data to EFI variable Storage. + // + Status =3D gRT->SetVariable( + MyBitVar, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (MY_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); + 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 6c97239..6947cea 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -82,10 +82,11 @@ typedef struct { =20 EFI_HANDLE DriverHandle[2]; EFI_HII_HANDLE HiiHandle[2]; DRIVER_SAMPLE_CONFIGURATION Configuration; MY_EFI_VARSTORE_DATA VarStoreConfig; + MY_BITS_VARSTORE_DATA BitsVarStoreConfig; =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..9b74dda 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -29,10 +29,11 @@ Revision History: #include #include #include =20 #define CONFIGURATION_VARSTORE_ID 0x1234 +#define BITS_VARSTORE_ID 0x2345 =20 #pragma pack(1) typedef struct { UINT16 MyStringData[40]; UINT16 SomethingHiddenForHtml; @@ -77,10 +78,28 @@ typedef struct { UINT16 Field16; UINT8 OrderedList[3]; UINT16 SubmittedCallback; } MY_EFI_VARSTORE_DATA; =20 +typedef struct { + UINT16 Field16; + UINT8 MyBits4 : 1; ///< Bits 0 + UINT8 MyBits3 : 3; ///< Bits 3:1 + UINT8 MyBits5 : 3; ///< Bits 6:4 + UINT16 MyBits6 : 4; ///< Bits 3:0 + UINT8 Field8; +} MY_BITS_VARSTORE_DATA1; + +typedef struct { + UINT16 Field16; + MY_BITS_VARSTORE_DATA1 BitsData; + UINT8 Field8; + UINT16 MyBits7 : 3; ///< Bits 2:0 + UINT16 MyBits8 : 3; ///< Bits 5:3 + UINT16 MyBits9 : 1; ///< Bits 6 +} MY_BITS_VARSTORE_DATA; + // // Labels definition // #define LABEL_UPDATE1 0x1234 #define LABEL_UPDATE2 0x2234 diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/= Universal/DriverSampleDxe/Vfr.vfr index 4bdaf76..cbc8f6d 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -86,10 +86,18 @@ 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_BITS_VARSTORE_DATA, // This is the data structure t= ype + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures + name =3D MyBitVar, // Define referenced name in= vfr + guid =3D DRIVER_SAMPLE_FORMSET_GUID; // GUID of this buffer stora= ge + + // // 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] @@ -112,10 +120,67 @@ formset =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT); =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); =20 + checkbox varid =3D MyBitVar.BitsData.MyBits4, + questionid =3D 0x6666, + prompt =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyBitVar.BitsData.MyBits3, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_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 MyBitVar.BitsData.MyBits5, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 5, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 6, defaultstore =3D MyManufactureDefault, // This= is manufacture default value + endnumeric; + + numeric varid =3D MyBitVar.BitsData.MyBits6, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 15, + step =3D 0, + default =3D 11, defaultstore =3D MyStandardDefault, // Thi= s is standard default value + default =3D 12, defaultstore =3D MyManufactureDefault, // Thi= s is manufacture default value + endnumeric; + + checkbox varid =3D MyBitVar.MyBits9, + prompt =3D STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyBitVar.MyBits8, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_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 MyBitVar.MyBits7, + prompt =3D STRING_TOKEN(STR_BIT_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 5, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 6, defaultstore =3D MyManufactureDefault, // This= is manufacture default value + endnumeric; + // // Define a display only text (EFI_IFR_TEXT) // text help =3D STRING_TOKEN(STR_TEXT_HELP), // Help string diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeMod= ulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 8d24a47..9a52c02 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -55,10 +55,14 @@ #language fr-FR "Please select the = number" =20 #string STR_NUMERIC_NUM_HELP #language en-US "Check the input nu= mber, test the efi buffer varstore" #language fr-FR "Check the input nu= mber, test the efi buffer varstore" =20 #string STR_ONE_OF_PROMPT #language en-US "My one-of prompt #= 1" #language fr-FR "Mi uno- de gu=C3= =ADa # 1" +#string STR_ONE_OF_BIT_PROMPT #language en-US "BIT one-of" + #language fr-FR "BIT one-of" +#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_PROMPT_KEYWORD #language en-US "My Keyword Namespa= ce Test" #language fr-FR "My Keyword Namespa= ce Test" #language x-UEFI-ns "iSCSIBootEnabl= e" #string STR_CHECK_KEYWORD_SUPPORT #language en-US "Check iSCSI Boot E= nable" #language fr-FR "Check iSCSI Boot E= nable" @@ -78,12 +82,20 @@ #language fr-FR "Mi uno- del texto = # 6" #string STR_BOOT_ORDER1 #language en-US "SmallBootList" #language fr-FR "Mi uno- del texto = # 7" #string STR_BOOT_ORDER2 #language en-US "LargeBootList" #language fr-FR "Mi uno- del texto = # 8" +#string STR_BIT_NUMERIC_PROMPT #language en-US "BIT numeric" + #language fr-FR "BIT numeric" +#string STR_BIT_NEST_NUMERIC_PROMPT #language en-US "NEST_BIT numeric" + #language fr-FR "NEST_BIT numeric" #string STR_CHECK_BOX_PROMPT #language en-US "Activate this chec= k box" #language fr-FR "Active Las Armas N= ucleares" +#string STR_BIT_CHECK_BOX_PROMPT #language en-US "BIT check box" + #language fr-FR "BIT check box" +#string STR_BIT_NEST_CHECK_BOX_PROMPT #language en-US "NEST_BIT check box" + #language fr-FR "NEST_BIT check box" #string STR_CHECK_BOX_HELP #language en-US "This is the help m= essage for the activation of check boxes. This is not to be confused with = activating Czech boxes, since one can never tell what the ramifications are= of activating foreign controlled boxes are." #language fr-FR "=C3=89ste es el me= nsaje de la ayuda para la activaci=C3=B3n del armamento nuclear. Cu=C3=A1l = es exactamente resistente calcular fuera sobre de eso?" #string STR_CHECK_DYNAMIC_PROMPT #language en-US "Activate Dynamic c= heck box" #language fr-FR "Activate Dynamico = check box" #string STR_CHECK_DYNAMIC_HELP #language en-US "This is the help m= essage for the activation of check boxes. This is not to be confused with = activating Czech boxes, since one can never tell what the ramifications are= of activating foreign controlled boxes are." --=20 1.9.5.msysgit.1 --===============0048130975599519945== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel --===============0048130975599519945==--