Donnerstag, 16. Juli 2009

20.) ACPI DSDT Table (Differentiated System Description Table)

I started diving into all this wired ACPI / DSDT stuff. The ACPI-Spec has more than 700 pages! Part of the ACPI is the DSDT. DSDT is an acronym for Differentiated System Description Table. This table contains the Differentiated Definition Block, which supplies the information and configuration information about the base system. Here are some useful link to start reading:
  1. ACPI - Advanced Configuration and Power Interface
  2. Linux/ACPI - DSDT: Overview
  3. HOWTO: Fix Common ACPI Problems (DSDT, ECDT, etc.)
  4. ACPI Downloads (eg. iASL Compiler/Disassembler, Source)
  5. DSDT Patcher - InsanelyMac Forum (contains Mac OS X iASL binary)
Each mainboard, even different BIOS version, has it's own DSDT. All Information I'm giving you here in this Blog is specific to the Gigabyte GA-EP45-DS3 mainboard with BIOS version F9. Your DSDT might look very similar and the patches/fixes/solutions should be done in a similar way, but I cannot guarantee this.

I managed to get, disassemble, compile the DSDT. I had to fix some errors in the DSDT, which is very common if you use the Intel iASL Compiler. Seems that the Microsoft Compiler is not so piggy and almost all mainboard makers using the Microsoft Compiler for their ACPI stuff. After this very first steps I started to modify the DSDT. I modified the RTC and the HPET section to make AppleRTC.kext and AppleIntelCPUPowerManagement.kext work. After that I could delete Disabler.kext from the Extra/Extensions folder of the Chameleon USB-stick. Great, isn't it!

To start working with DSDT you need the DSDT of your mainboard and an ASL Compiler/Disassembler like the iASL. You can download the tools from the InsanelyMac forum or here. These are tools for Mac OS X. Windows and Linux versions are also available in the net.

How to obtain the DSDT. Under Mac OS X run the script getDSDT.sh in the Terminal:
admin@MacBook [~/Downloads/Tools] > ls -la
total 1160
drwxr-xr-x@ 4 admin staff 136 Jul 16 18:20 .
drwx------+ 38 admin staff 1292 Jul 16 18:20 ..
-rwxr-xr-x@ 1 admin staff 252 Nov 2 2008 getDSDT.sh
-rwxr-xr-x@ 1 admin staff 587968 Oct 25 2008 iasl
admin@MacBook [~/Downloads/Tools] > ./getDSDT.sh
admin@MacBook [~/Downloads/Tools] > ls -la
total 1208
drwxr-xr-x@ 5 admin staff 170 Jul 16 18:20 .
drwx------+ 38 admin staff 1292 Jul 16 18:20 ..
-rw-r--r-- 1 admin staff 23454 Jul 16 18:20 dsdt.dat
-rwxr-xr-x@ 1 admin staff 252 Nov 2 2008 getDSDT.sh
-rwxr-xr-x@ 1 admin staff 587968 Oct 25 2008 iasl
It gives you the file dsdt.dat, which is the compiled DSDT. Under Linux it's even much easier. Issue "cat /proc/acpi/dsdt > dsdt.aml" and you have the compiled DSDT. Don't get the DSDT under an EFI-X™ controlled Mac, because it might be already modified/patched in some way. Use a Linux Live-CD (Ubuntu) or Chameleon without a DSDT in the Extra folder. Now disassemble the compiled DSDT:
admin@MacBook [~/Downloads/Tools] > ./iasl -d dsdt.dat

Intel ACPI Component Architecture
AML Disassembler version 20080926 [Oct 4 2008]
Copyright (C) 2000 - 2008 Intel Corporation
Supports ACPI Specification Revision 3.0a

Loading Acpi table from file dsdt.dat
Acpi table [DSDT] successfully installed and loaded
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"
Now you can open the file "dsdt.dsl" with your favorite editor, but take care to save it as plain text. But first I will check whether I can compile the original DSDT without errors and warnings:
admin@MacBook [~/Downloads/Tools] > ./iasl -ta dsdt.dsl

Intel ACPI Component Architecture
ASL Optimizing Compiler version 20080926 [Oct 4 2008]
Copyright (C) 2000 - 2008 Intel Corporation
Supports ACPI Specification Revision 3.0a

dsdt.dsl 222: Method (\_WAK, 1, NotSerialized)
Warning 1080 - ^ Reserved method must return a value (_WAK)

dsdt.dsl 285: Store (Local0, Local0)
Error 4050 - ^ Method local variable is not initialized (Local0)

dsdt.dsl 290: Store (Local0, Local0)
Error 4050 - ^ Method local variable is not initialized (Local0)

ASL Input: dsdt.dsl - 5683 lines, 189412 bytes, 2339 keywords
Compilation complete. 2 Errors, 1 Warnings, 0 Remarks, 661 Optimizations
As you can see I got 2 errors and 1 warning. The original Gigabyte DSDT is buggy. The error 4050 can be fixed very easy. Actually Store(Local0, Local0) means nothing but a NOP. It stores the content of the local variable Local0 into Local0. The problem is, that Local0 is not initialized. Change it to for instance Store ("Local0", Local0) or Store(Zero, Local0). The warning 1080 comes out because the _WAK method must return a value. ACPI-spec 7.3.7 defines a return of a package with 2 integers. So inserting Return (Package (0x02) {Zero, Zero}) will fix the warning. Returning Zero is not critical, even Apple returns Zero in their DSDTs. All fixes are colored green
Method (_WAK, 1, NotSerialized)
{
...

If (OSFL)
{
Notify (\_SB.PWRB, 0x02)
}
Else
{
If (LEqual (RTCW, Zero))
{
Notify (\_SB.PWRB, 0x02)
}
}

Notify (\_SB.PCI0.USB0, Zero)
Notify (\_SB.PCI0.USB1, Zero)
Notify (\_SB.PCI0.USB2, Zero)
Notify (\_SB.PCI0.USB3, Zero)
Notify (\_SB.PCI0.USB4, Zero)
Notify (\_SB.PCI0.USB5, Zero)
Return (Package (0x02)
{
Zero,
Zero
})

}

Scope (_SI)
{
Method (_MSG, 1, NotSerialized)
{
Store (Zero, Local0)
}

Method (_SST, 1, NotSerialized)
{
Store (Zero, Local0)
}
}

Now lets compile the fixed DSDT:
admin@MacBook [~/Downloads/Tools] > ./iasl -ta dsdt.dsl

Intel ACPI Component Architecture
ASL Optimizing Compiler version 20080926 [Oct 4 2008]
Copyright (C) 2000 - 2008 Intel Corporation
Supports ACPI Specification Revision 3.0a

ASL Input: dsdt.dsl - 5686 lines, 188406 bytes, 2340 keywords
AML Output: dsdt.aml - 18151 bytes, 661 named objects, 1679 executable opcodes

Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 31 Optimizations

No warnings, no errors. Fine! You can download the fixed DSDT for my Gigabyte GA-EP45-DS3 mainboard here. To get AppleIntelCPUPowerManagement.kext and AppleRTC working, the devices HPET, RTC and TMR must be modified. The device order in my DSDT is TMR, HPET and RTC.

For the TMR device patch the method _CRS to return ATT6 (ResourceTemplate without IRQNoFlags:
Device (TMR)
{
Name (_HID, EisaId ("PNP0100"))
Name (ATT5, ResourceTemplate ()
{
IO (Decode16,
0x0040, // Range Minimum
0x0040, // Range Maximum
0x00, // Alignment
0x04, // Length
)
IRQNoFlags ()
{0}
})
Name (ATT6, ResourceTemplate ()
{
IO (Decode16,
0x0040, // Range Minimum
0x0040, // Range Maximum
0x00, // Alignment
0x04, // Length
)
})
Method (_CRS, 0, NotSerialized)
{
Return (ATT6)
}
}
For the HPET device patch method _CRS to return ATT3 (ResourceTemplate with IRQNoFlags) and method _STA to return 0x0f:
Device (HPET)
{
Name (_HID, EisaId ("PNP0103"))
Name (ATT3, ResourceTemplate ()
{
IRQNoFlags ()
{0}
IRQNoFlags ()
{8}
Memory32Fixed (ReadWrite,
0xFED00000, // Address Base
0x00000400, // Address Length
)
})
Name (ATT4, ResourceTemplate ()
{
})
Method (_STA, 0, NotSerialized)
{
Return (0x0F)
}

Method (_CRS, 0, NotSerialized)
{
Return (ATT3)
}
}
For the RTC device patch method _CRS to return ATT1 (ResourceTemplate without IRQNoFlags):
Device (RTC)
{
Name (_HID, EisaId ("PNP0B00"))
Name (ATT0, ResourceTemplate ()
{
IO (Decode16,
0x0070, // Range Minimum
0x0070, // Range Maximum
0x00, // Alignment
0x04, // Length
)
IRQNoFlags ()
{8}
})
Name (ATT1, ResourceTemplate ()
{
IO (Decode16,
0x0070, // Range Minimum
0x0070, // Range Maximum
0x00, // Alignment
0x04, // Length
)
})
Method (_CRS, 0, NotSerialized)
{
Return (ATT1)
}
}
Save and then compile it:
admin@MacBook [~/Downloads/Tools] > ./iasl -ta dsdt.dsl

Intel ACPI Component Architecture
ASL Optimizing Compiler version 20080926 [Oct 4 2008]
Copyright (C) 2000 - 2008 Intel Corporation
Supports ACPI Specification Revision 3.0a

ASL Input: dsdt.dsl - 5631 lines, 186571 bytes, 2312 keywords
AML Output: dsdt.aml - 18040 bytes, 661 named objects, 1651 executable opcodes

Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 31 Optimizations
Put the resulting compiled DSDT "dsdt.aml" in the Extra folder of the Chameleon USB-stick. You are now safe to remove Disabler.kext from the Extra/Extensions folder. Don't forget to rebuild Extensions.mkext. Download the final DSDT here.

9 Kommentare:

  1. Thanks for another great post! This is the first post I've seen that's more of a tutorial in learning about the DSDT, instead of of a vague set of steps.

    I'm up and running on my EP45T-DS3R with an nVidia 9800GTX+ and have removed Disabler.kext. However now I don't have Hardware Accel/Quartz Extreme... Any tips where to look?

    Thanks - James

    AntwortenLöschen
  2. I have to thank you for this post as well. I have a 965P-DS3 and was also receiving the same errors you were (in almost the same line numbers). Due to your help i was able to resolve the 2 "4050" errors, but cant quite figure out exactly where to insert "Return (Package (0x02) {Zero, Zero})" to resolve the 1080 warning. Could you expand on that a little? Maybe show a bit of the code preceding & following so that i can be sure i have it in the right place with correct syntax...

    oh and thanks again,
    -dave

    AntwortenLöschen
  3. Thank you again, i now have a dsdt.aml file with zero errors & zero warnings....can't wait to try it out!

    AntwortenLöschen
  4. Like I said before, it is a great and hard work !
    The best part is the learning what is going on instead of vague and confuse instructions.
    I have barely scratched the surface though... I am trying to get my Lenovo T60 with SL (works great with Leo)... but I am finding that many (if not all) the patches here are not found in my T60 DSDT.
    Well, at least one of them (RTC) seems already ok.
    Good job !

    AntwortenLöschen
  5. Hello Aserebln, this post is like water in the middle of the desert for me as i didn't find simple as this is to perfectly fix dsdt for my motherboard. Actually my motherboard is Intel 945GCNl, I used ubuntu 9.04 live cd to get my original dsdt, & compiled it(original dsdt) to check for errors. It didn't give any errors but one warning, the warning is like this

    dsdt.dsl 1922: Acquire (MUT0, 0x0FFF)
    warning 1104 - possible operator timout is ignored ^

    What this warning is all about & any solution to fix this. If this warning is fixed does that mean i have a good fixed dsdt to use in Mac os x(both with leopard & snow leopard). As I said i havn't changed anything in my original dsdt under RTC,HPET & TMR etc, as those lines are different from what u posted in this post as well as in the 'prepare dsdt' section of your 'snow leopard installation guide'(i understand it is different because my mobo is intel945gcnl) so i didn't understand or know what to change in my dsdt.

    Please help me if u can to have a good fixed dsdt for leopard & snow leopard(particularly for snow leopard as i am planing to install it but stuck at this dsdt fixing) by looking at my original dsdt(http://rapidshare.com/files/306226734/original_intel945gcnl_dsdt.aml.zip) and suggest necessary changes.

    I ask this to you, i did not find any dsdt fixing guide particularly for my motherboard on the net & asked help in forums lik insanelymac,infinitemac & uphuck but no help. And I am stuck at this in the way of installing snow leopard on my pc.

    AntwortenLöschen
  6. @msr2cool

    This warning is due the missing timeout handling. If you try to acquire a mutex and use a timeout, then you should also provide code, which handles the timeout. The bios programmer did not! Maybe he is absolutely sure, that a timeout will never occur. But why he did not used a TimeoutValue of 0xffff, which means no Timeout.

    To fix the warning, supply a dummy timeouthandler. This does not change the semantic. Or use 0xffff as TimeoutValue, which does change the semantic.

    AntwortenLöschen
  7. Thanks AsereBLN for such a quick response & u rock man, the solution u gave me worked & it returned with 0 errors 0 warnings & 0remarks. I thank u for this but does this mean i have a good fixed dsdt to use with snow leopard, as i said in earlier message i haven't changed anything in other sections such as RTC,HPET & TMR in my original dsdt as there is quite a difference in the lines & i don't know which lines to change exactly.

    Once more i request you to look at my original dsdt(http://rapidshare.com/files/306226734/original_intel945gcnl_dsdt.aml.zip), if possible to you, and guide me accordingly.

    With Best Regards,
    msr2cool

    AntwortenLöschen
  8. Hi and thanks,

    you helped me alot with your blog. i am still runnig 10.5.8 on my ep45-ds3 but not with your "final-dsdt". with your final version (HPET,RTC,TMR) the first pci-slot (old 5v) isnt working anymore.

    the same problem i have on an ep45-ds3l under 10.6.2. with all the dsdt-patches the first pci-slot isnt working anymore.

    could you confirm this?

    tomorrow i will try to enumerate this problem closer.

    the last days i had success to bring my pov 9400 gt fully working und 10.6.2. i made a dsdt "myself". but im in need for the two old pci-slots on these two mobos ep45-ds3 and ds3l.

    but nice work overall helped me alotto understand a little bit more step by step

    best regards
    gnatze

    AntwortenLöschen