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.136; helo=mga12.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 6E2AF21F6A6E9 for ; Tue, 27 Feb 2018 21:53:28 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 21:59:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,404,1515484800"; d="scan'208";a="204307352" Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2018 21:59:33 -0800 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Wed, 28 Feb 2018 13:59:20 +0800 Message-Id: <20180228055921.35432-3-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 In-Reply-To: <20180228055921.35432-1-bob.c.feng@intel.com> References: <20180228055921.35432-1-bob.c.feng@intel.com> Subject: [Patch 3/4] BaseTool: GUID assignment fail. 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: Wed, 28 Feb 2018 05:53:28 -0000 Structure PCD GUID assignment fail. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DecBuildData.py | 3 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 289 ++++++++++++++-------- 2 files changed, 182 insertions(+), 110 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 18101a0add..ee00ec0719 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -13,10 +13,11 @@ # from Common.String import * from Common.DataType import * from Common.Misc import * from types import * +from collections import OrderedDict from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject ## Platform build information from DEC file # @@ -365,11 +366,11 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return self._Pcds def ProcessStructurePcd(self, StructurePcdRawDataSet): - s_pcd_set = dict() + s_pcd_set = OrderedDict() for s_pcd,LineNo in StructurePcdRawDataSet: if s_pcd.TokenSpaceGuidCName not in s_pcd_set: s_pcd_set[s_pcd.TokenSpaceGuidCName] = [] s_pcd_set[s_pcd.TokenSpaceGuidCName].append((s_pcd,LineNo)) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 59bfd9c8e0..29c43e751f 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -37,10 +37,11 @@ from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject +from collections import OrderedDict # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # PcdValueInitName = 'PcdValueInit' @@ -1281,11 +1282,11 @@ class DscBuildData(PlatformBuildClassObject): if SkuName in SkuIds and "." in TokenSpaceGuid: S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]]) # handle pcd value override StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) - S_pcd_set = {} + S_pcd_set = OrderedDict() for str_pcd in StrPcdSet: str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None) str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None) if not isinstance (str_pcd_dec, StructurePcd): EdkLogger.error('build', PARSER_ERROR, @@ -1559,10 +1560,181 @@ class DscBuildData(PlatformBuildClassObject): Result = Result + '\\x%02x' % (Value & 0xff) Value = Value >> 8 Result = Result + '"' return Result + def GenerateSizeFunction(self,Pcd): + CApp = "// Default Value in Dec \n" + CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + for FieldList in [Pcd.DefaultValues]: + if not FieldList: + continue + for FieldName in FieldList: + FieldName = "." + FieldName + IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) + if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): + try: + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) + Value, ValueSize = ParseFieldValue(Value) + CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); + else: + NewFieldName = '' + FieldName_ori = FieldName.strip('.') + 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); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) + for skuname in Pcd.SkuOverrideValues: + if skuname == "COMMON": + continue + for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]: + CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) + for FieldList in [Pcd.SkuOverrideValues[skuname].get(defaultstorenameitem)]: + if not FieldList: + continue + for FieldName in FieldList: + FieldName = "." + FieldName + IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) + if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): + try: + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) + Value, ValueSize = ParseFieldValue(Value) + CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); + else: + NewFieldName = '' + FieldName_ori = FieldName.strip('.') + 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); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) + CApp = CApp + "}\n" + return CApp + def GenerateSizeStatments(self,Pcd): + CApp = ' Size = sizeof(%s);\n' % (Pcd.DatumType) + CApp = CApp + ' Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + return CApp + def GenerateDefaultValueAssignFunction(self,Pcd): + CApp = "// Default value in Dec \n" + CApp = CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType) + CApp = CApp + ' UINT32 FieldSize;\n' + CApp = CApp + ' CHAR8 *Value;\n' + DefaultValueFromDec = Pcd.DefaultValueFromDec + IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec) + if IsArray: + try: + DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) + except BadExpression: + EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" % + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec)) + Value, ValueSize = ParseFieldValue (DefaultValueFromDec) + if isinstance(Value, str): + CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec) + CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) + for FieldList in [Pcd.DefaultValues]: + if not FieldList: + continue + for FieldName in FieldList: + IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0]) + if IsArray: + try: + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2])) + + try: + Value, ValueSize = ParseFieldValue (FieldList[FieldName][0]) + except Exception: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2])) + 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, 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]) + CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD') + inherit_OverrideValues = Pcd.SkuOverrideValues['DEFAULT'] + pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue + for FieldList in [pcddefaultvalue,inherit_OverrideValues.get('STANDARD')]: + if not FieldList: + continue + if pcddefaultvalue and FieldList == pcddefaultvalue: + IsArray = self.IsFieldValueAnArray(FieldList) + if IsArray: + try: + FieldList = ValueExpressionEx(FieldList, "VOID*")(True) + except BadExpression: + EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" % + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) + Value, ValueSize = ParseFieldValue (FieldList) + if isinstance(Value, str): + CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) + continue + for FieldName in FieldList: + IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0]) + if IsArray: + try: + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2])) + try: + Value, ValueSize = ParseFieldValue (FieldList[FieldName][0]) + except Exception: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2])) + 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, 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]) + CApp = CApp + "}\n" + return CApp + def GenerateDefaultValueAssignStatement(self,Pcd): + CApp = ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + return CApp def GenerateInitializeFunc(self, SkuName, DefaultStoreName, Pcd, InitByteValue, CApp): OverrideValues = {DefaultStoreName:""} if Pcd.SkuOverrideValues: OverrideValues = Pcd.SkuOverrideValues[SkuName] for DefaultStoreName in OverrideValues.keys(): @@ -1598,69 +1770,11 @@ class DscBuildData(PlatformBuildClassObject): # array member is detected, and the size is based on the highest index used with # 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) - CApp = CApp + "// Default Value in Dec \n" - for FieldList in [Pcd.DefaultValues]: - if not FieldList: - continue - for FieldName in FieldList: - FieldName = "." + FieldName - IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) - if IsArray: - try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) - except BadExpression: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % - (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) - Value, ValueSize = ParseFieldValue(Value) - CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); - else: - NewFieldName = '' - FieldName_ori = FieldName.strip('.') - 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); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) - for skuname in self.SkuIdMgr.GetSkuChain(SkuName): - inherit_OverrideValues = Pcd.SkuOverrideValues[skuname] - storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName] - for defaultstorenameitem in storeset: - CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) - for FieldList in [inherit_OverrideValues.get(defaultstorenameitem)]: - if not FieldList: - continue - for FieldName in FieldList: - FieldName = "." + FieldName - IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) - if IsArray: - try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) - except BadExpression: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % - (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) - Value, ValueSize = ParseFieldValue(Value) - CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); - else: - NewFieldName = '' - FieldName_ori = FieldName.strip('.') - 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); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) - if skuname == SkuName: - break + CApp = CApp + self.GenerateSizeStatments(Pcd) # # Allocate and zero buffer for the PCD # Must handle cases where current value is smaller, larger, or same size # Always keep that larger one as the current size @@ -1675,59 +1789,14 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n' # # Assign field values in PCD # - CApp = CApp + "// Default value in Dec \n" - DefaultValueFromDec = Pcd.DefaultValueFromDec - IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec) - if IsArray: - try: - DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) - except BadExpression: - EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" % - (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec)) - Value, ValueSize = ParseFieldValue (DefaultValueFromDec) - if isinstance(Value, str): - CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec) - elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec) - CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) - for FieldList in [Pcd.DefaultValues]: - if not FieldList: - continue - for FieldName in FieldList: - IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0]) - if IsArray: - try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) - except BadExpression: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % - (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2])) - - try: - Value, ValueSize = ParseFieldValue (FieldList[FieldName][0]) - except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2])) - 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]) + CApp = CApp + self.GenerateDefaultValueAssignStatement(Pcd) for skuname in self.SkuIdMgr.GetSkuChain(SkuName): + if skuname == "DEFAULT": + continue inherit_OverrideValues = Pcd.SkuOverrideValues[skuname] storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName] for defaultstorenameitem in storeset: CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) pcddefaultvalue = Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue @@ -1770,11 +1839,11 @@ class DscBuildData(PlatformBuildClassObject): # # 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) + CApp = CApp + ' memcpy (&Pcd->%s, 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]) @@ -1811,10 +1880,12 @@ class DscBuildData(PlatformBuildClassObject): Includes[IncludeFile] = True CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] + CApp = CApp + self.GenerateSizeFunction(Pcd) + CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd) if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): -- 2.14.3.windows.1