From nobody Sat Apr 20 04:14:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+66252+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+66252+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1602759556; cv=none; d=zohomail.com; s=zohoarc; b=jZ80swZSfq7g73lp2VgO23XEiW/YvY0ofYDvEcVu3Nh7qTDVyUAMIfetOJO7Wc83HloKIJQ2t4J5kapMeaDoT+N3W2O8K3cMhdVyrHtJzyYcBgVrXcDgknf0yUB7X7geUyDPO/VslUrWIOBv67q5YYEw8TmJJwWm7G1YMU/PsEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602759556; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=xfC5bXjOIl4cTJXqiC/m91O6LfGf3HLUTSvXbNDlUNo=; b=oHKQsIJcEdsIJ53r5Pc7CVY4+FRWxIqibWGTcMjmDAWEVcvCxk7EuvVaA07QTJCEbbANaWz90ewi7nDjxAhZKCQJXUJv73H3pDr2FO2XEW6oP6UhLmDj5D4O7aRgAanfd4SV31mqN60fu3tNreyr66f62ggWBQLayln8jr22e4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+66252+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 160275955625861.71176848241157; Thu, 15 Oct 2020 03:59:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OVOGYY1788612x9IUqT6IHJL; Thu, 15 Oct 2020 03:59:15 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.9573.1602759555104663345 for ; Thu, 15 Oct 2020 03:59:15 -0700 IronPort-SDR: zCfr9/HWed2pERJfxgjF643c6SGpcsiBbFaZkcoTugHrTa8i/XPWP4WKfmidT1tSzNHbkb1mcV AvWFw/6kDHhA== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="153248372" X-IronPort-AV: E=Sophos;i="5.77,378,1596524400"; d="scan'208";a="153248372" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2020 03:59:12 -0700 IronPort-SDR: k9G0i4ldVBhYrAmk/bKsfP0OBjYl9J2JWye09mBsDi8OoCUTfIKt/IZ+K+MYHZdkObag7HXN+C UyX0Vfd8Jf0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,378,1596524400"; d="scan'208";a="521797944" X-Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.66]) by fmsmga005.fm.intel.com with ESMTP; 15 Oct 2020 03:59:09 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Yuwei Chen Subject: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope Structure Pcd Date: Thu, 15 Oct 2020 18:58:51 +0800 Message-Id: <20201015105851.37944-1-bob.c.feng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,bob.c.feng@intel.com X-Gm-Message-State: sTQQ6L8v39drHbsKzvtKnr4Jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1602759555; bh=C5Y4eN2WCvTwqbtAesyTOwRb9ZUuf0Ocl0zLfyG7YrY=; h=Cc:Date:From:Reply-To:Subject:To; b=HdfW4M7YFpo8+d2AhLVjc8VU7lDXQfJBc39vcwWZxvUzEUg+FMqMNHsvbdwJCmU4XF6 Jg2Od+NagqdsH9WuefTWuA/miMkGY5/5F03HAdXWQCgoK+T5gs7Gz3BxhtM/dqbE7XOwr zESJRFAcBk44tPeFQSFHhdqSShndPVndeg4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This patch is to enable the Module scoped Structure Pcd usage. User can set structure pcd field value in module scope. For example, under the [components] section of a dsc file, user can override some field value for a specific module. Package/Module.inf{ gUefiTokenSpaceGuid.StructurePcdModule.FieldName | 5 } Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yuwei Chen --- V2: Fixed the incorrect format in build report. BaseTools/Source/Python/AutoGen/DataPipe.py | 5 +- .../Source/Python/AutoGen/ModuleAutoGen.py | 4 +- .../Python/AutoGen/ModuleAutoGenHelper.py | 10 +- .../Source/Python/AutoGen/PlatformAutoGen.py | 8 +- .../Python/Workspace/BuildClassObject.py | 12 + .../Source/Python/Workspace/DscBuildData.py | 243 ++++++++++++++++-- BaseTools/Source/Python/build/BuildReport.py | 109 ++++---- 7 files changed, 319 insertions(+), 72 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source= /Python/AutoGen/DataPipe.py index 50403fbfb5..86ac2b928d 100755 --- a/BaseTools/Source/Python/AutoGen/DataPipe.py +++ b/BaseTools/Source/Python/AutoGen/DataPipe.py @@ -70,13 +70,14 @@ class MemoryDataPipe(DataPipe): } =20 #Platform Module Pcds ModulePcds =3D {} for m in PlatformInfo.Platform.Modules: - m_pcds =3D PlatformInfo.Platform.Modules[m].Pcds + module =3D PlatformInfo.Platform.Modules[m] + m_pcds =3D module.Pcds if m_pcds: - ModulePcds[(m.File,m.Root,m.Arch)] =3D [PCD_DATA( + ModulePcds[module.Guid] =3D [PCD_DATA( pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type, pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue, pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validate= ranges, pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.To= kenValue) for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()] diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index eebf6e87f5..d70b0d7ae8 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -1030,11 +1030,11 @@ class ModuleAutoGen(AutoGen): # @retval list The list of PCD # @cached_property def ModulePcdList(self): # apply PCD settings from platform - RetVal =3D self.PlatformInfo.ApplyPcdSetting(self.Module, self.Mod= ule.Pcds) + RetVal =3D self.PlatformInfo.ApplyPcdSetting(self, self.Module.Pcd= s) =20 return RetVal @cached_property def _PcdComments(self): ReVal =3D OrderedListDict() @@ -1061,11 +1061,11 @@ class ModuleAutoGen(AutoGen): # skip duplicated PCDs if Key in self.Module.Pcds or Key in Pcds: continue Pcds.add(Key) PcdsInLibrary[Key] =3D copy.copy(Library.Pcds[Key]) - RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, P= cdsInLibrary, Library=3DLibrary)) + RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self, PcdsInLi= brary, Library=3DLibrary)) return RetVal =20 ## Get the GUID value mapping # # @retval dict The mapping between GUID cname and its value diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseT= ools/Source/Python/AutoGen/ModuleAutoGenHelper.py index 9dd93b9beb..8e60643d1f 100644 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py @@ -477,12 +477,13 @@ class PlatformInfo(AutoGenInfo): SkuName =3D TAB_DEFAULT ToPcd.SkuInfoList =3D { SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuNa= me][0], '', '', '', '', '', ToPcd.DefaultValue) } =20 - def ApplyPcdSetting(self, Module, Pcds, Library=3D""): + def ApplyPcdSetting(self, Ma, Pcds, Library=3D""): # for each PCD in module + Module=3DMa.Module for Name, Guid in Pcds: PcdInModule =3D Pcds[Name, Guid] # find out the PCD setting in platform if (Name, Guid) in self.Pcds: PcdInPlatform =3D self.Pcds[Name, Guid] @@ -505,13 +506,16 @@ class PlatformInfo(AutoGenInfo): % (Guid, Name, str= (Module)), File=3Dself.MetaFile ) =20 # override PCD settings with module specific setting + ModuleScopePcds =3D self.DataPipe.Get("MOL_PCDS") if Module in self.Platform.Modules: PlatformModule =3D self.Platform.Modules[str(Module)] - for Key in PlatformModule.Pcds: + PCD_DATA =3D ModuleScopePcds.get(Ma.Guid,{}) + mPcds =3D {(pcd.TokenCName,pcd.TokenSpaceGuidCName): pcd for p= cd in PCD_DATA} + for Key in mPcds: if self.BuildOptionPcd: for pcd in self.BuildOptionPcd: (TokenSpaceGuidCName, TokenCName, FieldName, pcdva= lue, _) =3D pcd if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D"": PlatformModule.Pcds[Key].DefaultValue =3D pcdv= alue @@ -526,11 +530,11 @@ class PlatformInfo(AutoGenInfo): if PcdItem in Pcds: ToPcd =3D Pcds[PcdItem] Flag =3D True break if Flag: - self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Mod= ule, Msg=3D"DSC Components Module scoped PCD section", Library=3DLibrary) + self._OverridePcd(ToPcd, mPcds[Key], Module, Msg=3D"DS= C Components Module scoped PCD section", Library=3DLibrary) # use PCD value to calculate the MaxDatumSize when it is not speci= fied for Name, Guid in Pcds: Pcd =3D Pcds[Name, Guid] if Pcd.DatumType =3D=3D TAB_VOID and not Pcd.MaxDatumSize: Pcd.MaxSizeUserSet =3D None diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools= /Source/Python/AutoGen/PlatformAutoGen.py index 26ab8e7f36..c7a4cb9a08 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -1041,11 +1041,17 @@ class PlatformAutoGen(AutoGen): TokenNumber +=3D 1 return RetVal =20 @cached_property def _MbList(self): - return [self.BuildDatabase[m, self.Arch, self.BuildTarget, self.To= olChain] for m in self.Platform.Modules] + mlist =3D [] + for m in self.Platform.Modules: + component =3D self.Platform.Modules[m] + module =3D self.BuildDatabase[m, self.Arch, self.BuildTarget, = self.ToolChain] + module.Guid =3D component.Guid + mlist.append(module) + return mlist =20 @cached_property def _MaList(self): for ModuleFile in self.Platform.Modules: Ma =3D ModuleAutoGen( diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTo= ols/Source/Python/Workspace/BuildClassObject.py index db40e3b10c..ebb65fc2fe 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -68,10 +68,11 @@ class PcdClassObject(object): self.DscRawValueInfo =3D {} if IsDsc: self.DscDefaultValue =3D Value self.PcdValueFromComm =3D "" self.PcdValueFromFdf =3D "" + self.PcdValueFromComponents =3D {} #{ModuleGuid:value, file_path,l= ineNo} self.CustomAttribute =3D {} self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresFlag self._Capacity =3D None =20 @property @@ -296,10 +297,11 @@ class StructurePcd(PcdClassObject): self.DefaultValueFromDecInfo =3D None self.ValueChain =3D set() self.PcdFieldValueFromComm =3D OrderedDict() self.PcdFieldValueFromFdf =3D OrderedDict() self.DefaultFromDSC=3DNone + self.PcdFiledValueFromDscComponent =3D OrderedDict() def __repr__(self): return self.TypeName =20 def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo=3D0= ,DimensionAttr =3D"-1"): if DimensionAttr not in self.DefaultValues: @@ -322,10 +324,16 @@ class StructurePcd(PcdClassObject): if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][= DimensionAttr]: del self.SkuOverrideValues[SkuName][DefaultStoreName][Dimensio= nAttr][FieldName] self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][F= ieldName] =3D [Value.strip(), FileName, LineNo] return self.SkuOverrideValues[SkuName][DefaultStoreName][Dimension= Attr][FieldName] =20 + def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid, FileN= ame=3D"", LineNo=3D0, DimensionAttr =3D '-1'): + self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid, OrderedD= ict()) + self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(Dimensio= nAttr,OrderedDict()) + self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][Fiel= dName] =3D [Value.strip(), FileName, LineNo] + return self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAtt= r][FieldName] + def SetPcdMode (self, PcdMode): self.PcdMode =3D PcdMode =20 def copy(self, PcdObject): self.TokenCName =3D PcdObject.TokenCName if PcdObject.TokenCName e= lse self.TokenCName @@ -363,10 +371,11 @@ class StructurePcd(PcdClassObject): self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if PcdObjec= t.PcdDefineLineNo else self.PcdDefineLineNo self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else s= elf.PkgPath self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueCha= in else self.ValueChain self.PcdFieldValueFromComm =3D PcdObject.PcdFieldValueFromComm= if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm self.PcdFieldValueFromFdf =3D PcdObject.PcdFieldValueFromFdf i= f PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf + self.PcdFiledValueFromDscComponent =3D PcdObject.PcdFiledValue= FromDscComponent if PcdObject.PcdFiledValueFromDscComponent else self.PcdFi= ledValueFromDscComponent =20 def __deepcopy__(self,memo): new_pcd =3D StructurePcd() self.sharedcopy(new_pcd) =20 @@ -381,10 +390,11 @@ class StructurePcd(PcdClassObject): new_pcd.DefaultValues =3D CopyDict(self.DefaultValues) new_pcd.DefaultFromDSC=3DCopyDict(self.DefaultFromDSC) new_pcd.SkuOverrideValues =3D CopyDict(self.SkuOverrideValues) new_pcd.PcdFieldValueFromComm =3D CopyDict(self.PcdFieldValueFromC= omm) new_pcd.PcdFieldValueFromFdf =3D CopyDict(self.PcdFieldValueFromFd= f) + new_pcd.PcdFiledValueFromDscComponent =3D CopyDict(self.PcdFiledVa= lueFromDscComponent) new_pcd.ValueChain =3D {item for item in self.ValueChain} return new_pcd =20 LibraryClassObject =3D namedtuple('LibraryClassObject', ['LibraryClass','S= upModList']) =20 @@ -461,10 +471,12 @@ class ModuleBuildClassObject(object): self.Includes =3D [] self.Packages =3D [] self.Pcds =3D {} self.BuildOptions =3D {} self.Depex =3D {} + self.StrPcdSet =3D [] + self.StrPcdOverallValue =3D {} =20 ## Convert the class to a string # # Convert member MetaFile of the class to a string # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 1ed3d9b909..1bb4fdc183 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -753,13 +753,14 @@ class DscBuildData(PlatformBuildClassObject): ErrorCode, ErrorInfo =3D ModuleFile.Validate('.inf') if ErrorCode !=3D 0: EdkLogger.error('build', ErrorCode, File=3Dself.MetaFile, = Line=3DLineNo, ExtraData=3DErrorInfo) =20 + ModuleBuildData =3D self._Bdb[ModuleFile, self._Arch, self._Ta= rget, self._Toolchain] Module =3D ModuleBuildClassObject() Module.MetaFile =3D ModuleFile - + Module.Guid =3D ModuleBuildData.Guid # get module private library instance RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Ar= ch, None, ModuleId] for Record in RecordList: LibraryClass =3D Record[0] LibraryPath =3D PathClass(NormPath(Record[1], Macros), Glo= balData.gWorkspace, Arch=3Dself._Arch) @@ -776,11 +777,11 @@ class DscBuildData(PlatformBuildClassObject): LibraryClass =3D 'NULL%d' % self._NullLibraryNumber EdkLogger.verbose("Found forced library for %s\n\t%s [= %s]" % (ModuleFile, LibraryPath, LibraryClass)) Module.LibraryClasses[LibraryClass] =3D LibraryPath if LibraryPath not in self.LibraryInstances: self.LibraryInstances.append(LibraryPath) - + S_PcdSet =3D [] # get module private PCD setting for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_= MODULE, \ MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_= PCD_DYNAMIC_EX]: RecordList =3D self._RawData[Type, self._Arch, None, Modul= eId] for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dum= my3, Dummy4, Dummy5 in RecordList: @@ -790,24 +791,35 @@ class DscBuildData(PlatformBuildClassObject): if len(TokenList) > 2: MaxDatumSize =3D TokenList[2] else: MaxDatumSize =3D '' TypeString =3D self._PCD_TYPE_STRING_[Type] - Pcd =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - TypeString, - '', - DefaultValue, - '', - MaxDatumSize, - {}, - False, - None - ) - Module.Pcds[PcdCName, TokenSpaceGuid] =3D Pcd =20 + TCName,PCName,DimensionAttr,Field =3D self.ParsePcdNam= eStruct(TokenSpaceGuid, PcdCName) + + if ("." in TokenSpaceGuid or "[" in PcdCName): + S_PcdSet.append([ TCName,PCName,DimensionAttr,Fiel= d, ModuleBuildData.Guid, "", Dummy5, AnalyzePcdExpression(Setting)[0]]) + DefaultValue =3D '' + if ( PCName,TCName) not in Module.Pcds: + Pcd =3D PcdClassObject( + PCName, + TCName, + TypeString, + '', + DefaultValue, + '', + MaxDatumSize, + {}, + False, + None, + IsDsc=3DTrue) + Module.Pcds[PCName, TCName] =3D Pcd + + Module.StrPcdSet =3D S_PcdSet + for TCName,PCName, _,_,_,_,_,_ in S_PcdSet: + if (PCName,TCName) in Module.Pcds: + Module.StrPcdOverallValue[(PCName,TCName)] =3D Module.= Pcds[(PCName,TCName)].DefaultValue, self.MetaFile,Dummy5 # get module private build options RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, sel= f._Arch, None, ModuleId] for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3= , Dummy4, Dummy5 in RecordList: if (ToolChainFamily, ToolChain) not in Module.BuildOptions: Module.BuildOptions[ToolChainFamily, ToolChain] =3D Op= tion @@ -820,11 +832,13 @@ class DscBuildData(PlatformBuildClassObject): if len(RecordList) !=3D 1: EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GU= ID can be listed in section.', File=3Dself.MetaFile, ExtraData=3Dstr(= ModuleFile), Line=3DLineNo) ModuleFile =3D ProcessDuplicatedInf(ModuleFile, RecordList= [0][2], GlobalData.gWorkspace) ModuleFile.Arch =3D self._Arch - + Module.Guid =3D RecordList[0][2] + for item in Module.StrPcdSet: + item[4] =3D RecordList[0][2] self._Modules[ModuleFile] =3D Module return self._Modules =20 ## Retrieve all possible library instances used in this platform @property @@ -1497,11 +1511,19 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', PARSER_ERROR, "Pcd (%s.%s) is not declared as Structure = PCD in DEC files. Arch: ['%s']" % (TCName, PCName, self._Arch), File=3Dself.MetaFile, Line =3D Dummy5) =20 S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuNa= me, default_store, Dummy5, AnalyzePcdExpression(Setting)[0]]) - + ModuleScopeOverallValue =3D {} + for m in self.Modules.values(): + mguid =3D m.Guid + if m.StrPcdSet: + S_PcdSet.extend(m.StrPcdSet) + mguid =3D m.StrPcdSet[0][4] + for (PCName,TCName) in m.StrPcdOverallValue: + Value, dsc_file, lineNo =3D m.StrPcdOverallValue[(PCName,T= CName)] + ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mgu= id] =3D Value, dsc_file, lineNo # handle pcd value override StrPcdSet =3D DscBuildData.GetStructurePcdInfo(S_PcdSet) S_pcd_set =3D OrderedDict() for str_pcd in StrPcdSet: str_pcd_obj =3D Pcds.get((str_pcd[1], str_pcd[0]), None) @@ -1515,10 +1537,15 @@ class DscBuildData(PlatformBuildClassObject): else: str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultSto= res} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[4] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[3], str(= str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] =3D=3D TAB_COMMON else str= _pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D=3D TAB_COMM= ON else str_pcd_data[5], self.MetaFile.File if self.WorkspaceDir not in sel= f.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.Work= spaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:], LineNo=3Dst= r_pcd_data[6],DimensionAttr =3D str_pcd_data[2]) + elif GlobalData.gGuidPattern.match(str_pcd_data[4]): + str_pcd_obj_str.AddComponentOverrideValue(str_pcd_data= [3], str(str_pcd_data[7]), str_pcd_data[4].replace("-","S"), self.MetaFile.= File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File= [len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len= (self.WorkspaceDir)+1:], LineNo=3Dstr_pcd_data[6],DimensionAttr =3D str_pcd= _data[2]) + PcdComponentValue =3D ModuleScopeOverallValue.get((str= _pcd_obj_str.TokenCName,str_pcd_obj_str.TokenSpaceGuidCName)) + for module_guid in PcdComponentValue: + str_pcd_obj_str.PcdValueFromComponents[module_guid= .replace("-","S")] =3D PcdComponentValue[module_guid] S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str =20 # Add the Structure PCD that only defined in DEC, don't have overr= ide in DSC file for Pcd in self.DecPcds: if isinstance(self._DecPcds[Pcd], StructurePcd): @@ -1573,11 +1600,14 @@ class DscBuildData(PlatformBuildClassObject): if defaultstoreid not in stru_pcd.SkuOverrideValue= s[skuid]: stru_pcd.SkuOverrideValues[skuid][defaultstore= id] =3D CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]) stru_pcd.ValueChain.add((skuid, defaultstoreid= )) S_pcd_set =3D DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceD= ir) S_pcd_set =3D DscBuildData.OverrideByComm(S_pcd_set) + + # Create a tool to caculate structure pcd value Str_Pcd_Values =3D self.GenerateByteArrayValue(S_pcd_set) + if Str_Pcd_Values: for (skuname, StoreName, PcdGuid, PcdName, PcdValue) in Str_Pc= d_Values: str_pcd_obj =3D S_pcd_set.get((PcdName, PcdGuid)) if str_pcd_obj is None: print(PcdName, PcdGuid) @@ -1591,10 +1621,18 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.= update({StoreName:PcdValue}) elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD= _FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE]]: if skuname in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT,= TAB_COMMON): str_pcd_obj.DefaultValue =3D PcdValue + else: + #Module Scope Structure Pcd + moduleguid =3D skuname.replace("S","-") + if GlobalData.gGuidPattern.match(moduleguid): + for component in self.Modules.values(): + if component.Guid =3D=3D moduleguid: + component.Pcds[(PcdName, PcdGuid)].Def= aultValue =3D PcdValue + else: if skuname not in str_pcd_obj.SkuInfoList: nextskuid =3D self.SkuIdMgr.GetNextSkuId(skuname) NoDefault =3D False while nextskuid not in str_pcd_obj.SkuInfoList: @@ -2339,10 +2377,79 @@ class DscBuildData(PlatformBuildClassObject): else: CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 + def GenerateModuleScopeValue(self, Pcd): + CApp =3D "// Value in Dsc Module scope \n" + for ModuleGuid in Pcd.PcdFiledValueFromDscComponent: + + CApp =3D CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" % (Pc= d.TokenSpaceGuidCName, Pcd.TokenCName, ModuleGuid,Pcd.BaseDatumType) + CApp =3D CApp + ' UINT32 FieldSize;\n' + CApp =3D CApp + ' CHAR8 *Value;\n' + pcddefaultvalue, file_path,lineNo =3D Pcd.PcdValueFromComponen= ts.get(ModuleGuid,(None,None,None)) + + if pcddefaultvalue: + IsArray =3D _IsFieldValueAnArray(pcddefaultvalue) + if IsArray: + try: + FieldList =3D ValueExpressionEx(pcddefaultvalue, T= AB_VOID)(True) + except BadExpression: + EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from %s Line %s: %s" % + (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, file_path, lineNo, FieldList)) + Value, ValueSize =3D ParseFieldValue (FieldList) + + if isinstance(Value, str): + CApp =3D CApp + ' Pcd =3D %s; // From %s Line %s \n' = % (Value, file_path, lineNo) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + ' Value =3D %s; // From %s Line %= s.\n' % (DscBuildData.IntToCString(Value, ValueSize), file_path, lineNo) + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) + + + PcdFiledValue =3D Pcd.PcdFiledValueFromDscComponent.get(Module= Guid) + for index in PcdFiledValue: + FieldList =3D PcdFiledValue[index] + if not FieldList: + continue + for FieldName in FieldList: + IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][= 0]) + if IsArray: + try: + FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[Field= Name][2])) + except: + print("error") + try: + Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][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 =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.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList= [FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, Fie= ldName, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], F= ieldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (Field= Size > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, = ValueSize) + else: + if '[' in FieldName and ']' in FieldName: + Index =3D int(FieldName.split('[')[1].split(']= ')[0]) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.= split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[= FieldName][2], FieldName) + 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]) + CApp =3D CApp + "}\n" + return CApp + @staticmethod def GenerateCommandLineValueStatement(Pcd): CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSp= aceGuidCName, Pcd.TokenCName) return CApp def GenerateFdfValue(self,Pcd): @@ -2412,10 +2519,88 @@ class DscBuildData(PlatformBuildClassObject): @staticmethod def GenerateFdfValueStatement(Pcd): CApp =3D ' Assign_%s_%s_Fdf_Value(Pcd);\n' % (Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName) return CApp =20 + @staticmethod + def GenerateModuleValueStatement(module_guid, Pcd): + CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % (Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName, module_guid) + return CApp + def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd, InitByteValu= e, CApp): + for module_guid in Pcd.PcdFiledValueFromDscComponent: + CApp =3D CApp + 'void\n' + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (module_guid, TA= B_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' void\n' + CApp =3D CApp + ' )\n' + CApp =3D CApp + '{\n' + CApp =3D CApp + ' UINT32 Size;\n' + CApp =3D CApp + ' UINT32 FieldSize;\n' + CApp =3D CApp + ' CHAR8 *Value;\n' + CApp =3D CApp + ' UINT32 OriginalSize;\n' + CApp =3D CApp + ' VOID *OriginalPcd;\n' + + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % (Pc= d.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) + + CApp =3D CApp + '\n' + + PcdDefaultValue =3D StringToArray(Pcd.DefaultValueFromDec.stri= p()) + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, TAB_D= EFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumTy= pe, PcdDefaultValue) + # + # Get current PCD value and size + # + CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName) + + # + # Determine the size of the PCD. For simple structures, sizeo= f(TYPE) provides + # the correct value. For structures with a flexible array mem= ber, the flexible + # array member is detected, and the size is based on the highe= st index used with + # 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 + DscBuildData.GenerateSizeStatments(Pcd,SkuName= ,TAB_DEFAULT_STORES_DEFAULT) + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": + CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % (Pcd.BaseDatumType,Pcd.PcdArr= aySize(),Pcd.BaseDatumType,Pcd.PcdArraySize()) + CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.Ba= seDatumType,Pcd.PcdArraySize()) + + # + # 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 + # + CApp =3D CApp + ' Size =3D (OriginalSize > Size ? OriginalSiz= e : Size);\n' + CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.= BaseDatumType,) + CApp =3D CApp + ' memset (Pcd, 0, Size);\n' + + # + # Copy current PCD value into allocated buffer. + # + CApp =3D CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n' + + # + # Assign field values in PCD + # + CApp =3D CApp + DscBuildData.GenerateDefaultValueAssignStateme= nt(Pcd) + + CApp =3D CApp + "// SkuName: %s, DefaultStoreName: STANDARD \= n" % self.SkuIdMgr.SystemSkuId + CApp =3D CApp + DscBuildData.GenerateInitValueStatement(Pcd, s= elf.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) + CApp =3D CApp + DscBuildData.GenerateFdfValueStatement(Pcd) + CApp =3D CApp + DscBuildData.GenerateCommandLineValueStatement= (Pcd) + CApp =3D CApp + DscBuildData.GenerateModuleValueStatement(modu= le_guid,Pcd) + # + # Set new PCD value and size + # + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName,= Pcd.TokenCName) + + # + # Free PCD + # + CApp =3D CApp + ' free (Pcd);\n' + CApp =3D CApp + '}\n' + CApp =3D CApp + '\n' + return InitByteValue,CApp + def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteV= alue, CApp): OverrideValues =3D {DefaultStore:{}} if Pcd.SkuOverrideValues: OverrideValues =3D Pcd.SkuOverrideValues[SkuName] if not OverrideValues: @@ -2584,26 +2769,42 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + '\n' for Pcd in StructuredPcds.values(): CApp =3D CApp + self.GenerateArrayAssignment(Pcd) for PcdName in sorted(StructuredPcds.keys()): Pcd =3D StructuredPcds[PcdName] + + #create void void Cal_tocken_cname_Size functions CApp =3D CApp + self.GenerateSizeFunction(Pcd) + + #create void Assign_ functions + + # From DEC CApp =3D CApp + self.GenerateDefaultValueAssignFunction(Pcd) + # From Fdf CApp =3D CApp + self.GenerateFdfValue(Pcd) + # From CommandLine CApp =3D CApp + self.GenerateCommandLineValue(Pcd) + + # From Dsc Global setting if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: CApp =3D CApp + self.GenerateInitValueFunction(Pcd, self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]: CApp =3D CApp + self.GenerateInitValueFunction(Pcd= , SkuName, DefaultStoreName) + + # From Dsc module scope setting + CApp =3D CApp + self.GenerateModuleScopeValue(Pcd) + + #create Initialize_ functions if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: InitByteValue, CApp =3D self.GenerateInitializeFunc(self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp) + InitByteValue, CApp =3D self.GenerateModuleScopeInitializ= eFunc(self.SkuIdMgr.SystemSkuId,Pcd,InitByteValue,CApp) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue for DefaultStoreName in Pcd.DefaultStoreName: @@ -2616,10 +2817,12 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' )\n' CApp =3D CApp + '{\n' for Pcd in StructuredPcds.values(): if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_ST= RING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.Sk= uIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pc= d.TokenCName) + for ModuleGuid in Pcd.PcdFiledValueFromDscComponent: + CApp +=3D " Initialize_%s_%s_%s_%s();\n" % (ModuleGui= d,TAB_DEFAULT_STORES_DEFAULT ,Pcd.TokenSpaceGuidCName, Pcd.TokenCName) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in self.SkuIdMgr.AvailableSkuIdSet: continue for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]: @@ -2631,10 +2834,11 @@ class DscBuildData(PlatformBuildClassObject): if not os.path.exists(self.OutputPath): os.makedirs(self.OutputPath) CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValueInitNam= e) SaveFileOnChange(CAppBaseFileName + '.c', CApp, False) =20 + # start generating makefile MakeApp =3D PcdMakefileHeader if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Output= Path, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECT= S =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.joi= n(self.OutputPath, PcdValueCommonName)) + 'INC =3D ' else: MakeApp =3D MakeApp + PcdGccMakefile @@ -2753,19 +2957,22 @@ class DscBuildData(PlatformBuildClassObject): MakeApp =3D MakeApp + '\tcp -f %s %s/PcdValueCommon.c\n' % (Pc= dValueCommonPath, self.OutputPath) MakeFileName =3D os.path.join(self.OutputPath, 'Makefile') MakeApp +=3D "$(OBJECTS) : %s\n" % MakeFileName SaveFileOnChange(MakeFileName, MakeApp, False) =20 + # start generating input file InputValueFile =3D os.path.join(self.OutputPath, 'Input.txt') OutputValueFile =3D os.path.join(self.OutputPath, 'Output.txt') SaveFileOnChange(InputValueFile, InitByteValue, False) =20 Dest_PcdValueInitExe =3D PcdValueInitName if not sys.platform =3D=3D "win32": Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName) else: Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName) +".exe" + + #start building the structure pcd value tool Messages =3D '' if sys.platform =3D=3D "win32": MakeCommand =3D 'nmake -f %s' % (MakeFileName) returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Ma= keCommand) Messages =3D StdOut @@ -2824,17 +3031,19 @@ class DscBuildData(PlatformBuildClassObject): if MessageGroup: EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".joi= n(MessageGroup) ) else: EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute= command: %s\n%s\n%s' % (MakeCommand, StdOut, StdErr)) =20 + #start executing the structure pcd value tool if DscBuildData.NeedUpdateOutput(OutputValueFile, Dest_PcdValueIni= tExe, InputValueFile): Command =3D Dest_PcdValueInitExe + ' -i %s -o %s' % (InputValu= eFile, OutputValueFile) returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Co= mmand) EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut, StdErr)) if returncode !=3D 0: EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect = output from command: %s\n%s\n' % (Command, StdOut, StdErr)) =20 + #start update structure pcd final value File =3D open (OutputValueFile, 'r') FileBuffer =3D File.readlines() File.close() =20 StructurePcdSet =3D [] diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index 8efa869162..d4de07cae2 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -694,11 +694,11 @@ class ModuleReport(object): FileWrite(File, "PCI Class Code: %s" % self.PciClassCode) =20 FileWrite(File, gSectionSep) =20 if "PCD" in ReportType: - GlobalPcdReport.GenerateReport(File, self.ModulePcdSet) + GlobalPcdReport.GenerateReport(File, self.ModulePcdSet,self.Fi= leGuid) =20 if "LIBRARY" in ReportType: self.LibraryReport.GenerateReport(File) =20 if "DEPEX" in ReportType: @@ -879,11 +879,11 @@ class PcdReport(object): for (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds: DscDefaultValue =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)].DscDefaultValue if DscDefaultValue: self.DscPcdDefault[(TokenCName, TokenSpaceGuidCName)] = =3D DscDefaultValue =20 - def GenerateReport(self, File, ModulePcdSet): + def GenerateReport(self, File, ModulePcdSet,module_guid=3DNone): if not ModulePcdSet: if self.ConditionalPcds: self.GenerateReportDetail(File, ModulePcdSet, 1) if self.UnusedPcds: IsEmpty =3D True @@ -895,11 +895,11 @@ class PcdReport(object): break if not IsEmpty: break if not IsEmpty: self.GenerateReportDetail(File, ModulePcdSet, 2) - self.GenerateReportDetail(File, ModulePcdSet) + self.GenerateReportDetail(File, ModulePcdSet,module_guid =3D modul= e_guid) =20 ## # Generate report for PCD information # # This function generates report for separate module expression @@ -911,11 +911,11 @@ class PcdReport(object): # platform PCD report # @param ReportySubType 0 means platform/module PCD report, 1 means C= onditional # directives section report, 2 means Unused Pcd= s section report # @param DscOverridePcds Module DSC override PCDs set # - def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =3D 0= ): + def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =3D 0= ,module_guid=3DNone): PcdDict =3D self.AllPcds if ReportSubType =3D=3D 1: PcdDict =3D self.ConditionalPcds elif ReportSubType =3D=3D 2: PcdDict =3D self.UnusedPcds @@ -991,14 +991,16 @@ class PcdReport(object): if DscDefaultValue: PcdValue =3D DscDefaultValue #The DefaultValue of StructurePcd already be the latest, n= o need to update. if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceG= uidCName): Pcd.DefaultValue =3D PcdValue + PcdComponentValue =3D None if ModulePcdSet is not None: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not= in ModulePcdSet: continue - InfDefaultValue, PcdValue =3D ModulePcdSet[Pcd.TokenCN= ame, Pcd.TokenSpaceGuidCName, Type] + InfDefaultValue, PcdComponentValue =3D ModulePcdSet[Pc= d.TokenCName, Pcd.TokenSpaceGuidCName, Type] + PcdValue =3D PcdComponentValue #The DefaultValue of StructurePcd already be the lates= t, no need to update. if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSp= aceGuidCName): Pcd.DefaultValue =3D PcdValue if InfDefaultValue: try: @@ -1079,62 +1081,68 @@ class PcdReport(object): if self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidC= Name): IsStructure =3D True if TypeName in ('DYNVPD', 'DEXVPD'): SkuInfoList =3D Pcd.SkuInfoList Pcd =3D GlobalData.gStructurePcd[self.Arch][(Pcd.Token= CName, Pcd.TokenSpaceGuidCName)] + if ModulePcdSet and ModulePcdSet.get((Pcd.TokenCName, = Pcd.TokenSpaceGuidCName, Type)): + InfDefaultValue, PcdComponentValue =3D ModulePcdSe= t[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] + DscDefaultValBak =3D Pcd.DefaultValue + Pcd.DefaultValue =3D PcdComponentValue + Pcd.DatumType =3D Pcd.StructName if TypeName in ('DYNVPD', 'DEXVPD'): Pcd.SkuInfoList =3D SkuInfoList if Pcd.PcdValueFromComm or Pcd.PcdFieldValueFromComm: BuildOptionMatch =3D True DecMatch =3D False elif Pcd.PcdValueFromFdf or Pcd.PcdFieldValueFromFdf: DscDefaultValue =3D True DscMatch =3D True DecMatch =3D False - elif Pcd.SkuOverrideValues: - DscOverride =3D False - if Pcd.DefaultFromDSC: - DscOverride =3D True - else: - DictLen =3D 0 - for item in Pcd.SkuOverrideValues: - DictLen +=3D len(Pcd.SkuOverrideValues[ite= m]) - if not DictLen: - DscOverride =3D False + else: + if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_= EX_TYPE_SET: + DscOverride =3D False + if Pcd.DefaultFromDSC: + DscOverride =3D True else: - if not Pcd.SkuInfoList: - OverrideValues =3D Pcd.SkuOverrideValu= es - if OverrideValues: - for Data in OverrideValues.values(= ): - Struct =3D list(Data.values()) - if Struct: - DscOverride =3D self.Parse= Struct(Struct[0]) - break + DictLen =3D 0 + for item in Pcd.SkuOverrideValues: + DictLen +=3D len(Pcd.SkuOverrideValues= [item]) + if not DictLen: + DscOverride =3D False else: - SkuList =3D sorted(Pcd.SkuInfoList.key= s()) - for Sku in SkuList: - SkuInfo =3D Pcd.SkuInfoList[Sku] - if SkuInfo.DefaultStoreDict: - DefaultStoreList =3D sorted(Sk= uInfo.DefaultStoreDict.keys()) - for DefaultStore in DefaultSto= reList: - OverrideValues =3D Pcd.Sku= OverrideValues[Sku] - DscOverride =3D self.Parse= Struct(OverrideValues[DefaultStore]) - if DscOverride: + if not Pcd.SkuInfoList: + OverrideValues =3D Pcd.SkuOverride= Values + if OverrideValues: + for Data in OverrideValues.val= ues(): + Struct =3D list(Data.value= s()) + if Struct: + DscOverride =3D self.P= arseStruct(Struct[0]) break - if DscOverride: - break - if DscOverride: + else: + SkuList =3D sorted(Pcd.SkuInfoList= .keys()) + for Sku in SkuList: + SkuInfo =3D Pcd.SkuInfoList[Sk= u] + if SkuInfo.DefaultStoreDict: + DefaultStoreList =3D sorte= d(SkuInfo.DefaultStoreDict.keys()) + for DefaultStore in Defaul= tStoreList: + OverrideValues =3D Pcd= .SkuOverrideValues[Sku] + DscOverride =3D self.P= arseStruct(OverrideValues[DefaultStore]) + if DscOverride: + break + if DscOverride: + break + if DscOverride: + DscDefaultValue =3D True + DscMatch =3D True + DecMatch =3D False + else: + DecMatch =3D True + else: DscDefaultValue =3D True DscMatch =3D True DecMatch =3D False - else: - DecMatch =3D True - else: - DscDefaultValue =3D True - DscMatch =3D True - DecMatch =3D False =20 # # Report PCD item according to their override relationship # if Pcd.DatumType =3D=3D 'BOOLEAN': @@ -1151,17 +1159,18 @@ class PcdReport(object): elif InfDefaultValue and InfMatch: self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*M') elif BuildOptionMatch: self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*B') else: - if DscDefaultValue and DscMatch: + if PcdComponentValue: + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, InfMatch, PcdComponentValue, = DecMatch, DecDefaultValue, '*M', module_guid) + elif DscDefaultValue and DscMatch: if (Pcd.TokenCName, Key, Field) in self.FdfPcdSet: self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*F') else: self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*P') - else: - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, De= cMatch, DecDefaultValue, '*M') + =20 if ModulePcdSet is None: if IsStructure: continue if not TypeName in ('PATCH', 'FLAG', 'FIXED'): @@ -1263,11 +1272,11 @@ class PcdReport(object): self.PrintStructureInfo(File, filedvalues) if DecMatch and IsStructure: for filedvalues in Pcd.DefaultValues.values(): self.PrintStructureInfo(File, filedvalues) =20 - def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag =3D ' '): + def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag =3D ' ',module_guid=3DNone): if not Pcd.SkuInfoList: Value =3D Pcd.DefaultValue IsByteArray, ArrayList =3D ByteArrayForamt(Value) if IsByteArray: FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{')) @@ -1286,18 +1295,24 @@ class PcdReport(object): FiledOverrideFlag =3D False if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in GlobalData.= gPcdSkuOverrides: OverrideValues =3D GlobalData.gPcdSkuOverrides[(Pcd.To= kenCName,Pcd.TokenSpaceGuidCName)] else: OverrideValues =3D Pcd.SkuOverrideValues + FieldOverrideValues =3D None if OverrideValues: for Data in OverrideValues.values(): Struct =3D list(Data.values()) if Struct: - OverrideFieldStruct =3D self.OverrideFieldValu= e(Pcd, Struct[0]) - self.PrintStructureInfo(File, OverrideFieldStr= uct) + FieldOverrideValues =3D Struct[0] FiledOverrideFlag =3D True break + if Pcd.PcdFiledValueFromDscComponent and module_guid and m= odule_guid.replace("-","S") in Pcd.PcdFiledValueFromDscComponent: + FieldOverrideValues =3D Pcd.PcdFiledValueFromDscCompon= ent[module_guid.replace("-","S")] + if FieldOverrideValues: + OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, F= ieldOverrideValues) + self.PrintStructureInfo(File, OverrideFieldStruct) + if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or= Pcd.PcdFieldValueFromFdf): OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, {= }) self.PrintStructureInfo(File, OverrideFieldStruct) self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefa= ultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) else: --=20 2.20.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#66252): https://edk2.groups.io/g/devel/message/66252 Mute This Topic: https://groups.io/mt/77525412/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-