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.web08.6903.1604451518819761004 for ; Tue, 03 Nov 2020 16:58:40 -0800 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 ; Wed, 04 Nov 2020 08:58:35 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Yuwei Chen'" , References: <20201103000212.1837-1-bob.c.feng@intel.com> In-Reply-To: <20201103000212.1837-1-bob.c.feng@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BhdGNoIFYzXSBCYXNlVG9vbHM6IEVuYWJsZSBNb2R1bGUgU2NvcGUgU3RydWN0dXJlIFBjZA==?= Date: Wed, 4 Nov 2020 08:58:35 +0800 Message-ID: <001f01d6b245$9fd0b0f0$df7212d0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHoI50ss60K/+WUEfY8ZQBcXUd/xqmTjExA Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Bob: I verify the patch. It works as the expectation. I have the small = comments on the coding style.=20 Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: bounce+27952+66883+4905953+8761045@groups.io > =B4=FA=B1=ED Bob Feng > =B7=A2=CB=CD=CA=B1=BC=E4: 2020=C4=EA11=D4=C23=C8=D5 8:02 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Liming Gao ; Yuwei Chen > > =D6=F7=CC=E2: [edk2-devel] [Patch V3] BaseTools: Enable Module Scope = Structure 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 > --- >=20 > V3: >=20 > 1. Place the the module level PCD value assignment >=20 > before Fdf PCD value assignment. >=20 > 2. Fixed the incorrect value format for module level >=20 > structure PCD in build report. >=20 >=20 > 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 | 244 > ++++++++++++++++-- > BaseTools/Source/Python/build/BuildReport.py | 117 +++++---- > 7 files changed, 326 insertions(+), 74 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 >=20 >=20 > #Platform Module Pcds >=20 > ModulePcds =3D {} >=20 > for m in PlatformInfo.Platform.Modules: >=20 > - m_pcds =3D PlatformInfo.Platform.Modules[m].Pcds >=20 > + module =3D PlatformInfo.Platform.Modules[m] >=20 > + m_pcds =3D module.Pcds >=20 > if m_pcds: >=20 > - ModulePcds[(m.File,m.Root,m.Arch)] =3D [PCD_DATA( >=20 > + ModulePcds[module.Guid] =3D [PCD_DATA( >=20 > pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type, >=20 > pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue, >=20 >=20 > pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validateranges, >=20 >=20 > pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.TokenValue) >=20 > for pcd in = PlatformInfo.Platform.Modules[m].Pcds.values()] >=20 > 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 >=20 > # >=20 > @cached_property >=20 > def ModulePcdList(self): >=20 > # apply PCD settings from platform >=20 > - RetVal =3D self.PlatformInfo.ApplyPcdSetting(self.Module, > self.Module.Pcds) >=20 > + RetVal =3D self.PlatformInfo.ApplyPcdSetting(self, self.Module.Pcds) >=20 >=20 >=20 > return RetVal >=20 > @cached_property >=20 > def _PcdComments(self): >=20 > ReVal =3D OrderedListDict() >=20 > @@ -1061,11 +1061,11 @@ class ModuleAutoGen(AutoGen): > # skip duplicated PCDs >=20 > if Key in self.Module.Pcds or Key in Pcds: >=20 > continue >=20 > Pcds.add(Key) >=20 > PcdsInLibrary[Key] =3D copy.copy(Library.Pcds[Key]) >=20 > - = RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, > PcdsInLibrary, Library=3DLibrary)) >=20 > + RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self, > PcdsInLibrary, Library=3DLibrary)) >=20 > return RetVal >=20 >=20 >=20 > ## Get the GUID value mapping >=20 > # >=20 > # @retval dict The mapping between GUID cname and its > value >=20 > 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 >=20 > ToPcd.SkuInfoList =3D { >=20 > SkuName : SkuInfoClass(SkuName, > self.Platform.SkuIds[SkuName][0], '', '', '', '', '', = ToPcd.DefaultValue) >=20 > } >=20 >=20 >=20 > - def ApplyPcdSetting(self, Module, Pcds, Library=3D""): >=20 > + def ApplyPcdSetting(self, Ma, Pcds, Library=3D""): >=20 > # for each PCD in module >=20 > + Module=3DMa.Module >=20 > for Name, Guid in Pcds: >=20 > PcdInModule =3D Pcds[Name, Guid] >=20 > # find out the PCD setting in platform >=20 > if (Name, Guid) in self.Pcds: >=20 > PcdInPlatform =3D self.Pcds[Name, Guid] >=20 > @@ -505,13 +506,16 @@ class PlatformInfo(AutoGenInfo): > % > (Guid, Name, str(Module)), >=20 > File=3Dself.MetaFile >=20 > ) >=20 >=20 >=20 > # override PCD settings with module specific setting >=20 > + ModuleScopePcds =3D self.DataPipe.Get("MOL_PCDS") >=20 > if Module in self.Platform.Modules: >=20 > PlatformModule =3D self.Platform.Modules[str(Module)] >=20 > - for Key in PlatformModule.Pcds: >=20 > + PCD_DATA =3D ModuleScopePcds.get(Ma.Guid,{}) >=20 > + mPcds =3D {(pcd.TokenCName,pcd.TokenSpaceGuidCName): > pcd for pcd in PCD_DATA} >=20 > + for Key in mPcds: >=20 > if self.BuildOptionPcd: >=20 > for pcd in self.BuildOptionPcd: >=20 > (TokenSpaceGuidCName, TokenCName, > FieldName, pcdvalue, _) =3D pcd >=20 > if (TokenCName, TokenSpaceGuidCName) =3D=3D > Key and FieldName =3D=3D"": >=20 > PlatformModule.Pcds[Key].DefaultValue > =3D pcdvalue >=20 > @@ -526,11 +530,11 @@ class PlatformInfo(AutoGenInfo): > if PcdItem in Pcds: >=20 > ToPcd =3D Pcds[PcdItem] >=20 > Flag =3D True >=20 > break >=20 > if Flag: >=20 > - self._OverridePcd(ToPcd, = PlatformModule.Pcds[Key], > Module, Msg=3D"DSC Components Module scoped PCD section", > Library=3DLibrary) >=20 > + self._OverridePcd(ToPcd, mPcds[Key], Module, > Msg=3D"DSC Components Module scoped PCD section", Library=3DLibrary) >=20 > # use PCD value to calculate the MaxDatumSize when it is not > specified >=20 > for Name, Guid in Pcds: >=20 > Pcd =3D Pcds[Name, Guid] >=20 > if Pcd.DatumType =3D=3D TAB_VOID and not = Pcd.MaxDatumSize: >=20 > Pcd.MaxSizeUserSet =3D None >=20 > 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 >=20 > return RetVal >=20 >=20 >=20 > @cached_property >=20 > def _MbList(self): >=20 > - return [self.BuildDatabase[m, self.Arch, self.BuildTarget, > self.ToolChain] for m in self.Platform.Modules] >=20 > + mlist =3D [] >=20 mlist may be ModuleList? > + for m in self.Platform.Modules: >=20 > + component =3D self.Platform.Modules[m] >=20 > + module =3D self.BuildDatabase[m, self.Arch, = self.BuildTarget, > self.ToolChain] >=20 > + module.Guid =3D component.Guid >=20 > + mlist.append(module) >=20 > + return mlist >=20 >=20 >=20 > @cached_property >=20 > def _MaList(self): >=20 > for ModuleFile in self.Platform.Modules: >=20 > Ma =3D ModuleAutoGen( >=20 > 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 {} >=20 > if IsDsc: >=20 > self.DscDefaultValue =3D Value >=20 > self.PcdValueFromComm =3D "" >=20 > self.PcdValueFromFdf =3D "" >=20 > + self.PcdValueFromComponents =3D {} #{ModuleGuid:value, > file_path,lineNo} >=20 > self.CustomAttribute =3D {} >=20 > self.UserDefinedDefaultStoresFlag =3D = UserDefinedDefaultStoresFlag >=20 > self._Capacity =3D None >=20 >=20 >=20 > @property >=20 > @@ -296,10 +297,11 @@ class StructurePcd(PcdClassObject): > self.DefaultValueFromDecInfo =3D None >=20 > self.ValueChain =3D set() >=20 > self.PcdFieldValueFromComm =3D OrderedDict() >=20 > self.PcdFieldValueFromFdf =3D OrderedDict() >=20 > self.DefaultFromDSC=3DNone >=20 > + self.PcdFiledValueFromDscComponent =3D OrderedDict() >=20 > def __repr__(self): >=20 > return self.TypeName >=20 >=20 >=20 > def AddDefaultValue (self, FieldName, Value, FileName=3D"", > LineNo=3D0,DimensionAttr =3D"-1"): >=20 > if DimensionAttr not in self.DefaultValues: >=20 > @@ -322,10 +324,16 @@ class StructurePcd(PcdClassObject): > if FieldName in > self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]: >=20 > del > = self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN > ame] >=20 >=20 > = self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN > ame] =3D [Value.strip(), FileName, LineNo] >=20 > return > = self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN > ame] >=20 >=20 >=20 > + def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid, > FileName=3D"", LineNo=3D0, DimensionAttr =3D '-1'): >=20 > + self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid, > OrderedDict()) >=20 > + > self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(DimensionAtt > r,OrderedDict()) >=20 > + > self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa > me] =3D [Value.strip(), FileName, LineNo] >=20 > + return > self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa > me] >=20 > + >=20 > def SetPcdMode (self, PcdMode): >=20 > self.PcdMode =3D PcdMode >=20 >=20 >=20 > def copy(self, PcdObject): >=20 > self.TokenCName =3D PcdObject.TokenCName if > PcdObject.TokenCName else self.TokenCName >=20 > @@ -363,10 +371,11 @@ class StructurePcd(PcdClassObject): > self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if > PcdObject.PcdDefineLineNo else self.PcdDefineLineNo >=20 > self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath = else > self.PkgPath >=20 > self.ValueChain =3D PcdObject.ValueChain if > PcdObject.ValueChain else self.ValueChain >=20 > self.PcdFieldValueFromComm =3D > PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm > else self.PcdFieldValueFromComm >=20 > self.PcdFieldValueFromFdf =3D = PcdObject.PcdFieldValueFromFdf > if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf >=20 > + self.PcdFiledValueFromDscComponent =3D > PcdObject.PcdFiledValueFromDscComponent if > PcdObject.PcdFiledValueFromDscComponent else > self.PcdFiledValueFromDscComponent >=20 >=20 >=20 > def __deepcopy__(self,memo): >=20 > new_pcd =3D StructurePcd() >=20 > self.sharedcopy(new_pcd) >=20 >=20 >=20 > @@ -381,10 +390,11 @@ class StructurePcd(PcdClassObject): > new_pcd.DefaultValues =3D CopyDict(self.DefaultValues) >=20 > new_pcd.DefaultFromDSC=3DCopyDict(self.DefaultFromDSC) >=20 > new_pcd.SkuOverrideValues =3D = CopyDict(self.SkuOverrideValues) >=20 > new_pcd.PcdFieldValueFromComm =3D > CopyDict(self.PcdFieldValueFromComm) >=20 > new_pcd.PcdFieldValueFromFdf =3D > CopyDict(self.PcdFieldValueFromFdf) >=20 > + new_pcd.PcdFiledValueFromDscComponent =3D > CopyDict(self.PcdFiledValueFromDscComponent) >=20 > new_pcd.ValueChain =3D {item for item in self.ValueChain} >=20 > return new_pcd >=20 >=20 >=20 > LibraryClassObject =3D namedtuple('LibraryClassObject', > ['LibraryClass','SupModList']) >=20 >=20 >=20 > @@ -461,10 +471,12 @@ class ModuleBuildClassObject(object): > self.Includes =3D [] >=20 > self.Packages =3D [] >=20 > self.Pcds =3D {} >=20 > self.BuildOptions =3D {} >=20 > self.Depex =3D {} >=20 > + self.StrPcdSet =3D [] >=20 > + self.StrPcdOverallValue =3D {} >=20 >=20 >=20 > ## Convert the class to a string >=20 > # >=20 > # Convert member MetaFile of the class to a string >=20 > # >=20 > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py > b/BaseTools/Source/Python/Workspace/DscBuildData.py > index 1ed3d9b909..5f07d3e75c 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') >=20 > if ErrorCode !=3D 0: >=20 > EdkLogger.error('build', ErrorCode, = File=3Dself.MetaFile, > Line=3DLineNo, >=20 > ExtraData=3DErrorInfo) >=20 >=20 >=20 > + ModuleBuildData =3D self._Bdb[ModuleFile, self._Arch, > self._Target, self._Toolchain] >=20 > Module =3D ModuleBuildClassObject() >=20 > Module.MetaFile =3D ModuleFile >=20 > - >=20 > + Module.Guid =3D ModuleBuildData.Guid >=20 > # get module private library instance >=20 > RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, > self._Arch, None, ModuleId] >=20 > for Record in RecordList: >=20 > LibraryClass =3D Record[0] >=20 > LibraryPath =3D PathClass(NormPath(Record[1], = Macros), > GlobalData.gWorkspace, Arch=3Dself._Arch) >=20 > @@ -776,11 +777,11 @@ class DscBuildData(PlatformBuildClassObject): > LibraryClass =3D 'NULL%d' % = self._NullLibraryNumber >=20 > EdkLogger.verbose("Found forced library > for %s\n\t%s [%s]" % (ModuleFile, LibraryPath, LibraryClass)) >=20 > Module.LibraryClasses[LibraryClass] =3D LibraryPath >=20 > if LibraryPath not in self.LibraryInstances: >=20 > self.LibraryInstances.append(LibraryPath) >=20 > - >=20 > + S_PcdSet =3D [] >=20 > # get module private PCD setting >=20 > for Type in [MODEL_PCD_FIXED_AT_BUILD, > MODEL_PCD_PATCHABLE_IN_MODULE, \ >=20 > MODEL_PCD_FEATURE_FLAG, > MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]: >=20 > RecordList =3D self._RawData[Type, self._Arch, None, > ModuleId] >=20 > for TokenSpaceGuid, PcdCName, Setting, Dummy1, > Dummy2, Dummy3, Dummy4, Dummy5 in RecordList: >=20 > @@ -790,24 +791,35 @@ class DscBuildData(PlatformBuildClassObject): > if len(TokenList) > 2: >=20 > MaxDatumSize =3D TokenList[2] >=20 > else: >=20 > MaxDatumSize =3D '' >=20 > TypeString =3D self._PCD_TYPE_STRING_[Type] >=20 > - Pcd =3D PcdClassObject( >=20 > - PcdCName, >=20 > - TokenSpaceGuid, >=20 > - TypeString, >=20 > - '', >=20 > - DefaultValue, >=20 > - '', >=20 > - MaxDatumSize, >=20 > - {}, >=20 > - False, >=20 > - None >=20 > - ) >=20 > - Module.Pcds[PcdCName, TokenSpaceGuid] =3D Pcd >=20 >=20 >=20 > + TCName,PCName,DimensionAttr,Field =3D > self.ParsePcdNameStruct(TokenSpaceGuid, PcdCName) >=20 > + >=20 > + if ("." in TokenSpaceGuid or "[" in PcdCName): >=20 > + > S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, > ModuleBuildData.Guid, "", Dummy5, AnalyzePcdExpression(Setting)[0]]) >=20 > + DefaultValue =3D '' >=20 > + if ( PCName,TCName) not in Module.Pcds: >=20 > + Pcd =3D PcdClassObject( >=20 > + PCName, >=20 > + TCName, >=20 > + TypeString, >=20 > + '', >=20 > + DefaultValue, >=20 > + '', >=20 > + MaxDatumSize, >=20 > + {}, >=20 > + False, >=20 > + None, >=20 > + IsDsc=3DTrue) >=20 > + Module.Pcds[PCName, TCName] =3D Pcd >=20 > + >=20 > + Module.StrPcdSet =3D S_PcdSet >=20 > + for TCName,PCName, _,_,_,_,_,_ in S_PcdSet: >=20 > + if (PCName,TCName) in Module.Pcds: >=20 > + Module.StrPcdOverallValue[(PCName,TCName)] =3D > Module.Pcds[(PCName,TCName)].DefaultValue, self.MetaFile,Dummy5 >=20 > # get module private build options >=20 > RecordList =3D > self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, None, > ModuleId] >=20 > for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, > Dummy3, Dummy4, Dummy5 in RecordList: >=20 > if (ToolChainFamily, ToolChain) not in > Module.BuildOptions: >=20 > Module.BuildOptions[ToolChainFamily, ToolChain] = =3D > Option >=20 > @@ -820,11 +832,13 @@ class DscBuildData(PlatformBuildClassObject): > if len(RecordList) !=3D 1: >=20 > EdkLogger.error('build', OPTION_UNKNOWN, 'Only > FILE_GUID can be listed in section.', >=20 > File=3Dself.MetaFile, > ExtraData=3Dstr(ModuleFile), Line=3DLineNo) >=20 > ModuleFile =3D ProcessDuplicatedInf(ModuleFile, > RecordList[0][2], GlobalData.gWorkspace) >=20 > ModuleFile.Arch =3D self._Arch >=20 > - >=20 > + Module.Guid =3D RecordList[0][2] >=20 > + for item in Module.StrPcdSet: >=20 > + item[4] =3D RecordList[0][2] >=20 > self._Modules[ModuleFile] =3D Module >=20 > return self._Modules >=20 >=20 >=20 > ## Retrieve all possible library instances used in this platform >=20 > @property >=20 > @@ -1497,11 +1511,19 @@ class DscBuildData(PlatformBuildClassObject): > EdkLogger.error('build', PARSER_ERROR, >=20 > "Pcd (%s.%s) is not declared as > Structure PCD in DEC files. Arch: ['%s']" % (TCName, PCName, = self._Arch), >=20 > File=3Dself.MetaFile, Line =3D = Dummy5) >=20 >=20 >=20 >=20 > S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuName, > default_store, Dummy5, AnalyzePcdExpression(Setting)[0]]) >=20 > - >=20 > + ModuleScopeOverallValue =3D {} >=20 > + for m in self.Modules.values(): >=20 > + mguid =3D m.Guid >=20 > + if m.StrPcdSet: >=20 > + S_PcdSet.extend(m.StrPcdSet) >=20 > + mguid =3D m.StrPcdSet[0][4] >=20 > + for (PCName,TCName) in m.StrPcdOverallValue: >=20 > + Value, dsc_file, lineNo =3D > m.StrPcdOverallValue[(PCName,TCName)] >=20 > + > ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mguid] =3D = Value, > dsc_file, lineNo >=20 > # handle pcd value override >=20 > StrPcdSet =3D DscBuildData.GetStructurePcdInfo(S_PcdSet) >=20 > S_pcd_set =3D OrderedDict() >=20 > for str_pcd in StrPcdSet: >=20 > str_pcd_obj =3D Pcds.get((str_pcd[1], str_pcd[0]), None) >=20 > @@ -1515,10 +1537,15 @@ class DscBuildData(PlatformBuildClassObject): > else: >=20 > 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} >=20 > for str_pcd_data in StrPcdSet[str_pcd]: >=20 > if str_pcd_data[4] in SkuIds: >=20 > 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_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]) >=20 > + elif GlobalData.gGuidPattern.match(str_pcd_data[4]): >=20 > + > 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]) >=20 > + PcdComponentValue =3D > = ModuleScopeOverallValue.get((str_pcd_obj_str.TokenCName,str_pcd_obj_str. > TokenSpaceGuidCName)) >=20 > + for module_guid in PcdComponentValue: >=20 > + > str_pcd_obj_str.PcdValueFromComponents[module_guid.replace("-","S")] = =3D > PcdComponentValue[module_guid] >=20 > S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str >=20 >=20 >=20 > # Add the Structure PCD that only defined in DEC, don't have > override in DSC file >=20 > for Pcd in self.DecPcds: >=20 > if isinstance(self._DecPcds[Pcd], StructurePcd): >=20 > @@ -1573,11 +1600,14 @@ class DscBuildData(PlatformBuildClassObject): > if defaultstoreid not in > stru_pcd.SkuOverrideValues[skuid]: >=20 >=20 > stru_pcd.SkuOverrideValues[skuid][defaultstoreid] =3D > CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]) >=20 > stru_pcd.ValueChain.add((skuid, > defaultstoreid)) >=20 > S_pcd_set =3D > DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceDir) >=20 > S_pcd_set =3D DscBuildData.OverrideByComm(S_pcd_set) >=20 > + >=20 > + # Create a tool to caculate structure pcd value >=20 > Str_Pcd_Values =3D self.GenerateByteArrayValue(S_pcd_set) >=20 > + >=20 > if Str_Pcd_Values: >=20 > for (skuname, StoreName, PcdGuid, PcdName, PcdValue) in > Str_Pcd_Values: >=20 > str_pcd_obj =3D S_pcd_set.get((PcdName, PcdGuid)) >=20 > if str_pcd_obj is None: >=20 > print(PcdName, PcdGuid) >=20 > @@ -1591,10 +1621,18 @@ class DscBuildData(PlatformBuildClassObject): >=20 > = str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdV > alue}) >=20 > elif str_pcd_obj.Type in > [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: >=20 > if skuname in (self.SkuIdMgr.SystemSkuId, > TAB_DEFAULT, TAB_COMMON): >=20 > str_pcd_obj.DefaultValue =3D PcdValue >=20 > + else: >=20 > + #Module Scope Structure Pcd >=20 > + moduleguid =3D skuname.replace("S","-") >=20 > + if > GlobalData.gGuidPattern.match(moduleguid): >=20 > + for component in self.Modules.values(): >=20 > + if component.Guid =3D=3D moduleguid: >=20 > + component.Pcds[(PcdName, > PcdGuid)].DefaultValue =3D PcdValue >=20 > + >=20 > else: >=20 > if skuname not in str_pcd_obj.SkuInfoList: >=20 > nextskuid =3D > self.SkuIdMgr.GetNextSkuId(skuname) >=20 > NoDefault =3D False >=20 > while nextskuid not in = str_pcd_obj.SkuInfoList: >=20 > @@ -2339,10 +2377,79 @@ class DscBuildData(PlatformBuildClassObject): > else: >=20 > 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]) >=20 > CApp =3D CApp + "}\n" >=20 > return CApp >=20 >=20 >=20 > + def GenerateModuleScopeValue(self, Pcd): >=20 > + CApp =3D "// Value in Dsc Module scope \n" >=20 > + for ModuleGuid in Pcd.PcdFiledValueFromDscComponent: >=20 > + >=20 > + CApp =3D CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" = % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, > ModuleGuid,Pcd.BaseDatumType) >=20 > + CApp =3D CApp + ' UINT32 FieldSize;\n' >=20 > + CApp =3D CApp + ' CHAR8 *Value;\n' >=20 > + pcddefaultvalue, file_path,lineNo =3D > Pcd.PcdValueFromComponents.get(ModuleGuid,(None,None,None)) >=20 > + >=20 > + if pcddefaultvalue: >=20 > + IsArray =3D _IsFieldValueAnArray(pcddefaultvalue) >=20 > + if IsArray: >=20 > + try: >=20 > + FieldList =3D = ValueExpressionEx(pcddefaultvalue, > TAB_VOID)(True) >=20 > + except BadExpression: >=20 > + EdkLogger.error("Build", FORMAT_INVALID, > "Invalid value format for %s.%s, from %s Line %s: %s" % >=20 > + > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, file_path, lineNo, = FieldList)) >=20 > + Value, ValueSize =3D ParseFieldValue (FieldList) >=20 > + >=20 > + if isinstance(Value, str): >=20 > + CApp =3D CApp + ' Pcd =3D %s; // From %s Line %s = \n' % > (Value, file_path, lineNo) >=20 > + elif IsArray: >=20 > + # >=20 > + # Use memcpy() to copy value into field >=20 > + # >=20 > + CApp =3D CApp + ' Value =3D %s; // From %s > Line %s.\n' % (DscBuildData.IntToCString(Value, ValueSize), file_path, lineNo) >=20 > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % > (ValueSize) >=20 > + >=20 > + >=20 > + PcdFiledValue =3D > Pcd.PcdFiledValueFromDscComponent.get(ModuleGuid) >=20 > + for index in PcdFiledValue: >=20 > + FieldList =3D PcdFiledValue[index] >=20 > + if not FieldList: >=20 > + continue >=20 > + for FieldName in FieldList: >=20 > + IsArray =3D > _IsFieldValueAnArray(FieldList[FieldName][0]) >=20 > + if IsArray: >=20 > + try: >=20 > + FieldList[FieldName][0] =3D > ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, = self._GuidDict)(True) >=20 > + except BadExpression: >=20 > + EdkLogger.error('Build', > FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % >=20 > + > (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), > FieldList[FieldName][1], FieldList[FieldName][2])) >=20 > + except: >=20 > + print("error") >=20 > + try: >=20 > + Value, ValueSize =3D ParseFieldValue > (FieldList[FieldName][0]) >=20 > + except Exception: >=20 > + 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])) >=20 > + if isinstance(Value, str): >=20 > + 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]) >=20 > + elif IsArray: >=20 > + # >=20 > + # Use memcpy() to copy value into field >=20 > + # >=20 > + CApp =3D CApp + ' FieldSize =3D > __FIELD_SIZE(%s, %s);\n' % (Pcd.BaseDatumType, FieldName) >=20 > + 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]) >=20 > + 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]) >=20 > + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, > (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, > ValueSize) >=20 > + else: >=20 > + if '[' in FieldName and ']' in FieldName: >=20 > + Index =3D > int(FieldName.split('[')[1].split(']')[0]) >=20 > + CApp =3D CApp + ' __STATIC_ASSERT((%d > < __ARRAY_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) >=20 > + if ValueSize > 4: >=20 > + 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]) >=20 > + else: >=20 > + 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]) >=20 > + CApp =3D CApp + "}\n" >=20 > + return CApp >=20 > + >=20 > @staticmethod >=20 > def GenerateCommandLineValueStatement(Pcd): >=20 > CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > return CApp >=20 > def GenerateFdfValue(self,Pcd): >=20 > @@ -2412,10 +2519,89 @@ class DscBuildData(PlatformBuildClassObject): > @staticmethod >=20 > def GenerateFdfValueStatement(Pcd): >=20 > CApp =3D ' Assign_%s_%s_Fdf_Value(Pcd);\n' % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > return CApp >=20 >=20 >=20 > + @staticmethod >=20 > + def GenerateModuleValueStatement(module_guid, Pcd): >=20 > + CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, module_guid) >=20 > + return CApp >=20 > + def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd, > InitByteValue, CApp): >=20 > + for module_guid in Pcd.PcdFiledValueFromDscComponent: >=20 > + CApp =3D CApp + 'void\n' >=20 > + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % = (module_guid, > TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) >=20 > + CApp =3D CApp + ' void\n' >=20 > + CApp =3D CApp + ' )\n' >=20 > + CApp =3D CApp + '{\n' >=20 > + CApp =3D CApp + ' UINT32 Size;\n' >=20 > + CApp =3D CApp + ' UINT32 FieldSize;\n' >=20 > + CApp =3D CApp + ' CHAR8 *Value;\n' >=20 > + CApp =3D CApp + ' UINT32 OriginalSize;\n' >=20 > + CApp =3D CApp + ' VOID *OriginalPcd;\n' >=20 > + >=20 > + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' = % > (Pcd.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) >=20 > + >=20 > + CApp =3D CApp + '\n' >=20 > + >=20 > + PcdDefaultValue =3D > StringToArray(Pcd.DefaultValueFromDec.strip()) >=20 > + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, > TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, > Pcd.TokenCName, Pcd.DatumType, PcdDefaultValue) >=20 > + # >=20 > + # Get current PCD value and size >=20 > + # >=20 > + CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, = %s, > &OriginalSize);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, > Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > + >=20 > + # >=20 > + # Determine the size of the PCD. For simple structures, > sizeof(TYPE) provides >=20 > + # the correct value. For structures with a flexible = array > member, the flexible >=20 > + # array member is detected, and the size is based on the > highest index used with >=20 > + # the flexible array member. The flexible array member > must be the last field >=20 > + # in a structure. The size formula for this case is: >=20 > + # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) = * > (HighestIndex + 1) >=20 > + # >=20 > + CApp =3D CApp + > DscBuildData.GenerateSizeStatments(Pcd,SkuName,TAB_DEFAULT_STORES_D > EFAULT) >=20 > + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": >=20 > + CApp =3D CApp + ' OriginalSize =3D OriginalSize < = sizeof(%s) > * %d? OriginalSize:sizeof(%s) * %d; \n' % > = (Pcd.BaseDatumType,Pcd.PcdArraySize(),Pcd.BaseDatumType,Pcd.PcdArraySiz > e()) >=20 > + CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % > (Pcd.BaseDatumType,Pcd.PcdArraySize()) >=20 > + >=20 > + # >=20 > + # Allocate and zero buffer for the PCD >=20 > + # Must handle cases where current value is smaller, = larger, or > same size >=20 > + # Always keep that larger one as the current size >=20 > + # >=20 > + CApp =3D CApp + ' Size =3D (OriginalSize > Size ? = OriginalSize : > Size);\n' >=20 > + CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % > (Pcd.BaseDatumType,) >=20 > + CApp =3D CApp + ' memset (Pcd, 0, Size);\n' >=20 > + >=20 > + # >=20 > + # Copy current PCD value into allocated buffer. >=20 > + # >=20 > + CApp =3D CApp + ' memcpy (Pcd, OriginalPcd, = OriginalSize);\n' >=20 > + >=20 > + # >=20 > + # Assign field values in PCD >=20 > + # >=20 > + CApp =3D CApp + > DscBuildData.GenerateDefaultValueAssignStatement(Pcd) >=20 > + >=20 > + CApp =3D CApp + "// SkuName: %s, DefaultStoreName: > STANDARD \n" % self.SkuIdMgr.SystemSkuId >=20 > + CApp =3D CApp + > DscBuildData.GenerateInitValueStatement(Pcd, = self.SkuIdMgr.SystemSkuId, > TAB_DEFAULT_STORES_DEFAULT) >=20 > + CApp =3D CApp + > DscBuildData.GenerateModuleValueStatement(module_guid,Pcd) >=20 > + CApp =3D CApp + > DscBuildData.GenerateFdfValueStatement(Pcd) >=20 > + CApp =3D CApp + > DscBuildData.GenerateCommandLineValueStatement(Pcd) >=20 > + >=20 > + # >=20 > + # Set new PCD value and size >=20 > + # >=20 > + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void > *)Pcd);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, > Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > + >=20 > + # >=20 > + # Free PCD >=20 > + # >=20 > + CApp =3D CApp + ' free (Pcd);\n' >=20 > + CApp =3D CApp + '}\n' >=20 > + CApp =3D CApp + '\n' >=20 > + return InitByteValue,CApp >=20 > + >=20 > def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, > InitByteValue, CApp): >=20 > OverrideValues =3D {DefaultStore:{}} >=20 > if Pcd.SkuOverrideValues: >=20 > OverrideValues =3D Pcd.SkuOverrideValues[SkuName] >=20 > if not OverrideValues: >=20 > @@ -2584,26 +2770,42 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + '\n' >=20 > for Pcd in StructuredPcds.values(): >=20 > CApp =3D CApp + self.GenerateArrayAssignment(Pcd) >=20 > for PcdName in sorted(StructuredPcds.keys()): >=20 > Pcd =3D StructuredPcds[PcdName] >=20 > + >=20 > + #create void void Cal_tocken_cname_Size functions >=20 > CApp =3D CApp + self.GenerateSizeFunction(Pcd) >=20 > + >=20 > + #create void Assign_ functions >=20 > + >=20 > + # From DEC >=20 > CApp =3D CApp + = self.GenerateDefaultValueAssignFunction(Pcd) >=20 > + # From Fdf >=20 > CApp =3D CApp + self.GenerateFdfValue(Pcd) >=20 > + # From CommandLine >=20 > CApp =3D CApp + self.GenerateCommandLineValue(Pcd) >=20 > + >=20 > + # From Dsc Global setting >=20 > if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or > Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: >=20 > CApp =3D CApp + self.GenerateInitValueFunction(Pcd, > self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) >=20 > else: >=20 > for SkuName in self.SkuIdMgr.SkuOverrideOrder(): >=20 > if SkuName not in Pcd.SkuOverrideValues: >=20 > continue >=20 > for DefaultStoreName in > Pcd.SkuOverrideValues[SkuName]: >=20 > CApp =3D CApp + > self.GenerateInitValueFunction(Pcd, SkuName, DefaultStoreName) >=20 > + >=20 > + # From Dsc module scope setting >=20 > + CApp =3D CApp + self.GenerateModuleScopeValue(Pcd) >=20 > + >=20 > + #create Initialize_ functions >=20 > if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or > Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >=20 >=20 > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: >=20 > InitByteValue, CApp =3D > self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, > TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp) >=20 > + InitByteValue, CApp =3D > self.GenerateModuleScopeInitializeFunc(self.SkuIdMgr.SystemSkuId,Pcd,Init= By > teValue,CApp) >=20 > else: >=20 > for SkuName in self.SkuIdMgr.SkuOverrideOrder(): >=20 > if SkuName not in Pcd.SkuOverrideValues: >=20 > continue >=20 > for DefaultStoreName in Pcd.DefaultStoreName: >=20 > @@ -2616,10 +2818,12 @@ class DscBuildData(PlatformBuildClassObject): > CApp =3D CApp + ' )\n' >=20 > CApp =3D CApp + '{\n' >=20 > for Pcd in StructuredPcds.values(): >=20 > 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]]: >=20 > CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % > (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, > Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > + for ModuleGuid in > Pcd.PcdFiledValueFromDscComponent: >=20 > + CApp +=3D " Initialize_%s_%s_%s_%s();\n" % > (ModuleGuid,TAB_DEFAULT_STORES_DEFAULT ,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) >=20 > else: >=20 > for SkuName in self.SkuIdMgr.SkuOverrideOrder(): >=20 > if SkuName not in = self.SkuIdMgr.AvailableSkuIdSet: >=20 > continue >=20 > for DefaultStoreName in > Pcd.SkuOverrideValues[SkuName]: >=20 > @@ -2631,10 +2835,11 @@ class DscBuildData(PlatformBuildClassObject): > if not os.path.exists(self.OutputPath): >=20 > os.makedirs(self.OutputPath) >=20 > CAppBaseFileName =3D os.path.join(self.OutputPath, > PcdValueInitName) >=20 > SaveFileOnChange(CAppBaseFileName + '.c', CApp, False) >=20 >=20 >=20 > + # start generating makefile >=20 > MakeApp =3D PcdMakefileHeader >=20 > if sys.platform =3D=3D "win32": >=20 > 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 ' >=20 > else: >=20 > MakeApp =3D MakeApp + PcdGccMakefile >=20 > @@ -2753,19 +2958,22 @@ class DscBuildData(PlatformBuildClassObject): > MakeApp =3D MakeApp + '\tcp -f %s %s/PcdValueCommon.c\n' = % > (PcdValueCommonPath, self.OutputPath) >=20 > MakeFileName =3D os.path.join(self.OutputPath, 'Makefile') >=20 > MakeApp +=3D "$(OBJECTS) : %s\n" % MakeFileName >=20 > SaveFileOnChange(MakeFileName, MakeApp, False) >=20 >=20 >=20 > + # start generating input file >=20 > InputValueFile =3D os.path.join(self.OutputPath, 'Input.txt') >=20 > OutputValueFile =3D os.path.join(self.OutputPath, = 'Output.txt') >=20 > SaveFileOnChange(InputValueFile, InitByteValue, False) >=20 >=20 >=20 > Dest_PcdValueInitExe =3D PcdValueInitName >=20 > if not sys.platform =3D=3D "win32": >=20 > Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, > PcdValueInitName) >=20 > else: >=20 > Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, > PcdValueInitName) +".exe" >=20 > + >=20 > + #start building the structure pcd value tool >=20 > Messages =3D '' >=20 > if sys.platform =3D=3D "win32": >=20 > MakeCommand =3D 'nmake -f %s' % (MakeFileName) >=20 > returncode, StdOut, StdErr =3D = DscBuildData.ExecuteCommand > (MakeCommand) >=20 > Messages =3D StdOut >=20 > @@ -2824,17 +3032,19 @@ class DscBuildData(PlatformBuildClassObject): > if MessageGroup: >=20 > EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, > "\n".join(MessageGroup) ) >=20 > else: >=20 > EdkLogger.error('Build', COMMAND_FAILURE, 'Can not > execute command: %s\n%s\n%s' % (MakeCommand, StdOut, StdErr)) >=20 >=20 >=20 > + #start executing the structure pcd value tool >=20 > if DscBuildData.NeedUpdateOutput(OutputValueFile, > Dest_PcdValueInitExe, InputValueFile): >=20 > Command =3D Dest_PcdValueInitExe + ' -i %s -o %s' % > (InputValueFile, OutputValueFile) >=20 > returncode, StdOut, StdErr =3D = DscBuildData.ExecuteCommand > (Command) >=20 > EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut, > StdErr)) >=20 > if returncode !=3D 0: >=20 > EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not > collect output from command: %s\n%s\n' % (Command, StdOut, StdErr)) >=20 >=20 >=20 > + #start update structure pcd final value >=20 > File =3D open (OutputValueFile, 'r') >=20 > FileBuffer =3D File.readlines() >=20 > File.close() >=20 >=20 >=20 > StructurePcdSet =3D [] >=20 > diff --git a/BaseTools/Source/Python/build/BuildReport.py > b/BaseTools/Source/Python/build/BuildReport.py > index 8efa869162..2b7e456524 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 >=20 >=20 > FileWrite(File, gSectionSep) >=20 >=20 >=20 > if "PCD" in ReportType: >=20 > - GlobalPcdReport.GenerateReport(File, self.ModulePcdSet) >=20 > + GlobalPcdReport.GenerateReport(File, > self.ModulePcdSet,self.FileGuid) >=20 >=20 >=20 > if "LIBRARY" in ReportType: >=20 > self.LibraryReport.GenerateReport(File) >=20 >=20 >=20 > if "DEPEX" in ReportType: >=20 > @@ -879,11 +879,11 @@ class PcdReport(object): > for (TokenCName, TokenSpaceGuidCName) in > Pa.Platform.Pcds: >=20 > DscDefaultValue =3D Pa.Platform.Pcds[(TokenCName, > TokenSpaceGuidCName)].DscDefaultValue >=20 > if DscDefaultValue: >=20 > self.DscPcdDefault[(TokenCName, > TokenSpaceGuidCName)] =3D DscDefaultValue >=20 >=20 >=20 > - def GenerateReport(self, File, ModulePcdSet): >=20 > + def GenerateReport(self, File, ModulePcdSet,module_guid=3DNone): >=20 > if not ModulePcdSet: >=20 > if self.ConditionalPcds: >=20 > self.GenerateReportDetail(File, ModulePcdSet, 1) >=20 > if self.UnusedPcds: >=20 > IsEmpty =3D True >=20 > @@ -895,11 +895,11 @@ class PcdReport(object): > break >=20 > if not IsEmpty: >=20 > break >=20 > if not IsEmpty: >=20 > self.GenerateReportDetail(File, ModulePcdSet, 2) >=20 > - self.GenerateReportDetail(File, ModulePcdSet) >=20 > + self.GenerateReportDetail(File, ModulePcdSet,module_guid =3D > module_guid) >=20 >=20 >=20 > ## >=20 > # Generate report for PCD information >=20 > # >=20 > # This function generates report for separate module expression >=20 > @@ -911,11 +911,11 @@ class PcdReport(object): > # platform PCD report >=20 > # @param ReportySubType 0 means platform/module PCD report, 1 > means Conditional >=20 > # directives section report, 2 means > Unused Pcds section report >=20 > # @param DscOverridePcds Module DSC override PCDs set >=20 > # >=20 > - def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType = =3D 0): >=20 > + def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType = =3D > 0,module_guid=3DNone): >=20 > PcdDict =3D self.AllPcds >=20 > if ReportSubType =3D=3D 1: >=20 > PcdDict =3D self.ConditionalPcds >=20 > elif ReportSubType =3D=3D 2: >=20 > PcdDict =3D self.UnusedPcds >=20 > @@ -991,14 +991,16 @@ class PcdReport(object): > if DscDefaultValue: >=20 > PcdValue =3D DscDefaultValue >=20 > #The DefaultValue of StructurePcd already be the = latest, > no need to update. >=20 > if not self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): >=20 > Pcd.DefaultValue =3D PcdValue >=20 > + PcdComponentValue =3D None >=20 > if ModulePcdSet is not None: >=20 > if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, > Type) not in ModulePcdSet: >=20 > continue >=20 > - InfDefaultValue, PcdValue =3D > ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] >=20 > + InfDefaultValue, PcdComponentValue =3D > ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] >=20 > + PcdValue =3D PcdComponentValue >=20 > #The DefaultValue of StructurePcd already be the > latest, no need to update. >=20 > if not self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): >=20 > Pcd.DefaultValue =3D PcdValue >=20 > if InfDefaultValue: >=20 > try: >=20 > @@ -1079,62 +1081,72 @@ class PcdReport(object): > if self.IsStructurePcd(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName): >=20 > IsStructure =3D True >=20 > if TypeName in ('DYNVPD', 'DEXVPD'): >=20 > SkuInfoList =3D Pcd.SkuInfoList >=20 > Pcd =3D > GlobalData.gStructurePcd[self.Arch][(Pcd.TokenCName, > Pcd.TokenSpaceGuidCName)] >=20 > + if ModulePcdSet and > ModulePcdSet.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type)): >=20 > + InfDefaultValue, PcdComponentValue =3D > ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] >=20 > + DscDefaultValBak =3D Pcd.DefaultValue >=20 > + Pcd.DefaultValue =3D PcdComponentValue >=20 > + >=20 > Pcd.DatumType =3D Pcd.StructName >=20 > if TypeName in ('DYNVPD', 'DEXVPD'): >=20 > Pcd.SkuInfoList =3D SkuInfoList >=20 > if Pcd.PcdValueFromComm or > Pcd.PcdFieldValueFromComm: >=20 > BuildOptionMatch =3D True >=20 > DecMatch =3D False >=20 > elif Pcd.PcdValueFromFdf or > Pcd.PcdFieldValueFromFdf: >=20 > DscDefaultValue =3D True >=20 > DscMatch =3D True >=20 > DecMatch =3D False >=20 > - elif Pcd.SkuOverrideValues: >=20 > - DscOverride =3D False >=20 > - if Pcd.DefaultFromDSC: >=20 > - DscOverride =3D True >=20 > - else: >=20 > - DictLen =3D 0 >=20 > - for item in Pcd.SkuOverrideValues: >=20 > - DictLen +=3D > len(Pcd.SkuOverrideValues[item]) >=20 > - if not DictLen: >=20 > - DscOverride =3D False >=20 > + else: >=20 > + if Pcd.Type in PCD_DYNAMIC_TYPE_SET | > PCD_DYNAMIC_EX_TYPE_SET: >=20 > + DscOverride =3D False >=20 > + if Pcd.DefaultFromDSC: >=20 > + DscOverride =3D True >=20 > else: >=20 > - if not Pcd.SkuInfoList: >=20 > - OverrideValues =3D > Pcd.SkuOverrideValues >=20 > - if OverrideValues: >=20 > - for Data in > OverrideValues.values(): >=20 > - Struct =3D > list(Data.values()) >=20 > - if Struct: >=20 > - DscOverride =3D > self.ParseStruct(Struct[0]) >=20 > - break >=20 > + DictLen =3D 0 >=20 > + for item in Pcd.SkuOverrideValues: >=20 > + DictLen +=3D > len(Pcd.SkuOverrideValues[item]) >=20 > + if not DictLen: >=20 > + DscOverride =3D False >=20 > else: >=20 > - SkuList =3D > sorted(Pcd.SkuInfoList.keys()) >=20 > - for Sku in SkuList: >=20 > - SkuInfo =3D > Pcd.SkuInfoList[Sku] >=20 > - if > SkuInfo.DefaultStoreDict: >=20 > - DefaultStoreList =3D > sorted(SkuInfo.DefaultStoreDict.keys()) >=20 > - for DefaultStore in > DefaultStoreList: >=20 > - OverrideValues =3D > Pcd.SkuOverrideValues[Sku] >=20 > - DscOverride =3D > self.ParseStruct(OverrideValues[DefaultStore]) >=20 > - if DscOverride: >=20 > + if not Pcd.SkuInfoList: >=20 > + OverrideValues =3D > Pcd.SkuOverrideValues >=20 > + if OverrideValues: >=20 > + for Data in > OverrideValues.values(): >=20 > + Struct =3D > list(Data.values()) >=20 > + if Struct: >=20 > + > DscOverride =3D self.ParseStruct(Struct[0]) >=20 > break >=20 > - if DscOverride: >=20 > - break >=20 > - if DscOverride: >=20 > - DscDefaultValue =3D True >=20 > - DscMatch =3D True >=20 > - DecMatch =3D False >=20 > + else: >=20 > + SkuList =3D > sorted(Pcd.SkuInfoList.keys()) >=20 > + for Sku in SkuList: >=20 > + SkuInfo =3D > Pcd.SkuInfoList[Sku] >=20 > + if > SkuInfo.DefaultStoreDict: >=20 > + DefaultStoreList > =3D sorted(SkuInfo.DefaultStoreDict.keys()) >=20 > + for DefaultStore > in DefaultStoreList: >=20 > + > OverrideValues =3D Pcd.SkuOverrideValues[Sku] >=20 > + > DscOverride =3D self.ParseStruct(OverrideValues[DefaultStore]) >=20 > + if > DscOverride: >=20 > + break >=20 > + if DscOverride: >=20 > + break >=20 > + if DscOverride: >=20 > + DscDefaultValue =3D True >=20 > + DscMatch =3D True >=20 > + DecMatch =3D False >=20 > + else: >=20 > + DecMatch =3D True >=20 > else: >=20 > - DecMatch =3D True >=20 > - else: >=20 > - DscDefaultValue =3D True >=20 > - DscMatch =3D True >=20 > - DecMatch =3D False >=20 > + if Pcd.DscRawValue or (module_guid and > module_guid.replace("-","S") in Pcd.PcdValueFromComponents): >=20 > + DscDefaultValue =3D True >=20 > + DscMatch =3D True >=20 > + DecMatch =3D False >=20 > + else: >=20 > + DscDefaultValue =3D False >=20 > + DecMatch =3D True >=20 >=20 >=20 > # >=20 > # Report PCD item according to their override > relationship >=20 > # >=20 > if Pcd.DatumType =3D=3D 'BOOLEAN': >=20 > @@ -1151,17 +1163,18 @@ class PcdReport(object): > elif InfDefaultValue and InfMatch: >=20 > self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > InfDefaultValue, DecMatch, DecDefaultValue, '*M') >=20 > elif BuildOptionMatch: >=20 > self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > InfDefaultValue, DecMatch, DecDefaultValue, '*B') >=20 > else: >=20 > - if DscDefaultValue and DscMatch: >=20 > + if PcdComponentValue: >=20 > + self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > PcdComponentValue, DecMatch, DecDefaultValue, '*M', module_guid) >=20 > + elif DscDefaultValue and DscMatch: >=20 > if (Pcd.TokenCName, Key, Field) in > self.FdfPcdSet: >=20 > self.PrintPcdValue(File, Pcd, > PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak, > InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*F') >=20 > else: >=20 > self.PrintPcdValue(File, Pcd, > PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak, > InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*P') >=20 > - else: >=20 > - self.PrintPcdValue(File, Pcd, PcdTokenCName, > TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, > InfDefaultValue, DecMatch, DecDefaultValue, '*M') >=20 > + >=20 >=20 >=20 > if ModulePcdSet is None: >=20 > if IsStructure: >=20 > continue >=20 > if not TypeName in ('PATCH', 'FLAG', 'FIXED'): >=20 > @@ -1263,11 +1276,11 @@ class PcdReport(object): > self.PrintStructureInfo(File, filedvalues) >=20 > if DecMatch and IsStructure: >=20 > for filedvalues in Pcd.DefaultValues.values(): >=20 > self.PrintStructureInfo(File, filedvalues) >=20 >=20 >=20 > - def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, > IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, > DecDefaultValue, Flag =3D ' '): >=20 > + def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, > IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, > DecDefaultValue, Flag =3D ' ',module_guid=3DNone): Here, module_guid may be ModuleGuid.=20 Thanks Liming >=20 > if not Pcd.SkuInfoList: >=20 > Value =3D Pcd.DefaultValue >=20 > IsByteArray, ArrayList =3D ByteArrayForamt(Value) >=20 > if IsByteArray: >=20 > FileWrite(File, ' %-*s : %6s %10s =3D %s' % = (self.MaxLen, > Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{')) >=20 > @@ -1286,18 +1299,24 @@ class PcdReport(object): > FiledOverrideFlag =3D False >=20 > if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in > GlobalData.gPcdSkuOverrides: >=20 > OverrideValues =3D > GlobalData.gPcdSkuOverrides[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName) > ] >=20 > else: >=20 > OverrideValues =3D Pcd.SkuOverrideValues >=20 > + FieldOverrideValues =3D None >=20 > if OverrideValues: >=20 > for Data in OverrideValues.values(): >=20 > Struct =3D list(Data.values()) >=20 > if Struct: >=20 > - OverrideFieldStruct =3D > self.OverrideFieldValue(Pcd, Struct[0]) >=20 > - self.PrintStructureInfo(File, > OverrideFieldStruct) >=20 > + FieldOverrideValues =3D Struct[0] >=20 > FiledOverrideFlag =3D True >=20 > break >=20 > + if Pcd.PcdFiledValueFromDscComponent and > module_guid and module_guid.replace("-","S") in > Pcd.PcdFiledValueFromDscComponent: >=20 > + FieldOverrideValues =3D > Pcd.PcdFiledValueFromDscComponent[module_guid.replace("-","S")] >=20 > + if FieldOverrideValues: >=20 > + OverrideFieldStruct =3D = self.OverrideFieldValue(Pcd, > FieldOverrideValues) >=20 > + self.PrintStructureInfo(File, = OverrideFieldStruct) >=20 > + >=20 > if not FiledOverrideFlag and > (Pcd.PcdFieldValueFromComm or Pcd.PcdFieldValueFromFdf): >=20 > OverrideFieldStruct =3D = self.OverrideFieldValue(Pcd, > {}) >=20 > self.PrintStructureInfo(File, = OverrideFieldStruct) >=20 > self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, > DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) >=20 > else: >=20 > -- > 2.29.1.windows.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#66883): = https://edk2.groups.io/g/devel/message/66883 > Mute This Topic: https://groups.io/mt/77995840/4905953 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [gaoliming@byosoft.com.cn] > -=3D-=3D-=3D-=3D-=3D-=3D >=20