Iasl: acpi source Language Optimizing Compiler and Disassembler

Download 357.69 Kb.
Date conversion29.04.2016
Size357.69 Kb.
1   2   3   4   5   6   7   8

4.2ASL-to-AML Disassembler

The AML disassembler is used to regenerate the original ASL code from a binary ACPI AML table. Tables that contain AML are typically the DSDT and any SSDTs.

The disassembler is invoked by using the –d option of iASL.

Because the AML contains all of the original symbols from the ASL, the AML byte code of a binary ACPI table can be disassembled back to nearly the original ASL code with only a few caveats.

4.2.1Multiple Table Disassembly

There is a known difficulty in disassembling control method invocations for methods that are external to the table being disassembled. This is because there is often insufficient information within the AML to properly disassemble these method invocations.

Therefore, whenever possible, all DSDTs and SSDTs for a given machine should be disassembled together using the –da or –e option. If all SSDTs are included this way, the necessary information will be available to fully and correctly disassemble the target table.

For example, to disassemble the DSDT on a machine with multiple SSDTs:
$ iasl -essdt1.dat,ssdt2.dat,ssdt3.dat -d dsdt.dat
Intel ACPI Component Architecture

AML Disassembler version 20100528 [May 28 2010]

Copyright (c) 2000 - 2010 Intel Corporation

Supports ACPI Specification Revision 5.0

Loading Acpi table from file DSDT.dat

Acpi table [DSDT] successfully installed and loaded

Loading Acpi table from file ssdt1.dat

Acpi table [SSDT] successfully installed and loaded

Pass 1 parse of [SSDT]

Pass 2 parse of [SSDT]

Loading Acpi table from file ssdt2.dat

Acpi table [SSDT] successfully installed and loaded

Pass 1 parse of [SSDT]

Pass 2 parse of [SSDT]

Loading Acpi table from file ssdt3.dat

Acpi table [SSDT] successfully installed and loaded

Pass 1 parse of [SSDT]

Pass 2 parse of [SSDT]

Pass 1 parse of [DSDT]

Pass 2 parse of [DSDT]

Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)


Parsing completed

Disassembly completed, written to "DSDT.dsl"

4.2.2External Declarations

During disassembly, any ACPI names that cannot be found or resolved within the table under disassembly are added to a list of externals that are emitted at the start of the table definition block, as shown below:
DefinitionBlock ("DSDT.aml", "DSDT", 1, "INTEL ", "EXAMPLE", 0x06040000)


External (Z003)

External (\_SB_.PCI0.LNKH)

If the object type that is associated with the name can be resolved during the disassembly, this type is emitted with the extenal statement also:

External (PETE, IntObj)

External (HDOS, MethodObj) // 0 Arguments

External (ECST, MethodObj) // 1 Arguments

External (PSEN, FieldUnitObj)

External (C7EN, FieldUnitObj)

External (\_PR_.CPU1, DeviceObj)

External (\_PR_.CPU0, DeviceObj)

5ACPI Data Table Subsystem

This subsystem consists of tools to compile ACPI Data Tables such as the FADT, MADT, SRAT, etc., to binary ACPI tables, and to disassemble binary ACPI data tables to formatted and structured tables in the data table language.

5.1Data Table Compiler

The iASL Data Table Compiler is intended to compile ACPI data tables (FADT, MADT, etc) to binary data, to be integrated into a BIOS project.

Data Tables are described in a simple language that is directly compatible with the output of the data table disassembler. The two goals for this language are simplicity and compatibility with the disassembler.

Data Table input files are automatically detected and differentiated from ASL files, therefore no special iASL option is required to invoke the data table compiler.

The default output is a binary ACPI data table. Use one of the iASL options –ta, –tc, or –ts, in order to create the binary output in an ASCII hex table that is suitable for direct inclusion into a BIOS project.

On some host operating systems, the iASL data table disassembler and compiler may be used to disassemble a data table, modify it, then recompile it to a binary file that can be used to override the original table. This override support depends upon features supported by the host operating system. This feature would be useful, for example, to repair invalid or incorrect values in an important table such as the FADT.

5.1.1Input Format

The format of the input file is a series of fields, each of which represents a field in the target ACPI table. Each field is comprised of a field name and a field value, separated by a colon. The fields must appear in the exact order in which they are defined for the target ACPI table.






Both slash-asterisk and slash-slash comments are supported. Blank lines are ignored.

The language itself is defined in the next section. The Field Names (AcpiTableFieldName) that are available for any given ACPI table can be obtained from the template file generated by the iASL Template Generator:

iASL –T // Obtain one template

iASL –T all // Obtain templates for all ACPI tables Fields/Comments

Comments can be either traditional /* .. */ style or // style.

Additional fields that are ignored (and are essentially comments) are fields surrounded by brackets – [..]. This allows automatic compatibility with the output of the AML disassembler.

5.1.2Data Table Definition Language


// Root Term


DataTable :=


// Field Terms


FieldList :=

Field |

Field :=
FieldDefinition :=
// Fields for predefined (known) ACPI tables

:’ FieldValue> |

// Generic data types (used for custom or undefined ACPI tables)

<‘UINT8’ ‘:’ IntegerExpression> | // 8-bit unsigned integer
<‘UINT16’ ‘:’ IntegerExpression> | // 16-bit unsigned integer
<‘UINT24’ ‘:’ IntegerExpression> | // 24-bit unsigned integer
<‘UINT32’ ‘:’ IntegerExpression> | // 32-bit unsigned integer
<‘UINT40’ ‘:’ IntegerExpression> | // 40-bit unsigned integer
<‘UINT48’ ‘:’ IntegerExpression> | // 48-bit unsigned integer
<‘UINT56’ ‘:’ IntegerExpression> | // 56-bit unsigned integer
<‘UINT64’ ‘:’ IntegerExpression> | // 64-bit unsigned integer
<‘String’ ‘:’ String> | // Quoted ASCII string
<‘Unicode’ ‘:’ String> | // Quoted ASCII string -> Unicode string
<‘Buffer’ ‘:’ ByteConstList> | // Raw buffer of 8-bit unsigned integers
<‘GUID’ ‘:’ Guid> | // In GUID format
<‘Label’ ‘:’ Label> // ASCII label – unquoted string
OptionalFieldName :=
Nothing |
AsciiCharList // Optional field name/description
FieldValue :=
IntegerExpression | String | Buffer | Flags | Label
OptionalFieldComment :=
Nothing |
<‘[’ AsciiCharList ‘]’>
CommentField :=
<‘//’ AsciiCharList NewLine> |
<‘/*’ AsciiCharList ‘*/’> |
<‘[’ AsciiCharList ‘]’>


// Data Expressions


IntegerExpression :=

Integer |
<‘(’ IntegerExpression ‘)’>

// Operators below are shown in precedence order. The meanings and precedence rules

// are the same as the C language. Parentheses have precedence over

// all operators.


IntegerOperator :=

!’ | ‘~’ | ‘*’ | ‘/’ | ‘%’ | ‘+’ | ‘-’ | ‘<<’ | ‘>>’ |
<’ | ‘>’ | ‘<=’ | ‘>=’ | ‘==’ | ‘!=’ | ‘&’ | ‘^’ | ‘|’ |
&&’ |‘||’ |

// Data Types


String :=

<‘’ AsciiCharList ‘’>

Buffer :=


Guid :=
-’ WordConst ‘-’ WordConst ‘-’ WordConst ‘-’ Const48>

Label :=

// Data Terms


Integer :=

ByteConst | WordConst | Const24 | DWordConst | Const40 | Const48 | Const56 | QWordConst | LabelReference
LabelReference :=
<‘$’ Label>
Flags :=
OneBit | TwoBits
ByteConstList :=
ByteConst |

AsciiCharList :=
Nothing |
PrintableAsciiChar |


// Terminals


ByteConst :=


WordConst :=

0x0000 - 0xFFFF

Const24 :=

0x000000 - 0xFFFFFF

DWordConst :=

0x00000000 - 0xFFFFFFFF

Const40 :=

0x0000000000 – 0xFFFFFFFFFF

Const48 :=

0x000000000000 – 0xFFFFFFFFFFFF

Const56 :=

0x00000000000000 - 0xFFFFFFFFFFFFFF

QWordConst :-

0x0000000000000000 - 0xFFFFFFFFFFFFFFFF
OneBit :=
0 - 1

TwoBits :=

0 - 3
PrintableAsciiChar :=
0x20 – 0x7E

NewLine :=


5.1.3Input Example

Input is similar to the output of the Data Table disassembler. The example below shows a portion of input describing a FADT.

* Intel ACPI Component Architecture

* iASL Compiler/Disassembler version 20100528


* Template for [FACP] ACPI Table

* Format: [ByteLength] FieldName : HexFieldValue

[004] Signature : "FACP" // Fixed ACPI Description Table

[004] Table Length : 000000F4

[001] Revision : 04

[001] Checksum : 4E

[006] Oem ID : "INTEL "

[008] Oem Table ID : "TEMPLATE"

[004] Oem Revision : 00000000

[004] Asl Compiler ID : "INTL"

[004] Asl Compiler Revision : 20100528

[004] FACS Address : 00000001

Each valid, non-comment line in the input file represents a field within the target ACPI table. The value in brackets (e.g., “[004]”) is the required length (in bytes) of the field described on the line. It is essentially a comment and is not required; this value is created by the iASL template generator for reference purposes only.

5.1.4Data Types for User-Entered Fields

The following data types are supported:

All integers in ACPI are unsigned. Four major types of unsigned integers are supported by the compiler: Bytes, Words, DWords and QWords. In addition, for special cases, there are some odd sized integers such as 24-bit and 56-bit. The actual required width of an integer is defined by the ACPI table. If an integer is specified that is numerically larger than the width of the target field within the input source, an error is issued by the compiler. Integers are expected by the data table compiler to be entered in hexadecimal with no “hex” prefix.


[001] Revision : 04 // Byte (8-bit)

[002] C2 Latency : 0000 // Word (16-bit)

[004] DSDT Address : 00000001 // DWord (32-bit)

[008] Address : 0000000000000001 // QWord (64-bit)

Length of non-power-of-two examples:
[003] Reserved : 000000 // 24 bits

[007] Capabilities : 00000000000000 // 56 bits Expressions

Expressions are supported in all fields that require an integer value.

Supported operators (Standard C meanings, in precedence order):

! Logical NOT

~ Bitwise ones compliment (NOT)

* Multiply

/ Divide

% Modulo

+ Add

- Subtract

<< Shift left

>> Shift right

< Less than

> Greater than

<= Less than or equal

>= Greater than or equal

== Equal

!= Not Equal

& Bitwise AND

^ bitwise Exclusive OR

| Bitwise OR

&& Logical AND

|| Logical OR
[001] Revision : 04 * 4 // Byte (8-bit)

[002] C2 Latency : 0032 + 8 // Word (16-bit)

[004] DSDT Address : 00000001 // DWord (32-bit)

[008] Address : 0000000000000001 // QWord (64-bit)

Many ACPI tables contain flag fields. For these fields, only the individual flag bits need to be specified to the compiler. The individual bits are aggregated into a single integer of the proper size by the compiler.


[002] Flags (decoded below) : 0005

Polarity : 1

Trigger Mode : 1

In this example, only the Polarity and Trigger Mode fields need to be specified to the compiler (as either zero or one). The compiler then creates the final 16-bit Flags field for the ACPI table.

Strings must always be surrounded by quotes. The actual string that is generated by the compiler may or may not be null-terminated, depending on the table definition in the ACPI specification. For example, the OEM ID and OEM Table ID in the common ACPI table header (shown above) are fixed at six and eight characters, respectively. They are not necessarily null terminated. Most other strings, however, are of variable-length and are automatically null terminated by the compiler. If a string is specified that is too long for a fixed-length string field, an error is issued. String lengths are specified in the definition for each relevant ACPI table.

Escape sequences within a quoted string are not allowed. The backslash character ‘\’ refers to the root of the ACPI namespace.

[008] Oem Table ID : "TEMPLATE" // Fixed length

[006] Processor UID String : "\CPU0" // Variable length

A buffer is typically used whenever the required binary data is larger than a QWord, or the data does not fit exactly into one of the standard integer widths. Examples include UUIDs and byte data defined by the SLIT table.


// SLIT entry
[032] Locality 0 : 0A 10 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 \

04 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33

// DMAR entry
[002] PCI Path : 1F 07
Each hexadecimal byte should be entered separately, separated by a space. Additional lines may be specified with the continuation character (‘\’).

5.1.5Fields Set Automatically

There are several types of ACPI table fields that are set automatically by the compiler. This simplifies the process of ACPI table development by relieving the programmer from these tasks.

Checksums: All ACPI table checksums are computed and inserted automatically. This includes the main checksum that appears in the standard ACPI table header, as well as any additional checksum fields such as the extended checksum that appears in the ACPI 2.0 RSDP.

Table Lengths: All ACPI table lengths are computed and inserted automatically. This includes the master table length that appears in the common ACPI table header, and the length of any internal subtables as applicable.


[004] Table Length : 000000F4
[001] Subtable Type : 08

[001] Length : 10

[001] Subtable Type : 01

[001] Length : 28

Flags: As described in the previous section, individual flags are aggregated automatically by the compiler and inserted into the ACPI table as the correctly sized and valued integer.

Compiler IDs: The data table compiler automatically inserts the ID and current revision for iASL into the common ACPI table header for each table during compilation.

5.1.6Special Fields

Reserved Fields: All fields that are declared as Reserved by the table definition within the ACPI (or other) specification should be set to zero.

Table Revision: This field in the common ACPI table header is often very important and defines the structure of the remaining table. The developer should take care to ensure that this value is correct and current. This field is not set automatically.

The iASL table template generator emits tables with a TableRevision that is the latest known value.

Table Signature: There are several table signatures within ACPI that are either different from the table name, or have unusual length:
FADT – signature is "FACP".

MADT – signature is "APIC".

RSDP – signature is "RSD PTR " (with trailing space)

5.1.7Generic Fields / Generic Data Types

The following “generic” data types/field names are provided to support tables like the UEFI, which mostly consist of platform-defined data.
UINT8 Generates an 8-bit unsigned integer

UINT16 Generates a 16-bit unsigned integer

UINT24 Generates a 24-bit unsigned integer

UINT32 Generates a 32-bit unsigned integer

UINT40 Generates a 40-bit unsigned integer

UINT48 Generates a 48-bit unsigned integer

UINT56 Generates a 56-bit unsigned integer

UINT64 Generates a 64-bit unsigned integer

String Generates a null-terminated ASCII string (ASCIIZ)

Unicode Generates a null terminated Unicode (UTF-16) string

Buffer Generates a buffer of 8-bit unsigned integers

GUID Generates an encoded GUID in a 16-byte buffer

Label Generates a Label at the current location (offset) within the table. This label can be referenced within integer expressions by prepending the label with a ‘$’ sign.
Label : StartRecord

UINT8 : 11

UINT16 : $EndRecord - $StartRecord // Record length

UINT24 : 112233

UINT32 : 11223344

UINT56 : 11223344556677

UINT64 : 1122334455667788
String : "This is a string"

DevicePath : "\PciRoot(0)\Pci(0x1f,1)\Usb(0,0)"

Unicode : "This string will be encoded to Unicode"
Buffer : AA 01 32 4C 77

GUID : 11223344-5566-7788-99aa-bbccddeeff00

Label : EndRecord

Example UEFI table with generic data types:


* Intel ACPI Component Architecture

* iASL Compiler/Disassembler version 20101209-32 [Jan 6 2011]

* Copyright (c) 2000 - 2011 Intel Corporation


* Template for [UEFI] ACPI Table

* Format: [ByteLength] FieldName : HexFieldValue

[004] Signature : "UEFI" /* UEFI Boot Optimization Table */

[004] Table Length : 00000036

[001] Revision : 01

[001] Checksum : 9B

[006] Oem ID : "INTEL "

[008] Oem Table ID : "TEMPLATE"

[004] Oem Revision : 00000001

[004] Asl Compiler ID : "INTL"

[004] Asl Compiler Revision : 20100528

[016] UUID Identifier : 03020100-0504-0706-0809-0A0B0C0D0E0F

[002] Data Offset : 0000

Label : StartRecord

UINT8 : ab

UINT16 : $EndRecord - $StartRecord // length

UINT24 : 123456

UINT32 : 01020304

UINT56 : 11223344556677

UINT64 : 0102030405060708
String : "This is a string"

DevicePath : "\PCI0\ABCD"

Unicode : "Unicode String"
Buffer : 41 42 43 44 45

String : ""

GUID : 03020100-0504-0706-0809-0A0B0C0D0E0F

Label : EndRecord

1   2   3   4   5   6   7   8

The database is protected by copyright ©essaydocs.org 2016
send message

    Main page