Contribute
Register

[Guide] How to patch DSDT for working battery status

Added the patch to github. Please test from repo. Thanks!

I've tested the patch from the repo, and am happy to see it works perfectly!

Now to move on to trying to find decent documentation/tutorials on how to write kexts and drivers for macOS, so I can try to finally have a working trackpad...

But that's a project for a different thread :p (Though if you have any suggestions on where to start I'd appreciate it)
 
Sir, thanks for your work very much. I followed this post and found out all the codes that could be patch in my dsdt.dsl.I have restarted my computer again and again, expecting to see the miracle can happen,but the battery status still not . In other words, nothing happened after each my fix.I really do not know how to patch it.Is there any way to solve it please?

P.S. my patch code is:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;


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 GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
Note:there are two. errors that I fix it manually because I don't know how to write the RE.one of them is "Return (BET2)"which I change it to "Return(B1B2(\_SB.PCI0.LPCB.H_EC.T290,\_SB.PCI0.LPCB.H_EC.T291))", the other is "ECRD (RefOf (B2FC)) in "If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC)))) which I change it to "B1B2(FC90,FC91)".

Here are my configures:
 
Sir, thanks for your work very much. I followed this post and found out all the codes that could be patch in my dsdt.dsl.I have restarted my computer again and again, expecting to see the miracle can happen,but the battery status still not work. In other words, nothing happened after each my patch.I really do not know how to patch it.Is there any way to solve it please?
P.S. my patch code is:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;


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 GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
Note:there are two. errors that I fix it manually because I don't know how to write the RE.one of them is "Return (BET2)"which I change it to "Return(B1B2(\_SB.PCI0.LPCB.H_EC.T290,\_SB.PCI0.LPCB.H_EC.T291))", the other is "ECRD (RefOf (B2FC)) in "If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC)))) which I change it to "B1B2(FC90,FC91)".

Another, there is one come with 256 bit:SMD0 256,I patch it as follow:
Code:
into device label H_EC code_regex (SMD0,)\s+(256) replace_matched begin SMDX,%2,//%1%2 end;

into method label WE1B parent_label H_EC remove_entry;
into method label WECB parent_label H_EC remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
// Arg2 - value to write\n
{\n
    ShiftRight(Add(Arg1,7), 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;

and then I change "Store (SMD0, FB4)" to "WECB(0x1C,256, FB4)"

PS:The dsdt.aml I used is extract from Linux.Because I found the acpi extract from clover[F4] are little strange.
Sorry for my poor English!
Here are my configures:
 

Attachments

  • Problemreport.zip
    2.4 MB · Views: 105
Last edited:
Sir, thanks for your work very much. I followed this post and found out all the codes that could be patch in my dsdt.dsl.I have restarted my computer again and again, expecting to see the miracle can happen,but the battery status still not work. In other words, nothing happened after each my patch.I really do not know how to patch it.Is there any way to solve it please?
P.S. my patch code is:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;


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 GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
Note:there are two. errors that I fix it manually because I don't know how to write the RE.one of them is "Return (BET2)"which I change it to "Return(B1B2(\_SB.PCI0.LPCB.H_EC.T290,\_SB.PCI0.LPCB.H_EC.T291))", the other is "ECRD (RefOf (B2FC)) in "If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC)))) which I change it to "B1B2(FC90,FC91)".

Another, there is one come with 256 bit:SMD0 256,I patch it as follow:
Code:
into device label H_EC code_regex (SMD0,)\s+(256) replace_matched begin SMDX,%2,//%1%2 end;

into method label WE1B parent_label H_EC remove_entry;
into method label WECB parent_label H_EC remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
// Arg2 - value to write\n
{\n
    ShiftRight(Add(Arg1,7), 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;

and then I change "Store (SMD0, FB4)" to "WECB(0x1C,256, FB4)"

PS:The dsdt.aml I used is extract from Linux.Because I found the acpi extract from clover[F4] are little strange.
Sorry for my poor English!
Here are my configures:

Maybe one of the existing patches in the repo may be a match...
Note:
Code:
u430:battery Admin$ grep -l FB4 *.txt
battery_Lenovo-Ideapad-100.txt
battery_Lenovo-Ideapad-Y700.txt
battery_Lenovo-Yoga-13.txt
battery_Lenovo-Yoga-900-13ISK.txt
battery_Lenovo-Yoga-Pro2.txt
battery_Lenovo-Z50-70.txt
battery_Lenovo-y580.txt
 
Maybe one of the existing patches in the repo may be a match...
Note:
Code:
u430:battery Admin$ grep -l FB4 *.txt
battery_Lenovo-Ideapad-100.txt
battery_Lenovo-Ideapad-Y700.txt
battery_Lenovo-Yoga-13.txt
battery_Lenovo-Yoga-900-13ISK.txt
battery_Lenovo-Yoga-Pro2.txt
battery_Lenovo-Z50-70.txt
battery_Lenovo-y580.txt
Thank you for your reply, but unfortunately they are not working. I once again seriously checked and found a new field which I think maybe be patching:
Code:
OperationRegion (ECF2, SystemMemory, 0xBCE2CD98, 0x0100)
(ECF2, ByteAcc, Lock, Preserve)
{
...
}
so, just do it!However, in the process of repairing I encountered difficulties.I don't know how to fix this one which in ECF2:
Code:
If (LAnd (And (\_SB.PCI0.LPCB.H_EC.WKRS, 0x0400), LEqual (Arg0, 0x03))) {}
If you check the "dsdt.dsl" you will find that "WKRS" is a 16-bit field.I don't know how to change this field so it is broken into two peices!
I'm so sorry for my ignorance .Once again trouble you.
this is the new dsdt.aml(and dsdt.dsl) that I have fixed the most af it and just leave which I said above.
 

Attachments

  • DSDT.zip
    98.5 KB · Views: 88
Thank you for your reply, but unfortunately they are not working. I once again seriously checked and found a new field which I think maybe be patching:
Code:
OperationRegion (ECF2, SystemMemory, 0xBCE2CD98, 0x0100)
(ECF2, ByteAcc, Lock, Preserve)
{
...
}
so, just do it!However, in the process of repairing I encountered difficulties.I don't know how to fix this one which in ECF2:
Code:
If (LAnd (And (\_SB.PCI0.LPCB.H_EC.WKRS, 0x0400), LEqual (Arg0, 0x03))) {}
If you check the "dsdt.dsl" you will find that "WKRS" is a 16-bit field.I don't know how to change this field so it is broken into two peices!
I'm so sorry for my ignorance .Once again trouble you.
this is the new dsdt.aml(and dsdt.dsl) that I have fixed the most af it and just leave which I said above.

SystemMemory fields do not need patching. Only EmbeddedControl fields.
Please read the guide carefully.
 
SystemMemory fields do not need patching. Only EmbeddedControl fields.
Please read the guide carefully.
After trying many times, I thought if there were other places that needed to be patched. Maybe my computer is surprisingly different?But,now, after read your reply, I found that maybe my idea was wrong. I'm sorry about that. I spent a lot of time checking again. I put my steps and files out here. Hope you can help me to make my battery state to work.thanks!
First,I found all the field that need to be fixed in my dsdt.dsl,there are:
Code:
                Offset (0x18),
                SMD0,   256,

                Offset (0x60)
                B1CY,   16,


                Offset (0x98),
                B2RC,   16,
                B2FC,   16,
                B2CC,   16,

                Offset (0xAA),
                BET2,   16,

                Offset (0xB6),
                BAPV,   16,
                B1CC,   16,
                Offset (0xC2),
                BARC,   16,
                BADC,   16,
                BADV,   16,
                BAFC,   16,
                B1CR,   16,

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

And then,I change that field so it is broken into two peices:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;
into device label H_EC code_regex B1CR,\s+16, replace_matched begin CR90,8,CR91,8, end;

now I can replace the method:
Code:
into method label GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;
into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
into method label _BST code_regex \(B1CR, replaceall_matched begin (B1B2(CR90,CR91), end;
Note:there are two filed that not be matched, so you should fix it manually(sorry for my poor knowledge of RE):
Code:
Return (BET2)      =====> Return(B1B2(T290,T291))
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC))))      ======>
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (B1B2(FC90,FC91)), ECRD (RefOf (B1DC))))


To here, only lefts SMD0:
First:
Code:
into method label MHPF code_regex Store\s\(FB4,\sSMD0\) replaceall_matched begin WECB(0x1C,256,FB4) end;
into method label MHPF code_regex SMD0 replaceall_matched begin RECB(0x1C, 256) end; #this line must not ahead the last line

Now,I patch the methods RECB and WECB:
Code:
# utility methods to read/write buffers from/to EC
into method label RE1B parent_label EC0 remove_entry;
into method label RECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\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 EC0 remove_entry;
into method label WECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
// Arg2 - value to write\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;
Here I found that the methods(WECB&RECB) are not in the the EC device, in the case of this DSDT, named H_EC,So I moved them to EC device!
The above is the whole process of my patch!After did that,I found some changes,I stored them in the picture name "powerstatus",this picture is attacked below in "allfile.zip"
 

Attachments

  • allfile.zip
    1.8 MB · Views: 124
  • ioreg.zip
    498.6 KB · Views: 117
After trying many times, I thought if there were other places that needed to be patched. Maybe my computer is surprisingly different?But,now, after read your reply, I found that maybe my idea was wrong. I'm sorry about that. I spent a lot of time checking again. I put my steps and files out here. Hope you can help me to make my battery state to work.thanks!
First,I found all the field that need to be fixed in my dsdt.dsl,there are:
Code:
                Offset (0x18),
                SMD0,   256,

                Offset (0x60)
                B1CY,   16,


                Offset (0x98),
                B2RC,   16,
                B2FC,   16,
                B2CC,   16,

                Offset (0xAA),
                BET2,   16,

                Offset (0xB6),
                BAPV,   16,
                B1CC,   16,
                Offset (0xC2),
                BARC,   16,
                BADC,   16,
                BADV,   16,
                BAFC,   16,
                B1CR,   16,

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

And then,I change that field so it is broken into two peices:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;
into device label H_EC code_regex B1CR,\s+16, replace_matched begin CR90,8,CR91,8, end;

now I can replace the method:
Code:
into method label GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;
into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
into method label _BST code_regex \(B1CR, replaceall_matched begin (B1B2(CR90,CR91), end;
Note:there are two filed that not be matched, so you should fix it manually(sorry for my poor knowledge of RE):
Code:
Return (BET2)      =====> Return(B1B2(T290,T291))
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC))))      ======>
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (B1B2(FC90,FC91)), ECRD (RefOf (B1DC))))


To here, only lefts SMD0:
First:
Code:
into method label MHPF code_regex Store\s\(FB4,\sSMD0\) replaceall_matched begin WECB(0x1C,256,FB4) end;
into method label MHPF code_regex SMD0 replaceall_matched begin RECB(0x1C, 256) end; #this line must not ahead the last line

Now,I patch the methods RECB and WECB:
Code:
# utility methods to read/write buffers from/to EC
into method label RE1B parent_label EC0 remove_entry;
into method label RECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\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 EC0 remove_entry;
into method label WECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
// Arg2 - value to write\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;
Here I found that the methods(WECB&RECB) are not in the the EC device, in the case of this DSDT, named H_EC,So I moved them to EC device!
The above is the whole process of my patch!After did that,I found some changes,I stored them in the picture name "powerstatus",this picture is attacked below in "allfile.zip"

If you still have an issue (and expect help), you must provide "Problem Reporting" files as per post #1.
(no ioreg attached)
 
If you still have an issue (and expect help), you must provide "Problem Reporting" files as per post #1.
(no ioreg attached)
OK.thanks for your reply.
 
After trying many times, I thought if there were other places that needed to be patched. Maybe my computer is surprisingly different?But,now, after read your reply, I found that maybe my idea was wrong. I'm sorry about that. I spent a lot of time checking again. I put my steps and files out here. Hope you can help me to make my battery state to work.thanks!
First,I found all the field that need to be fixed in my dsdt.dsl,there are:
Code:
                Offset (0x18),
                SMD0,   256,

                Offset (0x60)
                B1CY,   16,


                Offset (0x98),
                B2RC,   16,
                B2FC,   16,
                B2CC,   16,

                Offset (0xAA),
                BET2,   16,

                Offset (0xB6),
                BAPV,   16,
                B1CC,   16,
                Offset (0xC2),
                BARC,   16,
                BADC,   16,
                BADV,   16,
                BAFC,   16,
                B1CR,   16,

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

And then,I change that field so it is broken into two peices:
Code:
into device label H_EC code_regex B1CY,\s+16, replace_matched begin CY90,8,CY91,8, end;
into device label H_EC code_regex B2RC,\s+16, replace_matched begin RC90,8,RC91,8, end;
into device label H_EC code_regex B2FC,\s+16, replace_matched begin FC90,8,FC91,8, end;
into device label H_EC code_regex B2CC,\s+16, replace_matched begin CC90,8,CC91,8, end;
into device label H_EC code_regex BET2,\s+16, replace_matched begin T290,8,T291,8, end;
into device label H_EC code_regex BAPV,\s+16, replace_matched begin PV90,8,PV91,8, end;
into device label H_EC code_regex B1CC,\s+16, replace_matched begin CC92,8,CC93,8, end;
into device label H_EC code_regex BARC,\s+16, replace_matched begin RC92,8,RC93,8, end;
into device label H_EC code_regex BADC,\s+16, replace_matched begin DC90,8,DC91,8, end;
into device label H_EC code_regex BADV,\s+16, replace_matched begin DV90,8,DV91,8, end;
into device label H_EC code_regex BAFC,\s+16, replace_matched begin FC92,8,FC93,8, end;
into device label H_EC code_regex B1CR,\s+16, replace_matched begin CR90,8,CR91,8, end;

now I can replace the method:
Code:
into method label GBID code_regex \(B1CY, replaceall_matched begin (B1B2(CY90,CY91), end;
into method label _BST code_regex \(ECRD\s\(RefOf\s\(B2RC\)\), replaceall_matched begin (B1B2(RC90,RC91), end;
into method label _BIF code_regex \(ECRD\s\(RefOf\s\(B2FC\)\), replaceall_matched begin (B1B2(FC90,FC91), end;
into method label PNOT code_regex \(B2CC, replaceall_matched begin (B1B2(CC90,CC91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B2CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC90,\\_SB.PCI0.LPCB.H_EC.CC91), end;
into method label _BST code_regex \(BAPV, replaceall_matched begin (B1B2(PV90,PV91), end;
into method label PNOT code_regex \\\_SB\.PCI0\.LPCB\.H\_EC\.ECRD\s\(RefOf\s\(\\\_SB\.PCI0\.LPCB\.H\_EC\.B1CC\)\), replaceall_matched begin B1B2(\\_SB.PCI0.LPCB.H_EC.CC92,\\_SB.PCI0.LPCB.H_EC.CC93), end;
into method label _BST code_regex \(BARC, replaceall_matched begin (B1B2(RC92,RC93), end;
into method label _BIF code_regex \(BADC, replaceall_matched begin (B1B2(DC90,DC91), end;
into method label _BIF code_regex \(BADV, replaceall_matched begin (B1B2(DV90,DV91), end;
into method label _BIF code_regex \(BAFC, replaceall_matched begin (B1B2(FC92,FC93), end;
into method label _BST code_regex \(B1CR, replaceall_matched begin (B1B2(CR90,CR91), end;
Note:there are two filed that not be matched, so you should fix it manually(sorry for my poor knowledge of RE):
Code:
Return (BET2)      =====> Return(B1B2(T290,T291))
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (RefOf (B2FC))), ECRD (RefOf (B1DC))))      ======>
If (LAnd (LAnd (ECRD (RefOf (B1DV)), ECRD (B1B2(FC90,FC91)), ECRD (RefOf (B1DC))))


To here, only lefts SMD0:
First:
Code:
into method label MHPF code_regex Store\s\(FB4,\sSMD0\) replaceall_matched begin WECB(0x1C,256,FB4) end;
into method label MHPF code_regex SMD0 replaceall_matched begin RECB(0x1C, 256) end; #this line must not ahead the last line

Now,I patch the methods RECB and WECB:
Code:
# utility methods to read/write buffers from/to EC
into method label RE1B parent_label EC0 remove_entry;
into method label RECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\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 EC0 remove_entry;
into method label WECB parent_label EC0 remove_entry;
into device label H_EC 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
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
// Arg2 - value to write\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;
Here I found that the methods(WECB&RECB) are not in the the EC device, in the case of this DSDT, named H_EC,So I moved them to EC device!
The above is the whole process of my patch!After did that,I found some changes,I stored them in the picture name "powerstatus",this picture is attacked below in "allfile.zip"

ACPIBatteryManager.kext does not seem to be installed.
It is not optional.
 
Back
Top