xref: /illumos-gate/usr/src/cmd/acpi/iasl/new_table.txt (revision bc36eafd)
1*bc36eafdSMike GerdtsHow to add a new ACPI table to ACPICA and the iASL compiler.
2*bc36eafdSMike Gerdts------------------------------------------------------------
3*bc36eafdSMike Gerdts
4*bc36eafdSMike GerdtsThere are four main tasks that are needed to provide support for a
5*bc36eafdSMike Gerdtsnew ACPI table:
6*bc36eafdSMike Gerdts    1) Create a full definition of the table and any subtables
7*bc36eafdSMike Gerdts       in the ACPICA headers.
8*bc36eafdSMike Gerdts    2) Add disassembler support for the new table
9*bc36eafdSMike Gerdts    3) Add iASL table compiler support for the new table
10*bc36eafdSMike Gerdts    4) Create a default template for the new table for iASL -T
11*bc36eafdSMike Gerdts       option.
12*bc36eafdSMike Gerdts
13*bc36eafdSMike GerdtsNotes for each of these tasks provided below.
14*bc36eafdSMike Gerdts
15*bc36eafdSMike Gerdts
16*bc36eafdSMike Gerdts1) Header Support
17*bc36eafdSMike Gerdts-----------------
18*bc36eafdSMike Gerdts
19*bc36eafdSMike GerdtsNew tables should be added to the appropriate header:
20*bc36eafdSMike Gerdts    actbl2.h: Used for new tables that are not defined in the ACPI spec.
21*bc36eafdSMike Gerdts    actbl3.h: Used for new tables that are defined in the ACPI spec.
22*bc36eafdSMike Gerdts
23*bc36eafdSMike GerdtsUse ACPI_TABLE_HEADER for the common ACPI table header.
24*bc36eafdSMike GerdtsSubtables should be defined separately from the main table.
25*bc36eafdSMike GerdtsDon't add placeholder fields for subtables and other multiple data items.
26*bc36eafdSMike Gerdts    (Don't use xxxxx[1] for a field that can have multiple items.)
27*bc36eafdSMike Gerdts    The disassembler and data table compiler depends on this.
28*bc36eafdSMike GerdtsFor tables not defined in the ACPI spec, add a comment to indicate where
29*bc36eafdSMike Gerdts    the table came from.
30*bc36eafdSMike GerdtsUse other table definitions for additional guidance.
31*bc36eafdSMike Gerdts
32*bc36eafdSMike Gerdts
33*bc36eafdSMike Gerdts2) iASL Disassembler Support
34*bc36eafdSMike Gerdts----------------------------
35*bc36eafdSMike Gerdts
36*bc36eafdSMike GerdtsAdd definition of the table (and subtables) in common/dmtbinfo.c
37*bc36eafdSMike GerdtsAdd table access macro(s) of the form ACPI_xxxx_OFFSET
38*bc36eafdSMike GerdtsAdd ACPI_DMT_TERMINATOR at the end of every table/subtable definition
39*bc36eafdSMike Gerdts
40*bc36eafdSMike GerdtsAdd externals for the table/subtable definitions in acdisasm.h
41*bc36eafdSMike GerdtsAdd an entry for the new table in the AcpiDmTableData in common/dmtable.c
42*bc36eafdSMike Gerdts
43*bc36eafdSMike GerdtsIf there are no subtables, add the AcpiDmTableInfoXXXX name to the
44*bc36eafdSMike Gerdts    AcpiDmTableData and it will automatically be disassembled.
45*bc36eafdSMike Gerdts
46*bc36eafdSMike GerdtsIf there are subtables, a dump routine must be written:
47*bc36eafdSMike GerdtsAdd an AcpiDmDumpXXXX function to dmtbdump.c -- note, code for another
48*bc36eafdSMike Gerdts    similar table can often be ported for the new table.
49*bc36eafdSMike GerdtsAdd an external for this function to acdisasm.h
50*bc36eafdSMike GerdtsAdd this function to the AcpiDmTableData entry for the new ACPI table
51*bc36eafdSMike Gerdts
52*bc36eafdSMike GerdtsDebug/Test: Either find an existing example of the new ACPI table, or
53*bc36eafdSMike Gerdts    create one using the "generic ACPI table support" included in the
54*bc36eafdSMike Gerdts    iASL data table compiler. Use the -G option to force a
55*bc36eafdSMike Gerdts    generic compile. It is often best to create the table from scratch,
56*bc36eafdSMike Gerdts    since this clearly exposes the dependencies (lengths, offsets, etc.)
57*bc36eafdSMike Gerdts    that the Table Compiler support will need to generate.
58*bc36eafdSMike Gerdts
59*bc36eafdSMike Gerdts
60*bc36eafdSMike Gerdts3) iASL Table Compiler Support
61*bc36eafdSMike Gerdts------------------------------
62*bc36eafdSMike Gerdts
63*bc36eafdSMike GerdtsSimple tables do not require a compile routine. The definition of the
64*bc36eafdSMike Gerdts    table in common/dmtbinfo.c (created in step 2 above) will suffice.
65*bc36eafdSMike Gerdts
66*bc36eafdSMike GerdtsComplex tables with subtables will require a compile routine with a name
67*bc36eafdSMike Gerdts    of the form DtCompileXXXX.
68*bc36eafdSMike GerdtsAdd a DtCompileXXXX function to the dttable.c module.
69*bc36eafdSMike GerdtsAdd an external for this function in dtcompiler.h
70*bc36eafdSMike GerdtsAdd this function to the AcpiDmTableData entry for the new ACPI table
71*bc36eafdSMike Gerdts    in common/dmtable.c
72*bc36eafdSMike Gerdts
73*bc36eafdSMike Gerdts
74*bc36eafdSMike Gerdts4) Template Support (-T iASL option)
75*bc36eafdSMike Gerdts------------------------------------
76*bc36eafdSMike Gerdts
77*bc36eafdSMike GerdtsCreate an example of the new ACPI table. This example should create
78*bc36eafdSMike Gerdts    multiple subtables (if supported), and multiple instances of any
79*bc36eafdSMike Gerdts    variable length data.
80*bc36eafdSMike Gerdts
81*bc36eafdSMike GerdtsCompile the example file with the -sc option. This will create a C
82*bc36eafdSMike Gerdts    array that contains the table contents.
83*bc36eafdSMike Gerdts
84*bc36eafdSMike GerdtsAdd this array to the dttemplate.h file. Name the array TemplateXXXX.
85*bc36eafdSMike GerdtsAdd this array name to the AcpiDmTableData entry for the new ACPI table
86*bc36eafdSMike Gerdts
87*bc36eafdSMike GerdtsDebug/Test: Create the template file. Compile the file. Disassemble the file.
88*bc36eafdSMike Gerdts    Compile the disassembly file.
89