Skip to content

Instantly share code, notes, and snippets.

@pmdevita
Created May 17, 2020 03:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmdevita/2c8293ae8f0a7b17b98cc01cf7cee3ad to your computer and use it in GitHub Desktop.
Save pmdevita/2c8293ae8f0a7b17b98cc01cf7cee3ad to your computer and use it in GitHub Desktop.
Rehabman DSDT Debugging Tool CloverEFI Hotpatch
DefinitionBlock ("", "SSDT", 2, "hack", "RMDT", 0x00000000)
{
// Copy these External references to the SSDT you want to debug in
External (RMDT, DeviceObj)
External (RMDT.PUSH, MethodObj)
External (RMDT.P1, MethodObj)
External (RMDT.P2, MethodObj)
External (RMDT.P3, MethodObj)
External (RMDT.P4, MethodObj)
External (RMDT.P5, MethodObj)
External (RMDT.P6, MethodObj)
External (RMDT.P7, MethodObj)
Device (RMDT)
{
Name (_HID, "RMD0000")
Name (RING, Package(256) { })
Mutex (RTMX, 0)
Name (HEAD, 0)
Name (TAIL, 0)
// PUSH: Use to push a trace item into RING for ACPIDebug.kext
Method (PUSH, 1, NotSerialized)
{
Acquire(RTMX, 0xFFFF)
// push new item at HEAD
Add(HEAD, 1, Local0)
If (LGreaterEqual(Local0, SizeOf(RING))) { Store(0, Local0) }
if (LNotEqual(Local0, TAIL))
{
Store(Arg0, Index(RING, HEAD))
Store(Local0, HEAD)
}
Release(RTMX)
Notify(RMDT, 0x80)
}
// FTCH: Used by ACPIDebug.kext to fetch an item from RING
Method (FTCH, 0, NotSerialized)
{
Acquire(RTMX, 0xFFFF)
// pull item from TAIL and return it
Store(0, Local0)
if (LNotEqual(HEAD, TAIL))
{
Store(DerefOf(Index(RING, TAIL)), Local0)
Increment(TAIL)
If (LGreaterEqual(TAIL, SizeOf(RING))) { Store(0, TAIL) }
}
Release(RTMX)
Return(Local0)
}
// COUN: Used by ACPIDebug.kext to determine number of items in RING
Method (COUN, 0, NotSerialized)
{
Acquire(RTMX, 0xFFFF)
// return count of items in RING
Subtract(HEAD, TAIL, Local0)
if (LLess(Local0, 0)) { Add(Local0, SizeOf(RING), Local0) }
Release(RTMX)
Return(Local0)
}
// Helper functions for multiple params at one time
Method (P1, 1, NotSerialized) { PUSH(Arg0) }
Method (P2, 2, Serialized)
{
Name (TEMP, Package(2) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
PUSH(TEMP)
}
Method (P3, 3, Serialized)
{
Name (TEMP, Package(3) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
Store(Arg2, Index(TEMP, 2))
PUSH(TEMP)
}
Method (P4, 4, Serialized)
{
Name (TEMP, Package(4) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
Store(Arg2, Index(TEMP, 2))
Store(Arg3, Index(TEMP, 3))
PUSH(TEMP)
}
Method (P5, 5, Serialized)
{
Name (TEMP, Package(5) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
Store(Arg2, Index(TEMP, 2))
Store(Arg3, Index(TEMP, 3))
Store(Arg4, Index(TEMP, 4))
PUSH(TEMP)
}
Method (P6, 6, Serialized)
{
Name (TEMP, Package(6) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
Store(Arg2, Index(TEMP, 2))
Store(Arg3, Index(TEMP, 3))
Store(Arg4, Index(TEMP, 4))
Store(Arg5, Index(TEMP, 5))
PUSH(TEMP)
}
Method (P7, 7, Serialized)
{
Name (TEMP, Package(7) { })
Store(Arg0, Index(TEMP, 0))
Store(Arg1, Index(TEMP, 1))
Store(Arg2, Index(TEMP, 2))
Store(Arg3, Index(TEMP, 3))
Store(Arg4, Index(TEMP, 4))
Store(Arg5, Index(TEMP, 5))
Store(Arg6, Index(TEMP, 6))
PUSH(TEMP)
}
}
}
@pmdevita
Copy link
Author

pmdevita commented May 17, 2020

How to

  1. Compile this into AML and add it to your Clover/ACPI/patched folder
  2. Follow Rehabman's guide on how to add the logging commands and the kext https://github.com/RehabMan/OS-X-ACPI-Debug
  3. Copy the External() methods for the commands you want to use and place them at the beginning inside the DefinitionBlock you are debugging in
  4. Run something like log show --last "10m" | grep ACPIDebug in the terminal to read the output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment