summaryrefslogtreecommitdiff
path: root/Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py
diff options
context:
space:
mode:
Diffstat (limited to 'Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py')
-rw-r--r--Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py b/Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py
new file mode 100644
index 0000000000..312c1abb75
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Tools/AmlGenOffset/AmlGenOffset.py
@@ -0,0 +1,78 @@
+## @file
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+'''
+AmlGenOffset
+'''
+
+import os
+import sys
+import argparse
+import subprocess
+import uuid
+import struct
+import collections
+import binascii
+import re
+from ctypes import *
+
+#
+# Globals for help information
+#
+__prog__ = 'AmlGenOffset'
+__version__ = '%s Version %s' % (__prog__, '0.1 ')
+__copyright__ = 'Copyright (c) 2017, Intel Corporation. All rights reserved.'
+__usage__ = '%s -e|-d [options] <input_file>' % (__prog__)
+
+
+if __name__ == '__main__':
+ #
+ # Create command line argument parser object
+ #
+ parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve')
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument("-e", action="store_true", dest='Encode', help='encode file')
+ group.add_argument("-d", action="store_true", dest='Decode', help='decode file')
+ parser.add_argument("-o", "--output", dest='OutputFile', type=str, metavar='filename', help="specify the output filename", required=True)
+ parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages")
+ parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages")
+ parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level")
+ parser.add_argument("--aml_filter", dest='AmlFilterStr', type=str, help="specify the AML filter.")
+ parser.add_argument(metavar="input_file", dest='InputFile', type=argparse.FileType('rb'), help="specify the input filename")
+
+ #
+ # Parse command line arguments
+ #
+ args = parser.parse_args()
+
+ if args.Encode:
+ print 'Unsupported'
+
+ if args.Decode:
+ args.OutputFileName = args.OutputFile
+ args.OutputFile = open(args.OutputFileName, 'wb')
+
+ AmlFilter = args.AmlFilterStr
+ filter_pattern = '|'.join(AmlFilter.split(' '))
+
+ lines = args.InputFile.readlines()
+ args.InputFile.close()
+ for line in lines:
+ if line.strip().startswith('{\"') == False:
+ if line.strip().startswith('* Compilation') == False and line.strip().startswith('* ASL+') == False and line.strip().startswith('* Copyright') == False:
+ args.OutputFile.write(line)
+ else:
+ match_obj = re.search(filter_pattern, line, re.M | re.I)
+ if match_obj is not None:
+ args.OutputFile.write(line)
+ args.OutputFile.close()
+