From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 59F2A222275A3 for ; Sun, 7 Jan 2018 19:28:26 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 19:33:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8902286" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 07 Jan 2018 19:33:35 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 7 Jan 2018 19:33:35 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 7 Jan 2018 19:33:34 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Mon, 8 Jan 2018 11:33:32 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Fix Pcd value override issue caused by SKU inherit Thread-Index: AQHTfjM542KXkNpRIkioSboju5bWXKNpZmtw Date: Mon, 8 Jan 2018 03:33:32 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1A016B@SHSMSX104.ccr.corp.intel.com> References: <20171226102017.16892-1-bob.c.feng@intel.com> In-Reply-To: <20171226102017.16892-1-bob.c.feng@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: [Patch] BaseTools: Fix Pcd value override issue caused by SKU inherit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 03:28:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Feng, Bob C >Sent: Tuesday, December 26, 2017 6:20 PM >To: edk2-devel@lists.01.org >Cc: Feng, Bob C ; Gao, Liming >Subject: [Patch] BaseTools: Fix Pcd value override issue caused by SKU inh= erit > >Pcd default value in DEC should only be assigned once. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Bob Feng >Cc: Liming Gao >--- > BaseTools/Source/Python/Workspace/DscBuildData.py | 46 >++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 2 deletions(-) > >diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py >b/BaseTools/Source/Python/Workspace/DscBuildData.py >index 054ad2c254..e4f3586654 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -1300,13 +1300,32 @@ class DscBuildData(PlatformBuildClassObject): > # the flexible array member. The flexible array member must = be the >last field > # in a structure. The size formula for this case is: > # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * >(HighestIndex + 1) > # > CApp =3D CApp + ' Size =3D sizeof(%s);\n' % (Pcd.DatumType) >+ for FieldList in [Pcd.DefaultValues]: >+ if not FieldList: >+ continue >+ for FieldName in FieldList: >+ FieldName =3D "." + FieldName >+ IsArray =3D >self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) >+ if IsArray: >+ Value, ValueSize =3D ParseFieldValue >(FieldList[FieldName.strip(".")][0]) >+ CApp =3D CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, = %d / >__ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% >__ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, >FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), >ValueSize, Pcd.DatumType, FieldName.strip(".")); >+ else: >+ NewFieldName =3D '' >+ while '[' in FieldName: >+ NewFieldName =3D NewFieldName + FieldName.spl= it('[', 1)[0] + >'[0]' >+ ArrayIndex =3D int(FieldName.split('[', 1)[1]= .split(']', 1)[0]) >+ FieldName =3D FieldName.split(']', 1)[1] >+ FieldName =3D NewFieldName + FieldName >+ while '[' in FieldName: >+ FieldName =3D FieldName.rsplit('[', 1)[0] >+ CApp =3D CApp + ' __FLEXIBLE_SIZE(Size, %s, = %s, %d);\n' % >(Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1) > for skuname in self.SkuIdMgr.SkuOverrideOrder(): > inherit_OverrideValues =3D Pcd.SkuOverrideValues[skuname] >- for FieldList in [Pcd.DefaultValues, >inherit_OverrideValues.get(DefaultStoreName)]: >+ for FieldList in [inherit_OverrideValues.get(DefaultStore= Name)]: > if not FieldList: > continue > for FieldName in FieldList: > FieldName =3D "." + FieldName > IsArray =3D >self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) >@@ -1341,13 +1360,36 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n= ' > > # > # Assign field values in PCD > # >+ for FieldList in [Pcd.DefaultValues]: >+ if not FieldList: >+ continue >+ for FieldName in FieldList: >+ IsArray =3D self.IsFieldValueAnArray(FieldList[FieldN= ame][0]) >+ try: >+ Value, ValueSize =3D ParseFieldValue (FieldList[F= ieldName][0]) >+ except Exception: >+ print FieldList[FieldName][0] >+ if isinstance(Value, str): >+ CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Lin= e %d Value %s\n' % >(FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], >FieldList[FieldName][0]) >+ elif IsArray: >+ # >+ # Use memcpy() to copy value into field >+ # >+ CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s,= %s);\n' % >(Pcd.DatumType, FieldName) >+ CApp =3D CApp + ' Value =3D %s; // From %s L= ine %d Value %s\n' % >(self.IntToCString(Value, ValueSize), FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >+ CApp =3D CApp + ' memcpy (&Pcd->%s[0], Value, (F= ieldSize > 0 && >FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) >+ else: >+ if ValueSize > 4: >+ CApp =3D CApp + ' Pcd->%s =3D %dULL; // From= %s Line %d >Value %s\n' % (FieldName, Value, FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >+ else: >+ CApp =3D CApp + ' Pcd->%s =3D %d; // From %s= Line %d >Value %s\n' % (FieldName, Value, FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) > for skuname in self.SkuIdMgr.SkuOverrideOrder(): > inherit_OverrideValues =3D Pcd.SkuOverrideValues[skuname] >- for FieldList in [Pcd.DefaultValues, >Pcd.DefaultFromDSC,inherit_OverrideValues.get(DefaultStoreName)]: >+ for FieldList in >[Pcd.DefaultFromDSC,inherit_OverrideValues.get(DefaultStoreName)]: > if not FieldList: > continue > if Pcd.DefaultFromDSC and FieldList =3D=3D Pcd.Defaul= tFromDSC: > IsArray =3D self.IsFieldValueAnArray(FieldList) > Value, ValueSize =3D ParseFieldValue (FieldList) >-- >2.14.3.windows.1