Contribute
Register

[Guide] How to patch DSDT for working battery status

How to patch DSDT for working battery status

Hi RehabMan, congrats on this guide!

Your expertise would be much appreciated...

What is the SMD0 offset in the following section of my DSDT? (i.e. where from do I start adding??)

Code:
 Scope (_SB.PCI0.LPCB)
    {
        Mutex (\MUEC, 0x00)
        Device (EC)
        {
            Name (_HID, EisaId ("PNP0C09"))
            Name (_GPE, 0x17)
            Name (CTID, Zero)
            Name (MYEC, One)
            Name (CTSD, Zero)
            Name (\PTHR, Zero)
            OperationRegion (IO_2, SystemIO, 0x68, 0x05)
            Field (IO_2, ByteAcc, Lock, Preserve)
            {
                DAT2,   8, 
                Offset (0x04), 
                CMD2,   8
            }
            Field (IO_2, ByteAcc, Lock, Preserve)
            {
                Offset (0x04), 
                OUT2,   1, 
                INP2,   1
            }
            Method (IRD2, 0, Serialized)
            {
                Return (LNot (INP2))
            }
            Method (ORD2, 0, Serialized)
            {
                Return (OUT2)
            }
            OperationRegion (IO8, SystemIO, 0x80, One)
            Field (IO8, ByteAcc, Lock, Preserve)
            {
                DBG8,   8
            }
            OperationRegion (TEST, SystemIO, 0xB2, One)
            Field (TEST, ByteAcc, Lock, Preserve)
            {
                APMC,   8
            }
            Method (_REG, 2, NotSerialized)
            {
                If (LEqual (Arg0, 0x03))
                {
                    Store (Arg1, MYEC)
                    If (LEqual (Arg1, One))
                    {
                        If (_OSI ("Windows 2012"))
                        {
                            Store (0x04, OSVR)
                        }
                        Else
                        {
                            If (_OSI ("Windows 2009"))
                            {
                                Store (0x03, OSVR)
                            }
                            Else
                            {
                                If (_OSI ("Windows 2006"))
                                {
                                    Store (0x02, OSVR)
                                }
                                Else
                                {
                                    If (_OSI ("Windows 2001"))
                                    {
                                        Store (One, OSVR)
                                    }
                                    Else
                                    {
                                        If (_OSI ("Windows 2001 SP1"))
                                        {
                                            Store (One, OSVR)
                                        }
                                        Else
                                        {
                                            If (_OSI ("Windows 2001 SP2"))
                                            {
                                                Store (One, OSVR)
                                            }
                                            Else
                                            {
                                                If (_OSI ("Windows 2001 SP3"))
                                                {
                                                    Store (One, OSVR)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                Store (Zero, CTSD)
                Store (LIDS, ^^^IGPU.CLID)
                If (POWS)
                {
                    Store (One, PWRS)
                }
                Else
                {
                    Store (Zero, PWRS)
                }
                PNOT ()
            }
            Name (_CRS, ResourceTemplate ()
            {
                IO (Decode16,
                    0x0062,             // Range Minimum
                    0x0062,             // Range Maximum
                    0x00,               // Alignment
                    0x01,               // Length
                    )
                IO (Decode16,
                    0x0066,             // Range Minimum
                    0x0066,             // Range Maximum
                    0x00,               // Alignment
                    0x01,               // Length
                    )
            })
            OperationRegion (EC, EmbeddedControl, Zero, 0x0100)
            Field (EC, ByteAcc, NoLock, Preserve)
            {
                SMPR,   8, 
                SMST,   8, 
                SMAD,   8, 
                SMCM,   8, 
                [B]SMD0,   264, [/B]
                SMAA,   8, 
                Offset (0x2C),

Thanks in advance!
 
How to patch DSDT for working battery status

Hi RehabMan, congrats on this guide!

Your expertise would be much appreciated...

What is the SMD0 offset in the following section of my DSDT? (i.e. where from do I start adding??)
...

Thanks in advance!

The relevant section:
Code:
            OperationRegion (EC, EmbeddedControl, [B]Zero[/B], 0x0100)
            Field (EC, ByteAcc, NoLock, Preserve)
            {
                SMPR,   8, //0
                SMST,   8, //1
                SMAD,   8, //2
                SMCM,   8, //3
                [B]SMD0,   264,[/B]  //4

The EC region starts at Zero (see bolded section in OperationRegion declaration), and there are four 8-bit registers prior (one byte each), so it is at offset 4.
 
How to patch DSDT for working battery status

The relevant section:
Code:
            OperationRegion (EC, EmbeddedControl, [B]Zero[/B], 0x0100)
            Field (EC, ByteAcc, NoLock, Preserve)
            {
                SMPR,   8, //0
                SMST,   8, //1
                SMAD,   8, //2
                SMCM,   8, //3
                [B]SMD0,   264,[/B]  //4

The EC region starts at Zero (see bolded section in OperationRegion declaration), and there are four 8-bit registers prior (one byte each), so it is at offset 4.

Thank you RehabMan!

Actually turns out that the only 264 size(SDM0) did not turn up anywhere else.
The rest of the 16bit registers refer to the SCM (System Control Manager) device of the Laptop that controls Quick buttons on the laptop chassis (Turbo, Eject, Screen Toggle etc..) and I think that they have nothing to do with battery.
I then installed the battery Kext and it worked! So MSI GT60-220US (HM77 Ivy Bridge HD4000 + Optimus) does not need a battery DSDT patch after all.

However, after installing your kext Mavericks fails to Wake from sleep only when on battery power!
When on AC waking is flawless...
(Do you think I should patch the SCM registers after all?)

I attach my DSDT for your convenience (perhaps its the DSDT's fault ?)
One more thing I should mention is that when USB3.0 WLAN Stick is in use the system also fails to sleep.
I suspect that it has to do with USB powermanagement Specs in the patched EHC and XHC devices DSM sections.
When I remove all DSMs the system sleeps and AUTO-wakes up in seconds.

Thanks
 

Attachments

  • DSDT.rar
    17.4 KB · Views: 122
How to patch DSDT for working battery status

Thank you RehabMan!

Actually turns out that the only 264 size(SDM0) did not turn up anywhere else.
The rest of the 16bit registers refer to the SCM (System Control Manager) device of the Laptop that controls Quick buttons on the laptop chassis (Turbo, Eject, Screen Toggle etc..) and I think that they have nothing to do with battery.
I then installed the battery Kext and it worked! So MSI GT60-220US (HM77 Ivy Bridge HD4000 + Optimus) does not need a battery DSDT patch after all.

However, after installing your kext Mavericks fails to Wake from sleep only when on battery power!
When on AC waking is flawless...
(Do you think I should patch the SCM registers after all?)

I attach my DSDT for your convenience (perhaps its the DSDT's fault ?)
One more thing I should mention is that when USB3.0 WLAN Stick is in use the system also fails to sleep.
I suspect that it has to do with USB powermanagement Specs in the patched EHC and XHC devices DSM sections.
When I remove all DSMs the system sleeps and AUTO-wakes up in seconds.

Thanks

If there are multi-byte EC registers accessed from other methods and those methods are called by OS X, it would cause issues (the methods will abort as soon as the registers are accessed).

I don't have a RAR reader handy, so can't really look at your DSDT. Best to upload in a universal format like ZIP.

It is common to have sleep issues with USB WiFi. Best to use a supported internal card instead.
 
How to patch DSDT for working battery status

That points to a separate issue. Probably a problem with your kernel cache. Post ioreg: http://www.tonymacx86.com/audio/58368-guide-how-make-copy-ioreg.html You should also repair permissions (Disk Utility) & rebuild cache (DPCIManager) noting any errors.

Also, double check all your changes to the DSDT.

Note: FLD3 is still being accessed directly. There is a reason I rename all multi-byte EC registers...


hi rehabman, thanks for the reply. i have noted on the the FLD3 and rename the registers which are used by the EC and are multi-byte. i have a question though, coz i'm not sure how to go about this.

on the method below
Code:
Method (_BIF, 0, NotSerialized)

i found an execution for the following SMWR and SMRD
Code:
^^PCI0.LPCB.EC0.SMWR (0x08, 0x14, One, Local2)
^^PCI0.LPCB.EC0.SMRD (0x09, 0x14, One, RefOf (Local3))

under SMRD another method is executed named "GBFE" and "PBFE" which uses a register named "TIDX" and a 32-bit register.
i know how to break down the 32-bit register into 4 8-bit registers.

i can break it down to the following:
Code:
IDX0,   8,
IDX1,   8,
IDX2,   8,
IDX3,   8,

the one i'm confused is on how to patch the code below, since a write process to a register
Code:
CreateByteField (Arg0, Arg1, TIDX)

i tried to apply the patch as
Code:
CreateByteField (Arg0, Arg1, IDX0)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX1)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX2)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX3)
in replace to the previous code above - but generates an error upon compiling... the syntax was also "CreateByteField". but the patch I commonly notice is for "Store".

any idea on this?

best regards,

#james

PS: by the my I have generated ioreg as attached.
 

Attachments

  • Gener8HackbookPro.ioreg
    2.5 MB · Views: 124
How to patch DSDT for working battery status

Thanx for answering.
If there are multi-byte EC registers accessed from other methods and those methods are called by OS X, it would cause issues (the methods will abort as soon as the registers are accessed).
Since the hang occurs after installing your Kext and only on battery power I thought you would want to have a look at my DSDT. Perhaps it will help you improve your Kext.
As for the other registers, I will definitely have to improve my DSDT by creating a patch for these too and report back...

I don't have a RAR reader handy, so can't really look at your DSDT.
Here is a free opensource RAR unpacker in case it becomes handy.

http://sourceforge.net/projects/rarexpander/files/RAR Expander/0.8.4/rar_expander_v084.dmg/download

Best to upload in a universal format like ZIP.
You will find my DSDT attached in the universal ZIP format.


It is common to have sleep issues with USB WiFi. Best to use a supported internal card instead.
Thank you for the advice
 

Attachments

  • DSDT.zip
    19.1 KB · Views: 100
How to patch DSDT for working battery status

That points to a separate issue. Probably a problem with your kernel cache. Post ioreg: http://www.tonymacx86.com/audio/58368-guide-how-make-copy-ioreg.html You should also repair permissions (Disk Utility) & rebuild cache (DPCIManager) noting any errors.

Hi rehabman, after doing some permission repair and rebuild cache as suggested did the job. thanks for the tips.
hopefully it will be enough for me to migrate to 10.9 mavericks. LAN and sleep may be my next section to work on.

maybe you have idea for a 64-bit kext for Realtek 10EC:8136 (RTL8101E/RTL8102E) - searched for quite a while and yet can't find a compatible one.

best regards and thanks for the help!

#james
 
How to patch DSDT for working battery status

hi rehabman, thanks for the reply. i have noted on the the FLD3 and rename the registers which are used by the EC and are multi-byte. i have a question though, coz i'm not sure how to go about this.

on the method below
Code:
Method (_BIF, 0, NotSerialized)

i found an execution for the following SMWR and SMRD
Code:
^^PCI0.LPCB.EC0.SMWR (0x08, 0x14, One, Local2)
^^PCI0.LPCB.EC0.SMRD (0x09, 0x14, One, RefOf (Local3))

under SMRD another method is executed named "GBFE" and "PBFE" which uses a register named "TIDX" and a 32-bit register.
i know how to break down the 32-bit register into 4 8-bit registers.

i can break it down to the following:
Code:
IDX0,   8,
IDX1,   8,
IDX2,   8,
IDX3,   8,

the one i'm confused is on how to patch the code below, since a write process to a register
Code:
CreateByteField (Arg0, Arg1, TIDX)

i tried to apply the patch as
Code:
CreateByteField (Arg0, Arg1, IDX0)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX1)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX2)
CreateByteField (ShiftRight(Arg0, Arg1,8), IDX3)
in replace to the previous code above - but generates an error upon compiling... the syntax was also "CreateByteField". but the patch I commonly notice is for "Store".

any idea on this?

best regards,

#james

PS: by the my I have generated ioreg as attached.

TIDX is in SystemMemory, not EmbeddedControl:
Code:
            OperationRegion (IGDM, SystemMemory, ASLB, 0x2000)
            Field (IGDM, AnyAcc, NoLock, Preserve)
            {
...
                TIDX,   32,

You don't need to touch it.

As far as QE/CI, in this ioreg, it is active and working. Although I can see a few more things:

- you're not using the latest ACPIBatteryManager
- you have not implemented power management correctly (NullCPUPowerManagement is loaded)
 
How to patch DSDT for working battery status

Thank you RehabMan!

Actually turns out that the only 264 size(SDM0) did not turn up anywhere else.
The rest of the 16bit registers refer to the SCM (System Control Manager) device of the Laptop that controls Quick buttons on the laptop chassis (Turbo, Eject, Screen Toggle etc..) and I think that they have nothing to do with battery.
I then installed the battery Kext and it worked! So MSI GT60-220US (HM77 Ivy Bridge HD4000 + Optimus) does not need a battery DSDT patch after all.

I think these 16-bit registers are inconsequential. They are accessed only from methods that are never called.

However, after installing your kext Mavericks fails to Wake from sleep only when on battery power!
When on AC waking is flawless...
(Do you think I should patch the SCM registers after all?)

I think this is probably an issue with your DSDT _WAK method. I notice you don't have the "Fix _WAK Arg0 v2" patch applied. See the patch in my repo for more information.
 

Attachments

  • IOCopy.ioreg
    4.2 MB · Views: 96
Back
Top