From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.7557.1592977726595522267 for ; Tue, 23 Jun 2020 22:48:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=xpYpu8Gr; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: bob.c.feng@intel.com) IronPort-SDR: Hq8cv9PrIiXD5PBn+km8BhMsEzaRIgzMupc2pOXOBp3c8D1Yub3vDFHmvbXF0Ftb9iycKHJvzN 7DtPbzRls7Sw== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="205850107" X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="205850107" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 22:48:45 -0700 IronPort-SDR: 3cA7zTxMGGPGx65OLcC27FsSlrkNPIZWxDr2L2a8RO1GrbkJXuvnPIM7/Z3nItMvd4YNhcathg QA/AeajbsF7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="279363994" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 23 Jun 2020 22:48:45 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jun 2020 22:48:39 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jun 2020 22:48:39 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jun 2020 22:48:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bQLei7d9Q43lFVybN59TWpeXhfpJ8t80oB36+rSpgASHpHPSzn1MHxN3q8EzWeIkhFRSGnZuTv6D/qtS7+291R/dE5eLQw8k9MvPY6lGVnjnty7J2vdvAyCNV5j7wqtS2Db05g4N4MjJiiJBJjvtRs8x+9fWHpi5epR867JMxW8MmP5TSeEQn6SK6TAE1Sonk4DBlaOlUSuzRYzwO07uTURqwnQV50dYLyjk+Br9MPA/O0g48giU8tFYldDuree39g1AoUhN/OvgisrN5jyMwrbOs1NP90/E3d9m7NFPT2goX40uEh1uYE4q+zMA+9vik/iCgW6UAq/elhMuPfQ6xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GM6qZzvFEdwr/eiveDweYKT0ge1CGJz52qU+7O5IkR0=; b=KwTR/50m8lYLHfjRJbzAs6BH9qVmQl1UhH1VmYD+qLK5AnZDE587s/cyta+yzXoMtgXj+qnKDF9THnd8kxeOmHCnNLIIRXDDDQpp5/+uUGQnejgISSVTloRmLPoUwX812g/y4Cu+AIly+WyiYtKnLPY+uS+ht+p4Hf5Wubslila5DcuE46l+6PHptDj06v0Azd5ZH2p4f1Qu4+acFQ7yRnHwvqSX80C57zsWWGfz3fJg0PG9zjxp4rCs0n7X4mB8+heAN2GCsRA3yOxNStYASBFYNp6dyp6+u5ln7anE7anGs2JZ1QpZXwaKTAy10cRUnhBQtL2JNlqDxf5D1PHajg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GM6qZzvFEdwr/eiveDweYKT0ge1CGJz52qU+7O5IkR0=; b=xpYpu8GrVBedNrLB/8rkepr50hvDPcgeJz4fBRTGTK4rvt9likjslZjJOmXKk5y3XaWhyHcwQnX4/pghtaVeOJlEApL2B6ofQKLpjLA0450vygV9Uc3PpftML9x8e4TDyE+QzZLOk6Xq/RMUZbqShKfa1zVEO/GzHWAgHeWQEqA= Received: from BN6PR11MB0068.namprd11.prod.outlook.com (2603:10b6:405:69::17) by BN6PR11MB1955.namprd11.prod.outlook.com (2603:10b6:404:100::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Wed, 24 Jun 2020 05:48:37 +0000 Received: from BN6PR11MB0068.namprd11.prod.outlook.com ([fe80::6870:82d3:5bde:4153]) by BN6PR11MB0068.namprd11.prod.outlook.com ([fe80::6870:82d3:5bde:4153%6]) with mapi id 15.20.3109.027; Wed, 24 Jun 2020 05:48:37 +0000 From: "Bob Feng" To: "devel@edk2.groups.io" , "pierre.gondois@arm.com" CC: "sami.mujawar@arm.com" , "tomas.pilar@arm.com" , "Gao, Liming" , "nd@arm.com" Subject: Re: [edk2-devel] [PATCH v2 3/4] BaseTools: Compile AML bytecode arrays into .obj file Thread-Topic: [edk2-devel] [PATCH v2 3/4] BaseTools: Compile AML bytecode arrays into .obj file Thread-Index: AQHWRXyknXQclksXRUarh5VQ12XMKqjnSxTA Date: Wed, 24 Jun 2020 05:48:37 +0000 Message-ID: References: <20200618142713.146412-1-pierre.gondois@arm.com> <20200618142713.146412-4-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-4-pierre.gondois@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.45] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 63fd8ef2-49e2-4d5a-6ff5-08d818023d98 x-ms-traffictypediagnostic: BN6PR11MB1955: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:88; x-forefront-prvs: 0444EB1997 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2+roUp2Q9T5XCkBkQekyPZkxlfY/3I3USRs4IBbU9Nmqhua9s34EkKGq4t2CPtsWeud1JnVUb3B1rErNjSUQhz3ekA1EZkiNcXMF09ND/ythPrW9z2epFc7vA5MyJsU9PP56Qti+kjia55ROot30qGYWA+x6+fDEc3sPnbCi+qU/CfV9Eq9pHwaSY3fMpDYOnUeYu47FwxUKmcw+RuWJ1vzHz+ZzAi0aOZKBcpML8r5SVZ8q/XJqL/2lBbBk7BQYnfya7j1h0bwCQMzE3Hti8w0tlohM9nrVDDgskYzzSg440hGeVLP3FfZ4O5XG0OMYbJM9nveZhElIvMCXci6gjia1PCNDcu0+Cj93MywCGFkhr3VXNKu6CJufl9dveZFkMDhvpwIxHC3UzyF4/AFhd+eJoM3Hsb2z1lUiRPBiXzfIiYp0XFEbWBA9Isb8b1I6+kZTQvolKKw64PvpqikMAQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB0068.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(66556008)(66476007)(8936002)(6506007)(30864003)(64756008)(66446008)(316002)(76116006)(110136005)(8676002)(66946007)(5660300002)(54906003)(55016002)(9686003)(2906002)(71200400001)(478600001)(7696005)(186003)(4326008)(53546011)(52536014)(26005)(86362001)(83380400001)(966005)(33656002)(142923001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: U6618mnJ1G8u5WBbsNsWN5Rvv506yITgFdmMnTvFx/gLFCT+3LThsHvcjV7eO5XSFGJ89szk/VSohFRBDYKjZE0vvDRIt+tblYLQ4Y1t4xE9ea6zmmTajK2ND50biSvMGj01SJyJ8ytdR8Y1Tz8Uy4DGPKBAQ9keE4zm0J0PDFSpJ2JUg+kjs3cfad2vv5aQ8JIySg57t/wILDfDsWNgUmxgvS6fCGxu+0qITxvOTxJS6ymtExUwT+0hSJC+T/ctA7elAeiTU/0NBJVl/vzCaYv6C0T4dBVceX/dggrMqMYbOLfAtz5TA6nshTutmX5D8J0LG8easc0sXbU8A1Eaz+0/T2jhMsqZna+C+8bbVshha+mnf7cIby3XJi1hDiUWiAhNd3/dmzNZMGHC/d/Gq8UN19ZUv+CioUSYK+m1xtwInlju3MrV0QPhyUi1h+nywSwoFnZm4O9NWQBDQQchF+of7h2wNQmD3uJOeGt18Bd2S+mTnJ2kXM8Zmm79j35e MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 63fd8ef2-49e2-4d5a-6ff5-08d818023d98 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2020 05:48:37.3987 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: C6yOONQ9f8GurE2hBZ0p7WJmQObTan+70y1mfDeoZr72Hz6QUFuYqF708jVwOL4bBithPoWwNOs43F5qFT1thg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1955 Return-Path: bob.c.feng@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Pierre, The commit message should not have more than one Signed-off-by. Use of Suggested-by may be more appropriate here. Thanks, Bob -----Original Message----- From: devel@edk2.groups.io On Behalf Of PierreGondo= is Sent: Thursday, June 18, 2020 10:27 PM To: devel@edk2.groups.io Cc: Pierre Gondois ; sami.mujawar@arm.com; tomas.p= ilar@arm.com; Feng, Bob C ; Gao, Liming ; nd@arm.com Subject: [edk2-devel] [PATCH v2 3/4] BaseTools: Compile AML bytecode array= s into .obj file 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 ca= n then be included in a C file, allowing to access the AML bytecode from th= is 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" f= ile 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 thi= s 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 f= ile. 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 independentl= y. The C array must be defined as an external symbol. The linker is resolvi= ng 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 sy= stem 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 --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/80= 3_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_rul= e.template index 0822b681fcd9f61c6508e6f93ffc31fa70fd7059..c034869915914936e28f64a6aa= dba08e0169da44 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} $(OUTP= UT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii= i $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii=20 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_d= ir}(+)${s_base}.iiii - -AmlToHex $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml + $(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml=20 + $(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} $(OUTP= UT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii= i $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii=20 "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_d= ir}(+)${s_base}.iiii - -AmlToHex $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml + $(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml=20 + $(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/P= ython/AmlToC/AmlToC.py index 643db2910e37acfdd80ac18d288c921320a79ce1..346de7159de702d860bbd809dd= be8175f1493cfb 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 i= n a +# Convert an AML file to a .c file containing the AML bytecode stored=20 +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 con= tains +# By default, "Tables\Dsdt.aml" will generate "Tables\Dsdt.c". +# "Tables\Dsdt.c" will contain a C array named "dsdt_aml_code" that=20 +contains # 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=20 +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=20 +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 AM= L " + \ - "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= =20 + 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.Input= File) + EdkLogger.info("Invalid file type. File does not have a= =20 + valid 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),=20 + os.path.abspath(__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 s= tored +# 3- Converts an AML file to a .c file containing the AML bytecode sto= red # 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 = stored + # Convert an AML file to a .c file containing the AML bytecode=20 + stored # in a C array. - AmlToHex(CommandArguments.InputFile, CommandArguments.OutputFile, - CommandArguments.BaseName) + AmlToC(CommandArguments.InputFile, CommandArguments.OutputFile,= =20 + CommandArguments.BaseName) except Exception as e: print(e) return 1 -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'