Contribute
Register

[Guide] How to patch DSDT for working battery status

Sorry, my fault.

Nothing wrong here regarding battery status. It is working. You're running Sierra. Sierra does not show the remaining time. It is a feature, courtesy of the folks in Cupertino.

P.S. This is not a correct topic for this but as all dumps are here maybe it's easier to ask here. Initially after booting sleep works well, but after some amount of time (maybe an hour or more) notebook doesn't power off completely entering sleep mode...

You did not implement power management.
 
My battery status is moving really slow down (100 to 99 in like 15 minutes, which I don't believe is fine). It also shows 0:25 minutes remaining. The battery icon is also red. I used the Asus N55SL which worked for me last time, I believe.

Terminal output:

Code:
Josips-MacBook-Pro:~ josip$ kextstat|grep -y acpiplat

   13    2 0xffffff7f82bb8000 0x66000    0x66000    com.apple.driver.AppleACPIPlatform (4.0) A29C7512-D3A8-3AED-9721-3A5FF1A32EB2 <12 11 7 6 5 4 3 1>

Josips-MacBook-Pro:~ josip$ kextstat|grep -y appleintelcpu

Josips-MacBook-Pro:~ josip$ kextstat|grep -y applelpc

  103    0 0xffffff7f825da000 0x3000     0x3000     com.apple.driver.AppleLPC (3.1) 32BDCF9F-0473-32D4-9DAE-F523EFB2D244 <92 12 5 4 3>

Josips-MacBook-Pro:~ josip$ sudo touch /System/Library/Extensions && sudo kextcache -u /

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext IntelBacklight.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Intel_HD_Graphics.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Broadcom_WiFi.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext CodecCommander.kext

kext-dev-mode allowing invalid signature -67030 0xFFFFFFFFFFFEFA2A for kext AppleHDAHardwareConfigDriver.kext

kext-dev-mode allowing invalid signature -67061 0xFFFFFFFFFFFEFA0B for kext AppleHDA.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBatteryManager.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBacklight.kext

Josips-MacBook-Pro:~ josip$
 

Attachments

  • Archive.zip
    2 MB · Views: 84
My battery status is moving really slow down (100 to 99 in like 15 minutes, which I don't believe is fine). It also shows 0:25 minutes remaining. The battery icon is also red. I used the Asus N55SL which worked for me last time, I believe.

Terminal output:

Code:
Josips-MacBook-Pro:~ josip$ kextstat|grep -y acpiplat

   13    2 0xffffff7f82bb8000 0x66000    0x66000    com.apple.driver.AppleACPIPlatform (4.0) A29C7512-D3A8-3AED-9721-3A5FF1A32EB2 <12 11 7 6 5 4 3 1>

Josips-MacBook-Pro:~ josip$ kextstat|grep -y appleintelcpu

Josips-MacBook-Pro:~ josip$ kextstat|grep -y applelpc

  103    0 0xffffff7f825da000 0x3000     0x3000     com.apple.driver.AppleLPC (3.1) 32BDCF9F-0473-32D4-9DAE-F523EFB2D244 <92 12 5 4 3>

Josips-MacBook-Pro:~ josip$ sudo touch /System/Library/Extensions && sudo kextcache -u /

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext IntelBacklight.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Intel_HD_Graphics.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Broadcom_WiFi.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext CodecCommander.kext

kext-dev-mode allowing invalid signature -67030 0xFFFFFFFFFFFEFA2A for kext AppleHDAHardwareConfigDriver.kext

kext-dev-mode allowing invalid signature -67061 0xFFFFFFFFFFFEFA0B for kext AppleHDA.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBatteryManager.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBacklight.kext

Josips-MacBook-Pro:~ josip$

There is evidence in your patched files that you used a buggy version of iasl (and you're affected by the bugs).
Build the "last known good" version of iasl as per ACPI patching guide and use that one instead (re-extract, re-patch).

(I will probably update the pre-built iasl soon)

Also, your previous mistakes probably put the EC into a bad state. Do an EC reset.
 
There is evidence in your patched files that you used a buggy version of iasl (and you're affected by the bugs).
Build the "last known good" version of iasl as per ACPI patching guide and use that one instead (re-extract, re-patch).

(I will probably update the pre-built iasl soon)

Also, your previous mistakes probably put the EC into a bad state. Do an EC reset.

I used the 6.1 version you provided on your Bitbucket, and I'm not sure what other version you mean and I read the #1 post from the APCI patching guide. Did you mean the 5.1 version, also from your Bitbucket?
 
I used the 6.1 version you provided on your Bitbucket, and I'm not sure what other version you mean and I read the #1 post from the APCI patching guide. Did you mean the 5.1 version, also from your Bitbucket?

There is instructions in the guide for building a specific version of iasl from source.
 
My iasl does not show an error there (that particular error has come and gone with iasl changes).
But the original patching of that code was indeed wrong.
But your proposal is also wrong. It is storing the MSB/LSB reversed.

Here is the correct diff:
Code:
diff --git a/battery/battery_Lenovo-Yoga-S1.txt b/battery/battery_Lenovo-Yoga-S1.txt
index 13a6465..a49c7f4 100644
--- a/battery/battery_Lenovo-Yoga-S1.txt
+++ b/battery/battery_Lenovo-Yoga-S1.txt
@@ -3,6 +3,7 @@

 # Created by stkov 2014-04-12
 # Modifications by akebono 2015-04-03
+# Fix for HWAK write by nayeweiyang 2017-01-12 (after corrections by RehabMan)

 # works for:
 #  Lenovo Yoga S1
@@ -87,9 +88,14 @@ into method label GBIF code_regex \(SBMN, replaceall_matched begin (RECB(0xA0, 1
 into method label GBIF code_regex Store\s\(B1B2\(BSN0 replace_matched begin /* Store (B1B2(BSN0 end;
 into method label GBIF code_regex Index\s\(Arg1,\s0x0C\)\) replace_matched begin Index (Arg1, 0x0C)) */ end;

-# Fix HWAK
+# Fix HWAK Read
 into device label EC0 code_regex HWAK,\s+16 replace_matched begin WAK0,8,WAK1,8 end;
-into method label _WAK code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
-into method label _L0F code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
-into method label BL0F code_regex \\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label _WAK code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label _L0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;
+into method label BL0F code_regex \(\\\_SB.PCI0.LPCB.EC0.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.WAK0,\\_SB.PCI0.LPCB.EC0.WAK1) end;

+# Fix HWAK Write
+into method label _WAK code_regex Store\s\(Local0,\s\\\_SB.PCI0.LPCB.EC0.HWAK\) replaceall_matched
+begin
+Store (Local0,\\_SB.PCI0.LPCB.EC0.WAK0) Store (ShiftRight(Local0,8),\\_SB.PCI0.LPCB.EC0.WAK1)
+end;
Thanks.You correct a new wrong.But in fact,I only correct the HWAK Read and Write.
 
There is instructions in the guide for building a specific version of iasl from source.

I built the source from "b9c6c2b" commit and extracted using that one. Also I did reset the EC, still nothing. Still screwed up. Shows 100% then randomly changes to 26% or something similar.

Also terminal output:
Code:
Josips-MacBook-Pro:~ josip$ kextstat|grep -y acpiplat

   13    2 0xffffff7f82bc5000 0x66000    0x66000    com.apple.driver.AppleACPIPlatform (4.0) A29C7512-D3A8-3AED-9721-3A5FF1A32EB2 <12 11 7 6 5 4 3 1>

Josips-MacBook-Pro:~ josip$ kextstat|grep -y appleintelcpu

Josips-MacBook-Pro:~ josip$ kextstat|grep -y applelpc

   82    0 0xffffff7f825da000 0x3000     0x3000     com.apple.driver.AppleLPC (3.1) 32BDCF9F-0473-32D4-9DAE-F523EFB2D244 <81 12 5 4 3>

Josips-MacBook-Pro:~ josip$ sudo touch /System/Library/Extensions && sudo kextcache -u /

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext IntelBacklight.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Intel_HD_Graphics.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Broadcom_WiFi.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext CodecCommander.kext

kext-dev-mode allowing invalid signature -67030 0xFFFFFFFFFFFEFA2A for kext AppleHDA.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBatteryManager.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBacklight.kext
 

Attachments

  • Archive.zip
    2 MB · Views: 107
I built the source from "b9c6c2b" commit and extracted using that one. Also I did reset the EC, still nothing. Still screwed up. Shows 100% then randomly changes to 26% or something similar.

Also terminal output:
Code:
Josips-MacBook-Pro:~ josip$ kextstat|grep -y acpiplat

   13    2 0xffffff7f82bc5000 0x66000    0x66000    com.apple.driver.AppleACPIPlatform (4.0) A29C7512-D3A8-3AED-9721-3A5FF1A32EB2 <12 11 7 6 5 4 3 1>

Josips-MacBook-Pro:~ josip$ kextstat|grep -y appleintelcpu

Josips-MacBook-Pro:~ josip$ kextstat|grep -y applelpc

   82    0 0xffffff7f825da000 0x3000     0x3000     com.apple.driver.AppleLPC (3.1) 32BDCF9F-0473-32D4-9DAE-F523EFB2D244 <81 12 5 4 3>

Josips-MacBook-Pro:~ josip$ sudo touch /System/Library/Extensions && sudo kextcache -u /

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext IntelBacklight.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Intel_HD_Graphics.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Broadcom_WiFi.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext CodecCommander.kext

kext-dev-mode allowing invalid signature -67030 0xFFFFFFFFFFFEFA2A for kext AppleHDA.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBatteryManager.kext

kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBacklight.kext

It is still showing incorrect differences that don't happen when I disassemble. I think you're still using a different iasl:

For example, your code in ACPI/patched:
Code:
        Method (BCLE, 1, Serialized)
        {
            If (Arg0)
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB1S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
            ElseIf (ECAV ())
            {
                Store (Ones, Local0)
                Store (EB0S, Local1)
                And (Local1, 0xFFFF, Local1)
                If (LNotEqual (Local1, 0xFFFF))
                {
                    And (Local1, 0x16, Local1)
                    If (LEqual (Local1, 0x04))
                    {
                        Store (Zero, Local0)
                    }
                    ElseIf (LEqual (Local1, 0x02))
                    {
                        Store (One, Local0)
                    }
                    ElseIf (LEqual (Local1, 0x10))
                    {
                        Store (One, Local0)
                    }
                }
            }
            Else
            {
                Store (Ones, Local0)
            }
        }

And my disassembly of ACPI/origin:
Code:
        Method (BCLE, 1, Serialized)
        {
            If (Arg0)
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB1S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
            Else
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB0S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
        }
 
It is still showing incorrect differences that don't happen when I disassemble. I think you're still using a different iasl:

For example, your code in ACPI/patched:
Code:
        Method (BCLE, 1, Serialized)
        {
            If (Arg0)
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB1S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
            ElseIf (ECAV ())
            {
                Store (Ones, Local0)
                Store (EB0S, Local1)
                And (Local1, 0xFFFF, Local1)
                If (LNotEqual (Local1, 0xFFFF))
                {
                    And (Local1, 0x16, Local1)
                    If (LEqual (Local1, 0x04))
                    {
                        Store (Zero, Local0)
                    }
                    ElseIf (LEqual (Local1, 0x02))
                    {
                        Store (One, Local0)
                    }
                    ElseIf (LEqual (Local1, 0x10))
                    {
                        Store (One, Local0)
                    }
                }
            }
            Else
            {
                Store (Ones, Local0)
            }
        }

And my disassembly of ACPI/origin:
Code:
        Method (BCLE, 1, Serialized)
        {
            If (Arg0)
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB1S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
            Else
            {
                If (ECAV ())
                {
                    Store (Ones, Local0)
                    Store (EB0S, Local1)
                    And (Local1, 0xFFFF, Local1)
                    If (LNotEqual (Local1, 0xFFFF))
                    {
                        And (Local1, 0x16, Local1)
                        If (LEqual (Local1, 0x04))
                        {
                            Store (Zero, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x02))
                        {
                            Store (One, Local0)
                        }
                        ElseIf (LEqual (Local1, 0x10))
                        {
                            Store (One, Local0)
                        }
                    }
                }
                Else
                {
                    Store (Ones, Local0)
                }

                Return (Local0)
            }
        }

My iasl binary is 20161117-64(RM) version. Not sure from which commit should I build one then.
 
Back
Top