Contribute
Register

[Guide] How to patch DSDT for working battery status

Ahhh, my bad. I corrected the Surface Pro 4 patch. I've also added RPM1 and RPM2 to the Gigabyte patch - On 10.10, it didn't make any difference I could detect, but interestingly, I get faster shutdown and restart times with them patched on El Cap.

Gigabyte patch looks ok now... Added to repo.

The SP4 patch though...another review, and found another problem.

This translation is incorrect:
Code:
                                Store (Local0, B1B2(BTP0,BTP1))

B1B2 cannot be the target of a write. It is for reads only.

That particular line must be broke into two stores:
Code:
                                Store (Local0, BTP0)
                                Store (ShiftRight(Local0,8), BTP1)
 
Gigabyte patch looks ok now... Added to repo.

The SP4 patch though...another review, and found another problem.

This translation is incorrect:
Code:
                                Store (Local0, B1B2(BTP0,BTP1))

B1B2 cannot be the target of a write. It is for reads only.

That particular line must be broke into two stores:
Code:
                                Store (Local0, BTP0)
                                Store (ShiftRight(Local0,8), BTP1)

Ok, the third time's the charm as they say. I've broken up the line as shown, but my method of formatting is a little clunky I think.
 

Attachments

  • SurfacePro4-batterypatch.zip
    43.8 KB · Views: 74
Ok, the third time's the charm as they say. I've broken up the line as shown, but my method of formatting is a little clunky I think.

Added the patch for SP4, but made a slight tweak...

New Store(Local0,B1TP) patch:
Code:
into_all method label _BTP code_regex Store\s+\(Local0,\s+B1TP\) replace_matched begin Store(Local0,BTP0) Store(ShiftRight(Local0,8),BTP1) end;

I never worry about formatting, and would rather search for the specific code sequence in this case...
 
Patch for Dell Vostro 3360

Hi RehabMan. Thank you for your superb guide!!
Without your guides many of us would be totally lost.

Here is a patch I created by modifying code from your guide. It works for Dell Vostro 3360.
It is right now working on my laptop. Would you take a look please.

Code:
# Battery Dell Vostro 3360


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

# 16-bit registers
into device label EC0 code_regex CTL1,\s+16 replace_matched begin DC00,8,DC01,8 end;
into device label EC0 code_regex FTAC,\s+16 replace_matched begin DC10,8,DC11,8 end;
into device label EC0 code_regex FSPD,\s+16 replace_matched begin FC00,8,FC01,8 end;
into device label EC0 code_regex CAP0,\s+16 replace_matched begin FC10,8,FC11,8 end;
into device label EC0 code_regex RCP0,\s+16 replace_matched begin DV00,8,DV01,8 end;
into device label EC0 code_regex VOT0,\s+16 replace_matched begin DV10,8,DV11,8 end;
into device label EC0 code_regex CRT0,\s+16 replace_matched begin PR00,8,PR01,8 end;
into device label EC0 code_regex BTM0,\s+16 replace_matched begin PR10,8,PR11,8 end;
into device label EC0 code_regex BST0,\s+16 replace_matched begin RC00,8,RC01,8 end;
into device label EC0 code_regex BRC0,\s+16 replace_matched begin RC10,8,RC11,8 end;
into device label EC0 code_regex FCP0,\s+16 replace_matched begin CC00,8,CC01,8 end;
into device label EC0 code_regex DCP0,\s+16 replace_matched begin CC10,8,CC11,8 end;
into device label EC0 code_regex DVT0,\s+16 replace_matched begin CV10,8,CV11,8 end;
into device label EC0 code_regex MER0,\s+16 replace_matched begin CV20,8,CV21,8 end;
into device label EC0 code_regex MFD0,\s+16 replace_matched begin CV30,8,CV31,8 end;
into device label EC0 code_regex BSN0,\s+16 replace_matched begin CV40,8,CV41,8 end;
into device label EC0 code_regex MAS0,\s+16 replace_matched begin CV50,8,CV51,8 end;
into device label EC0 code_regex CAP1,\s+16 replace_matched begin CV60,8,CV61,8 end;
into device label EC0 code_regex RCP1,\s+16 replace_matched begin CV70,8,CV71,8 end;
into device label EC0 code_regex VOT1,\s+16 replace_matched begin CV80,8,CV81,8 end;
into device label EC0 code_regex CRT1,\s+16 replace_matched begin PBA0,8,PBA1,8 end;
into device label EC0 code_regex BTM1,\s+16 replace_matched begin PBB0,8,PBB1,8 end;
into device label EC0 code_regex BST1,\s+16 replace_matched begin MD00,8,MD01,8 end;
into device label EC0 code_regex BRC1,\s+16 replace_matched begin MD10,8,MD11,8 end;
into device label EC0 code_regex FCP1,\s+16 replace_matched begin PV00,8,PV01,8 end;
into device label EC0 code_regex DCP1,\s+16 replace_matched begin PV10,8,PV11,8 end;
into device label EC0 code_regex DVT1,\s+16 replace_matched begin SN00,8,SN01,8 end;
into device label EC0 code_regex MER1,\s+16 replace_matched begin SN10,8,SN11,8 end;
into device label EC0 code_regex MFD1,\s+16 replace_matched begin BV00,8,BV01,8 end;
into device label EC0 code_regex BSN1,\s+16 replace_matched begin BV10,8,BV11,8 end;
into device label EC0 code_regex MAS1,\s+16 replace_matched begin RG00,8,RG01,8 end;


# fix 16-bit methods
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.DCP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CC10,^^PCI0.LPCB.EC0.CC11)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.FCP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CC00,^^PCI0.LPCB.EC0.CC01)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.DVT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CV10,^^PCI0.LPCB.EC0.CV11)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.BSN0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CV40,^^PCI0.LPCB.EC0.CV41)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.CAP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.FC10,^^PCI0.LPCB.EC0.FC11)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.VOT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.DV10,^^PCI0.LPCB.EC0.DV11)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.CRT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.PR00,^^PCI0.LPCB.EC0.PR01)) end;

Thanks.

DSDT without patches is attached as Clean compile.
DSDT with patches is attached Patched battery
View attachment Patched Battery.zip
 

Attachments

  • Clean Conpile DSDT.zip
    34.8 KB · Views: 79
Hi RehabMan. Thank you for your superb guide!!
Without your guides many of us would be totally lost.

Here is a patch I created by modifying code from your guide. It works for Dell Vostro 3360.
It is right now working on my laptop. Would you take a look please.

Code:
# Battery Dell Vostro 3360


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

# 16-bit registers
into device label EC0 code_regex CTL1,\s+16 replace_matched begin DC00,8,DC01,8 end;
into device label EC0 code_regex FTAC,\s+16 replace_matched begin DC10,8,DC11,8 end;
into device label EC0 code_regex FSPD,\s+16 replace_matched begin FC00,8,FC01,8 end;
into device label EC0 code_regex CAP0,\s+16 replace_matched begin FC10,8,FC11,8 end;
into device label EC0 code_regex RCP0,\s+16 replace_matched begin DV00,8,DV01,8 end;
into device label EC0 code_regex VOT0,\s+16 replace_matched begin DV10,8,DV11,8 end;
into device label EC0 code_regex CRT0,\s+16 replace_matched begin PR00,8,PR01,8 end;
into device label EC0 code_regex BTM0,\s+16 replace_matched begin PR10,8,PR11,8 end;
into device label EC0 code_regex BST0,\s+16 replace_matched begin RC00,8,RC01,8 end;
into device label EC0 code_regex BRC0,\s+16 replace_matched begin RC10,8,RC11,8 end;
into device label EC0 code_regex FCP0,\s+16 replace_matched begin CC00,8,CC01,8 end;
into device label EC0 code_regex DCP0,\s+16 replace_matched begin CC10,8,CC11,8 end;
into device label EC0 code_regex DVT0,\s+16 replace_matched begin CV10,8,CV11,8 end;
into device label EC0 code_regex MER0,\s+16 replace_matched begin CV20,8,CV21,8 end;
into device label EC0 code_regex MFD0,\s+16 replace_matched begin CV30,8,CV31,8 end;
into device label EC0 code_regex BSN0,\s+16 replace_matched begin CV40,8,CV41,8 end;
into device label EC0 code_regex MAS0,\s+16 replace_matched begin CV50,8,CV51,8 end;
into device label EC0 code_regex CAP1,\s+16 replace_matched begin CV60,8,CV61,8 end;
into device label EC0 code_regex RCP1,\s+16 replace_matched begin CV70,8,CV71,8 end;
into device label EC0 code_regex VOT1,\s+16 replace_matched begin CV80,8,CV81,8 end;
into device label EC0 code_regex CRT1,\s+16 replace_matched begin PBA0,8,PBA1,8 end;
into device label EC0 code_regex BTM1,\s+16 replace_matched begin PBB0,8,PBB1,8 end;
into device label EC0 code_regex BST1,\s+16 replace_matched begin MD00,8,MD01,8 end;
into device label EC0 code_regex BRC1,\s+16 replace_matched begin MD10,8,MD11,8 end;
into device label EC0 code_regex FCP1,\s+16 replace_matched begin PV00,8,PV01,8 end;
into device label EC0 code_regex DCP1,\s+16 replace_matched begin PV10,8,PV11,8 end;
into device label EC0 code_regex DVT1,\s+16 replace_matched begin SN00,8,SN01,8 end;
into device label EC0 code_regex MER1,\s+16 replace_matched begin SN10,8,SN11,8 end;
into device label EC0 code_regex MFD1,\s+16 replace_matched begin BV00,8,BV01,8 end;
into device label EC0 code_regex BSN1,\s+16 replace_matched begin BV10,8,BV11,8 end;
into device label EC0 code_regex MAS1,\s+16 replace_matched begin RG00,8,RG01,8 end;


# fix 16-bit methods
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.DCP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CC10,^^PCI0.LPCB.EC0.CC11)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.FCP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CC00,^^PCI0.LPCB.EC0.CC01)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.DVT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CV10,^^PCI0.LPCB.EC0.CV11)) end;
into method label _BIF  code_regex \^\^PCI0.LPCB.EC0.BSN0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.CV40,^^PCI0.LPCB.EC0.CV41)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.CAP0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.FC10,^^PCI0.LPCB.EC0.FC11)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.VOT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.DV10,^^PCI0.LPCB.EC0.DV11)) end;
into method label  _BST code_regex \^\^PCI0.LPCB.EC0.CRT0 replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.PR00,^^PCI0.LPCB.EC0.PR01)) end;

Thanks.

DSDT without patches is attached as Clean compile.
DSDT with patches is attached Patched battery
View attachment 171515

Keep in mind fields that are not accessed do not need to be patched.

There is likely an existing patch in the repo already matching your DSDT.

Note:
Code:
SPEEDY-OSX:battery RehabMan$ grep -y vostro *.txt
battery_Dell-Inspiron-13z.txt:#  Dell Vostro 3750, per 459below
battery_Dell-Vostro-15xx.txt:#battery_Dell-Vostro-15xx.txt
battery_Dell-Vostro-15xx.txt:#  Dell Vostro 1510
battery_Dell-XPS-13.txt:#  Dell Vostro 5470 (per sonic1978)
battery_Dell-XPS-13.txt:#  Dell Vostro 3750 (per Moorre)

And also note:
Code:
SPEEDY-OSX:battery RehabMan$ grep -l EC0.*CAP0 *.txt
battery_Dell-Inspiron-13z.txt
battery_Dell-Studio-1558.txt
battery_Dell-XPS-13.txt
battery_Dell-XPS-L502x.txt
 
Keep in mind fields that are not accessed do not need to be patched.

There is likely an existing patch in the repo already matching your DSDT.

Note:
Code:
SPEEDY-OSX:battery RehabMan$ grep -y vostro *.txt
battery_Dell-Inspiron-13z.txt:#  Dell Vostro 3750, per 459below
battery_Dell-Vostro-15xx.txt:#battery_Dell-Vostro-15xx.txt
battery_Dell-Vostro-15xx.txt:#  Dell Vostro 1510
battery_Dell-XPS-13.txt:#  Dell Vostro 5470 (per sonic1978)
battery_Dell-XPS-13.txt:#  Dell Vostro 3750 (per Moorre)

And also note:
Code:
SPEEDY-OSX:battery RehabMan$ grep -l EC0.*CAP0 *.txt
battery_Dell-Inspiron-13z.txt
battery_Dell-Studio-1558.txt
battery_Dell-XPS-13.txt
battery_Dell-XPS-L502x.txt

Hi, yes I tried all those first which kind of work for my 3360.... Well I managed to get -414,800% battery trying the DSDT patches in the repo. I tried all Dell patches but the -% was the best I got which is why I came back and read your guide.
Even if I did miss one, good guide and I learned something

Cheers :thumbup:

Keep in mind fields that are not accessed do not need to be patched.
So if I had searched all 16bit registers a little more and identified those only apearing once in the DSDT, I could have omitted them from the patch?
 
Hi, yes I tried all those first which kind of work for my 3360....

The problem is your DSDT is not disassembled correctly. You forgot to use the "-dl" flag.
 
Hi Rehabman,

I am dropping by to say 'thanks' for the latest ACPIBatteryManager.kext. My battery is now showing in the status bar in El Capitan and Yosemite.

cheers!
 
The problem is your DSDT is not disassembled correctly. You forgot to use the "-dl" flag.

Oh wow, I wish there were a facepalm emoticon, this time the repo patch worked, but.
I disasembled again (-dl -da *.aml) still got the same disasembly warnings though. Same initial compilation error too.

Code:
    External (HBRT, MethodObj)    // Warning: Unresolved method, guessing 1 arguments
    External (HDOS, MethodObj)    // Warning: Unresolved method, guessing 0 arguments
    External (HNOT, MethodObj)    // Warning: Unresolved method, guessing 1 arguments
    External (IDAB, MethodObj)    // Warning: Unresolved method, guessing 0 arguments

I'm wondering what is the difference if I get the same warnings and compilation (PARSEOP unexpected / unexpected end file) errors. What's going on that I cant see.
 
Greetings Rehabman!

First off, I'd like to thank you for all your guides.
I've gotten my Acer v3-571g working almost near perfect (brightness/battery only fixes left).

I followed the guide and looked at some other battery patches in the repo for a better understanding.

The patch seemed to nearly work using the kext provided in the original post.
The battery status doesn't appear at the top, only sometimes randomly extremely quickly.

I've attached a zip with my original DSDT and the patched DSDT including a text file with the patch I applied.

I seemed to only have a 256 bit fix (SMD0) because the other ones weren't accessed.

Thank you once again!
 

Attachments

  • Acer v3-571g Battery.zip
    49.5 KB · Views: 62
Back
Top