From nobody Sun May 5 21:13:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514283655173666.7265188208412; Tue, 26 Dec 2017 02:20:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6C30F222F4E20; Tue, 26 Dec 2017 02:15:57 -0800 (PST) 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 B578D22225C17 for ; Tue, 26 Dec 2017 02:15:55 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 02:20:49 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga001.jf.intel.com with ESMTP; 26 Dec 2017 02:20:48 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="18993088" From: BobCF To: edk2-devel@lists.01.org Date: Tue, 26 Dec 2017 18:20:17 +0800 Message-Id: <20171226102017.16892-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [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: , Cc: 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" 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 Reviewed-by: 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 b= e the last field # in a structure. The size formula for this case is: # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (H= ighestIndex + 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[FieldNa= me.strip(".")][0]) + if IsArray: + Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName.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.DatumTyp= e, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip(".")); + else: + NewFieldName =3D '' + while '[' in FieldName: + NewFieldName =3D NewFieldName + FieldName.spli= t('[', 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_OverrideValue= s.get(DefaultStoreName)]: + for FieldList in [inherit_OverrideValues.get(DefaultStoreN= ame)]: if not FieldList: continue for FieldName in FieldList: FieldName =3D "." + FieldName IsArray =3D self.IsFieldValueAnArray(FieldList[Fie= ldName.strip(".")][0]) @@ -1341,13 +1360,36 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n' =20 # # Assign field values in PCD # + for FieldList in [Pcd.DefaultValues]: + if not FieldList: + continue + for FieldName in FieldList: + IsArray =3D self.IsFieldValueAnArray(FieldList[FieldNa= me][0]) + try: + Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0]) + except Exception: + print FieldList[FieldName][0] + if isinstance(Value, str): + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][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 Li= ne %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldNa= me][1], FieldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s[0], Value, (Fi= eldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSiz= e, ValueSize) + else: + if ValueSize > 4: + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From = %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldL= ist[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,in= herit_OverrideValues.get(DefaultStoreName)]: + for FieldList in [Pcd.DefaultFromDSC,inherit_OverrideValue= s.get(DefaultStoreName)]: if not FieldList: continue if Pcd.DefaultFromDSC and FieldList =3D=3D Pcd.Default= FromDSC: IsArray =3D self.IsFieldValueAnArray(FieldList) Value, ValueSize =3D ParseFieldValue (FieldList) --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel