--- /dev/null
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+ python_exe=${PYTHON_COMMAND}
+fi
+
+full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
+dir=$(dirname "$full_cmd")
+exe=$(basename "$full_cmd")
+
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
+exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@"
+++ /dev/null
-#!/usr/bin/env bash\r
-#python `dirname $0`/RunToolFromSource.py `basename $0` $*\r
-\r
-# If a ${PYTHON_COMMAND} command is available, use it in preference to python\r
-if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then\r
- python_exe=${PYTHON_COMMAND}\r
-fi\r
-\r
-full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here\r
-dir=$(dirname "$full_cmd")\r
-exe=$(basename "$full_cmd")\r
-\r
-export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"\r
-exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@"\r
--- /dev/null
+@setlocal\r
+@set ToolName=%~n0%\r
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
+++ /dev/null
-@setlocal\r
-@set ToolName=%~n0%\r
-@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*\r
--- /dev/null
+## @file\r
+#\r
+# Convert an AML file to a .hex file containing the AML bytecode stored in a\r
+# C array.\r
+# By default, "Tables\Dsdt.aml" will generate "Tables\Dsdt.hex".\r
+# "Tables\Dsdt.hex" will contain a C array named "dsdt_aml_code" that contains\r
+# the AML bytecode.\r
+#\r
+# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+\r
+import argparse\r
+import Common.EdkLogger as EdkLogger\r
+from Common.BuildToolError import *\r
+import sys\r
+import os\r
+\r
+## Parse the command line arguments.\r
+#\r
+# @retval A argparse.NameSpace instance, containing parsed values.\r
+#\r
+def ParseArgs():\r
+ # Initialize the parser.\r
+ Parser = argparse.ArgumentParser(\r
+ description="Convert an AML file to a .hex file containing the AML " + \\r
+ "bytecode stored in a C array. By default, " + \\r
+ "\"Tables\\Dsdt.aml\" will generate" + \\r
+ "\"Tables\\Dsdt.hex\". \"Tables\\Dsdt.hex\" will " + \\r
+ "contain a C array named \"dsdt_aml_code\" that " + \\r
+ "contains the AML bytecode."\r
+ )\r
+\r
+ # Define the possible arguments.\r
+ Parser.add_argument(\r
+ dest="InputFile",\r
+ help="Path to an input AML file to generate a .hex file from."\r
+ )\r
+ Parser.add_argument(\r
+ "-o", "--out-dir", dest="OutDir",\r
+ help="Output directory where the .hex file will be generated. " + \\r
+ "Default is the input file's directory."\r
+ )\r
+\r
+ # Parse the input arguments.\r
+ Args = Parser.parse_args()\r
+ SplitInputName = ""\r
+\r
+ if not os.path.exists(Args.InputFile):\r
+ EdkLogger.error(__file__, FILE_OPEN_FAILURE,\r
+ ExtraData=Args.InputFile)\r
+ return None\r
+ else:\r
+ with open(Args.InputFile, "rb") as fIn:\r
+ Signature = str(fIn.read(4))\r
+ if ("DSDT" not in Signature) and ("SSDT" not in Signature):\r
+ EdkLogger.info("Invalid file type. " + \\r
+ "File does not have a valid " + \\r
+ "DSDT or SSDT signature: %s" % Args.InputFile)\r
+ return None\r
+\r
+ # Get the basename of the input file.\r
+ SplitInputName = os.path.splitext(Args.InputFile)\r
+ BaseName = os.path.basename(SplitInputName[0])\r
+\r
+ # If no output directory is specified, output to the input directory.\r
+ if not Args.OutDir:\r
+ Args.OutputFile = os.path.join(\r
+ os.path.dirname(Args.InputFile),\r
+ BaseName + ".hex"\r
+ )\r
+ else:\r
+ if not os.path.exists(Args.OutDir):\r
+ os.mkdir(Args.OutDir)\r
+ Args.OutputFile = os.path.join(Args.OutDir, BaseName + ".hex")\r
+\r
+ Args.BaseName = BaseName\r
+\r
+ return Args\r
+\r
+## Convert an AML file to a .hex file containing the AML bytecode stored\r
+# in a C array.\r
+#\r
+# @param InputFile Path to the input AML file.\r
+# @param OutputFile Path to the output .hex file to generate.\r
+# @param BaseName Base name of the input file.\r
+# This is also the name of the generated .hex file.\r
+#\r
+def AmlToHex(InputFile, OutputFile, BaseName):\r
+\r
+ MacroName = "__{}_HEX__".format(BaseName.upper())\r
+ ArrayName = BaseName.lower() + "_aml_code"\r
+\r
+ with open(InputFile, "rb") as fIn, open(OutputFile, "w") as fOut:\r
+ # Write header.\r
+ fOut.write("// This file has been generated from:\n" + \\r
+ "// \tPython script: " + \\r
+ os.path.abspath(__file__) + "\n" + \\r
+ "// \tInput AML file: " + \\r
+ os.path.abspath(InputFile) + "\n\n" + \\r
+ "#ifndef {}\n".format(MacroName) + \\r
+ "#define {}\n\n".format(MacroName)\r
+ )\r
+\r
+ # Write the array and its content.\r
+ fOut.write("unsigned char {}[] = {{\n ".format(ArrayName))\r
+ cnt = 0\r
+ byte = fIn.read(1)\r
+ while len(byte) != 0:\r
+ fOut.write("0x{0:02X}, ".format(ord(byte)))\r
+ cnt += 1\r
+ if (cnt % 8) == 0:\r
+ fOut.write("\n ")\r
+ byte = fIn.read(1)\r
+ fOut.write("\n};\n")\r
+\r
+ # Write footer.\r
+ fOut.write("#endif // {}\n".format(MacroName))\r
+\r
+## Main method\r
+#\r
+# This method:\r
+# 1- Initialize an EdkLogger instance.\r
+# 2- Parses the input arguments.\r
+# 3- Converts an AML file to a .hex file containing the AML bytecode stored\r
+# in a C array.\r
+#\r
+# @retval 0 Success.\r
+# @retval 1 Error.\r
+#\r
+def Main():\r
+ # Initialize an EdkLogger instance.\r
+ EdkLogger.Initialize()\r
+\r
+ try:\r
+ # Parse the input arguments.\r
+ CommandArguments = ParseArgs()\r
+ if not CommandArguments:\r
+ return 1\r
+\r
+ # Convert an AML file to a .hex file containing the AML bytecode stored\r
+ # in a C array.\r
+ AmlToHex(CommandArguments.InputFile, CommandArguments.OutputFile,\r
+ CommandArguments.BaseName)\r
+ except Exception as e:\r
+ print(e)\r
+ return 1\r
+\r
+ return 0\r
+\r
+if __name__ == '__main__':\r
+ r = Main()\r
+ # 0-127 is a safe return range, and 1 is a standard default error\r
+ if r < 0 or r > 127: r = 1\r
+ sys.exit(r)\r
+++ /dev/null
-## @file\r
-#\r
-# Convert an AML file to a .hex file containing the AML bytecode stored in a\r
-# C array.\r
-# By default, "Tables\Dsdt.aml" will generate "Tables\Dsdt.hex".\r
-# "Tables\Dsdt.hex" will contain a C array named "dsdt_aml_code" that contains\r
-# the AML bytecode.\r
-#\r
-# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-\r
-import argparse\r
-import Common.EdkLogger as EdkLogger\r
-from Common.BuildToolError import *\r
-import sys\r
-import os\r
-\r
-## Parse the command line arguments.\r
-#\r
-# @retval A argparse.NameSpace instance, containing parsed values.\r
-#\r
-def ParseArgs():\r
- # Initialize the parser.\r
- Parser = argparse.ArgumentParser(\r
- description="Convert an AML file to a .hex file containing the AML " + \\r
- "bytecode stored in a C array. By default, " + \\r
- "\"Tables\\Dsdt.aml\" will generate" + \\r
- "\"Tables\\Dsdt.hex\". \"Tables\\Dsdt.hex\" will " + \\r
- "contain a C array named \"dsdt_aml_code\" that " + \\r
- "contains the AML bytecode."\r
- )\r
-\r
- # Define the possible arguments.\r
- Parser.add_argument(\r
- dest="InputFile",\r
- help="Path to an input AML file to generate a .hex file from."\r
- )\r
- Parser.add_argument(\r
- "-o", "--out-dir", dest="OutDir",\r
- help="Output directory where the .hex file will be generated. " + \\r
- "Default is the input file's directory."\r
- )\r
-\r
- # Parse the input arguments.\r
- Args = Parser.parse_args()\r
- SplitInputName = ""\r
-\r
- if not os.path.exists(Args.InputFile):\r
- EdkLogger.error(__file__, FILE_OPEN_FAILURE,\r
- ExtraData=Args.InputFile)\r
- return None\r
- else:\r
- with open(Args.InputFile, "rb") as fIn:\r
- Signature = str(fIn.read(4))\r
- if ("DSDT" not in Signature) and ("SSDT" not in Signature):\r
- EdkLogger.info("Invalid file type. " + \\r
- "File does not have a valid " + \\r
- "DSDT or SSDT signature: %s" % Args.InputFile)\r
- return None\r
-\r
- # Get the basename of the input file.\r
- SplitInputName = os.path.splitext(Args.InputFile)\r
- BaseName = os.path.basename(SplitInputName[0])\r
-\r
- # If no output directory is specified, output to the input directory.\r
- if not Args.OutDir:\r
- Args.OutputFile = os.path.join(\r
- os.path.dirname(Args.InputFile),\r
- BaseName + ".hex"\r
- )\r
- else:\r
- if not os.path.exists(Args.OutDir):\r
- os.mkdir(Args.OutDir)\r
- Args.OutputFile = os.path.join(Args.OutDir, BaseName + ".hex")\r
-\r
- Args.BaseName = BaseName\r
-\r
- return Args\r
-\r
-## Convert an AML file to a .hex file containing the AML bytecode stored\r
-# in a C array.\r
-#\r
-# @param InputFile Path to the input AML file.\r
-# @param OutputFile Path to the output .hex file to generate.\r
-# @param BaseName Base name of the input file.\r
-# This is also the name of the generated .hex file.\r
-#\r
-def AmlToHex(InputFile, OutputFile, BaseName):\r
-\r
- MacroName = "__{}_HEX__".format(BaseName.upper())\r
- ArrayName = BaseName.lower() + "_aml_code"\r
-\r
- with open(InputFile, "rb") as fIn, open(OutputFile, "w") as fOut:\r
- # Write header.\r
- fOut.write("// This file has been generated from:\n" + \\r
- "// \tPython script: " + \\r
- os.path.abspath(__file__) + "\n" + \\r
- "// \tInput AML file: " + \\r
- os.path.abspath(InputFile) + "\n\n" + \\r
- "#ifndef {}\n".format(MacroName) + \\r
- "#define {}\n\n".format(MacroName)\r
- )\r
-\r
- # Write the array and its content.\r
- fOut.write("unsigned char {}[] = {{\n ".format(ArrayName))\r
- cnt = 0\r
- byte = fIn.read(1)\r
- while len(byte) != 0:\r
- fOut.write("0x{0:02X}, ".format(ord(byte)))\r
- cnt += 1\r
- if (cnt % 8) == 0:\r
- fOut.write("\n ")\r
- byte = fIn.read(1)\r
- fOut.write("\n};\n")\r
-\r
- # Write footer.\r
- fOut.write("#endif // {}\n".format(MacroName))\r
-\r
-## Main method\r
-#\r
-# This method:\r
-# 1- Initialize an EdkLogger instance.\r
-# 2- Parses the input arguments.\r
-# 3- Converts an AML file to a .hex file containing the AML bytecode stored\r
-# in a C array.\r
-#\r
-# @retval 0 Success.\r
-# @retval 1 Error.\r
-#\r
-def Main():\r
- # Initialize an EdkLogger instance.\r
- EdkLogger.Initialize()\r
-\r
- try:\r
- # Parse the input arguments.\r
- CommandArguments = ParseArgs()\r
- if not CommandArguments:\r
- return 1\r
-\r
- # Convert an AML file to a .hex file containing the AML bytecode stored\r
- # in a C array.\r
- AmlToHex(CommandArguments.InputFile, CommandArguments.OutputFile,\r
- CommandArguments.BaseName)\r
- except Exception as e:\r
- print(e)\r
- return 1\r
-\r
- return 0\r
-\r
-if __name__ == '__main__':\r
- r = Main()\r
- # 0-127 is a safe return range, and 1 is a standard default error\r
- if r < 0 or r > 127: r = 1\r
- sys.exit(r)\r