From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="18993088" 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 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao 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: [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: Tue, 26 Dec 2017 10:15:56 -0000 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 = CApp + ' Size = sizeof(%s);\n' % (Pcd.DatumType) + for FieldList in [Pcd.DefaultValues]: + if not FieldList: + continue + for FieldName in FieldList: + FieldName = "." + FieldName + IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) + if IsArray: + Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0]) + CApp = 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 = '' + while '[' in FieldName: + NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]' + ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0]) + FieldName = FieldName.split(']', 1)[1] + FieldName = NewFieldName + FieldName + while '[' in FieldName: + FieldName = FieldName.rsplit('[', 1)[0] + CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1) for skuname in self.SkuIdMgr.SkuOverrideOrder(): inherit_OverrideValues = Pcd.SkuOverrideValues[skuname] - for FieldList in [Pcd.DefaultValues, inherit_OverrideValues.get(DefaultStoreName)]: + for FieldList in [inherit_OverrideValues.get(DefaultStoreName)]: if not FieldList: continue for FieldName in FieldList: FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) @@ -1341,13 +1360,36 @@ class DscBuildData(PlatformBuildClassObject): CApp = 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 = self.IsFieldValueAnArray(FieldList[FieldName][0]) + try: + Value, ValueSize = ParseFieldValue (FieldList[FieldName][0]) + except Exception: + print FieldList[FieldName][0] + if isinstance(Value, str): + CApp = CApp + ' Pcd->%s = %s; // From %s Line %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 = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName) + CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) + CApp = CApp + ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) + else: + if ValueSize > 4: + CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) + else: + CApp = CApp + ' Pcd->%s = %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 = 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 == Pcd.DefaultFromDSC: IsArray = self.IsFieldValueAnArray(FieldList) Value, ValueSize = ParseFieldValue (FieldList) -- 2.14.3.windows.1