A simple and complete DSDT guide for your iAtkos


What is a DSDT ?

DSDT (Differentiated System Description Table), is a table which gives information about your computer to the Operating System which are ACPI (Advanced Configuration and Power Interface) complaint . 
OSX has an incomplete ACPI implementation , so we have to create our own DSDT , to give full information about our hardware to the operating system instead of getting half (or) wrong information about our hardware from BIOS.



Step -1 (Extracting)




How to extract a correct DSDT ? (Method -1,Perfect and very simple)
1. Boot Hackintosh-India Linux Live cd, Get it from Downloads.
2. Grab the DSDT from the Deskop and take it to your OSX for further editing.


Watch this video about procedure


How to extract a correct DSDT? (Method -2, simple-not perfect)
1. Grab the EvO DSDTSE editor from the Downloads .
2. Use Extract table , to generate DSDT information about your computer . 
The generated DSDT information can be edited and compiled to get the DSDT.aml file.

Step -2 (Choosing Editor)

How to edit the generated DSDT?(Method -1,simple-recommended)
1. Use the Evo DSDTSE editor to edit the DSDT, if you do not have it grab it from the Downloads.
Follow what to edit from the next section and edit your DSDT.

How to edit the generated DSDT?(Method -2, for linux power users)
1. Edit the generated DSDT.asl file with your favorite editor.
Follow what to edit from the next section and edit your DSDT.
2. compile modified DSDT: "aisl -d DSDT.asl"
3. use "man acpidump" and "man aisl" for details .

Step -3 (Patching)

What to edit in the generated DSDT?
This is the most important and lengthy part of this procedure.
Below is a collection of patches for your DSDT, you should read about what it does and decide whether it is necessary for you. 
I would be adding information regarding each patch, to help you decide on the usage of the patch.

Use Search feature in DSDT editor to get to the proper methods.

Required: DTGP Method

This method is required for the USB fix and the NVidia injection to work. If you use don't use these you don't need it.Insert this method under the _WAK method.

Method (DTGP, 5, NotSerialized)
    {
If (LEqual (Arg0, Buffer (0x10)
{
/* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,
/* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B
}))
{
If (LEqual (Arg1, One))
{
If (LEqual (Arg2, Zero))
{
Store (Buffer (One)
{
0x03
}, Arg4)
Return (One)
}

If (LEqual (Arg2, One))
{
Return (One)
}
}
}

Store (Buffer (One)
{
0x00
}, Arg4)
Return (One)
}
Required for Snow Leopard: Fix USB Devices Randomly Not Working
Reportedly, some are having issues with USB randomly not working on startup, but then trying again will bring the USB back.
Remove the following two lines from the Device (TMR) section:

IRQNoFlags ()


{2}

Optional: USB Drive Sleep Fix
Find the EHC2 and EHC1 sections and insert this method before the _PWR method in both sections:
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x0B)
{
"AAPL,clock-id",
Buffer (One)
{
0x01
},

"device_type",
Buffer (0x05)
{
"EHCI"
},

"AAPL,current-available",
0x04B0,
"AAPL,current-extra",
0x02BC,
"AAPL,current-in-sleep",
0x03E8,
Buffer (One)
{
0x00
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
Optional: NVidia Injection (also required for clamshell and sleep): Updated to fix Black Screen in 10.7.2
Note : It is advised to use GraphicsEnabler=Yes in boot.plist instead of  DSDT edits for Graphics Cards. Use DSDT edit for graphics cards when GraphicsEnabler=Yes does not work. Insert this code under the Device (VID) section within the Device (AGP) section (not in the independent (VID) section) under Name (_ADR, 0x00) and above the _DOS section. If you do not use this patch and you have a NVidia card you can use an injector instead.
 Name (_SUN, One)

Method (_DSM, 4, NotSerialized)

{

Store (Package (0x18)

{

"@0,built-in",

Buffer (One)

{

0x01

},



"@0,compatible",

Buffer (0x0B)

{

"NVDA,NVMac"

},



"@0,device_type",

Buffer (0x08)

{

"display"

},



"@0,name",

Buffer (0x0F)

{

"NVDA,Display-A"

},



"@1,compatible",

Buffer (0x0B)

{

"NVDA,NVMac"

},



"@1,device_type",

Buffer (0x08)

{

"display"

},



"@0,display-cfg",

Buffer (0x04)

{

0x03, 0x01, 0x00, 0x00

},



"@1,display-cfg",

Buffer (0x04)

{

0xFF, 0xFF, 0x00, 0x01

},



"@1,name",

Buffer (0x0F)

{

"NVDA,Display-B"

},



"NVCAP",

Buffer (0x18)

{

/* 0000 */ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,

/* 0008 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

/* 0010 */ 0x00, 0x00, 0x00, 0x00

},



"device_type",

Buffer (0x0C)

{

"NVDA,Parent"

},



"model",

Buffer (0x18)

{

"NVIDIA GeForce 8400M GS"

}

}, Local0)

DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))

Return (Local0)

}


Optional: HD Audio Patching : Recommended - Without it the computer may wake up instantly after sleep. 
This patch allows the sound card to be detected as an HDEF audio card rather than an Azilla Audio card. Replace the Device (AZAL) section with this:
 Device (HDEF)
{
Name (_ADR, 0x001B0000)
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x04)
{
"codec-id",
Buffer (0x04)
{
0x16, 0x76, 0x84, 0x83
},

"layout-id",
Buffer (0x04)
{
0x0C, 0x00, 0x00, 0x00
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
You will also have to change any references to AZAL to HDEF. With either the AZAL or HDEF section, a patched AppleHDA.kext can be used without HDAEnabler.kext (Leopard only solution at this time I believe), or alternatively VoodooHDA can be used. If you use this patch and VoodooHDA.kext, AppleHDA.kext must be removed otherwise it will conflict. It seems that you need this patch for working sleep if you do not include the SSDT tables.
Optional: Adding SBUS Device (SMBI Address was Wrong) 
This allows the detection of the SBUS device, and it can be confirmed as detected using IORegistry Explorer by searching for SBUS. This device is required to get C-states working, however we still do not have working C-states even with this patch. Add this under the first curly brace under Scope (\_SB):
 Method (DBEN, 0, NotSerialized)
{
}
And this under the DTGP method we added:
 OperationRegion (GPIO, SystemIO, 0x0500, 0x3C)
Field (GPIO, ByteAcc, NoLock, Preserve)
{
GU00, 8,
GU01, 8,
GU02, 8,
GU03, 8,
GIO0, 8,
GIO1, 8,
GIO2, 8,
GIO3, 8,
Offset (0x0C),
GL00, 8,
GL01, 8,
GL02, 8,
GL03, 8,
Offset (0x18),
GB00, 8,
GB01, 8,
GB02, 8,
GB03, 8,
Offset (0x2C),
GIV0, 8,
GIV1, 7,
GI15, 1,
GIV2, 8,
GIV3, 8,
GU04, 8,
GU05, 8,
GU06, 8,
GU07, 8,
GIO4, 8,
GIO5, 8,
GIO6, 8,
GIO7, 8,
GL04, 8,
GL05, 8,
GL06, 8,
GL07, 8
}

OperationRegion (BSKU, SystemMemory, 0xFFBC0100, 0x01)
Field (BSKU, ByteAcc, NoLock, Preserve)
{
, 1,
BPHP, 3,
Offset (0x01)
}

OperationRegion (GPE0, SystemIO, 0x042C, 0x04)
Field (GPE0, ByteAcc, NoLock, Preserve)
{
, 1,
GPEH, 1,
, 7,
PEEN, 1,
, 1,
PMEE, 1,
Offset (0x03),
PCIX, 1,
Offset (0x04)
}
And finally this above the section Device (ISAB):
Device (SBUS) 
{
Name (_ADR, 0x001F0003)

// pci8086,283e -> pci8086,3a30
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x04)
{
"name",
"pci8086,3a30",

"device-id",
Buffer (0x04)
{
0x30, 0x3a, 0x00, 0x00
} /* ,

"subsystem-id",
Buffer (0x04)
{
0x70, 0x72, 0x00, 0x00
},

"subsystem-vendor-id",
Buffer (0x04)
{
0x86, 0x80, 0x00, 0x00
} */
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}

OperationRegion (SMBP, PCI_Config, 0x40, 0xC0)
Field (SMBP, DWordAcc, NoLock, Preserve)
{
, 2,
I2CE, 1
}

OperationRegion (SMBE, PCI_Config, 0x04, 0x02)
Field (SMBE, AnyAcc, NoLock, Preserve)
{
IOSE, 1
}

OperationRegion (SMBI, SystemIO, 0x10C0, 0x10)
Field (SMBI, ByteAcc, NoLock, Preserve)
{
HSTS, 8,
Offset (0x02),
HCON, 8,
HCOM, 8,
TXSA, 8,
DAT0, 8,
DAT1, 8,
HBDR, 8,
PECR, 8,
RXSA, 8,
SDAT, 16
}

Name (SBOK, 0x00)
Method (ENAB, 0, NotSerialized)
{
Store (0x01, IOSE)
Store (One, SBOK)
}

Method (DISB, 0, NotSerialized)
{
Store (Zero, SBOK)
}

Method (SSXB, 2, Serialized)
{
If (STRT ())
{
Return (0x00)
}

Store (0x00, I2CE)
Store (0xBF, HSTS)
Store (Arg0, TXSA)
Store (Arg1, HCOM)
Store (0x48, HCON)
If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (0x01)
}

Return (0x00)
}

Method (SRXB, 1, Serialized)
{
If (STRT ())
{
Return (0xFFFF)
}

Store (0x00, I2CE)
Store (0xBF, HSTS)
Store (Or (Arg0, 0x01), TXSA)
Store (0x44, HCON)
If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (DAT0)
}

Return (0xFFFF)
}

Method (SWRB, 3, Serialized)
{
If (STRT ())
{
Return (0x00)
}

Store (0x00, I2CE)
Store (0xBF, HSTS)
Store (Arg0, TXSA)
Store (Arg1, HCOM)
Store (Arg2, DAT0)
Store (0x48, HCON)
If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (0x01)
}

Return (0x00)
}

Method (SRDB, 2, Serialized)
{
If (STRT ())
{
Return (0xFFFF)
}

Store (0x00, I2CE)
Store (0xBF, HSTS)
Store (Or (Arg0, 0x01), TXSA)
Store (Arg1, HCOM)
Store (0x48, HCON)
If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (DAT0)
}

Return (0xFFFF)
}

Method (SBLW, 4, Serialized)
{
If (STRT ())
{
Return (0x00)
}

Store (Arg3, I2CE)
Store (0xBF, HSTS)
Store (Arg0, TXSA)
Store (Arg1, HCOM)
Store (SizeOf (Arg2), DAT0)
Store (0x00, Local1)
Store (DerefOf (Index (Arg2, 0x00)), HBDR)
Store (0x54, HCON)
While (LGreater (SizeOf (Arg2), Local1))
{
Store (0x0FA0, Local0)
While (LAnd (LNot (And (HSTS, 0x80)), Local0))
{
Decrement (Local0)
Stall (0x32)
}

If (LNot (Local0))
{
KILL ()
Return (0x00)
}

Store (0x80, HSTS)
Increment (Local1)
If (LGreater (SizeOf (Arg2), Local1))
{
Store (DerefOf (Index (Arg2, Local1)), HBDR)
}
}

If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (0x01)
}

Return (0x00)
}

Method (SBLR, 3, Serialized)
{
Name (TBUF, Buffer (0x0100) {})
If (STRT ())
{
Return (0x00)
}

Store (Arg2, I2CE)
Store (0xBF, HSTS)
Store (Or (Arg0, 0x01), TXSA)
Store (Arg1, HCOM)
Store (0x54, HCON)
Store (0x0FA0, Local0)
While (LAnd (LNot (And (HSTS, 0x80)), Local0))
{
Decrement (Local0)
Stall (0x32)
}

If (LNot (Local0))
{
KILL ()
Return (0x00)
}

Store (DAT0, Index (TBUF, 0x00))
Store (0x80, HSTS)
Store (0x01, Local1)
While (LLess (Local1, DerefOf (Index (TBUF, 0x00))))
{
Store (0x0FA0, Local0)
While (LAnd (LNot (And (HSTS, 0x80)), Local0))
{
Decrement (Local0)
Stall (0x32)
}

If (LNot (Local0))
{
KILL ()
Return (0x00)
}

Store (HBDR, Index (TBUF, Local1))
Store (0x80, HSTS)
Increment (Local1)
}

If (COMP ())
{
Or (HSTS, 0xFF, HSTS)
Return (TBUF)
}

Return (0x00)
}

Method (STRT, 0, Serialized)
{
Store (0xC8, Local0)
While (Local0)
{
If (And (HSTS, 0x40))
{
Decrement (Local0)
Sleep (0x01)
If (LEqual (Local0, 0x00))
{
Return (0x01)
}
}
Else
{
Store (0x00, Local0)
}
}

Store (0x0FA0, Local0)
While (Local0)
{
If (And (HSTS, 0x01))
{
Decrement (Local0)
Stall (0x32)
If (LEqual (Local0, 0x00))
{
KILL ()
}
}
Else
{
Return (0x00)
}
}

Return (0x01)
}

Method (COMP, 0, Serialized)
{
Store (0x0FA0, Local0)
While (Local0)
{
If (And (HSTS, 0x02))
{
Return (0x01)
}
Else
{
Decrement (Local0)
Stall (0x32)
If (LEqual (Local0, 0x00))
{
KILL ()
}
}
}

Return (0x00)
}

Method (KILL, 0, Serialized)
{
Or (HCON, 0x02, HCON)
Or (HSTS, 0xFF, HSTS)
}

Device (BUS0)
{
Name (_CID, "smbus")
Name (_ADR, 0x00)
Device (MKY0)
{
Name (_ADR, 0x00)
Name (_CID, "mikey")
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x07)
{
"refnum",
0x00,
"address",
0x39,
"device-id",
0x0CCB,
Buffer (0x01)
{
0x00
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}

Method (H1EN, 1, Serialized)
{
If (LLessEqual (Arg0, 0x01))
{
If (LEqual (Arg0, 0x01))
{
Or (GL04, 0x04, GL04)
}
Else
{
And (GL04, 0xFB, GL04)
}
}
}

Method (H1IL, 0, Serialized)
{
ShiftRight (And (GL00, 0x02), 0x01, Local0)
Return (Local0)
}

Method (H1IP, 1, Serialized)
{
Store (Arg0, Local0)
}

Name (H1IN, 0x11)
Scope (\_GPE)
{
Method (_L11, 0, NotSerialized)
{
Notify (\_SB.PCI0.SBUS.BUS0.MKY0, 0x80)
}
}

Method (P1IL, 0, Serialized)
{
ShiftRight (And (GL00, 0x40), 0x06, Local0)
Return (Local0)
}

Method (P1IP, 1, Serialized)
{
If (LLessEqual (Arg0, 0x01))
{
Not (Arg0, Arg0)
And (GIV1, 0x0B, Local0)
ShiftLeft (Arg0, 0x02, Local1)
Or (Local1, Local0, GIV1)
}
}

Name (P1IN, 0x16)
Scope (\_GPE)
{
Method (_L16, 0, NotSerialized)
{
XOr (GIV1, 0x04, GIV1)
Notify (\_SB.PCI0.SBUS.BUS0.MKY0, 0x81)
}
}
}

Device (DVL0)
{
Name (_ADR, 0x57)
Name (_CID, "diagsvault")
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x03)
{
"address",
0x57,
Buffer (0x01)
{
0x00
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
}
}
Optional: IDE Fix 
This fix allows you to use Snow Leopard with the vanilla IOATAFamily.kext. Under the both the Device (IDE0) and Device (IDE1) sections under the first Name line the add:
OperationRegion (IDET, PCI_Config, 0x40, 0x04) // IDE Timing Register
Field (IDET, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8,
Offset (0x03),
M4, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (0x07, M1)
Store (0xE3, M2)
Store (Zero, M3)
Store (0xC0, M4)
Return (Zero)
}
Optional: Clamshell FixThis patch lets your computer sleep when you close the lid (thanks Brett Whinnen). Under _SB add the following:
 Device (PNLF)
{
Name (_HID, EisaId ("APP0002"))
Name (_CID, "backlight")
Name (_UID, 0x0A)
Name (_STA, 0x0B)
}
Optional: SHUTDOWN FIX  
This patch allows the computer to shut down properly with NVidia graphics. 
Above method PTS, add the following:
OperationRegion (PMRS, SystemIO, 0x1030, One)
Field (PMRS, ByteAcc, NoLock, Preserve)
{
, 4,
SLPE, 1
}
and then replace the PTS method with the following:
Method (_PTS, 1, NotSerialized)
{
If (LEqual (Arg0, 0x05))
{
Store (Zero, SLPE)
Sleep (0x10)
}
}
Recommended for newer 10.6 releases: USB Patch to Fix Sleep
Later 10.6.X releases (10.6.6+?) caused sleep to stop working when disconnected from the power supply. This patch fixes this. Under USB1, USB3, and USB4, remove the block that begins with _PSW. Do not touch the _PSW method under the other USBs or anywhere else.Here is a sample USB1 after complete (note no _PSW method):
Device (USB1)
{
Name (_ADR, 0x001D0000)
Method (_PRW, 0, NotSerialized)
{
Store (UPRW (Zero, Zero), Local0)
If (LEqual (Local0, 0x03))
{
Return (Package (0x02)
{
0x03,
0x03
})
}

If (LEqual (Local0, One))
{
Return (Package (0x02)
{
0x03,
One
})
}

Return (Package (0x02)
{
0x03,
Zero
})
}

Device (HUB0)
{
Name (_ADR, Zero)
Device (CH00)
{
Name (_ADR, One)
}

Device (CH01)
{
Name (_ADR, 0x02)
}
}
}
Required for 10.6.8 and Lion: PCI Patch 
10.6.8 is much more Lion like.Without these patches you will get beach balling and kernel panics. You may also need to change your Mac model in the smbios.plist to fix speed step and prevent kernel panics. 

Replace

Device (PCI0)
{
Name (_HID, EisaId ("PNP0A03"))
Name (_ADR, Zero)
With


 Device (PCI0)
{
Name (_HID, EisaId ("PNP0A08"))
Name (_CID, EisaId ("PNP0A03"))
Name (_UID, Zero)

Required for 10.6.8 and Lion: RTC Patch 
This patch replaces the RTC with one from a Mac. Replace RTC with the below code:
                Device (RTC)
{
Name (_HID, EisaId ("PNP0B00"))
Name (_CRS, ResourceTemplate ()
{
IO (Decode16,
0x0070, // Range Minimum
0x0070, // Range Maximum
0x01, // Alignment
0x08, // Length
)
})
}
Required for 10.6.8 and Lion: SMBUS Patch  
This is a simplified SMBUS patch that fixes the SMBuspci error that you would get if you don't do it.
 Device (SBUS)
{
Name (_ADR, 0x001F0003)
Device (BUS0)
{
Name (_CID, "smbus")
Name (_ADR, Zero)
Device (DVL0)
{
Name (_ADR, 0x57)
Name (_CID, "diagsvault")
}
}

Method (_DSM, 4, NotSerialized)
{
Store (Package (0x0A)
{
"built-in",
Buffer (One)
{
0x00
},

"name",
"pci8086,283e",
"device-id",
Buffer (0x04)
{
0x3E, 0x28, 0x00, 0x00
},

"subsystem-id",
Buffer (0x04)
{
0xA0, 0x00, 0x00, 0x00
},

"subsystem-vendor-id",
Buffer (0x04)
{
0x6B, 0x10, 0x00, 0x00
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
Required: HPET  
The HPET is required for power management. If you use this HPET and the RTC above, you will no longer need to use the patcher. Replace the HPET with the one below.
                Device (HPET)
{
Name (_HID, EisaId ("PNP0103"))
Name (_CID, EisaId ("PNP0C01"))
Name (BUF0, ResourceTemplate ()
{
IRQNoFlags ()
{0}
IRQNoFlags ()
{8}
IRQNoFlags ()
{15}
Memory32Fixed (ReadOnly,
0xFED00000, // Address Base
0x00000400, // Address Length
)
})
Method (_STA, 0, NotSerialized)
{
Return (0x0B) //researching if F or B is best
}

Method (_CRS, 0, NotSerialized)
{
Return (BUF0)
}
}
Step -4 (Compile and Testing DSDT)
1. Compile the DSDT using 'Compile DSDT' in DSDT editor.
2. Check for any errors and correct it if any by checking this guide.
3. The final compiled file should be named 'DSDT.aml' 

Step -5 (Using the DSDT)
1. Use the DSDT.aml in the /Extra folder, so that it is loaded during boot by the Chameleon boot loader.


This guide would be updated on regular basis for new patches.

Credits : immo of insanely mac and others who helped him.