Iasl: acpi source Language Optimizing Compiler and Disassembler



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

6.4Compiler Output Examples

6.4.1Input ASL


Example input ASL that is used for the output examples below.
DefinitionBlock ("", "DSDT", 2, "Intel", "EXAMPLE", 1)

{

Name (BSTP, Package() {0,1,2,3})


Method (_BST)

{

Store (BSTP, Debug)



Return (BSTP)

}

}


6.4.2Output of –tc (make C hex table) Option


This is the output of the –tc option. The entire table is emitted in a single C array.
/*

*

* Intel ACPI Component Architecture



* ASL Optimizing Compiler version 20100331 [Mar 31 2010]

* Copyright (c) 2000 - 2010 Intel Corporation

* Supports ACPI Specification Revision 4.0

*

* Compilation of "dsdt.asl" - Tue Apr 27 14:20:41 2010



*

* C source code output

* AML code block contains 0x45 bytes

*

*/



unsigned char AmlCode[] =

{

0x44,0x53,0x44,0x54,0x45,0x00,0x00,0x00, /* 00000000 "DSDTE..." */



0x02,0xED,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */

0x45,0x58,0x41,0x4D,0x50,0x4C,0x45,0x00, /* 00000010 "EXAMPLE." */

0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */

0x31,0x03,0x10,0x20,0x08,0x42,0x53,0x54, /* 00000020 "1.. .BST" */

0x50,0x12,0x08,0x04,0x00,0x01,0x0A,0x02, /* 00000028 "P......." */

0x0A,0x03,0x14,0x12,0x5F,0x42,0x53,0x54, /* 00000030 "...._BST" */

0x00,0x70,0x42,0x53,0x54,0x50,0x5B,0x31, /* 00000038 ".pBSTP[1" */

0xA4,0x42,0x53,0x54,0x50 /* 00000040 ".BSTP" */

};

6.4.3Output of –sc (make C source) Option


This is the output of the –sc option. The table is emitted in multiple C arrays, approximatly one array per “block” of ASL code. For example, one array is emitted per control method.
/*

*

* Intel ACPI Component Architecture



* ASL Optimizing Compiler version 20090730 [Aug 14 2009]

* Copyright (C) 2000 - 2009 Intel Corporation

* Supports ACPI Specification Revision 4.0

*

* Compilation of "dsdt.asl" - Fri Aug 14 14:59:46 2009



*

*/

/*



* 1....

* 2....DefinitionBlock ("", "DSDT", 2, "Intel", "EXAMPLE", 1)

*/

unsigned char DSDT_EXAMPLE_Header [] =



{

0x44,0x53,0x44,0x54,0x45,0x00,0x00,0x00, /* 00000000 "DSDTE..." */

0x02,0xF1,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */

0x45,0x58,0x41,0x4D,0x50,0x4C,0x45,0x00, /* 00000010 "EXAMPLE." */

0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */

0x30,0x07,0x09,0x20, /* 0000001C "0.. " */

};
/*

* 3....{


* 4.... Name (BSTP, Package() {0,1,2,3})

*/

unsigned char DSDT_EXAMPLE_BSTP [] =



{

0x08,0x42,0x53,0x54,0x50, /* 00000021 ".BSTP" */

0x12,0x08,0x04,0x00,0x01,0x0A,0x02,0x0A, /* 00000029 "........" */

0x03, /* 0000002A "." */

};
/*

* 5....


* 6.... Method (_BST)

*/

unsigned char DSDT_EXAMPLE__BST [] =



{

0x14,0x12,0x5F,0x42,0x53,0x54,0x00, /* 00000031 ".._BST." */


/*

* 7.... {

* 8.... Store (BSTP, Debug)

*/

0x70,0x42,0x53,0x54,0x50,0x5B,0x31, /* 00000038 "pBSTP[1" */


/*

* 9.... Return (BSTP)

*/

0xA4,0x42,0x53,0x54,0x50, /* 0000003D ".BSTP" */



/*

* 10.... }

* 11....}

* 12....


*/

};

6.4.4Output of –ic (make include file) Option


This is the output of the –ic option. It creates external declarations for all of the arrays created by the –sc option above.
/*

*

* Intel ACPI Component Architecture



* ASL Optimizing Compiler version 20090730 [Aug 14 2009]

* Copyright (C) 2000 - 2009 Intel Corporation

* Supports ACPI Specification Revision 4.0

*

* Compilation of "dsdt.asl" - Fri Aug 14 15:05:34 2009



*

*/

extern unsigned char DSDT_EXAMPLE_Header [];



extern unsigned char DSDT_EXAMPLE_BSTP [];

extern unsigned char DSDT_EXAMPLE__BST [];



6.4.5Output of –l (Listing) Option


This is a standard listing file with intermixed ASL and AML code.

Intel ACPI Component Architecture

ASL Optimizing Compiler version 20090730 [Aug 14 2009]

Copyright (C) 2000 - 2009 Intel Corporation

Supports ACPI Specification Revision 4.0
Compilation of "dsdt.asl" - Fri Aug 14 15:08:30 2009
1....

2....DefinitionBlock ("", "DSDT", 2, "Intel", "EXAMPLE", 1)


00000000....44 53 44 54 45 00 00 00 "DSDTE..."

00000008....02 F1 49 6E 74 65 6C 00 "..Intel."

00000010....45 58 41 4D 50 4C 45 00 "EXAMPLE."

00000018....01 00 00 00 49 4E 54 4C "....INTL"

00000020....30 07 09 20 ............ "0.. "
3....{

4.... Name (BSTP, Package() {0,1,2,3})


[****iasl****]

dsdt.asl 4: Name (BSTP, Package() {0,1,2,3})

Optimize 6033 - ^ Integer optimized to single-byte AML opcode (Zero)
[****iasl****]

dsdt.asl 4: Name (BSTP, Package() {0,1,2,3})

Optimize 6033 - ^ Integer optimized to single-byte AML opcode (One)
00000024....08 42 53 54 50 ......... ".BSTP"

00000029....12 08 04 00 01 0A 02 0A "........"

00000031....03 ..................... "."
5....

6.... Method (_BST)


00000032....14 12 5F 42 53 54 00 ... ".._BST."
7.... {

8.... Store (BSTP, Debug)


00000039....70 42 53 54 50 5B 31 ... "pBSTP[1"
9.... Return (BSTP)
00000040....A4 42 53 54 50 ......... ".BSTP"

10.... }


11....}

12....
Summary of errors and warnings


ASL Optimizing Compiler version 20090730 [Aug 14 2009]

ASL Input: dsdt.asl - 13 lines, 178 bytes, 4 keywords

AML Output: dsdt.aml - 69 bytes, 2 named objects, 2 executable opcodes
Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 2 Optimizations


6.4.6Output of –lm (Hardware Mapfile) Option

Intel ACPI Component Architecture

ASL Optimizing Compiler version 20140828-32 [Sep 19 2014]

Copyright (c) 2000 - 2014 Intel Corporation


Compilation of "dsdt.dsl" - Fri Sep 19 09:43:52 2014

Resource Descriptor Connectivity Map

------------------------------------
GPIO Controller: INT33FC \_SB.GPO0 // Intel Baytrail GPIO Controller
Pin Type Direction Polarity Dest _HID Destination
0000 GpioInt -Interrupt- ActiveBoth INTCFD9 \_SB_.

0000 GpioInt -Interrupt- ActiveBoth INTCFD9 \_SB_.TBAD

0001 GpioInt -Interrupt- ActiveBoth INTCFD9 \_SB_.TBAD

0002 GpioIo OutputOnly -Field- \_SB_.GPO0.CCU2

0003 GpioIo OutputOnly -Field- \_SB_.GPO0.CCU3

0026 GpioIo InputOnly 80860F14 \_SB_.SDHC

0026 GpioInt -Interrupt- ActiveBoth 80860F14 \_SB_.SDHC

0028 GpioIo OutputOnly 80860F14 \_SB_.SDHC

0029 GpioIo OutputOnly 80860F14 \_SB_.SDHC

0036 GpioIo OutputOnly -No HID- \_SB_.PCI0.OTG1

0041 GpioIo OutputOnly 10EC5640 \_SB_.I2C2.RTEK

005F GpioIo OutputOnly -Field- \_SB_.GPO0.TCON

0060 GpioInt -Interrupt- ActiveBoth INTCFD9 \_SB_.TBAD

0064 GpioIo OutputOnly MCD0001 \MDM_


I2C Controller: 80860F41 \_SB.I2C2 // Intel Baytrail I2C Host Controller
Type Address Speed Dest _HID Destination

I2C 0010 00061A80 INT33BE \_SB_.I2C2.CAM1 // Camera Sensor OV5693

I2C 001C 00061A80 10EC5640 \_SB_.I2C2.RTEK // Realtek I2S Audio Codec

I2C 0048 00061A80 INT33F0 \_SB_.I2C2.CAMB // Camera Sensor MT9M114


SPI Controller: 80860F0E \_SB.SPI1 // Intel SPI Controller
Type Address Speed Dest _HID Destination

SPI 0001 007A1200 AUTH2750 \_SB_.SPI1.FPNT // AuthenTec AES2750


UART Controller: 80860F0A \_SB.URT1 // Intel Atom UART Controller
Type Address Speed Dest _HID Destination

UART 0000 0001C200 UTK0001 \_SB_.URT1.UART

UART 0000 0001C200 OBDA8723 \_SB_.URT1.BTH1

6.4.7Output of –ln (Namespace Listing) Option


This is a namespace listing file.
Intel ACPI Component Architecture

ASL Optimizing Compiler version 20090730 [Aug 14 2009]

Copyright (C) 2000 - 2009 Intel Corporation

Supports ACPI Specification Revision 4.0


Compilation of "dsdt.asl" - Fri Aug 14 15:08:30 2009
Contents of ACPI Namespace
Count Depth Name - Type
1 [1] _GPE - Scope

2 [1] _PR_ - Scope

3 [1] _SB_ - Device

4 [1] _SI_ - Scope

5 [1] _TZ_ - Thermal

6 [1] _REV - Integer

7 [1] _OS_ - String

8 [1] _GL_ - Mutex

9 [1] _OSI - Method

10 [1] BSTP - Package [Initial Length 0x04 elements]

11 [1] _BST - Method [Code Length 0x0011 bytes]
Namespace pathnames
\_GPE

\_PR_


\_SB_

\_SI_


\_TZ_

\_REV


\_OS_

\_GL_


\_OSI

\BSTP


\_BST

6.5Using the Disassembler

6.5.1Resolving External Control Methods


Once compiled, AML code does not contain specific information for the number of arguments that a control method requires. This limitation means that the disassembler often cannot determine the number of arguments to parse for externally-defined control methods. The end result of this can be incorrectly generated ASL code that will not compile.

The iASL disassembler provides two mechanisms to workaround this problem:



  1. The –e option allows additional AML tables (typically SSDTs) to be specified in order to resolve control methods.

  2. The –fe option allows an external declaration file to be imported into the disassembly. This file contains the definitions (with argument counts) for the external control methods.

In the example that follows, we show the disassembly of a DSDT that has an associated SSDT. The original ASL code is shown below:

DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001)

{

External (EXTS, MethodObj)



External (MTH1, MethodObj)
Method (MAIN, 0, NotSerialized)

{

MTH1 (1, 2, 3, 4)



EXTS (1, 2, 3)

Return (Zero)

}

}
DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "Template", 0x00000001)



{

Method (EXTS, 3, NotSerialized)

{

Return (Zero)



}

}
Note that the DSDT invokes two external control methods. MTH1 has 4 arguments and EXTS has 3 arguments. EXTS is defined in the SSDT, but we don’t know where MTH1 is defined.



6.5.1.1Standard Disassembly


In this example, we attempt a simple disassembly of the DSDT. Note that the disassembler cannot resolve the MTH1 and EXTS methods correctly and issues a warning.



  • iasl -d dsdt.aml

DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001)

{

/*

* iASL Warning: There were 2 external control methods found during



* disassembly, but additional ACPI tables to resolve these externals

* were not specified. This resulting disassembler output file may not

* compile because the disassembler did not know how many arguments

* to assign to these methods. To specify the tables needed to resolve

* external control method references, use the one of the following

* example iASL invocations:

* iasl -e -d

* iasl -e -d

*/

External (EXTS, MethodObj) // Warning: Unresolved Method, guessing 3 arguments (may be incorrect, see warning above)



External (MTH1, MethodObj) // Warning: Unresolved Method, guessing 7 arguments (may be incorrect, see warning above)

Method (MAIN, 0, NotSerialized)

{

MTH1 (One, 0x02, 0x03, 0x04, EXTS (One, 0x02, 0x03), Return (



Zero))

}

}



Both the invocation of MTH1 and EXTS have been disassembled incorrectly, because the disassembler does not know the proper number of arguments to parse for either one.

6.5.1.2Disassembly with –e option


In this example, we attempt to use the –e option to include the SSDT AML file into the disassembly. The disassembler finds the method EXTS and disassembles it correctly. However, the MTH1 method is still unresolved and is not disassembled correctly. An appropriate warning is issued.



  • iasl –e ssdt.aml-d dsdt.aml

DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001)

{

/*

* iASL Warning: There were 2 external control methods found during



* disassembly, but only 1 was resolved (1 unresolved). Additional

* ACPI tables are required to properly disassemble the code. This

* resulting disassembler output file may not compile because the

* disassembler did not know how many arguments to assign to the

* unresolved methods.

*/

External (MTH1, MethodObj) // Warning: Unresolved Method, guessing 5 arguments (may be incorrect, see warning above)


External (EXTS, MethodObj) // 3 Arguments
Method (MAIN, 0, NotSerialized)

{

MTH1 (One, 0x02, 0x03, 0x04, EXTS (One, 0x02, 0x03))



Return (Zero)

}

}



The number of arguments for method MTH1 is still incorrect as it was not found in the SSDT.

6.5.1.3Disassembly with both –e and –fe options


In this example, we will attempt to use the –fe option to fully resolve all external control methods. First, we create a file named “external.asl” that contains a single line as below:
External (MTH1, MethodObj, 4)

Note: To generate this file, simply copy the list of unresolved externals from the disassembler output, and add the number of arguments to the end of the External() statement for each method.

Now, we will invoke the disassembler using the –fe option and specifying “external.asl” as the external declaration import file:



  • iasl –e ssdt.aml –fe external.asl -d dsdt.aml

Note that now, all control methods have been resolved and the correct number of arguments for each are known. The DSDT is now disassembled correctly back to the original ASL code:

DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001)

{

/*



* External declarations that were imported from

* the reference file [externals.asl]

*/

External (MTH1, MethodObj) // 4 Arguments


External (EXTS, MethodObj) // 3 Arguments
Method (MAIN, 0, NotSerialized)

{

MTH1 (One, 0x02, 0x03, 0x04)



EXTS (One, 0x02, 0x03)

Return (Zero)

}

}

6.6Integration Into MS VC++ Environment


This section contains instructions for integrating the iASL compiler into MS VC++ 6.0 development environment.

6.6.1Integration as a Custom Tool


This procedure adds the iASL compiler as a custom tool that can be used to compile ASL source files. The output is sent to the VC output window.

a) Select Tools->Customize.

b) Select the "Tools" tab.

c) Scroll down to the bottom of the "Menu Contents" window. There you will see an empty rectangle. Click in the rectangle to enter a name for this tool.

d) Type "iASL Compiler" in the box and hit enter. You can now edit the other fields for this new custom tool.

e) Enter the following into the fields:

Command: C:\Acpi\iasl.exe

Arguments: -e "$(FilePath)"

Initial Directory: "$(FileDir)"

Use Output Window:


"Command" must be the path to wherever you copied the compiler.

"-e" instructs the compiler to produce messages appropriate for VC.

Quotes around FilePath and FileDir enable spaces in filenames.

f) Select "Close".

These steps will add the compiler to the tools menu as a custom tool. By enabling "Use Output Window", you can click on error messages in the output window and the source file and source line will be automatically displayed by VC. Also, you can use F4 to step through the messages and the corresponding source line(s).

6.6.2Integration into a Project Build


The compiler can be integrated into a project build by using it in the “custom build” step of the project generation. The commands and arguments should be similar to those described above.

7Generating iASL from Source Code


Generation of the ASL compiler from source code requires these items:

7.1Required Tools


The flex (or Lex) lexical analyzer generator

The Bison (Yacc replacement) (or Yacc itself) parser generator

An ANSI C compiler

7.2Required Source Code


There are three major source code components that are required to generate the compiler

The iASL compiler source

The ACPICA Subsystem source. In particular, the Namespace Manager component is used to create an internal ACPI namespace and symbol table.), and the AML Interpreter is used to evaluate constant expressions.

The Common source for all ACPI components


ACPICA and iASL source code is available at https://www.acpica.org/downloads/

iASL Windows binary is available at https://www.acpica.org/downloads/binary_tools.php


The source files appear in these directories by default:

Compiler Source: Acpica/Source/Compiler

Common Source: Acpica/Source//Common

Subsystem Source: Acpica/Source/Components/





1   2   3   4   5   6   7   8


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

    Main page