Help - Search - Members - Calendar
Full Version: ACPI Debugging
Project OS X Forums > Snow Leopard Guides & Tutorials > DSDT Patching
zhell
ACPI Debugging

This is for advanced users experienced with DSDT modification ONLY

As a primer, read a few of the 700+ pages of the ACPI specs from here: http://www.acpi.info/spec.htm

Many issues related to power management (speedstep, sleep and hibernation etc.) are governed by your board's ACPI tables.
Debugging ACPI is a royal pain as often the display is off when you would like it to output debug info.
Using a second machine you can attach to the kernel and obtain valuable data, but I have never done this myself. Rather, I'm collecting here hints on how to debug ACPI using facilities available to all of us.


Kernel Arguments

First off, using these kernel arguments, you can obtain some output to the console:
CODE
-v acpi_layer="ACPI_ALL_COMPONENTS ACPI_ALL_DRIVERS" acpi_level="ACPI_LV_ALL_EXCEPTIONS" debug=0x12a

In order to see the console at all times, set "Display login window" to "Name and password" in System Preferences/Accounts/Login Options; then log out and enter ">console" as user name and an empty password. Now you can log in on the console (type your user name, hit enter, then type your password).
To put the machine to sleep from the console, use
CODE
sudo pmset sleepnow



DSDT Debug Code

ACPI allows some debug code to be output by writing to the debug device, however if the display is off, this is useless. Instead, you can send some morse code using the power LED.
Here is an example snippet I added to my _WAK method that flashes the power LED and thus shows me, where in _WAK it is hanging on resume.
CODE

Method (_WAK, 1, Serialized)
{
Store ("Method _WAK begin...", Debug)
/*
* Blink power led slow 3 times */
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
/*
* Enough */

\_SB.PCI0.LPCB.WAK (Arg0)
/*
* Blink power led long on 3 times */
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
/*
* Enough */
Store ("Called method WAK returned", Debug)

If (CondRefOf (_OSI, Local0))
{
Store (0x21, OSTY)
}

/*
* Blink power led long off 3 times */
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x1f4)
Store (0x0F, \_SB.PCI0.LPCB.LED)
/*
* Enough */

Notify (\_SB.PCI0.UHC1, Zero)
Notify (\_SB.PCI0.UHC2, Zero)
Notify (\_SB.PCI0.UHC3, Zero)
Notify (\_SB.PCI0.UHC4, Zero)
Notify (\_SB.PCI0.UHC5, Zero)
Notify (\_SB.PCI0.UHC6, Zero)
Notify (\_SB.PCI0.EHC1, Zero)
Notify (\_SB.PCI0.UHCX, Zero)
Notify (\_SB.PCI0.EHC2, Zero)

If (LEqual (Arg0, 0x04))
{
If (LEqual (WAS4, One))
{
Notify (\_SB.SLPB, 0x02)
}
}


Store ("Method _WAK end", Debug)
/*
* Blink power led fast 6 times */
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x02, \_SB.PCI0.LPCB.LED)
Sleep (0x64)
Store (0x0F, \_SB.PCI0.LPCB.LED)
/*
* Enough */

Return (Zero)
}

You need to find out how to turn on and off the power LED on your own, as this is totally specific to each board. As a hint, look at method _PTS, as this method usually turns off the power LED.
I admit that this code should be replaced by a dedicated method which takes as argument a string and flashes the power LED accordingly to the morse code representation of the string. Writing this method is left as an exercise for the reader. Please post your solutions below :-)

USB Debugging

Many issues related to sleep are related to USB and I recommend to install the debug version of the USB kexts. You can obtain them from this page (requires free ADC membership): http://developer.apple.com/hardwaredrivers...d/usbdebug.html
18seven
Thanks for posting this info. That led diagnostic is wicked cool. I am currently deep into section 8 of the acpi specs trying to resolve why ApplePowerManagement has cut my CPU max frequency in half. Getting some info into console will hopefully give me a better shot than stabbing in the dark with a serious learning curve. Any sage wisdom would be most welcome.

Slice
Cool! blink.gif
apocolipse269
Question for you, i've been reading up on ACPI trying to fix my sleep issue, however i do think it is kext related (would like to fix my dsdt to use stock acpi kexts if i can eventually but...)
Currently my issue with sleep is that it will hang after wak, it will get up to the UI but it seems no disk i/o afterwards, then get loading cursor after a few secs and have to hard boot. i fixed the compile errors about no return values in my dsdt and still get this, wondering if thsi could be usb related (hopefully) so i dont have to keep wrackin my head and potentially mess up my compy messin w/ dsdt too much
alex
QUOTE (apocolipse269 @ Aug 12 2009, 04:57 PM) *
Question for you, i've been reading up on ACPI trying to fix my sleep issue, however i do think it is kext related (would like to fix my dsdt to use stock acpi kexts if i can eventually but...)
Currently my issue with sleep is that it will hang after wak, it will get up to the UI but it seems no disk i/o afterwards, then get loading cursor after a few secs and have to hard boot. i fixed the compile errors about no return values in my dsdt and still get this, wondering if thsi could be usb related (hopefully) so i dont have to keep wrackin my head and potentially mess up my compy messin w/ dsdt too much


Apocolipse I have exacly the same issue with sleep, have you managed to fixed it?
Mikehunt79
nice idea with the morse code, I wonder if you could get the console to log it's output to a file?
ytrox
can you post a dsdt example please?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.