From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.10108.1603779581368220490 for ; Mon, 26 Oct 2020 23:19:44 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Tue, 27 Oct 2020 14:19:33 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Feng, Bob C'" , Cc: "'Chen, Christine'" , "'Kinney, Michael D'" References: <163E2552F529AEC6.4805@groups.io> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BhdGNoIFYyXSBCYXNlVG9vbHM6IEVuYWJsZSBNb2R1bGUgU2NvcGUgU3RydWN0dXJlIFBjZA==?= Date: Tue, 27 Oct 2020 14:19:39 +0800 Message-ID: <002801d6ac29$26c30540$74490fc0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHMBonhSJuUOyA/UE/y207gdfnMUgH6JVSvqbBz2SA= Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Bob: I will review this change this week. Can you share your test case? I also want to check the build output.=20 Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Feng, Bob C > =B7=A2=CB=CD=CA=B1=BC=E4: 2020=C4=EA10=D4=C226=C8=D5 12:00 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io; Feng, Bob C ; Liming > Gao > =B3=AD=CB=CD: Chen, Christine ; Kinney, Michael D > > =D6=F7=CC=E2: RE: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope= Structure > Pcd >=20 > Liming, would you review this patch? >=20 > Thanks, > Bob >=20 > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Bob Feng > Sent: Thursday, October 15, 2020 6:59 PM > To: devel@edk2.groups.io > Cc: Liming Gao ; Chen, Christine > > Subject: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope Structur= e > Pcd >=20 > 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. >=20 > Package/Module.inf{ > > gUefiTokenSpaceGuid.StructurePcdModule.FieldName | 5 > } >=20 > 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(-) >=20 > 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, >=20 > pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validateranges, >=20 > pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.TokenValue) > for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()] > diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py > b/BaseTools/Source/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.Module.Pcds) > + RetVal =3D self.PlatformInfo.ApplyPcdSetting(self, self.Module.Pcds) >=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= , > PcdsInLibrary, Library=3DLibrary)) > + RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self, > PcdsInLibrary, 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/BaseTools/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[SkuName][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 pcd in PCD_DATA} > + for Key in mPcds: > if self.BuildOptionPcd: > for pcd in self.BuildOptionPcd: > (TokenSpaceGuidCName, TokenCName, > FieldName, pcdvalue, _) =3D pcd > if (TokenCName, TokenSpaceGuidCName) =3D=3D > Key and FieldName =3D=3D"": > PlatformModule.Pcds[Key].DefaultValue > =3D pcdvalue > @@ -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], > Module, Msg=3D"DSC Components Module scoped PCD section", > Library=3DLibrary) > + self._OverridePcd(ToPcd, mPcds[Key], Module, > Msg=3D"DSC Components Module scoped PCD section", Library=3DLibrary) > # use PCD value to calculate the MaxDatumSize when it is not > specified > 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.ToolChain] 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.BuildTarge= t, > 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/BaseTools/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,lineNo} > self.CustomAttribute =3D {} > self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresF= lag > 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][DimensionAttr][FieldN > ame] >=20 > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN > ame] =3D [Value.strip(), FileName, LineNo] > return > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN > ame] >=20 > + def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid, > FileName=3D"", LineNo=3D0, DimensionAttr =3D '-1'): > + self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid, > OrderedDict()) > + > self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(DimensionAtt > r,OrderedDict()) > + > self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa > me] =3D [Value.strip(), FileName, LineNo] > + return > self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa > me] > + > def SetPcdMode (self, PcdMode): > self.PcdMode =3D PcdMode >=20 > def copy(self, PcdObject): > self.TokenCName =3D PcdObject.TokenCName if > PcdObject.TokenCName else self.TokenCName > @@ -363,10 +371,11 @@ class StructurePcd(PcdClassObject): > self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if > PcdObject.PcdDefineLineNo else self.PcdDefineLineNo > self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath els= e > self.PkgPath > self.ValueChain =3D PcdObject.ValueChain if > PcdObject.ValueChain else self.ValueChain > self.PcdFieldValueFromComm =3D > PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm > else self.PcdFieldValueFromComm > self.PcdFieldValueFromFdf =3D PcdObject.PcdFieldValueFromFd= f > if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf > + self.PcdFiledValueFromDscComponent =3D > PcdObject.PcdFiledValueFromDscComponent if > PcdObject.PcdFiledValueFromDscComponent else > self.PcdFiledValueFromDscComponent >=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.PcdFieldValueFromComm) > new_pcd.PcdFieldValueFromFdf =3D > CopyDict(self.PcdFieldValueFromFdf) > + new_pcd.PcdFiledValueFromDscComponent =3D > CopyDict(self.PcdFiledValueFromDscComponent) > new_pcd.ValueChain =3D {item for item in self.ValueChain} > return new_pcd >=20 > LibraryClassObject =3D namedtuple('LibraryClassObject', > ['LibraryClass','SupModList']) >=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.MetaFil= e, > Line=3DLineNo, > ExtraData=3DErrorInfo) >=20 > + ModuleBuildData =3D self._Bdb[ModuleFile, self._Arch, > self._Target, 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._Arch, None, ModuleId] > for Record in RecordList: > LibraryClass =3D Record[0] > LibraryPath =3D PathClass(NormPath(Record[1], Macros), > GlobalData.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, > ModuleId] > for TokenSpaceGuid, PcdCName, Setting, Dummy1, > Dummy2, Dummy3, 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.ParsePcdNameStruct(TokenSpaceGuid, PcdCName) > + > + if ("." in TokenSpaceGuid or "[" in PcdCName): > + > S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, > 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, self._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 > Option > @@ -820,11 +832,13 @@ class DscBuildData(PlatformBuildClassObject): > if len(RecordList) !=3D 1: > EdkLogger.error('build', OPTION_UNKNOWN, 'Only > FILE_GUID 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 >=20 > S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuName, > 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,TCName)] > + > ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mguid] =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:{defaultstore: > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, > str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in > DefaultStores} 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 e= lse > str_pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D=3D > TAB_COMMON else str_pcd_data[5], 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]) > + 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.Fi= le 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 > override 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.SkuOverrideValues[skuid]: >=20 > stru_pcd.SkuOverrideValues[skuid][defaultstoreid] =3D > CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]) > stru_pcd.ValueChain.add((skuid, > defaultstoreid)) > S_pcd_set =3D > DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceDir) > 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_Pcd_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): >=20 > str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdV > alue}) > elif str_pcd_obj.Type in > [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_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)].DefaultValue =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[FieldName][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" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > ModuleGuid,Pcd.BaseDatumType) > + CApp =3D CApp + ' UINT32 FieldSize;\n' > + CApp =3D CApp + ' CHAR8 *Value;\n' > + pcddefaultvalue, file_path,lineNo =3D > Pcd.PcdValueFromComponents.get(ModuleGuid,(None,None,None)) > + > + if pcddefaultvalue: > + IsArray =3D _IsFieldValueAnArray(pcddefaultvalue) > + if IsArray: > + try: > + FieldList =3D ValueExpressionEx(pcddefaultvalue= , > TAB_VOID)(True) > + except BadExpression: > + EdkLogger.error("Build", FORMAT_INVALID, > "Invalid value format for %s.%s, from %s Line %s: %s" % > + > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, 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' % > (ValueSize) > + > + > + PcdFiledValue =3D > Pcd.PcdFiledValueFromDscComponent.get(ModuleGuid) > + 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)(Tru= e) > + 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])) > + except: > + print("error") > + try: > + Value, ValueSize =3D 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 =3D CApp + ' Pcd->%s =3D %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 =3D CApp + ' FieldSize =3D > __FIELD_SIZE(%s, %s);\n' % (Pcd.BaseDatumType, FieldName) > + CApp =3D CApp + ' Value =3D %s; // > From %s Line %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 the buffer array"); // From %s Line %d Value %s\n' % > (Pcd.BaseDatumType, FieldName, ValueSize, Pcd.BaseDatumType, FieldName, > FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0= ]) > + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, > (FieldSize > 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 > < __ARRAY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array ind= ex > 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]= , > 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]) > + CApp =3D CApp + "}\n" > + return CApp > + > @staticmethod > def GenerateCommandLineValueStatement(Pcd): > CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % > (Pcd.TokenSpaceGuidCName, 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.TokenSpaceGuidCName, Pcd.TokenCName) > return CApp >=20 > + @staticmethod > + def GenerateModuleValueStatement(module_guid, Pcd): > + CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, module_guid) > + return CApp > + def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd, > InitByteValue, CApp): > + for module_guid in Pcd.PcdFiledValueFromDscComponent: > + CApp =3D CApp + 'void\n' > + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (module_guid, > TAB_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' % > (Pcd.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) > + > + CApp =3D CApp + '\n' > + > + PcdDefaultValue =3D > StringToArray(Pcd.DefaultValueFromDec.strip()) > + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, > TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, > Pcd.TokenCName, Pcd.DatumType, 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.TokenSpaceGuidCName, Pcd.TokenCName) > + > + # > + # Determine the size of the PCD. For simple structures, > sizeof(TYPE) provides > + # the correct value. For structures with a flexible array > member, the flexible > + # 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 =3D CApp + > DscBuildData.GenerateSizeStatments(Pcd,SkuName,TAB_DEFAULT_STORES_D > EFAULT) > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > + CApp =3D CApp + ' OriginalSize =3D OriginalSize < size= of(%s) > * %d? OriginalSize:sizeof(%s) * %d; \n' % > (Pcd.BaseDatumType,Pcd.PcdArraySize(),Pcd.BaseDatumType,Pcd.PcdArraySiz > e()) > + CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % > (Pcd.BaseDatumType,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 ? Original= Size : > 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.GenerateDefaultValueAssignStatement(Pcd) > + > + CApp =3D CApp + "// SkuName: %s, DefaultStoreName: > STANDARD \n" % self.SkuIdMgr.SystemSkuId > + CApp =3D CApp + > DscBuildData.GenerateInitValueStatement(Pcd, self.SkuIdMgr.SystemSkuId, > TAB_DEFAULT_STORES_DEFAULT) > + CApp =3D CApp + > DscBuildData.GenerateFdfValueStatement(Pcd) > + CApp =3D CApp + > DscBuildData.GenerateCommandLineValueStatement(Pcd) > + CApp =3D CApp + > DscBuildData.GenerateModuleValueStatement(module_guid,Pcd) > + # > + # Set new PCD value and size > + # > + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void > *)Pcd);\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, > InitByteValue, 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.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: > CApp =3D CApp + self.GenerateInitValueFunction(Pcd, > self.SkuIdMgr.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.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: > InitByteValue, CApp =3D > self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, > TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp) > + InitByteValue, CApp =3D > self.GenerateModuleScopeInitializeFunc(self.SkuIdMgr.SystemSkuId,Pcd,InitB= y > teValue,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.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: > CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % > (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, > Pcd.TokenSpaceGuidCName, Pcd.TokenCName) > + for ModuleGuid in > Pcd.PcdFiledValueFromDscComponent: > + CApp +=3D " Initialize_%s_%s_%s_%s();\n" % > (ModuleGuid,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, > PcdValueInitName) > 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.OutputPath, PcdValueInitName) + 'APPNAME =3D %s\n' % > (PcdValueInitName) + 'OBJECTS =3D %s\%s.obj %s.obj\n' % (self.OutputPath= , > PcdValueInitName, os.path.join(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' % > (PcdValueCommonPath, 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, > PcdValueInitName) > else: > Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, > PcdValueInitName) +".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 > (MakeCommand) > Messages =3D StdOut > @@ -2824,17 +3031,19 @@ class DscBuildData(PlatformBuildClassObject): > if MessageGroup: > EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, > "\n".join(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_PcdValueInitExe, InputValueFile): > Command =3D Dest_PcdValueInitExe + ' -i %s -o %s' % > (InputValueFile, OutputValueFile) > returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand > (Command) > 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/Source/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.FileGuid) >=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, > TokenSpaceGuidCName)].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 > module_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 Conditional > # directives section report, 2 means > Unused Pcds 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= , > no need to update. > if not self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): > 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.TokenCName, Pcd.TokenSpaceGuidCName, Type] > + InfDefaultValue, PcdComponentValue =3D > ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] > + PcdValue =3D PcdComponentValue > #The DefaultValue of StructurePcd already be the > latest, no need to update. > if not self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): > Pcd.DefaultValue =3D PcdValue > if InfDefaultValue: > try: > @@ -1079,62 +1081,68 @@ class PcdReport(object): > if self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): > IsStructure =3D True > if TypeName in ('DYNVPD', 'DEXVPD'): > SkuInfoList =3D Pcd.SkuInfoList > Pcd =3D > GlobalData.gStructurePcd[self.Arch][(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName)] > + if ModulePcdSet and > ModulePcdSet.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type)): > + InfDefaultValue, PcdComponentValue =3D > ModulePcdSet[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[item]) > - 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.SkuOverrideValues > - if OverrideValues: > - for Data in > OverrideValues.values(): > - Struct =3D > list(Data.values()) > - if Struct: > - DscOverride =3D > self.ParseStruct(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.keys()) > - for Sku in SkuList: > - SkuInfo =3D > Pcd.SkuInfoList[Sku] > - if > SkuInfo.DefaultStoreDict: > - DefaultStoreList =3D > sorted(SkuInfo.DefaultStoreDict.keys()) > - for DefaultStore in > DefaultStoreList: > - OverrideValues =3D > Pcd.SkuOverrideValues[Sku] > - DscOverride =3D > self.ParseStruct(OverrideValues[DefaultStore]) > - if DscOverride: > + if not Pcd.SkuInfoList: > + OverrideValues =3D > Pcd.SkuOverrideValues > + if OverrideValues: > + for Data in > OverrideValues.values(): > + Struct =3D > list(Data.values()) > + if Struct: > + > DscOverride =3D self.ParseStruct(Struct[0]) > break > - if DscOverride: > - break > - if DscOverride: > + else: > + SkuList =3D > sorted(Pcd.SkuInfoList.keys()) > + for Sku in SkuList: > + SkuInfo =3D > Pcd.SkuInfoList[Sku] > + if > SkuInfo.DefaultStoreDict: > + DefaultStoreList > =3D sorted(SkuInfo.DefaultStoreDict.keys()) > + for DefaultStore > in DefaultStoreList: > + > OverrideValues =3D Pcd.SkuOverrideValues[Sku] > + > DscOverride =3D self.ParseStruct(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, DecMatch, DecDefaultValue, '*M') > elif BuildOptionMatch: > self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > InfDefaultValue, DecMatch, DecDefaultValue, '*B') > else: > - if DscDefaultValue and DscMatch: > + if PcdComponentValue: > + self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, 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, TypeName, IsStructure, DscMatch, DscDefaultValBak, > InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*F') > else: > self.PrintPcdValue(File, Pcd, > PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak, > InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*P') > - else: > - self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > InfDefaultValue, DecMatch, 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, > IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, > DecDefaultValue, Flag =3D ' '): > + def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, > IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, > DecDefaultValue, 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.Max= Len, > 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.TokenCName,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.OverrideFieldValue(Pcd, Struct[0]) > - self.PrintStructureInfo(File, > OverrideFieldStruct) > + FieldOverrideValues =3D Struct[0] > FiledOverrideFlag =3D True > break > + if Pcd.PcdFiledValueFromDscComponent and > module_guid and module_guid.replace("-","S") in > Pcd.PcdFiledValueFromDscComponent: > + FieldOverrideValues =3D > Pcd.PcdFiledValueFromDscComponent[module_guid.replace("-","S")] > + if FieldOverrideValues: > + OverrideFieldStruct =3D self.OverrideFieldValue(Pcd= , > FieldOverrideValues) > + 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, > DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) > else: > -- > 2.20.1.windows.1 >=20 >=20 >=20 >=20 >=20