From nobody Fri Apr 19 15:27:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61489+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61489+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592490446; cv=none; d=zohomail.com; s=zohoarc; b=PD+SXLVZwM7BcY5qDC2ALwYiJMOi8jjUgv4ENDYLLDpq1JCvNcF6/HE6LGqe1cngt/+JiNbbHG94mFejt0VkHiw9KurLHVsQ66FT6F5Di7sRFoVR6XeSwFtfLXmLW0vPCy/qgbp1OdtoOdfwS6tP9apgfy8EkMcA4cUH1JSJF0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592490446; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=lDWsrMZSCXnLqd3KiD6mJJoNLyOUAKbajb3W8PpoMyM=; b=g8LyJ9BZT8WmwSVRD/DTkxKpHT70Z0WK5pTOfd2MwNqRcIa7hPJHL1zKSrA7u7onOMqmozbL0fw6JPT41YBRi2opXU6IETH9Nzk96EUanu/D9tIaphKaYASvF7rP2IhBcxgBD6afHJL2zw9uHie5OZUTZW9DqtU34NxIPK6FaKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61489+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159249044662744.58864693449357; Thu, 18 Jun 2020 07:27:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CFSVYY1788612xDz9JoM0otV; Thu, 18 Jun 2020 07:27:25 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.49]) by mx.groups.io with SMTP id smtpd.web10.8740.1592490442759624864 for ; Thu, 18 Jun 2020 07:27:23 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05IERJ6X020245; Thu, 18 Jun 2020 15:27:19 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , sami.mujawar@arm.com, tomas.pilar@arm.com, bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v2 1/4] BaseTools: Generate multiple rules when multiple output files Date: Thu, 18 Jun 2020 15:27:10 +0100 Message-Id: <20200618142713.146412-2-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-1-pierre.gondois@arm.com> References: <20200618142713.146412-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: k8zP1GvcuOwtyDxPMGXaHiU6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592490445; bh=XrefPP2Ihxbm+l6GkdF86EKvGnXlVB+PWlVxVaDXui8=; h=Cc:Date:From:Reply-To:Subject:To; b=Reeb44UQ75OkXZ8knWiuZZf9n5GUejch5wl5dcCWt8n1T27WDkYyQulDsqFsK4w6cp/ rBpO4Fv+UqMEg4ZBvi0dvWVCOIliL3O93NH/YBlLAZXLDVIkOKZn2Hh80Blyk6grYfmnS +9IIazEDfj549B0eADnt0qoy0q/rfpSJoOo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois This patch modifies the Makefile generation not to stop adding Makfile rules when the first final target is found. E.g.: If the following rules are described in build_rule.txt: -[Rule1]: .X files generate .Y and .Z files; -[Rule2]: .Z files generate .Z1 files. Currently, if a File1.X file was part of the sources of a module, only [Rule1] would be generated in the Makefile. Indeed, there are no rules to apply to .Y files: .Y files are a final target. However, there is still [Rule2] to apply to .Z files. This patch also adds a dependency between the first ouput file of a rule and the other output files. For instance, with the same example as above, File1.Y and File1.Z are generated by the following rule: File1.Y: File1.X and the new dependency is: File1.Z: File1.Y This is necessary to keep a dependency order during the execution of the Makefile. Indeed, .Y and .Z files are generated by the execution of a common set of commands, and without this rule, there is no explicit dependency relation between them. Signed-off-by: Pierre Gondois Reviewed-by: Bob Feng --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/803= _Compile_AML_bytecode_array_into_OBJ_file_v2 Notes: Notes: v1: - Generate multiple rules when multiple output files are specified in the build_rule.txt file. [Pierre] v2: - Use the "FileType" variable in the _ApplyBuildRule function as it is in the current state. [Pierre] BaseTools/Source/Python/AutoGen/GenMake.py | 6 ++++ BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 38 +++++++++++--------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index bbb3c29446f53fa7f2cb61a216a5b119f72c3fbc..0314d0ea34d99a014379e8d30c4= 6ac0f0a7068ce 100755 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1054,6 +1054,12 @@ cleanlib: TargetDict =3D {"target": self.PlaceMacro(T.Target.Pat= h, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": Deps} self.BuildTargetList.append(self._BUILD_TARGET_TEMPLAT= E.Replace(TargetDict)) =20 + # Add a Makefile rule for targets generating multiple = files. + # The main output is a prerequisite for the other outp= ut files. + for i in T.Outputs[1:]: + AnnexeTargetDict =3D {"target": self.PlaceMacro(i.= Path, self.Macros), "cmd": "", "deps": self.PlaceMacro(T.Target.Path, self.= Macros)} + self.BuildTargetList.append(self._BUILD_TARGET_TEM= PLATE.Replace(AnnexeTargetDict)) + def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDi= ct, DependencyDict): if not CmdSumDict: for item in self._AutoGenObject.Targets[Type]: diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index aad591de65f086043d55aeea5661f59c53792e7c..dc8b1fe3d160cac2da22227fc23= 3e3aa0d92cb1e 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -860,7 +860,8 @@ class ModuleAutoGen(AutoGen): SubDirectory =3D os.path.join(self.OutputDir, File.SubDir) if not os.path.exists(SubDirectory): CreateDirectory(SubDirectory) - LastTarget =3D None + TargetList =3D set() + FinalTargetName =3D set() RuleChain =3D set() SourceList =3D [File] Index =3D 0 @@ -870,6 +871,9 @@ class ModuleAutoGen(AutoGen): self.BuildOption =20 while Index < len(SourceList): + # Reset the FileType if not the first iteration. + if Index > 0: + FileType =3D TAB_UNKNOWN_FILE Source =3D SourceList[Index] Index =3D Index + 1 =20 @@ -886,29 +890,25 @@ class ModuleAutoGen(AutoGen): elif Source.Ext in self.BuildRules: RuleObject =3D self.BuildRules[Source.Ext] else: - # stop at no more rules - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break + # No more rule to apply: Source is a final target. + FinalTargetName.add(Source) + continue =20 FileType =3D RuleObject.SourceFileType self._FileTypes[FileType].add(Source) =20 # stop at STATIC_LIBRARY for library if self.IsLibrary and FileType =3D=3D TAB_STATIC_LIBRARY: - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break + FinalTargetName.add(Source) + continue =20 Target =3D RuleObject.Apply(Source, self.BuildRuleOrder) if not Target: - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break - elif not Target.Outputs: - # Only do build for target with outputs - self._FinalBuildTargetList.add(Target) + # No Target: Source is a final target. + FinalTargetName.add(Source) + continue =20 + TargetList.add(Target) self._BuildTargets[FileType].add(Target) =20 if not Source.IsBinary and Source =3D=3D File: @@ -916,12 +916,16 @@ class ModuleAutoGen(AutoGen): =20 # to avoid cyclic rule if FileType in RuleChain: - break + EdkLogger.error("build", ERROR_STATEMENT, "Cyclic dependen= cy detected while generating rule for %s" % str(Source)) =20 RuleChain.add(FileType) SourceList.extend(Target.Outputs) - LastTarget =3D Target - FileType =3D TAB_UNKNOWN_FILE + + # For each final target name, retrieve the corresponding TargetDes= cBlock instance. + for FTargetName in FinalTargetName: + for Target in TargetList: + if FTargetName =3D=3D Target.Target: + self._FinalBuildTargetList.add(Target) =20 @cached_property def Targets(self): --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61489): https://edk2.groups.io/g/devel/message/61489 Mute This Topic: https://groups.io/mt/74959530/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 15:27:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61491+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61491+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592490447; cv=none; d=zohomail.com; s=zohoarc; b=HkdMWgs8r6zIjgQULi8NN8ijARU62nRz9OB7OIPUvOmtprGDA7xi/bGs0p/meuNpltMgiwDcEUt9v0ZKxjIgKzYC+jVqdNxk73Ct4WRbXBPDh1wGSNOBjFfuJWb7vj40gX11F3yiVeSo5vRxcLh3vBUTQQll9+J1J+CSwx32p3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592490447; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=hKon5j3tBg0eyMEPyPPvVqmXhjToEqKminZ/KparKMU=; b=Yd7xGkfuc0YWGCU7SuG/1CVu+4tN/v4Lz8aGMN7pHYqTn6PZP90LUpVy6Ly4Bq2Inkmg4HG/HbiUtr4oniJYtktydpgIoqVb7hMtHPIKFd5gIwvI5NLA9a9yZKYgMfaq3y4EJe7z7dqECm5JPMAULZlavmOK6q6gyIrvyD+Zkco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61491+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592490447422122.49494235236273; Thu, 18 Jun 2020 07:27:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JgGnYY1788612xinQz1AoGB6; Thu, 18 Jun 2020 07:27:27 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.49]) by mx.groups.io with SMTP id smtpd.web10.8739.1592490442759089235 for ; Thu, 18 Jun 2020 07:27:23 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05IERJ6Y020245; Thu, 18 Jun 2020 15:27:20 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , sami.mujawar@arm.com, tomas.pilar@arm.com, bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v2 2/4] BaseTools: Rename AmlToHex script to AmlToC Date: Thu, 18 Jun 2020 15:27:11 +0100 Message-Id: <20200618142713.146412-3-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-1-pierre.gondois@arm.com> References: <20200618142713.146412-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: rPSc6Mc3xPAZmJmk6Ui6f6Xxx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592490447; bh=D6Wge93l0/3geOXkYRDJ1CSLWcur3Y4RTy2vK6Tfhbk=; h=Cc:Date:From:Reply-To:Subject:To; b=tLXb8hHwTMuTzOSlwY0lvAhoKanqJwdPR2SxrMfQJmP0HB3Px7PXOdO+6oAF8kNJui7 HOsSP/KGAyjNgXRGZ4EnQoj0C3GAbXOt5BFfKWd4oEF6wddwVsK8QG7OfwoVvsYWov3AF /4MzOsldJPLXr6CalemVY8CNETJvNBZXEqw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The AmlToHex script and Posix/WindowsLike wrappers convert an AML file to a .hex file, containing a C array storing AML bytecode. This ".hex" file can then be included in a C file, allowing to access the AML bytecode from this C file. The EDK2 build system doesn't allow to a depict dependency orders between files of different languages. For instance, in a module containing a ".c" file and a ".asl", the ".c" file may or may not be built prior to the ".asl" file. This prevents any inclusion of a generated ".hex" in a ".c" file since this later ".hex" file may or may not have been created yet. This patch renames the script as AmlToC. It is posted as a separate patch to prevent git from seeing the renaming as a deletion plus addition of a new file. The ending line of the posix-like bin-wrapper script has also been corrected. This is a first step toward generating a C file containing the AML bytecode from an ASL file. This C file will then be handled by the EDK2 build system to generate an object file. Thus, no file inclusion will be required anymore. The C file requiring the AML bytecode as a C array, and the ASL file, will be compiled independently. The C array must be defined as an external symbol. The linker is resolving the reference to the C array symbol. To summarize, the flow goes as: -1. ASL file is compiled to AML; -2. AML file is copied to a ".amli" intermediate file; -3. EDK2 build system applies the rule relevant to ".amli" files. This is, calling the "AmlToC" script, generating a C file from the ".amli" file; -4. EDK2 build system applies the rule relevant to C files. This is creating an object file. -5. EDK2 build system links the object file containing the AML bytecode with the object file requiring it. Signed-off-by: Pierre Gondois Signed-off-by: Tomas Pilar Reviewed-by: Bob Feng --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/803= _Compile_AML_bytecode_array_into_OBJ_file_v2 Notes: Notes: v1: - Rename AmlToHex scripts to AmlToC, and change line endings of the PosixLike bin-wrapper. [Pierre] v2: - No modification. [Pierre] BaseTools/BinWrappers/PosixLike/{AmlToHex =3D> AmlToC} | 28 = ++++++++++---------- BaseTools/BinWrappers/WindowsLike/{AmlToHex.bat =3D> AmlToC.bat} | 0 BaseTools/Source/Python/{AmlToHex/AmlToHex.py =3D> AmlToC/AmlToC.py} | 0 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/BaseTools/BinWrappers/PosixLike/AmlToHex b/BaseTools/BinWrappe= rs/PosixLike/AmlToC similarity index 97% rename from BaseTools/BinWrappers/PosixLike/AmlToHex rename to BaseTools/BinWrappers/PosixLike/AmlToC index 9fb68299e4c67d1f332cd883fd348a896f1bdc50..1dd28e966288f6ea4fc52d42e2d= c7b1f74226c23 100755 --- a/BaseTools/BinWrappers/PosixLike/AmlToHex +++ b/BaseTools/BinWrappers/PosixLike/AmlToC @@ -1,14 +1,14 @@ -#!/usr/bin/env bash -#python `dirname $0`/RunToolFromSource.py `basename $0` $* - -# If a ${PYTHON_COMMAND} command is available, use it in preference to pyt= hon -if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then - python_exe=3D${PYTHON_COMMAND} -fi - -full_cmd=3D${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028= for a discussion of why $0 is not a good choice here -dir=3D$(dirname "$full_cmd") -exe=3D$(basename "$full_cmd") - -export PYTHONPATH=3D"$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" -exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@" +#!/usr/bin/env bash +#python `dirname $0`/RunToolFromSource.py `basename $0` $* + +# If a ${PYTHON_COMMAND} command is available, use it in preference to pyt= hon +if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then + python_exe=3D${PYTHON_COMMAND} +fi + +full_cmd=3D${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028= for a discussion of why $0 is not a good choice here +dir=3D$(dirname "$full_cmd") +exe=3D$(basename "$full_cmd") + +export PYTHONPATH=3D"$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" +exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@" diff --git a/BaseTools/BinWrappers/WindowsLike/AmlToHex.bat b/BaseTools/Bin= Wrappers/WindowsLike/AmlToC.bat similarity index 100% rename from BaseTools/BinWrappers/WindowsLike/AmlToHex.bat rename to BaseTools/BinWrappers/WindowsLike/AmlToC.bat diff --git a/BaseTools/Source/Python/AmlToHex/AmlToHex.py b/BaseTools/Sourc= e/Python/AmlToC/AmlToC.py similarity index 100% rename from BaseTools/Source/Python/AmlToHex/AmlToHex.py rename to BaseTools/Source/Python/AmlToC/AmlToC.py --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61491): https://edk2.groups.io/g/devel/message/61491 Mute This Topic: https://groups.io/mt/74959532/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 15:27:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61490+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61490+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592490449; cv=none; d=zohomail.com; s=zohoarc; b=DfkC11gxJ2DaujSQXHWKeFqAu4NMaqEKg4+An84zz6O62mCvgbR9vgckN7atwlZgz3mGeLdTfH+03bOg8Jw0pHlLEgGVCSirC2EZsc4K7lfYxMejrIhWxw7cxMJEnd6dX6wgUu97FJob19qmogAjmhBnnq3nB7D0lJipk9RMps0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592490449; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=i5QroN8xeGuN9nrtfpYlYpEMRlKjf93U82R6dX521p8=; b=egor+ohHdE6vwJFTZdoO4cWxrNArQF1i7azb6X8n5oDquUpt6Pw7VAAsq8VdN4Fvlmh9ayjXAsH9HZ63R6P+MXkGEOEv4W7zf8mq5Eo3ZRm4FaqSCMT+qWXKkgn3W6+v9nuGbT0VkEnV4yBSAv4iqBI7cArpvb9MA/or5DbHFP4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61490+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592490448986217.36815526394696; Thu, 18 Jun 2020 07:27:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fTccYY1788612xZFU7ge1vYZ; Thu, 18 Jun 2020 07:27:28 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.49]) by mx.groups.io with SMTP id smtpd.web12.8821.1592490442760633833 for ; Thu, 18 Jun 2020 07:27:23 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05IERJ6Z020245; Thu, 18 Jun 2020 15:27:20 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , sami.mujawar@arm.com, tomas.pilar@arm.com, bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v2 3/4] BaseTools: Compile AML bytecode arrays into .obj file Date: Thu, 18 Jun 2020 15:27:12 +0100 Message-Id: <20200618142713.146412-4-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-1-pierre.gondois@arm.com> References: <20200618142713.146412-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: PB4lc8vEai7s0iBq5YWfzAchx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592490448; bh=PJEMz+gLLIh2t1SFRUj8r+K5WC/qDBiOtEDVrZU2HFM=; h=Cc:Date:From:Reply-To:Subject:To; b=XcPTD2qF3uHXiRGLaCFaI/5zyrIs/jSVsC1cw2GJ4Miy0XISkdLemHuoT8n2+3qwCHd Ues9qr6NxEwTWDIMSeV9XOod967fERjxGpnOlHgkAvOM435QYtELWJ9cCrAFcYKHGARua 3mbWSyhwPeahSEu4vEMTzdxvo9O79JmtEfY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The AmlToHex script and Posix/WindowsLike wrappers convert an AML file to a .hex file, containing a C array storing AML bytecode. This ".hex" file can then be included in a C file, allowing to access the AML bytecode from this C file. The EDK2 build system doesn't allow to a depict dependency orders between files of different languages. For instance, in a module containing a ".c" file and a ".asl", the ".c" file may or may not be built prior to the ".asl" file. This prevents any inclusion of a generated ".hex" in a ".c" file since this later ".hex" file may or may not have been created yet. This patch modifies the AmlToC script to generate a C file instead of a ".hex" file. It also adds the generation of an intermediate ".amli" file when compiling an ASL file, and adds a rule to convert this ".amli" to a C file. This allows to generate a C file containing the AML bytecode from an ASL file. This C file will then be handled by the EDK2 build system to generate an object file. Thus, no file inclusion will be required anymore. The C file requiring the AML bytecode as a C array, and the ASL file, will be compiled independently. The C array must be defined as an external symbol. The linker is resolving the reference to the C array symbol. To summarize, the flow goes as: -1. ASL file is compiled to AML; -2. AML file is copied to a ".amli" intermediate file; -3. EDK2 build system applies the rule relevant to ".amli" files. This is, calling the "AmlToC" script, generating a C file from the ".amli" file; -4. EDK2 build system applies the rule relevant to C files. This is creating an object file. -5. EDK2 build system links the object file containing the AML bytecode with the object file requiring it. Signed-off-by: Pierre Gondois Signed-off-by: Tomas Pilar Reviewed-by: Bob Feng --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/803= _Compile_AML_bytecode_array_into_OBJ_file_v2 Notes: Notes: v1: - Add a new rule to the build_rule.template file to generate ".obj" files from .asl files, and modify the AmlToC script accordingly. [Pierre] v2: - Restrict the rule to DXE_DRIVER. This allows to build the OvmfPkg, which was not the case in v1. [Pierre] BaseTools/Conf/build_rule.template | 15 +++- BaseTools/Source/Python/AmlToC/AmlToC.py | 82 ++++++++------------ 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule= .template index 0822b681fcd9f61c6508e6f93ffc31fa70fd7059..c034869915914936e28f64a6aad= ba08e0169da44 100755 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -419,6 +419,7 @@ =20 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml + $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.amli =20 $(MAKE_FILE) @@ -428,14 +429,24 @@ "$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPU= T_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii= $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii=20 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_di= r}(+)${s_base}.iiii - -AmlToHex $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml + $(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s= _dir}(+)${s_base}.amli =20 Trim --asl-file --asl-deps -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}= .i -i $(INC_LIST) ${src} "$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPU= T_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii= $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii=20 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_di= r}(+)${s_base}.iiii - -AmlToHex $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml + $(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s= _dir}(+)${s_base}.amli + +[Acpi-Machine-Language-File-to-C.DXE_DRIVER] + + ?.amli + + + ${s_path}(+)${s_base}.c + + + -AmlToC ${src} =20 [C-Code-File.AcpiTable] diff --git a/BaseTools/Source/Python/AmlToC/AmlToC.py b/BaseTools/Source/Py= thon/AmlToC/AmlToC.py index 643db2910e37acfdd80ac18d288c921320a79ce1..346de7159de702d860bbd809ddb= e8175f1493cfb 100644 --- a/BaseTools/Source/Python/AmlToC/AmlToC.py +++ b/BaseTools/Source/Python/AmlToC/AmlToC.py @@ -1,9 +1,9 @@ ## @file # -# Convert an AML file to a .hex file containing the AML bytecode stored in= a +# Convert an AML file to a .c file containing the AML bytecode stored in a # C array. -# By default, "Tables\Dsdt.aml" will generate "Tables\Dsdt.hex". -# "Tables\Dsdt.hex" will contain a C array named "dsdt_aml_code" that cont= ains +# By default, "Tables\Dsdt.aml" will generate "Tables\Dsdt.c". +# "Tables\Dsdt.c" will contain a C array named "dsdt_aml_code" that contai= ns # the AML bytecode. # # Copyright (c) 2020, ARM Limited. All rights reserved.
@@ -17,31 +17,26 @@ from Common.BuildToolError import * import sys import os =20 +__description__ =3D """ +Convert an AML file to a .c file containing the AML bytecode stored in a C +array. By default, Tables\Dsdt.aml will generate Tables\Dsdt.c. +Tables\Dsdt.c will contain a C array named "dsdt_aml_code" that contains +the AML bytecode. +""" + ## Parse the command line arguments. # # @retval A argparse.NameSpace instance, containing parsed values. # def ParseArgs(): # Initialize the parser. - Parser =3D argparse.ArgumentParser( - description=3D"Convert an AML file to a .hex file containing the AML= " + \ - "bytecode stored in a C array. By default, " + \ - "\"Tables\\Dsdt.aml\" will generate" + \ - "\"Tables\\Dsdt.hex\". \"Tables\\Dsdt.hex\" will " + \ - "contain a C array named \"dsdt_aml_code\" that " + \ - "contains the AML bytecode." - ) + Parser =3D argparse.ArgumentParser(description=3D__description__) =20 # Define the possible arguments. - Parser.add_argument( - dest=3D"InputFile", - help=3D"Path to an input AML file to generate a .hex file from." - ) - Parser.add_argument( - "-o", "--out-dir", dest=3D"OutDir", - help=3D"Output directory where the .hex file will be generated. " + \ - "Default is the input file's directory." - ) + Parser.add_argument(dest=3D"InputFile", + help=3D"Path to an input AML file to generate a .c= file from.") + Parser.add_argument("-o", "--out-dir", dest=3D"OutDir", + help=3D"Output directory where the .c file will be= generated. Default is the input file's directory.") =20 # Parse the input arguments. Args =3D Parser.parse_args() @@ -55,9 +50,7 @@ def ParseArgs(): with open(Args.InputFile, "rb") as fIn: Signature =3D str(fIn.read(4)) if ("DSDT" not in Signature) and ("SSDT" not in Signature): - EdkLogger.info("Invalid file type. " + \ - "File does not have a valid " + \ - "DSDT or SSDT signature: %s" % Args.InputF= ile) + EdkLogger.info("Invalid file type. File does not have a va= lid DSDT or SSDT signature: {}".format(Args.InputFile)) return None =20 # Get the basename of the input file. @@ -66,42 +59,39 @@ def ParseArgs(): =20 # If no output directory is specified, output to the input directory. if not Args.OutDir: - Args.OutputFile =3D os.path.join( - os.path.dirname(Args.InputFile), - BaseName + ".hex" - ) + Args.OutputFile =3D os.path.join(os.path.dirname(Args.InputFile), + BaseName + ".c") else: if not os.path.exists(Args.OutDir): os.mkdir(Args.OutDir) - Args.OutputFile =3D os.path.join(Args.OutDir, BaseName + ".hex") + Args.OutputFile =3D os.path.join(Args.OutDir, BaseName + ".c") =20 Args.BaseName =3D BaseName =20 return Args =20 -## Convert an AML file to a .hex file containing the AML bytecode stored +## Convert an AML file to a .c file containing the AML bytecode stored # in a C array. # # @param InputFile Path to the input AML file. -# @param OutputFile Path to the output .hex file to generate. +# @param OutputFile Path to the output .c file to generate. # @param BaseName Base name of the input file. -# This is also the name of the generated .hex file. +# This is also the name of the generated .c file. # -def AmlToHex(InputFile, OutputFile, BaseName): +def AmlToC(InputFile, OutputFile, BaseName): =20 - MacroName =3D "__{}_HEX__".format(BaseName.upper()) ArrayName =3D BaseName.lower() + "_aml_code" + FileHeader =3D\ +""" +// This file has been generated from: +// -Python script: {} +// -Input AML file: {} + +""" =20 with open(InputFile, "rb") as fIn, open(OutputFile, "w") as fOut: # Write header. - fOut.write("// This file has been generated from:\n" + \ - "// \tPython script: " + \ - os.path.abspath(__file__) + "\n" + \ - "// \tInput AML file: " + \ - os.path.abspath(InputFile) + "\n\n" + \ - "#ifndef {}\n".format(MacroName) + \ - "#define {}\n\n".format(MacroName) - ) + fOut.write(FileHeader.format(os.path.abspath(InputFile), os.path.a= bspath(__file__))) =20 # Write the array and its content. fOut.write("unsigned char {}[] =3D {{\n ".format(ArrayName)) @@ -115,15 +105,12 @@ def AmlToHex(InputFile, OutputFile, BaseName): byte =3D fIn.read(1) fOut.write("\n};\n") =20 - # Write footer. - fOut.write("#endif // {}\n".format(MacroName)) - ## Main method # # This method: # 1- Initialize an EdkLogger instance. # 2- Parses the input arguments. -# 3- Converts an AML file to a .hex file containing the AML bytecode st= ored +# 3- Converts an AML file to a .c file containing the AML bytecode stor= ed # in a C array. # # @retval 0 Success. @@ -139,10 +126,9 @@ def Main(): if not CommandArguments: return 1 =20 - # Convert an AML file to a .hex file containing the AML bytecode s= tored + # Convert an AML file to a .c file containing the AML bytecode sto= red # in a C array. - AmlToHex(CommandArguments.InputFile, CommandArguments.OutputFile, - CommandArguments.BaseName) + AmlToC(CommandArguments.InputFile, CommandArguments.OutputFile, Co= mmandArguments.BaseName) except Exception as e: print(e) return 1 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61490): https://edk2.groups.io/g/devel/message/61490 Mute This Topic: https://groups.io/mt/74959531/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 15:27:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61488+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61488+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592490446; cv=none; d=zohomail.com; s=zohoarc; b=QIJWLGoqHtnFuk3K+9ZXJES74BYesRRA25oV8YnOmsiMzoO0eMLG4QGBYdC8j+1YbUSgP/QPupO6ty3ReszSLWQoDBDbGQilr+rXMYCjvHYGkiIwNPkYJBGnLekQb5iYWNGJR0xvR0nDHeBgCBSf/TyiTbfXBxFS0YnPtq5DEjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592490446; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=YrRppdVRzYMKEW/8nTCmmy/aVdFhWCWcwGrmuddnSjs=; b=WxQPXp3yMva5T+C4C/BklE1bZaviWgUfzWTBFb2Jw2EuWKKSwUvXb3TiUroycohppp7ELha99kveuFqhr0EpGPB2don14O3shwqwK+rjjv/5lhJIi+QjbhfdbDvsJzl49aJXCEGbgH0Me9szO1OFJfR6eo4Ll60UCUHyrOgNMZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61488+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592490446365566.8950004316348; Thu, 18 Jun 2020 07:27:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2SuCYY1788612xpXMHHSWauo; Thu, 18 Jun 2020 07:27:25 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.49]) by mx.groups.io with SMTP id smtpd.web10.8741.1592490442764003416 for ; Thu, 18 Jun 2020 07:27:23 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05IERJ6a020245; Thu, 18 Jun 2020 15:27:20 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , sami.mujawar@arm.com, tomas.pilar@arm.com, bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v2 4/4] BaseTools: Fix string concatenation Date: Thu, 18 Jun 2020 15:27:13 +0100 Message-Id: <20200618142713.146412-5-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-1-pierre.gondois@arm.com> References: <20200618142713.146412-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 4oRin2AIcOYUur6Wb2YEFAVWx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592490445; bh=HMq59XxvoPEjSFXQu8RuL44Jv0vkYQZ9qnszO9cBJmQ=; h=Cc:Date:From:Reply-To:Subject:To; b=v+3m4/JVdGvtCbuhkfyQCREyE+j1wWDX+2S7VJ4832lBLinlzVc+Tc/TWAuM+DONDJL SQES2KRdBw8tl6qIQMyWE0ToAjid1HHz1H3X0pdOp+XeiCmMXAVXkWgKXvp5g+jsFJSAd 0icQsFsgzsgo8lLDJQpk1qSd78g9ppx9TNI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Using Python 3.7.2 on win32, when printing a FileBuildRule instance, the following error occurs: File "edk2\BaseTools\Source\Python\AutoGen\BuildEngine.py", line 177, in __str__ DestString =3D ", ".join(self.DestFileList) TypeError: sequence item 0: expected str instance, PathClass found This patch converts each PathClass element of the list to a string instance before concatenating them. Signed-off-by: Pierre Gondois Reviewed-by: Bob Feng --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/803= _Compile_AML_bytecode_array_into_OBJ_file_v2 Notes: Notes: v2: - No v1 for this patch. Fix a __str__ method. [Pierre] BaseTools/Source/Python/AutoGen/BuildEngine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/Python/AutoGen/BuildEngine.py index d602414ca41f37155c9c6d00eec54ea3918840c3..722fead75af6d60aa82365d9998= 37cd5ac3299af 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -172,7 +172,7 @@ class FileBuildRule: def __str__(self): SourceString =3D "" SourceString +=3D " %s %s %s" % (self.SourceFileType, " ".join(sel= f.SourceFileExtList), self.ExtraSourceFileList) - DestString =3D ", ".join(self.DestFileList) + DestString =3D ", ".join([str(i) for i in self.DestFileList]) CommandString =3D "\n\t".join(self.CommandList) return "%s : %s\n\t%s" % (DestString, SourceString, CommandString) =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61488): https://edk2.groups.io/g/devel/message/61488 Mute This Topic: https://groups.io/mt/74959529/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-