acpi: extract aml from .lst

Add ACPI_EXTRACT_ALL_CODE directive, to support extracting
AML code from listing into a named array. Use that instead including C
file generated by iasl, this makes it possible to include multiple AML
tables without resorting to preprocessor tricks.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Michael S. Tsirkin 2011-10-26 23:28:02 +02:00 committed by Kevin O'Connor
parent f2fd79b5bf
commit 2e55b03e63
7 changed files with 7180 additions and 941 deletions

View File

@ -198,7 +198,7 @@ src/%.hex: src/%.dsl ./tools/acpi_extract_preprocess.py ./tools/acpi_extract.py
$(Q)./tools/acpi_extract_preprocess.py $(OUT)$*.dsl.i.orig > $(OUT)$*.dsl.i
$(Q)iasl -l -tc -p $(OUT)$* $(OUT)$*.dsl.i
$(Q)./tools/acpi_extract.py $(OUT)$*.lst > $(OUT)$*.off
$(Q)cat $(OUT)$*.hex $(OUT)$*.off > $@
$(Q)cat $(OUT)$*.off > $@
$(OUT)ccode32flat.o: src/acpi-dsdt.hex src/ssdt-proc.hex

View File

@ -16,6 +16,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
ACPI_EXTRACT_ALL_CODE AmlCode
DefinitionBlock (
"acpi-dsdt.aml", // Output Filename
"DSDT", // Signature

File diff suppressed because it is too large Load Diff

View File

@ -378,9 +378,7 @@ encodeLen(u8 *ssdt_ptr, int length, int bytes)
return ssdt_ptr + bytes;
}
#define AmlCode static ssdp_proc_aml
#include "ssdt-proc.hex"
#undef AmlCode
/* 0x5B 0x83 ProcessorOp PkgLength NameString ProcID */
#define SD_OFFSET_CPUHEX (*ssdt_proc_name - *ssdt_proc_start + 2)

View File

@ -14,6 +14,9 @@
* and a CPON array with the list of active and inactive cpus:
* Name(CPON, Package() { One, One, ..., Zero, Zero, ... })
*/
ACPI_EXTRACT_ALL_CODE ssdp_proc_aml
DefinitionBlock ("ssdt-proc.aml", "SSDT", 0x01, "BXPC", "BXSSDT", 0x1)
{
ACPI_EXTRACT_PROCESSOR_START ssdt_proc_start

View File

@ -1,40 +1,131 @@
/*
*
* Intel ACPI Component Architecture
* ASL Optimizing Compiler version 20100528 [Feb 9 2011]
* Copyright (c) 2000 - 2010 Intel Corporation
* Supports ACPI Specification Revision 4.0a
*
* Compilation of "out/ssdt-proc.dsl.i" - Wed Oct 12 21:14:18 2011
*
* C source code output
* AML code block contains 0x78 bytes
*
*/
unsigned char AmlCode[] =
{
0x53,0x53,0x44,0x54,0x78,0x00,0x00,0x00, /* 00000000 "SSDTx..." */
0x01,0xB3,0x42,0x58,0x50,0x43,0x00,0x00, /* 00000008 "..BXPC.." */
0x42,0x58,0x53,0x53,0x44,0x54,0x00,0x00, /* 00000010 "BXSSDT.." */
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
0x28,0x05,0x10,0x20,0x5B,0x83,0x42,0x05, /* 00000020 "(.. [.B." */
0x43,0x50,0x41,0x41,0xAA,0x10,0xB0,0x00, /* 00000028 "CPAA...." */
0x00,0x06,0x08,0x49,0x44,0x5F,0x5F,0x0A, /* 00000030 "...ID__." */
0xAA,0x08,0x5F,0x48,0x49,0x44,0x0D,0x41, /* 00000038 ".._HID.A" */
0x43,0x50,0x49,0x30,0x30,0x30,0x37,0x00, /* 00000040 "CPI0007." */
0x14,0x0F,0x5F,0x4D,0x41,0x54,0x00,0xA4, /* 00000048 ".._MAT.." */
0x43,0x50,0x4D,0x41,0x49,0x44,0x5F,0x5F, /* 00000050 "CPMAID__" */
0x14,0x0F,0x5F,0x53,0x54,0x41,0x00,0xA4, /* 00000058 ".._STA.." */
0x43,0x50,0x53,0x54,0x49,0x44,0x5F,0x5F, /* 00000060 "CPSTID__" */
0x14,0x0F,0x5F,0x45,0x4A,0x30,0x01,0x43, /* 00000068 ".._EJ0.C" */
0x50,0x45,0x4A,0x49,0x44,0x5F,0x5F,0x68 /* 00000070 "PEJID__h" */
static unsigned char ssdt_proc_name[] = {
0x28
};
static unsigned char ssdp_proc_aml[] = {
0x53,
0x53,
0x44,
0x54,
0x78,
0x0,
0x0,
0x0,
0x1,
0xb3,
0x42,
0x58,
0x50,
0x43,
0x0,
0x0,
0x42,
0x58,
0x53,
0x53,
0x44,
0x54,
0x0,
0x0,
0x1,
0x0,
0x0,
0x0,
0x49,
0x4e,
0x54,
0x4c,
0x28,
0x5,
0x10,
0x20,
0x5b,
0x83,
0x42,
0x5,
0x43,
0x50,
0x41,
0x41,
0xaa,
0x10,
0xb0,
0x0,
0x0,
0x6,
0x8,
0x49,
0x44,
0x5f,
0x5f,
0xa,
0xaa,
0x8,
0x5f,
0x48,
0x49,
0x44,
0xd,
0x41,
0x43,
0x50,
0x49,
0x30,
0x30,
0x30,
0x37,
0x0,
0x14,
0xf,
0x5f,
0x4d,
0x41,
0x54,
0x0,
0xa4,
0x43,
0x50,
0x4d,
0x41,
0x49,
0x44,
0x5f,
0x5f,
0x14,
0xf,
0x5f,
0x53,
0x54,
0x41,
0x0,
0xa4,
0x43,
0x50,
0x53,
0x54,
0x49,
0x44,
0x5f,
0x5f,
0x14,
0xf,
0x5f,
0x45,
0x4a,
0x30,
0x1,
0x43,
0x50,
0x45,
0x4a,
0x49,
0x44,
0x5f,
0x5f,
0x68
};
static unsigned char ssdt_proc_id[] = {
0x38
};
static unsigned char ssdt_proc_name[] = {
0x28
};
static unsigned char ssdt_proc_end[] = {
0x78
};

View File

@ -29,6 +29,8 @@
# ACPI_EXTRACT_PROCESSOR_START - start of Processor() block
# ACPI_EXTRACT_PROCESSOR_STRING - extract a NameString from Processor()
# ACPI_EXTRACT_PROCESSOR_END - offset at last byte of Processor() + 1
#
# ACPI_EXTRACT_ALL_CODE - create an array storing the generated AML bytecode
#
# ACPI_EXTRACT is not allowed anywhere else in code, except in comments.
@ -240,6 +242,11 @@ for i in range(len(asl)):
array = mext.group(2)
offset = asl[i].aml_offset
if (directive == "ACPI_EXTRACT_ALL_CODE"):
if array in output:
die("%s directive used more than once" % directive)
output[array] = aml
continue
if (directive == "ACPI_EXTRACT_NAME_DWORD_CONST"):
offset = aml_name_dword_const(offset)
elif (directive == "ACPI_EXTRACT_NAME_WORD_CONST"):
@ -261,21 +268,25 @@ for i in range(len(asl)):
if array not in output:
output[array] = []
output[array].append("0x%x" % offset)
output[array].append(offset)
debug = "at end of file"
#Use type large enough to fit the table
if (len(aml) >= 0x10000):
offsettype = "int"
elif (len(aml) >= 0x100):
offsettype = "short"
else:
offsettype = "char"
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():
sys.stdout.write("static unsigned %s %s[] = {\n" % (offsettype, array))
sys.stdout.write(",\n".join(output[array]))
otype = get_value_type(max(output[array]))
odata = []
for value in output[array]:
odata.append("0x%x" % value)
sys.stdout.write("static unsigned %s %s[] = {\n" % (otype, array))
sys.stdout.write(",\n".join(odata))
sys.stdout.write('\n};\n');