acpi_extract: Move main code to new function main()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2015-11-17 18:24:24 -05:00
parent fc0ac95e6e
commit 1e7d2edab4
1 changed files with 115 additions and 110 deletions

View File

@ -233,8 +233,19 @@ def aml_package_start(offset):
offset += 1
return offset + aml_pkglen_bytes(offset) + 1
lineno = 0
for line in fileinput.input():
def get_value_type(maxvalue):
#Use type large enough to fit the table
if (maxvalue >= 0x10000):
return "int"
elif (maxvalue >= 0x100):
return "short"
else:
return "char"
def main():
global debug
lineno = 0
for line in fileinput.input():
# Strip trailing newline
line = line.rstrip()
# line number and debug string to output in case of errors
@ -251,10 +262,10 @@ for line in fileinput.input():
if (m):
add_aml(m.group(1), paml.sub("", line))
# Now go over code
# Track AML offset of a previous non-empty ASL command
prev_aml_offset = -1
for i in range(len(asl)):
# Now go over code
# Track AML offset of a previous non-empty ASL command
prev_aml_offset = -1
for i in range(len(asl)):
debug = "input line %d: %s" % (asl[i].lineno, asl[i].line)
l = asl[i].line
@ -332,19 +343,10 @@ for i in range(len(asl)):
output[array] = []
output[array].append(offset)
debug = "at end of file"
debug = "at end of file"
def get_value_type(maxvalue):
#Use type large enough to fit the table
if (maxvalue >= 0x10000):
return "int"
elif (maxvalue >= 0x100):
return "short"
else:
return "char"
# Pretty print output
for array in output.keys():
# Pretty print output
for array in output.keys():
otype = get_value_type(max(output[array]))
odata = []
for value in output[array]:
@ -352,3 +354,6 @@ for array in output.keys():
sys.stdout.write("static unsigned %s %s[] = {\n" % (otype, array))
sys.stdout.write(",\n".join(odata))
sys.stdout.write('\n};\n')
if __name__ == '__main__':
main()