From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C3FC32098EAA3 for ; Thu, 19 Jul 2018 22:13:16 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2018 22:13:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,377,1526367600"; d="scan'208";a="59181986" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 19 Jul 2018 22:13:00 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 19 Jul 2018 22:12:43 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 19 Jul 2018 22:12:43 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.100]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Fri, 20 Jul 2018 13:12:31 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [Patch V3] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section Thread-Index: AQHUHXXmPgc2U3/HGkWx864Nlk4Sb6SXlUwA Date: Fri, 20 Jul 2018 05:12:31 +0000 Message-ID: References: <1531794520-10852-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1531794520-10852-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch V3] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2018 05:13:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yong= hong Zhu Sent: Tuesday, July 17, 2018 10:29 AM To: edk2-devel@lists.01.org Cc: Gao, Liming Subject: [edk2] [Patch V3] BaseTools: enable FixedAtBuild (VOID*) PCD use i= n the [DEPEX] section From: Yunhua Feng V3: Add some invalid type and datum check V2: limit the PCD used in the [Depex] section should be used in the module The PCD item used in INF [Depex] section must be defined as FixedAtBuild ty= pe and VOID* datum type, and the size of the PCD must be 16 bytes. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D443 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 32 +++++++++++++++++++= ++-- BaseTools/Source/Python/AutoGen/GenDepex.py | 6 +++++ BaseTools/Source/Python/Workspace/InfBuildData.py | 20 ++++++++++---- BaseTools/Source/Python/build/BuildReport.py | 7 ++++- 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index c5ab334..9bbf6e1 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2750,10 +2750,14 @@ class ModuleAutoGen(AutoGen): ## Store the FixedAtBuild Pcds # self._FixedAtBuildPcds =3D [] self.ConstPcd =3D {} =20 + ##Store the VOID* type FixedAtBuild Pcds + # + self._FixedPcdVoidTypeDict =3D {} + def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) =20 # Get FixedAtBuild Pcds of this Module def _GetFixedAtBuildPcds(self): @@ -2765,10 +2769,19 @@ class ModuleAutoGen(AutoGen): if Pcd not in self._FixedAtBuildPcds: self._FixedAtBuildPcds.append(Pcd) =20 return self._FixedAtBuildPcds =20 + def _GetFixedAtBuildVoidTypePcds(self): + if self._FixedPcdVoidTypeDict: + return self._FixedPcdVoidTypeDict + for Pcd in self.ModulePcdList: + if Pcd.Type =3D=3D TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType = =3D=3D TAB_VOID: + if '{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)= not in self._FixedPcdVoidTypeDict: + self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName)] =3D Pcd.DefaultValue + return self._FixedPcdVoidTypeDict + def _GetUniqueBaseName(self): BaseName =3D self.Name for Module in self.PlatformInfo.ModuleAutoGenList: if Module.MetaFile =3D=3D self.MetaFile: continue @@ -3034,11 +3047,11 @@ class ModuleAutoGen(AutoGen): self._DepexDict =3D {} if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION= _FILE in self.FileTypes: return self._DepexDict =20 self._DepexDict[self.ModuleType] =3D [] - + self._GetFixedAtBuildVoidTypePcds() for ModuleType in self._DepexDict: DepexList =3D self._DepexDict[ModuleType] # # Append depex from dependent libraries, if not "BEFORE", = "AFTER" expresion # @@ -3046,11 +3059,25 @@ class ModuleAutoGen(AutoGen): Inherited =3D False for D in M.Depex[self.Arch, ModuleType]: if DepexList !=3D []: DepexList.append('AND') DepexList.append('(') - DepexList.extend(D) + #replace D with value if D is FixedAtBuild PCD + NewList =3D [] + for item in D: + if '.' not in item: + NewList.append(item) + else: + if item not in self._FixedPcdVoidTypeDict: + EdkLogger.error("build", FORMAT_INVALI= D, "{} used in [Depex] section should be used as FixedAtBuild type and VOID= * datum type in the module.".format(item)) + else: + Value =3D self._FixedPcdVoidTypeDict[i= tem] + if len(Value.split(',')) !=3D 16: + EdkLogger.error("build", FORMAT_IN= VALID, + "{} used in [Depex= ] section should be used as FixedAtBuild type and VOID* datum type and 16 b= ytes in the module.".format(item)) + NewList.append(Value) + DepexList.extend(NewList) if DepexList[-1] =3D=3D 'END': # no need of a END= at this time DepexList.pop() DepexList.append(')') Inherited =3D True if Inherited: @@ -4418,10 +4445,11 @@ class ModuleAutoGen(AutoGen): BuildOptionIncPathList =3D property(_GetBuildOptionIncPathList) BuildCommand =3D property(_GetBuildCommand) =20 FixedAtBuildPcds =3D property(_GetFixedAtBuildPcds) UniqueBaseName =3D property(_GetUniqueBaseName) + FixedVoidTypePcds =3D property(_GetFixedAtBuildVoidTypePcds) =20 # This acts like the main() function for the script, unless it is 'import'= ed into another script. if __name__ =3D=3D '__main__': pass =20 diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source= /Python/AutoGen/GenDepex.py index d3b1eae..c12b613 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -20,10 +20,12 @@ from Common.LongFilePathSupport import OpenLongFilePath= as open from io import BytesIO from struct import pack from Common.Buil= dToolError import * from Common.Misc import SaveFileOnChange from Common.= Misc import GuidStructureStringToGuidString +from Common.Misc import GuidStructureByteArrayToGuidString +from Common.Misc import GuidStringToGuidStructureString from Common import EdkLogger as EdkLogger from Common.BuildVersion import= gBUILD_VERSION from Common.DataType import * =20 ## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END" @@ -331,10 +333,14 @@ class DependencyExpression: # @retval array The byte array representing the GUID value # def GetGuidValue(self, Guid): GuidValueString =3D Guid.replace("{", "").replace("}", "").replace= (" ", "") GuidValueList =3D GuidValueString.split(",") + if len(GuidValueList) !=3D 11 and len(GuidValueList) =3D=3D 16: + GuidValueString =3D GuidStringToGuidStructureString(GuidStruct= ureByteArrayToGuidString(Guid)) + GuidValueString =3D GuidValueString.replace("{", "").replace("= }", "").replace(" ", "") + GuidValueList =3D GuidValueString.split(",") if len(GuidValueList) !=3D 11: EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID value = string or opcode: %s" % Guid) return pack("1I2H8B", *(int(value, 16) for value in GuidValueList)= ) =20 ## Save the binary form of dependency expression in file diff --git a/= BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python= /Workspace/InfBuildData.py index f79ffe2..29e68ae 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -910,16 +910,26 @@ class InfBuildData(ModuleBuildClassObject): if Module is None: EdkLogger.error('build', RESOURCE_NOT_AVAILABL= E, "Module is not found in active platform", ExtraData=3DToken, File=3Dself= .MetaFile, Line=3DRecord[-1]) DepexList.append(Module.Guid) else: - # get the GUID value now - Value =3D ProtocolValue(Token, self.Packages, self= .MetaFile.Path) - if Value is None: - Value =3D PpiValue(Token, self.Packages, self.= MetaFile.Path) + # it use the Fixed PCD format + if '.' in Token: + if tuple(Token.split('.')[::-1]) not in self.P= cds: + EdkLogger.error('build', RESOURCE_NOT_AVAI= LABLE, "PCD [{}] used in [Depex] section should be listed in module PCD sec= tion".format(Token), File=3Dself.MetaFile, Line=3DRecord[-1]) + else: + if self.Pcds[tuple(Token.split('.')[::-1])= ].DatumType !=3D TAB_VOID: + EdkLogger.error('build', FORMAT_INVALI= D, "PCD [{}] used in [Depex] section should be VOID* datum type".format(Tok= en), File=3Dself.MetaFile, Line=3DRecord[-1]) + Value =3D Token + else: + # get the GUID value now + Value =3D ProtocolValue(Token, self.Packages,= =20 + self.MetaFile.Path) if Value is None: - Value =3D GuidValue(Token, self.Packages, = self.MetaFile.Path) + Value =3D PpiValue(Token, self.Packages, s= elf.MetaFile.Path) + if Value is None: + Value =3D GuidValue(Token,=20 + self.Packages, self.MetaFile.Path) + if Value is None: PackageList =3D "\n\t".join(str(P) for P in se= lf.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABL= E, "Value of [%s] is not found in= " % Token, ExtraData=3DPackageList, File= =3Dself.MetaFile, Line=3DRecord[-1]) diff --git a/BaseTools/Source/Python/b= uild/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index 273e7d4..176a390 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -278,11 +278,16 @@ class DepexParser(object): GuidValue =3D GuidStructureStringToGuidString(Package.= Ppis[Ppi]) self._GuidDb[GuidValue.upper()] =3D Ppi for Guid in Package.Guids: GuidValue =3D GuidStructureStringToGuidString(Package.= Guids[Guid]) self._GuidDb[GuidValue.upper()] =3D Guid - + for Ma in Pa.ModuleAutoGenList: + for Pcd in Ma.FixedVoidTypePcds: + PcdValue =3D Ma.FixedVoidTypePcds[Pcd] + if len(PcdValue.split(',')) =3D=3D 16: + GuidValue =3D GuidStructureByteArrayToGuidString(P= cdValue) + self._GuidDb[GuidValue.upper()] =3D Pcd ## # Parse the binary dependency expression files. # # This function parses the binary dependency expression file and trans= late it # to the instruction list. -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel