Contribute
Register

[Guide] How to patch DSDT for working battery status

How to patch DSDT for working battery status

TBPH I am pretty much lost after 16/32 bits instructions. I have zero programming skills (obv) and was shooting for a shortcut with the L1L4.

I also get a bunch of warnings unrelated to Battery.
Posting the native DSDT. I'd appreciate your input. Thanks!

View attachment 92997

Warnings do not matter. You can use "Fix *pnp/pnp lower case Error" to fix the two errors it has.
 
How to patch DSDT for working battery status

Hello, thanks for the guide.
I patched my DSDT like in your guide but it's still not working. I really have no idea why it's not working :(
Here is my patched DSDT:
View attachment 93115
And the ioreg
View attachment 93116

Could you please help me? Thanks :)

Use the debug ACPIBatteryManager.kext to determine which method is failing. Look in system.log for battery related logs.

Also, I can't do anything with a DSDT already patched. Post native DSDT plus the patches you created and applied.

In addition, your DSDT needs "Fix PNOT/PPNT" patch.
 

Attachments

  • compare_DSDTs.zip
    30.4 KB · Views: 76
  • battery_patch_Fujitsu_AH532_G21.txt.zip
    2.3 KB · Views: 169
How to patch DSDT for working battery status

hi Rehabman, thank you very much, with your guide I managed to patch my DSDT for Fujitsu AH532 G21 battery. I learned the registers , buffers, regex , adding methods, devices in dsdt with your guides
you are great
I am attaching file if anyone needs it. It works wery well

Great, but please post your native DSDT that corresponds to these patches.
 
How to patch DSDT for working battery status

Warnings do not matter. You can use "Fix *pnp/pnp lower case Error" to fix the two errors it has.

Thanks, the cosmetic stuff has been taken care of and I think I got the 16 bit stuff sorted, it is working to some extent anyway since I do have a working battery display since my first "false positive" post :oops:

I could really use some help with the 56 bit field though. I can't figure out how to correctly apply the info from post 1. I am pretty sure from reading this entire thread that what I have in the bolded part won't work...

Heres the patch I've got so far
Code:
#system_Mutex.txt (from repository)into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;


#fix_HID_pnp.txt (from repository)
into_all all code_regex (Name\s+\(_HID,\s+\")\*pnp(.*\") replaceall_matched begin %1PNP%2 end;
into_all all code_regex (Name\s+\(_HID,\s+\")pnp(.*\") replaceall_matched begin %1PNP%2 end; 


# 16-bit EC (fan related - copied from repository)
into device label EC0 code_regex ERIB,\s+16 replace_matched begin ERI0,8,ERI1,8 end;
into method label FANG code_regex Store\s+\(Arg0,\s+ERIB\) replace_matched 
begin
Store(ShiftRight(Arg0, 8), ERI1) Store(Arg0, ERI0)
end;
into method label FANW code_regex Store\s+\(Arg0,\s+ERIB\) replace_matched
begin
Store(ShiftRight(Arg0, 8), ERI1) Store(Arg0, ERI0)
end;


#16-bit EC
into device label EC0 code_regex BATM,\s+16, replace_matched begin ATM0,8,ATM1,8, end;
into device label EC0 code_regex BRC0,\s+16, replace_matched begin RC00,8,RC01,8, end;
into device label EC0 code_regex BSN0,\s+16, replace_matched begin SN00,8,SN01,8, end;
into device label EC0 code_regex BPV0,\s+16, replace_matched begin PV00,8,PV01,8, end;
into device label EC0 code_regex BDV0,\s+16, replace_matched begin DV00,8,DV01,8, end;
into device label EC0 code_regex BDC0,\s+16, replace_matched begin DC00,8,DC01,8, end;
into device label EC0 code_regex BFC0,\s+16, replace_matched begin FC00,8,FC01,8, end;
into device label EC0 code_regex BSCU,\s+16, replace_matched begin SCU0,8,SCU1,8, end;
into device label EC0 code_regex BAC0,\s+16, replace_matched begin AC00,8,AC01,8, end;
into device label EC0 code_regex BTMA,\s+16, replace_matched begin TMA0,8,TMA1,8, end;
into device label EC0 code_regex BTSS,\s+16, replace_matched begin TSS0,8,TSS1,8, end;
into device label EC0 code_regex BSC1,\s+16, replace_matched begin SC10,8,SC11,8, end;
into device label EC0 code_regex BSC2,\s+16, replace_matched begin SC20,8,SC21,8, end;
into device label EC0 code_regex BSC3,\s+16, replace_matched begin SC30,8,SC31,8, end;
into device label EC0 code_regex BSC4,\s+16, replace_matched begin SC40,8,SC41,8, end;
into device label EC0 code_regex BDME,\s+16, replace_matched begin DME0,8,DME1,8, end;
into device label EC0 code_regex BSCS,\s+16, replace_matched begin SCS0,8,SCS1,8, end;
into device label EC0 code_regex BDAD,\s+16, replace_matched begin DAD0,8,DAD1,8, end;
into device label EC0 code_regex BACV,\s+16, replace_matched begin ACV0,8,ACV1,8, end;
into device label EC0 code_regex BDFC,\s+16 replace_matched begin DFC0,8,DFC1,8, end;


into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BATM, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.ATM0,\\_SB.PCI0.LPC0.EC0.ATM1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BRC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.RC00,\\_SB.PCI0.LPC0.EC0.RC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BSN0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.SN00,\\_SB.PCI0.LPC0.EC0.SN01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BPV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.PV00,\\_SB.PCI0.LPC0.EC0.PV01), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BPV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.PV00,\\_SB.PCI0.LPC0.EC0.PV01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DV00,\\_SB.PCI0.LPC0.EC0.DV01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DV00,\\_SB.PCI0.LPC0.EC0.DV01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DC00,\\_SB.PCI0.LPC0.EC0.DC01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DC00,\\_SB.PCI0.LPC0.EC0.DC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BSCU, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.SCU0,\\_SB.PCI0.LPC0.EC0.SCU1), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BAC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.AC00,\\_SB.PCI0.LPC0.EC0.AC01), end;
into method label Z00G code_regex \(Local1,\s+\\\_SB\.PCI0\.LPC0\.EC0\.BTMA\) replaceall_matched begin (Local1, B1B2(\\_SB.PCI0.LPC0.EC0.TMA0,\\_SB.PCI0.LPC0.EC0.TMA1)) end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDME, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DME0,\\_SB.PCI0.LPC0.EC0.DME1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDAD, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DAD0,\\_SB.PCI0.LPC0.EC0.DAD1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDFC, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DFC0,\\_SB.PCI0.LPC0.EC0.DFC1), end;


[B]#56-bit EC[/B]
[B]into device label EC0 code_regex (BATD,)\s+(56) replace_matched begin BATX,%2,//%1%2 end;[/B]
[B]into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BATD, replaceall_matched begin (\SB.PCI0.LPC0.EC0.RECB(0x19,56), end;[/B]


# utility methods to read/write buffers from/to EC


into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return(Or(Arg0, ShiftLeft(Arg1, 8))) }\n
end;


into method label B1B4 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B4, 4, NotSerialized)\n
{\n
    Store(Arg3, Local0)\n
    Or(Arg2, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
    Return(Local0)\n
}\n
end;


into method label RE1B parent_label EC01 remove_entry;
into method label RECB parent_label EC01 remove_entry;
into device label EC01 insert
begin
Method (RE1B, 1, NotSerialized)\n
{\n
    OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
    Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
    Return(BYTE)\n
}\n
Method (RECB, 2, Serialized)\n
{\n
    ShiftRight(Arg1, 3, Arg1)\n
    Name(TEMP, Buffer(Arg1) { })\n
    Add(Arg0, Arg1, Arg1)\n
    Store(0, Local0)\n
    While (LLess(Arg0, Arg1))\n
    {\n
        Store(RE1B(Arg0), Index(TEMP, Local0))\n
        Increment(Arg0)\n
        Increment(Local0)\n
    }\n
    Return(TEMP)\n
}\n
end;


into method label WE1B parent_label EC01 remove_entry;
into method label WECB parent_label EC01 remove_entry;
into device label EC01 insert
begin
Method (WE1B, 2, NotSerialized)\n
{\n
    OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
    Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
    Store(Arg1, BYTE)\n
}\n
Method (WECB, 3, Serialized)\n
{\n
    ShiftRight(Arg1, 3, Arg1)\n
    Name(TEMP, Buffer(Arg1) { })\n
    Store(Arg2, TEMP)\n
    Add(Arg0, Arg1, Arg1)\n
    Store(0, Local0)\n
    While (LLess(Arg0, Arg1))\n
    {\n
        WE1B(Arg0, DerefOf(Index(TEMP, Local0)))\n
        Increment(Arg0)\n
        Increment(Local0)\n
    }\n
}\n
end;


# Cosmetics (from sourceforge)
into device label _T_0 set_label begin T_0 end;
into device label _T_1 set_label begin T_1 end;
into device label _T_2 set_label begin T_2 end;
into device label _T_3 set_label begin T_3 end;
into device label _T_4 set_label begin T_4 end;
into device label _T_5 set_label begin T_5 end;
into device label _T_6 set_label begin T_6 end;
into device label _T_7 set_label begin T_7 end;
into device label _T_8 set_label begin T_8 end;
into device label _T_9 set_label begin T_9 end;
into_all all code_regex _T_0 replaceall_matched begin T_0 end;
into_all all code_regex _T_1 replaceall_matched begin T_1 end;
into_all all code_regex _T_2 replaceall_matched begin T_2 end;
into_all all code_regex _T_3 replaceall_matched begin T_3 end;
into_all all code_regex _T_4 replaceall_matched begin T_4 end;
into_all all code_regex _T_5 replaceall_matched begin T_5 end;
into_all all code_regex _T_6 replaceall_matched begin T_6 end;
into_all all code_regex _T_7 replaceall_matched begin T_7 end;
into_all all code_regex _T_8 replaceall_matched begin T_8 end;
into_all all code_regex _T_9 replaceall_matched begin T_9 end;
And here's some snippets from the original DSDT

Code:
OperationRegion (ERAM, EmbeddedControl, 0x00, 0xFF)
                    Field (ERAM, ByteAcc, Lock, Preserve)
                    {
                                Offset (0x08), 
                        BATM,   16, 
                                Offset (0x19), 
                        BATD,   56, 
                                Offset (0x60),

The only place BATD is referred to:

Code:
Method (_BIF, 0, NotSerialized)
                    {
                        If (ECOK ())
                        {
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDC0, Index (PBIF, 0x01))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BFC0, Index (PBIF, 0x02))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDV0, Index (PBIF, 0x04))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDC0, Local2)
                            Divide (Local2, 0x64, Local6, Local2)
                            Multiply (Local2, 0x05, Local3)
                            Store (Local3, Index (PBIF, 0x05))
                            Multiply (Local2, 0x03, Local4)
                            Store (Local4, Index (PBIF, 0x06))
                            Store (\_SB.PCI0.LPC0.EC0.BATD, Index (PBIF, 0x09))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BTMF, Local1)
                            Sleep (0x14)
                            If (LEqual (Local1, 0x01))
                            {
                                Store ("SANYO ", Index (PBIF, 0x0C))
                            }
                            Else
                            {
                                If (LEqual (Local1, 0x02))
                                {
                                    Store ("SONY ", Index (PBIF, 0x0C))
                                }
                                Else
                                {
                                    If (LEqual (Local1, 0x04))
                                    {
                                        Store ("PANASONIC ", Index (PBIF, 0x0C))
                                    }
                                    Else
                                    {
                                        If (LEqual (Local1, 0x03))
                                        {
                                            Store ("Simplo ", Index (PBIF, 0x0C))
                                        }
                                        Else
                                        {
                                            Store ("COMPAL ", Index (PBIF, 0x0C))
                                        }
                                    }
                                }
                            }
                        }


                        Return (PBIF)
                    }

I have tried as you can see, but I need some help please. Thanks in advance!
 
How to patch DSDT for working battery status

Thanks, the cosmetic stuff has been taken care of and I think I got the 16 bit stuff sorted, it is working to some extent anyway since I do have a working battery display since my first "false positive" post :oops:

I could really use some help with the 56 bit field though. I can't figure out how to correctly apply the info from post 1. I am pretty sure from reading this entire thread that what I have in the bolded part won't work...

Heres the patch I've got so far
Code:
#system_Mutex.txt (from repository)into_all all code_regex Mutex\s+\(([^,]*),\s+[^)]*\) replaceall_matched begin Mutex(%1, 0) end;


#fix_HID_pnp.txt (from repository)
into_all all code_regex (Name\s+\(_HID,\s+\")\*pnp(.*\") replaceall_matched begin %1PNP%2 end;
into_all all code_regex (Name\s+\(_HID,\s+\")pnp(.*\") replaceall_matched begin %1PNP%2 end; 


# 16-bit EC (fan related - copied from repository)
into device label EC0 code_regex ERIB,\s+16 replace_matched begin ERI0,8,ERI1,8 end;
into method label FANG code_regex Store\s+\(Arg0,\s+ERIB\) replace_matched 
begin
Store(ShiftRight(Arg0, 8), ERI1) Store(Arg0, ERI0)
end;
into method label FANW code_regex Store\s+\(Arg0,\s+ERIB\) replace_matched
begin
Store(ShiftRight(Arg0, 8), ERI1) Store(Arg0, ERI0)
end;


#16-bit EC
into device label EC0 code_regex BATM,\s+16, replace_matched begin ATM0,8,ATM1,8, end;
into device label EC0 code_regex BRC0,\s+16, replace_matched begin RC00,8,RC01,8, end;
into device label EC0 code_regex BSN0,\s+16, replace_matched begin SN00,8,SN01,8, end;
into device label EC0 code_regex BPV0,\s+16, replace_matched begin PV00,8,PV01,8, end;
into device label EC0 code_regex BDV0,\s+16, replace_matched begin DV00,8,DV01,8, end;
into device label EC0 code_regex BDC0,\s+16, replace_matched begin DC00,8,DC01,8, end;
into device label EC0 code_regex BFC0,\s+16, replace_matched begin FC00,8,FC01,8, end;
into device label EC0 code_regex BSCU,\s+16, replace_matched begin SCU0,8,SCU1,8, end;
into device label EC0 code_regex BAC0,\s+16, replace_matched begin AC00,8,AC01,8, end;
into device label EC0 code_regex BTMA,\s+16, replace_matched begin TMA0,8,TMA1,8, end;
into device label EC0 code_regex BTSS,\s+16, replace_matched begin TSS0,8,TSS1,8, end;
into device label EC0 code_regex BSC1,\s+16, replace_matched begin SC10,8,SC11,8, end;
into device label EC0 code_regex BSC2,\s+16, replace_matched begin SC20,8,SC21,8, end;
into device label EC0 code_regex BSC3,\s+16, replace_matched begin SC30,8,SC31,8, end;
into device label EC0 code_regex BSC4,\s+16, replace_matched begin SC40,8,SC41,8, end;
into device label EC0 code_regex BDME,\s+16, replace_matched begin DME0,8,DME1,8, end;
into device label EC0 code_regex BSCS,\s+16, replace_matched begin SCS0,8,SCS1,8, end;
into device label EC0 code_regex BDAD,\s+16, replace_matched begin DAD0,8,DAD1,8, end;
into device label EC0 code_regex BACV,\s+16, replace_matched begin ACV0,8,ACV1,8, end;
into device label EC0 code_regex BDFC,\s+16 replace_matched begin DFC0,8,DFC1,8, end;


into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BATM, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.ATM0,\\_SB.PCI0.LPC0.EC0.ATM1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BRC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.RC00,\\_SB.PCI0.LPC0.EC0.RC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BSN0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.SN00,\\_SB.PCI0.LPC0.EC0.SN01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BPV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.PV00,\\_SB.PCI0.LPC0.EC0.PV01), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BPV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.PV00,\\_SB.PCI0.LPC0.EC0.PV01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DV00,\\_SB.PCI0.LPC0.EC0.DV01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDV0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DV00,\\_SB.PCI0.LPC0.EC0.DV01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DC00,\\_SB.PCI0.LPC0.EC0.DC01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DC00,\\_SB.PCI0.LPC0.EC0.DC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BFC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.FC00,\\_SB.PCI0.LPC0.EC0.FC01), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BSCU, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.SCU0,\\_SB.PCI0.LPC0.EC0.SCU1), end;
into method label _BST code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BAC0, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.AC00,\\_SB.PCI0.LPC0.EC0.AC01), end;
into method label Z00G code_regex \(Local1,\s+\\\_SB\.PCI0\.LPC0\.EC0\.BTMA\) replaceall_matched begin (Local1, B1B2(\\_SB.PCI0.LPC0.EC0.TMA0,\\_SB.PCI0.LPC0.EC0.TMA1)) end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDME, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DME0,\\_SB.PCI0.LPC0.EC0.DME1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDAD, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DAD0,\\_SB.PCI0.LPC0.EC0.DAD1), end;
into method label Z00G code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BDFC, replaceall_matched begin (B1B2(\\_SB.PCI0.LPC0.EC0.DFC0,\\_SB.PCI0.LPC0.EC0.DFC1), end;


[B]#56-bit EC[/B]
[B]into device label EC0 code_regex (BATD,)\s+(56) replace_matched begin BATX,%2,//%1%2 end;[/B]
[B]into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BATD, replaceall_matched begin (\SB.PCI0.LPC0.EC0.RECB(0x19,56), end;[/B]


# utility methods to read/write buffers from/to EC


into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return(Or(Arg0, ShiftLeft(Arg1, 8))) }\n
end;


into method label B1B4 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B4, 4, NotSerialized)\n
{\n
    Store(Arg3, Local0)\n
    Or(Arg2, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
    Return(Local0)\n
}\n
end;


into method label RE1B parent_label EC01 remove_entry;
into method label RECB parent_label EC01 remove_entry;
into device label EC01 insert
begin
Method (RE1B, 1, NotSerialized)\n
{\n
    OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
    Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
    Return(BYTE)\n
}\n
Method (RECB, 2, Serialized)\n
{\n
    ShiftRight(Arg1, 3, Arg1)\n
    Name(TEMP, Buffer(Arg1) { })\n
    Add(Arg0, Arg1, Arg1)\n
    Store(0, Local0)\n
    While (LLess(Arg0, Arg1))\n
    {\n
        Store(RE1B(Arg0), Index(TEMP, Local0))\n
        Increment(Arg0)\n
        Increment(Local0)\n
    }\n
    Return(TEMP)\n
}\n
end;


into method label WE1B parent_label EC01 remove_entry;
into method label WECB parent_label EC01 remove_entry;
into device label EC01 insert
begin
Method (WE1B, 2, NotSerialized)\n
{\n
    OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
    Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
    Store(Arg1, BYTE)\n
}\n
Method (WECB, 3, Serialized)\n
{\n
    ShiftRight(Arg1, 3, Arg1)\n
    Name(TEMP, Buffer(Arg1) { })\n
    Store(Arg2, TEMP)\n
    Add(Arg0, Arg1, Arg1)\n
    Store(0, Local0)\n
    While (LLess(Arg0, Arg1))\n
    {\n
        WE1B(Arg0, DerefOf(Index(TEMP, Local0)))\n
        Increment(Arg0)\n
        Increment(Local0)\n
    }\n
}\n
end;


# Cosmetics (from sourceforge)
into device label _T_0 set_label begin T_0 end;
into device label _T_1 set_label begin T_1 end;
into device label _T_2 set_label begin T_2 end;
into device label _T_3 set_label begin T_3 end;
into device label _T_4 set_label begin T_4 end;
into device label _T_5 set_label begin T_5 end;
into device label _T_6 set_label begin T_6 end;
into device label _T_7 set_label begin T_7 end;
into device label _T_8 set_label begin T_8 end;
into device label _T_9 set_label begin T_9 end;
into_all all code_regex _T_0 replaceall_matched begin T_0 end;
into_all all code_regex _T_1 replaceall_matched begin T_1 end;
into_all all code_regex _T_2 replaceall_matched begin T_2 end;
into_all all code_regex _T_3 replaceall_matched begin T_3 end;
into_all all code_regex _T_4 replaceall_matched begin T_4 end;
into_all all code_regex _T_5 replaceall_matched begin T_5 end;
into_all all code_regex _T_6 replaceall_matched begin T_6 end;
into_all all code_regex _T_7 replaceall_matched begin T_7 end;
into_all all code_regex _T_8 replaceall_matched begin T_8 end;
into_all all code_regex _T_9 replaceall_matched begin T_9 end;
And here's some snippets from the original DSDT

Code:
OperationRegion (ERAM, EmbeddedControl, 0x00, 0xFF)
                    Field (ERAM, ByteAcc, Lock, Preserve)
                    {
                                Offset (0x08), 
                        BATM,   16, 
                                Offset (0x19), 
                        BATD,   56, 
                                Offset (0x60),

The only place BATD is referred to:

Code:
Method (_BIF, 0, NotSerialized)
                    {
                        If (ECOK ())
                        {
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDC0, Index (PBIF, 0x01))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BFC0, Index (PBIF, 0x02))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDV0, Index (PBIF, 0x04))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BDC0, Local2)
                            Divide (Local2, 0x64, Local6, Local2)
                            Multiply (Local2, 0x05, Local3)
                            Store (Local3, Index (PBIF, 0x05))
                            Multiply (Local2, 0x03, Local4)
                            Store (Local4, Index (PBIF, 0x06))
                            Store (\_SB.PCI0.LPC0.EC0.BATD, Index (PBIF, 0x09))
                            Sleep (0x14)
                            Store (\_SB.PCI0.LPC0.EC0.BTMF, Local1)
                            Sleep (0x14)
                            If (LEqual (Local1, 0x01))
                            {
                                Store ("SANYO ", Index (PBIF, 0x0C))
                            }
                            Else
                            {
                                If (LEqual (Local1, 0x02))
                                {
                                    Store ("SONY ", Index (PBIF, 0x0C))
                                }
                                Else
                                {
                                    If (LEqual (Local1, 0x04))
                                    {
                                        Store ("PANASONIC ", Index (PBIF, 0x0C))
                                    }
                                    Else
                                    {
                                        If (LEqual (Local1, 0x03))
                                        {
                                            Store ("Simplo ", Index (PBIF, 0x0C))
                                        }
                                        Else
                                        {
                                            Store ("COMPAL ", Index (PBIF, 0x0C))
                                        }
                                    }
                                }
                            }
                        }


                        Return (PBIF)
                    }

I have tried as you can see, but I need some help please. Thanks in advance!

It is close, but your EC device is named EC0 not EC01. So the insertions of RECB/RE1B need to go to EC0, not EC01.

I never bother with cleaning warnings...

And your patch for calling RECB should be:
Code:
into method label _BIF code_regex \(\\_SB\.PCI0\.LPC0\.EC0\.BATD, replaceall_matched begin (\\_SB.PCI0.LPC0.EC0.RECB(0x19,56), end;

You were just missing a the \\_ part. In a replace you must escape the backslash as backslash has special meaning. And the path is \_SB... not \SB... (leading underscore).
 
How to patch DSDT for working battery status

It is close, but your EC device is named EC0 not EC01. So the insertions of RECB/RE1B need to go to EC0, not EC01.

I never bother with cleaning warnings...

I am told I can be anal. Still I missed the redundant 1. Makes me somewhat happy that I was fairly close - it goes to show that the guide works even for someone completely lacking skills in this department. Anyhow. Thanks a million! Applied rebooted and working.

Here's the patch with the changes:

edit: to say that this specific machine works really well with OSX so far, and installing was fairly easy, just follow the guide. Not much trickier than doing it on my friends 4340s.
 

Attachments

  • Acer Aspire 5737Z.txt
    8.3 KB · Views: 119
How to patch DSDT for working battery status

I am told I can be anal. Still I missed the redundant 1. Makes me somewhat happy that I was fairly close - it goes to show that the guide works even for someone completely lacking skills in this department. Anyhow. Thanks a million! Applied rebooted and working.

Here's the patch with the changes:

edit: to say that this specific machine works really well with OSX so far, and installing was fairly easy, just follow the guide. Not much trickier than doing it on my friends 4340s.

Slightly modified/cleaned up version pushed to the repo... I did not include the Mutex patch since the DSDT you posted previously didn't need it. And I left the _T renames out.
 
How to patch DSDT for working battery status

Thanks a lot the ACPIBatteryManager.kext works right away after installing it with kext drop!!
 
Back
Top