Contribute
Register

[Guide] How to patch DSDT for working battery status

Did all the things you mentioned, attaching new files.
Many, many thanks for your time!

You will need to install debug ACPIBatteryManager.kext to get debug kernel logs.
 
You will need to install debug ACPIBatteryManager.kext to get debug kernel logs.
Right now I can't even boot, so I think that might be a problem.
 
Off-topic.

Managed to boot, problem was:
XHCI -> XHC Hotpatch, showed me a lot of ACPI errors that made my system unbootable (Something related to _CPU0_ and PEG0...) I disabled the patch and those errors are gone.

Also disabled:
H_EC -> EC
EC0 -> EC

That way I'm not messing more than I should with battery stuff.

I've recorded a verbose boot using the slow-motion mode of an iPhone and I see some ACPI errors related to parsing the Battery section:

Example 1:

ACPI Error: Method parse/execution failed [\SB.PCI0.LPCB.EC0.BAT0._STA] (Node ffffff8047546780), AE_NOT_EXIST (20160930/psparse-632)
ACPI Error: No handler for Region [RAM_] (ffffff80476f80a0) [EmbeddedControl] (20160930/evregion-252)
ACPI Error: Region EmbeddedControl (ID=3) has no handler (20160930/exfldio-392)
[_STA] @00010 #002D: NB0A
No Local Variables are initialized for method [_STA]

No Arguments are initialized for method [_STA]

I can count 5 errors that display the same information as the example 1.

Maybe this is a problem?

I'm not sure, because my DSDT can be compiled without errors so, but there might be something wrong.

I'm attaching new files.

Thanks for your time!

EDIT:
ACPIBatteryManager kext installed is the Debug one you mentioned.
 
ACPI Error: Method parse/execution failed [\SB.PCI0.LPCB.EC0.BAT0._STA] (Node ffffff8047546780), AE_NOT_EXIST (20160930/psparse-632)
ACPI Error: No handler for Region [RAM_] (ffffff80476f80a0) [EmbeddedControl] (20160930/evregion-252)
ACPI Error: Region EmbeddedControl (ID=3) has no handler (20160930/exfldio-392)
[_STA] @00010 #002D: NB0A
No Local Variables are initialized for method [_STA]

No Arguments are initialized for method [_STA]

Your BAT0._STA is accessing the EC before the EC host is ready.
You should probably just hardcode _STA to return 0x1f.

Refer to ACPI spec for details.
 
Your BAT0._STA is accessing the EC before the EC host is ready.
You should probably just hardcode _STA to return 0x1f.

Refer to ACPI spec for details.

That fixed my battery display!
Is there any way I can submit a patch? If so, I’d gladly do it.
But I would need a bit of help in making my changes become a MaciASL patch
 
That fixed my battery display!
Is there any way I can submit a patch? If so, I’d gladly do it.
But I would need a bit of help in making my changes become a MaciASL patch

Refer to examples in the repo.
Clue:
Code:
battery_HP-Envy-14.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_HP-ProBook-4x0s-G1.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_HP-ProBook-Generic.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_Lenovo-G50-70.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_Lenovo-Miix-720.txt:#RehabMan: fixing BAT0._STA logic bug
battery_Lenovo-Miix-720.txt:into method label _STA parent_label BAT0 code_regex ([\s\S]*) replace_matched
battery_Lenovo-X201.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Lenovo-X220.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Lenovo-X230i.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Partaker_G3.txt:into method label _STA parent_label BAT2 replace_content begin Return(0) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label BAT1 replace_content begin Return (0x1F) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label BAT2 replace_content begin Return (Zero) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label H_EC replace_content begin Return (0x0F) end;
battery_Sony-VAIO-SVE1511.txt:into method label _STA parent_label BAT0 code_regex \(\^\^PCI0\.LPCB\.EC0\.BATD, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.BTD0,^^PCI0.LPCB.EC0.BTD1), end;
battery_TabletKiosk-i575.txt:into method label _STA code_regex \(\^\^LPCB.EC0\.B1FC, replaceall_matched begin (B1B2(^^LPCB.EC0.IFC0,^^LPCB.EC0.IFC1), end; 
battery_TabletKiosk-i575.txt:into method label _STA code_regex \(\^\^LPCB.EC0\.B2FC, replaceall_matched begin (B1B2(^^LPCB.EC0.ZFC0,^^LPCB.EC0.ZFC1), end;
battery_Vizio-Ultrabook-CT14.txt:into method label _STA parent_label BAT1 code_regex \(\^\^PCI0\.LPCB\.EC0\.DBAT, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.DBA0,^^PCI0.LPCB.EC0.DBA1), end;
 
Refer to examples in the repo.
Clue:
Code:
battery_HP-Envy-14.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_HP-ProBook-4x0s-G1.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_HP-ProBook-Generic.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_Lenovo-G50-70.txt:into method label _STA parent_label BAT1 replace_content begin Return (Zero) end;
battery_Lenovo-Miix-720.txt:#RehabMan: fixing BAT0._STA logic bug
battery_Lenovo-Miix-720.txt:into method label _STA parent_label BAT0 code_regex ([\s\S]*) replace_matched
battery_Lenovo-X201.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Lenovo-X220.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Lenovo-X230i.txt:into method label _STA parent_label BAT1 replace_content begin Return(0) end;
battery_Partaker_G3.txt:into method label _STA parent_label BAT2 replace_content begin Return(0) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label BAT1 replace_content begin Return (0x1F) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label BAT2 replace_content begin Return (Zero) end;
battery_Sony-VAIO-S.txt:into method label _STA parent_label H_EC replace_content begin Return (0x0F) end;
battery_Sony-VAIO-SVE1511.txt:into method label _STA parent_label BAT0 code_regex \(\^\^PCI0\.LPCB\.EC0\.BATD, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.BTD0,^^PCI0.LPCB.EC0.BTD1), end;
battery_TabletKiosk-i575.txt:into method label _STA code_regex \(\^\^LPCB.EC0\.B1FC, replaceall_matched begin (B1B2(^^LPCB.EC0.IFC0,^^LPCB.EC0.IFC1), end;
battery_TabletKiosk-i575.txt:into method label _STA code_regex \(\^\^LPCB.EC0\.B2FC, replaceall_matched begin (B1B2(^^LPCB.EC0.ZFC0,^^LPCB.EC0.ZFC1), end;
battery_Vizio-Ultrabook-CT14.txt:into method label _STA parent_label BAT1 code_regex \(\^\^PCI0\.LPCB\.EC0\.DBAT, replaceall_matched begin (B1B2(^^PCI0.LPCB.EC0.DBA0,^^PCI0.LPCB.EC0.DBA1), end;

After spending more than 6 hours, I've managed to make a working patch.
I've re-patched a vanilla DSDT using the patch I've made and it's working as it should.

I'm attaching it in txt format.

Thanks for your time!
 

Attachments

  • battery_HP-DV6-7010SS.txt
    10.4 KB · Views: 88
After spending more than 6 hours, I've managed to make a working patch.
I've re-patched a vanilla DSDT using the patch I've made and it's working as it should.

I'm attaching it in txt format.

Thanks for your time!

Read post #1, "Contributing" (native DSDT.aml is missing).
 
Back
Top