Jump to content
riley

DSDT expert needed :)

Recommended Posts

I'm trying to finalise my DSDT to flash back into my BIOS. I've attached the OSDW method to most of my device edits/injections so they only get loaded in OS X. But I'm stumped with my JMicron eSATA. The entries for Windows and OS X are completely different. And I can't figure out how to inject the OS X code so it only loads in OS X, leaving the original code alone.


Here's the original code

Device (JMB0)
               {
                   Name (_ADR, Zero)
                   OperationRegion (CF40, PCI_Config, 0x40, 0x04)
                   Field (CF40, ByteAcc, NoLock, Preserve)
                   {
                       CHE0,   1, 
                       MULT,   1, 
                           ,   1, 
                       CAB0,   1, 
                       CHE1,   1, 
                               Offset (0x01), 
                       AHEN,   1, 
                           ,   3, 
                       PRT0,   1, 
                       AHM0,   1, 
                       PRT1,   1, 
                       AHM1,   1, 
                       CF42,   6, 
                       SWAP,   1, 
                       PATA,   1, 
                           ,   6, 
                       WTEN,   1, 
                               Offset (0x04)
                   }
                   Name (PIOT, Package (0x05)
                   {
                       0x0258, 
                       0x0186, 
                       0x014A, 
                       0xB4, 
                       0x78
                   })
                   Name (UDMA, Package (0x07)
                   {
                       0x78, 
                       0x50, 
                       0x3C, 
                       0x28, 
                       0x1E, 
                       0x14, 
                       0x0F
                   })
                   Name (MDMA, Package (0x03)
                   {
                       0x01E0, 
                       0x96, 
                       0x78
                   })
                   Name (IDEB, Buffer (0x14) {})
                   CreateDWordField (IDEB, Zero, GTM0)
                   CreateDWordField (IDEB, 0x04, GTM1)
                   CreateDWordField (IDEB, 0x08, GTM2)
                   CreateDWordField (IDEB, 0x0C, GTM3)
                   CreateDWordField (IDEB, 0x10, GTM4)
                   Name (PIO0, 0x04)
                   Name (DMA0, 0x06)
                   Name (MDA0, 0x02)
                   Name (PIO1, 0x04)
                   Name (DMA1, 0x06)
                   Name (MDA1, 0x02)
                   Name (PIO2, 0x04)
                   Name (DMA2, 0x06)
                   Name (MDA2, 0x02)
                   Name (PIO3, 0x04)
                   Name (DMA3, 0x06)
                   Name (MDA3, 0x02)
                   Name (FLGP, 0x1F)
                   Name (FLGS, 0x1F)
                   Device (IDE0)
                   {
                       Name (_ADR, Zero)
                       Method (_GTM, 0, NotSerialized)
                       {
                           Store (DerefOf (Index (PIOT, PIO0)), Local0)
                           Store (DerefOf (Index (PIOT, PIO1)), Local2)
                           Store (0x1A, Local4)
                           If (LAnd (FLGP, One))
                           {
                               If (LNot (MULT))
                               {
                                   If (LAnd (CAB0, SWAP))
                                   {
                                       Store (0x02, DMA0)
                                   }
                               }
                               Store (DerefOf (Index (UDMA, DMA0)), Local1)
                               Or (Local4, One, Local4)
                           }
                           Else
                           {
                               Store (DerefOf (Index (MDMA, MDA0)), Local1)
                           }
                           If (LAnd (FLGP, 0x04))
                           {
                               If (LAnd (CAB0, SWAP))
                               {
                                   Store (0x02, DMA1)
                               }
                               Store (DerefOf (Index (UDMA, DMA1)), Local3)
                               Or (Local4, 0x04, Local4)
                           }
                           Else
                           {
                               Store (DerefOf (Index (MDMA, MDA1)), Local3)
                           }
                           Store (Local0, GTM0)
                           Store (Local1, GTM1)
                           Store (Local2, GTM2)
                           Store (Local3, GTM3)
                           Store (Local4, GTM4)
                           Return (IDEB)
                       }
                       Method (_STM, 3, NotSerialized)
                       {
                           Store (Arg0, IDEB)
                           Store (GTM0, Local0)
                           Store (GTM1, Local1)
                           Store (GTM2, Local2)
                           Store (GTM3, Local3)
                           Store (GTM4, Local4)
                           Store (Local4, FLGP)
                           If (LAnd (LNotEqual (Local0, 0xFFFFFFFF), LNotEqual (Local0, Zero)))
                           {
                               Store (Match (PIOT, MEQ, Local0, MTR, Zero, Zero), PIO0)
                           }
                           If (LAnd (LNotEqual (Local1, 0xFFFFFFFF), LNotEqual (Local1, Zero)))
                           {
                               If (LAnd (FLGP, One))
                               {
                                   Store (Match (UDMA, MEQ, Local1, MTR, Zero, Zero), DMA0)
                               }
                               Else
                               {
                                   Store (Match (MDMA, MEQ, Local1, MTR, Zero, Zero), MDA0)
                               }
                           }
                           If (LAnd (LNotEqual (Local2, 0xFFFFFFFF), LNotEqual (Local2, Zero)))
                           {
                               Store (Match (PIOT, MEQ, Local2, MTR, Zero, Zero), PIO1)
                           }
                           If (LAnd (LNotEqual (Local3, 0xFFFFFFFF), LNotEqual (Local3, Zero)))
                           {
                               If (LAnd (FLGP, 0x04))
                               {
                                   Store (Match (UDMA, MEQ, Local3, MTR, Zero, Zero), DMA1)
                               }
                               Else
                               {
                                   Store (Match (MDMA, MEQ, Local3, MTR, Zero, Zero), MDA1)
                               }
                           }
                       }
                       Device (DRV0)
                       {
                           Name (_ADR, Zero)
                           Method (_GTF, 0, NotSerialized)
                           {
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
                                   }, Local0)
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
                                   }, Local1)
                               CreateByteField (Local0, One, PIOM)
                               CreateByteField (Local1, One, DMAM)
                               Store (PIO0, PIOM)
                               Or (PIOM, 0x08, PIOM)
                               If (LAnd (FLGP, One))
                               {
                                   Store (DMA0, DMAM)
                                   Or (DMAM, 0x40, DMAM)
                               }
                               Else
                               {
                                   Store (MDA0, DMAM)
                                   Or (DMAM, 0x20, DMAM)
                               }
                               Concatenate (Local0, Local1, Local2)
                               Return (Local2)
                           }
                       }
                       Device (DRV1)
                       {
                           Name (_ADR, One)
                           Method (_GTF, 0, NotSerialized)
                           {
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xEF
                                   }, Local0)
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xEF
                                   }, Local1)
                               CreateByteField (Local0, One, PIOM)
                               CreateByteField (Local1, One, DMAM)
                               Store (PIO1, PIOM)
                               Or (PIOM, 0x08, PIOM)
                               If (LAnd (FLGP, 0x04))
                               {
                                   Store (DMA1, DMAM)
                                   Or (DMAM, 0x40, DMAM)
                               }
                               Else
                               {
                                   Store (MDA1, DMAM)
                                   Or (DMAM, 0x20, DMAM)
                               }
                               Concatenate (Local0, Local1, Local2)
                               Return (Local2)
                           }
                       }
                   }
                   Device (IDE1)
                   {
                       Name (_ADR, One)
                       Method (_GTM, 0, NotSerialized)
                       {
                           Store (DerefOf (Index (PIOT, PIO2)), Local0)
                           Store (DerefOf (Index (PIOT, PIO3)), Local2)
                           Store (0x1A, Local4)
                           If (LAnd (FLGS, One))
                           {
                               If (LNot (MULT))
                               {
                                   If (LAnd (CAB0, LNot (SWAP)))
                                   {
                                       Store (0x02, DMA2)
                                   }
                               }
                               Store (DerefOf (Index (UDMA, DMA2)), Local1)
                               Or (Local4, One, Local4)
                           }
                           Else
                           {
                               Store (DerefOf (Index (MDMA, MDA2)), Local1)
                           }
                           If (LAnd (FLGS, 0x04))
                           {
                               If (LAnd (CAB0, LNot (SWAP)))
                               {
                                   Store (0x02, DMA3)
                               }
                               Store (DerefOf (Index (UDMA, DMA3)), Local3)
                               Or (Local4, 0x04, Local4)
                           }
                           Else
                           {
                               Store (DerefOf (Index (MDMA, MDA3)), Local3)
                           }
                           Store (Local0, GTM0)
                           Store (Local1, GTM1)
                           Store (Local2, GTM2)
                           Store (Local3, GTM3)
                           Store (Local4, GTM4)
                           Return (IDEB)
                       }
                       Method (_STM, 3, NotSerialized)
                       {
                           Store (Arg0, IDEB)
                           Store (GTM0, Local0)
                           Store (GTM1, Local1)
                           Store (GTM2, Local2)
                           Store (GTM3, Local3)
                           Store (GTM4, Local4)
                           Store (Local4, FLGS)
                           If (LAnd (LNotEqual (Local0, 0xFFFFFFFF), LNotEqual (Local0, Zero)))
                           {
                               Store (Match (PIOT, MEQ, Local0, MTR, Zero, Zero), PIO2)
                           }
                           If (LAnd (LNotEqual (Local1, 0xFFFFFFFF), LNotEqual (Local1, Zero)))
                           {
                               If (LAnd (FLGS, One))
                               {
                                   Store (Match (UDMA, MEQ, Local1, MTR, Zero, Zero), DMA2)
                               }
                               Else
                               {
                                   Store (Match (MDMA, MEQ, Local1, MTR, Zero, Zero), MDA2)
                               }
                           }
                           If (LAnd (LNotEqual (Local2, 0xFFFFFFFF), LNotEqual (Local2, Zero)))
                           {
                               Store (Match (PIOT, MEQ, Local2, MTR, Zero, Zero), PIO3)
                           }
                           If (LAnd (LNotEqual (Local3, 0xFFFFFFFF), LNotEqual (Local3, Zero)))
                           {
                               If (LAnd (FLGS, 0x04))
                               {
                                   Store (Match (UDMA, MEQ, Local3, MTR, Zero, Zero), DMA3)
                               }
                               Else
                               {
                                   Store (Match (MDMA, MEQ, Local3, MTR, Zero, Zero), MDA3)
                               }
                           }
                       }
                       Device (DRV0)
                       {
                           Name (_ADR, Zero)
                           Method (_GTF, 0, NotSerialized)
                           {
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
                                   }, Local0)
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xEF
                                   }, Local1)
                               CreateByteField (Local0, One, PIOM)
                               CreateByteField (Local1, One, DMAM)
                               Store (PIO2, PIOM)
                               Or (PIOM, 0x08, PIOM)
                               If (LAnd (FLGS, One))
                               {
                                   Store (DMA2, DMAM)
                                   Or (DMAM, 0x40, DMAM)
                               }
                               Else
                               {
                                   Store (MDA2, DMAM)
                                   Or (DMAM, 0x20, DMAM)
                               }
                               Concatenate (Local0, Local1, Local2)
                               Return (Local2)
                           }
                       }
                       Device (DRV1)
                       {
                           Name (_ADR, One)
                           Method (_GTF, 0, NotSerialized)
                           {
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xEF
                                   }, Local0)
                               Store (Buffer (0x07)
                                   {
                                       0x03, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xEF
                                   }, Local1)
                               CreateByteField (Local0, One, PIOM)
                               CreateByteField (Local1, One, DMAM)
                               Store (PIO3, PIOM)
                               Or (PIOM, 0x08, PIOM)
                               If (LAnd (FLGS, 0x04))
                               {
                                   Store (DMA3, DMAM)
                                   Or (DMAM, 0x40, DMAM)
                               }
                               Else
                               {
                                   Store (MDA3, DMAM)
                                   Or (DMAM, 0x20, DMAM)
                               }
                               Concatenate (Local0, Local1, Local2)
                               Return (Local2)
                           }
                       }
                   }
               }

And here's the code for OS X

Device (JMB0)
               {
                   Name (_ADR, Zero)
                   OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
                   Field (BAR0, WordAcc, NoLock, Preserve)
                   {
                       M1,     8,
                       M2,     8,
                       M3,     8
                   }
                   Method (_DSM, 4, NotSerialized)
                   {
                       Store (0xB3, M1)
                       Store (0xA1, M2)
                       Store (0xC2, M3)
                       Store (Package (0x02)
                           {
                               "name",
                               "JMicron JMB362 eSATA"
                           }, Local0)
                       DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                       Return (Local0)
                   }
               }

As you can see the OS X code is much smaller. There's also some wake code I need to add that will need to be edited, but first off I need to see if this can be done.


Does anyone know how (or if) this can be done?

Link to comment
Share on other sites

hello


i think u only insert dsm method

 

 Method (_DSM, 4, NotSerialized)
                   {
                       Store (0xB3, M1)
                       Store (0xA1, M2)
                       Store (0xC2, M3)
                       Store (Package (0x02)
                           {
                               "name",
                               "JMicron JMB362 eSATA"
                           }, Local0)
                       DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                       Return (Local0)
                   }
               }

 

u must test...


good hack

PB Easy Note TM 86 - i5 430 M - H55M - Ram - 6 GB - Alc272 - Radeon HD 5470 512 QE/CI

Lenovo G500 - i5 3230m - HM77 - Ram - 8 GB - Conexant audio - HD 4000

My OS X Files 

Link to comment
Share on other sites

Thanks artur. I'm pretty sure I tried that already. But I gave it another go. When I compile it throw up errors that M1, M2 and M3 are missing. I haven't figured out how to add those to the Field header (Field unit extends beyond region limit).


However, the OperationRegion and Field headers are different in both sets of code. Even if I got the Mx variables added to CF40, they're supposed to be BAR0.

Link to comment
Share on other sites

I know they're variables but that's the error I got when I tried adding them to the original code.


Ideally what I need is for the DSDT to work like this:


Device (JMB0)

If OS X

Load OS X code

Else

Load original code


But (how) can that be done?

Link to comment
Share on other sites

This DSDT is going back into my BIOS (I'm booting using Ozmosis). That's why I need to have both sets of code in there. The OS X code is only loaded when I boot OS X.


I already have this working for other injections like USB and ethernet but they just add extra variables to the existing code. In this case I need to load one of two completely different pieces of code depending on the OS.


I don't have to do it this way, but it's a challenge and I like the idea of having everything hardcoded into the BIOS. Plus I almost have it fully working. Just need to get my eSATA to work (and maybe fix wake as well, though I don't use sleep).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now




×
  • Create New...
The popup will be closed in 15 seconds...