From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 03C7221945DC1 for ; Sun, 4 Jun 2017 20:41:56 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2017 20:43:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,299,1493708400"; d="scan'208";a="976762335" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 04 Jun 2017 20:43:02 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 4 Jun 2017 20:43:01 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.56]) with mapi id 14.03.0319.002; Mon, 5 Jun 2017 11:42:58 +0800 From: "Bi, Dandan" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Gao, Liming" Thread-Topic: [edk2] [RFC 1/2] BaseTool/VfrCompile: Support Union type in VFR Thread-Index: AQHS3aFtUXFq8/BiwUCDzpP3e0p4K6IVBzgAgACYeAA= Date: Mon, 5 Jun 2017 03:42:57 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB3B9288A5@shsmsx102.ccr.corp.intel.com> References: <1496628796-368572-1-git-send-email-dandan.bi@intel.com> <1496628796-368572-2-git-send-email-dandan.bi@intel.com> <734D49CCEBEEF84792F5B80ED585239D5B986CC8@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5B986CC8@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [RFC 1/2] BaseTool/VfrCompile: Support Union type in VFR X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2017 03:41:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, I can update the logic in VfrCompiler to avoid using gUnionTypeStructure. N= ew patches will send out. Thanks for your comments. Regards, Dandan -----Original Message----- From: Ni, Ruiyu=20 Sent: Monday, June 5, 2017 10:35 AM To: Bi, Dandan ; edk2-devel@lists.01.org Cc: Dong, Eric ; Gao, Liming Subject: RE: [edk2] [RFC 1/2] BaseTool/VfrCompile: Support Union type in VF= R Dandan, Can you avoid using gUnionTypeStructure? Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Dandan Bi > Sent: Monday, June 5, 2017 10:13 AM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Gao, Liming=20 > > Subject: [edk2] [RFC 1/2] BaseTool/VfrCompile: Support Union type in=20 > VFR >=20 > Cc: Eric Dong > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > BaseTools/Source/C/VfrCompile/VfrSyntax.g | 17 +++++++++++++++++ > BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 13 ++++++++++++- > BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 1 + > 3 files changed, 30 insertions(+), 1 deletion(-) >=20 > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > index 406dbc5..bd8457d 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > @@ -155,10 +155,11 @@ VfrParserStart ( > #token Label("label") "label" > #token Timeout("timeout") "timeout" > #token Inventory("inventory") "inventory" > #token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP" > #token Struct("struct") "struct" > +#token Union("union") "union" > #token Boolean("BOOLEAN") "BOOLEAN" > #token Uint64("UINT64") "UINT64" > #token Uint32("UINT32") "UINT32" > #token Uint16("UINT16") "UINT16" > #token Char16("CHAR16") "CHAR16" > @@ -270,10 +271,11 @@ vfrProgram > [UINT8 Return] : > mConstantOnlyInExpression =3D FALSE; > >> > ( > vfrPragmaPackDefinition > | vfrDataStructDefinition > + | vfrDataUnionDefinition > )* > vfrFormSetDefinition > << $Return =3D mParserStatus; >> > ; >=20 > @@ -318,10 +320,25 @@ vfrPragmaPackDefinition : > | pragmaPackNumber > } > "\)" > ; >=20 > + vfrDataUnionDefinition : > + { TypeDef } Union << gUnionTypeStructur= e =3D TRUE; > gCVfrVarDataTypeDB.DeclareDataTypeBegin (); >> > + { NonNvDataMap } > + { > + N1:StringIdentifier << > _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >> > + } > + OpenBrace > + vfrDataStructFields > + CloseBrace > + { > + N2:StringIdentifier << > _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >> > + } > + ";" << gCVfrVarDataTypeD= B.DeclareDataTypeEnd (); > gUnionTypeStructure =3D FALSE;>> > + ; > + > vfrDataStructDefinition : > { TypeDef } Struct << > gCVfrVarDataTypeDB.DeclareDataTypeBegin (); >> > { NonNvDataMap } > { > N1:StringIdentifier << > _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>=20 > diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > index 2f97975..b392476 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp > @@ -1018,12 +1018,14 @@ CVfrVarDataTypeDB::DataTypeAddField ( { > SVfrDataField *pNewField =3D NULL; > SVfrDataType *pFieldType =3D NULL; > SVfrDataField *pTmp; > UINT32 Align; > + UINT32 MaxDataTypeSize; >=20 > CHECK_ERROR_RETURN (GetDataType (TypeName, &pFieldType),=20 > VFR_RETURN_SUCCESS); > + MaxDataTypeSize =3D mNewDataType->mTotalSize; >=20 > if (strlen (FieldName) >=3D MAX_NAME_LEN) { > return VFR_RETURN_INVALID_PARAMETER; > } >=20 > @@ -1055,11 +1057,19 @@ CVfrVarDataTypeDB::DataTypeAddField ( > pTmp->mNext =3D pNewField; > pNewField->mNext =3D NULL; > } >=20 > mNewDataType->mAlign =3D MIN (mPackAlign, MAX (pFieldType->mAlign, > mNewDataType->mAlign)); > - mNewDataType->mTotalSize =3D pNewField->mOffset + (pNewField- > >mFieldType->mTotalSize) * ((ArrayNum =3D=3D 0) ? 1 : ArrayNum); > + > + if (gUnionTypeStructure) { > + if (MaxDataTypeSize < pNewField->mFieldType->mTotalSize) { > + mNewDataType->mTotalSize =3D pNewField->mFieldType->mTotalSize; > + } > + pNewField->mOffset =3D 0; > + } else { > + mNewDataType->mTotalSize =3D pNewField->mOffset + > + (pNewField->mFieldType->mTotalSize) * ((ArrayNum =3D=3D 0) ? 1 : > + ArrayNum); } >=20 > return VFR_RETURN_SUCCESS; > } >=20 > VOID > @@ -3715,10 +3725,11 @@ CVfrStringDB::GetUnicodeStringTextSize ( > } >=20 > return StringSize; > } >=20 > +BOOLEAN gUnionTypeStructure =3D FALSE; > BOOLEAN VfrCompatibleMode =3D FALSE; >=20 > CVfrVarDataTypeDB gCVfrVarDataTypeDB; CVfrDefaultStore =20 > gCVfrDefaultStore; CVfrDataStorage gCVfrDataStorage; diff --git=20 > a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h > b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h > index 59509c3..b6791ec 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h > +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h > @@ -19,10 +19,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,=20 > EITHER EXPRESS OR IMPLIED. > #include "string.h" > #include "Common/UefiBaseTypes.h" > #include "EfiVfr.h" > #include "VfrError.h" >=20 > +extern BOOLEAN gUnionTypeStructure; > extern BOOLEAN VfrCompatibleMode; >=20 > #define MAX_NAME_LEN 64 > #define MAX_STRING_LEN 0x100 > #define DEFAULT_ALIGN 1 > -- > 1.9.5.msysgit.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel