Contribute
Register

[Guide] How to patch DSDT for working battery status

How to patch DSDT for working battery status

Sorry for disturb again.

I meet new problems in other DSDT.

1.
HTML:
Or (BATD, 0xC0, BATD)
BATD is 16 bit field, I have no idea to handle it. In your last reply, the third param of or(,,,) is a "write". I have no idea about it.

A mechanical transform:
Assuming BATD is split BTD0,BTD1, translate to:
Or(ShiftRight(B1B2(BTD0,BTD1),8), ShiftRight(0xC0,8), BTD1)
Or(B1B2(BTD0,BTD1), 0xC0, BTD0)

or:
Store(ShiftRight(Or(B1B2(BTD0,BTD1),0xC0),8), BTD1)
Store(Or(B1B2(BTD0,BTD1),0xC0), BTD0)

A bit smarter (because we know only BTD0 is being changed):
Or(BTD0, 0xC0, BTD0)

2.
I also have a question. You told me 16 bit write code in last reply. But when I meet a 32 bit write, how the code should be like?

32-bit write, assuming EC field XX broken as XX0,XX1,XX2,XX3:

From:
Store(Arg0, XX)

To:
Store(ShiftRight(Arg0,24), XX3)
Store(ShiftRight(Arg0,16), XX2)
Store(ShiftRight(Arg0,8), XX1)
Store(Arg0, XX0)
 
How to patch DSDT for working battery status

A mechanical transform:
Assuming BATD is split BTD0,BTD1, translate to:
Or(ShiftRight(B1B2(BTD0,BTD1),8), ShiftRight(0xC0,8), BTD1)
Or(B1B2(BTD0,BTD1), 0xC0, BTD0)

or:
Store(ShiftRight(Or(B1B2(BTD0,BTD1),0xC0),8), BTD1)
Store(Or(B1B2(BTD0,BTD1),0xC0), BTD0)

A bit smarter (because we know only BTD0 is being changed):
Or(BTD0, 0xC0, BTD0)



32-bit write, assuming EC field XX broken as XX0,XX1,XX2,XX3:

From:
Store(Arg0, XX)

To:
Store(ShiftRight(Arg0,24), XX3)
Store(ShiftRight(Arg0,16), XX2)
Store(ShiftRight(Arg0,8), XX1)
Store(Arg0, XX0)

Thanks, thanks, thanks again. :)

I just learn more from you. :)

:)

I have a last question. I am making battery patch for a new dsdt I download. And I haven 't seen dsdt just like it. (battery code part)

I have made a patch already. I need your help for checking it if correct, please.

Sorry for that I have asked you lots of things.

View attachment Help_Check_Dell_N5110_Battery.zip
 
How to patch DSDT for working battery status

Thanks, thanks, thanks again. :)

I just learn more from you. :)

:)

I have a last question. I am making battery patch for a new dsdt I download. And I haven 't seen dsdt just like it. (battery code part)

I have made a patch already. I need your help for checking it if correct, please.

Sorry for that I have asked you lots of things.

View attachment 96886

Only fields in EC need patching. No need to change CreateWordField...
 
How to patch DSDT for working battery status

Hi
Just for checking, this is my entire BAT0 dsdt section

Is ok the debug methods call implementation?

PHP:
Device (BAT0)
        {
            Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_PCL, Package (0x01)  // _PCL: Power Consumer List
            {
                _SB
            })
            Name (BFCC, Zero)
            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                If (^^PCI0.LPCB.EC.ECOK)
                {
                    If (^^PCI0.LPCB.EC.BAT0)
                    {
                        Return (0x1F)
                    }
                    Else
                    {
                        Return (0x0F)
                    }
                }
                Else
                {
                    Return (0x0F)
                }
            }


            Name (PBIF, Package (0x0D)
            {
                One, 
                0xFFFFFFFF, 
                0xFFFFFFFF, 
                One, 
                0x39D0, 
                Zero, 
                Zero, 
                0x40, 
                0x40, 
                "BAT", 
                "0001", 
                "LION", 
                "NOTEBOOK"
            })
            Method (IVBI, 0, NotSerialized)
            {
                Store (0xFFFFFFFF, Index (PBIF, One))
                Store (0xFFFFFFFF, Index (PBIF, 0x02))
                Store (0xFFFFFFFF, Index (PBIF, 0x04))
                Store (" ", Index (PBIF, 0x09))
                Store (" ", Index (PBIF, 0x0A))
                Store (" ", Index (PBIF, 0x0B))
                Store (" ", Index (PBIF, 0x0C))
                Store (Zero, BFCC)
            }


            Method (UPBI, 0, NotSerialized)
            {
                If (^^PCI0.LPCB.EC.BAT0)
                {
                    And (B1B4 (^^PCI0.LPCB.EC.DC00, ^^PCI0.LPCB.EC.DC01, ^^PCI0.LPCB.EC.DC02, ^^PCI0.LPCB.EC.DC03), 0xFFFF, Local0)
                    Store (Local0, Index (PBIF, One))
                    And (B1B4 (^^PCI0.LPCB.EC.FC00, ^^PCI0.LPCB.EC.FC01, ^^PCI0.LPCB.EC.FC02, ^^PCI0.LPCB.EC.FC03), 0xFFFF, Local0)
                    Store (Local0, Index (PBIF, 0x02))
                    Store (Local0, BFCC)
                    And (B1B4 (^^PCI0.LPCB.EC.DV00, ^^PCI0.LPCB.EC.DV01, ^^PCI0.LPCB.EC.DV02, ^^PCI0.LPCB.EC.DV03), 0xFFFF, Local0)
                    Store (Local0, Index (PBIF, 0x04))
                    And (B1B4 (^^PCI0.LPCB.EC.CW00, ^^PCI0.LPCB.EC.CW01, ^^PCI0.LPCB.EC.CW02, ^^PCI0.LPCB.EC.CW03), 0xFFFF, Local0)
                    Store (Local0, Index (PBIF, 0x05))
                    And (B1B4 (^^PCI0.LPCB.EC.CL00, ^^PCI0.LPCB.EC.CL01, ^^PCI0.LPCB.EC.CL02, ^^PCI0.LPCB.EC.CL03), 0xFFFF, Local0)
                    Store (Local0, Index (PBIF, 0x06))
                    Store ("BAT", Index (PBIF, 0x09))
                    Store ("0001", Index (PBIF, 0x0A))
                    Store ("LION", Index (PBIF, 0x0B))
                    Store ("NOTEBOOK", Index (PBIF, 0x0C))
                }
                Else
                {
                    IVBI ()
                }
            }


            Method (_BIF, 0, NotSerialized)  // _BIF: Battery Information
            {
                If (^^PCI0.LPCB.EC.ECOK)
                {
                    UPBI ()
                }
                Else
                {
                    IVBI ()
                }


                Return (PBIF)
            }


            Name (PBST, Package (0x04)
            {
                Zero, 
                0xFFFFFFFF, 
                0xFFFFFFFF, 
                0x3D90
            })
            Method (IVBS, 0, NotSerialized)
            {
                Store (Zero, Index (PBST, Zero))
                Store (0xFFFFFFFF, Index (PBST, One))
                Store (0xFFFFFFFF, Index (PBST, 0x02))
                Store (0x2710, Index (PBST, 0x03))
            }


            Method (UPBS, 0, NotSerialized)
            {
                \RMDT.P1 ("UPBS enter")
                If (^^PCI0.LPCB.EC.BAT0)
                {
                    \RMDT.P1 ("UPBS EC.BAT0 true")
                    Store (Zero, Local0)
                    Store (Zero, Local1)
                    If (^^PCI0.LPCB.EC.ADP)
                    {
                        \RMDT.P1 ("UPBS EC.ADP true")
                        If (LEqual (And (B1B4 (^^PCI0.LPCB.EC.ST00, ^^PCI0.LPCB.EC.ST01, ^^PCI0.LPCB.EC.ST02, ^^PCI0.LPCB.EC.ST03), 0x02), 
                            0x02))
                        {
                            Or (Local0, 0x02, Local0)
                            And (B1B4 (^^PCI0.LPCB.EC.PR00, ^^PCI0.LPCB.EC.PR01, ^^PCI0.LPCB.EC.PR02, ^^PCI0.LPCB.EC.PR03), 0xFFFF, Local1)
                        }
                    }
                    Else
                    {
                        \RMDT.P1 ("UPBS EC.ADP false")
                        Or (Local0, One, Local0)
                        And (B1B4 (^^PCI0.LPCB.EC.PR00, ^^PCI0.LPCB.EC.PR01, ^^PCI0.LPCB.EC.PR02, ^^PCI0.LPCB.EC.PR03), 0xFFFF, Local1)
                    }


                    And (Local1, 0x8000, Local7)
                    If (LEqual (Local7, 0x8000))
                    {
                        \RMDT.P3 ("Force store 0xFFFFFFFF due to Local7", Local7, Local1)
                        Store (0xFFFFFFFF, Local1)
                    }


                    And (B1B4 (^^PCI0.LPCB.EC.RC00, ^^PCI0.LPCB.EC.RC01, ^^PCI0.LPCB.EC.RC02, ^^PCI0.LPCB.EC.RC03), 0xFFFF, Local2)
                    And (B1B4 (^^PCI0.LPCB.EC.PV00, ^^PCI0.LPCB.EC.PV01, ^^PCI0.LPCB.EC.PV02, ^^PCI0.LPCB.EC.PV03), 0xFFFF, Local3)
                    Store (Local0, Index (PBST, Zero))
                    Store (Local1, Index (PBST, One))
                    Store (Local2, Index (PBST, 0x02))
                    Store (Local3, Index (PBST, 0x03))
                    If (LNotEqual (BFCC, B1B4 (^^PCI0.LPCB.EC.FC00, ^^PCI0.LPCB.EC.FC01, ^^PCI0.LPCB.EC.FC02, ^^PCI0.LPCB.EC.FC03)))
                    {
                        Notify (BAT0, 0x81)
                    }
                }
                Else
                {
                    \RMDT.P1 ("calling IVBS from UPBS!!")
                    IVBS ()
                }
            }


            Method (_BST, 0, NotSerialized)  // _BST: Battery Status
            {
                If (^^PCI0.LPCB.EC.ECOK)
                {
                    \RMDT.P1 ("calling UPBS from _BST")
                    UPBS ()
                }
                Else
                {
                    \RMDT.P1 ("calling IVBS from _BST")
                    IVBS ()
                }


                \RMDT.P2 ("_BST returns", PBST)
                Return (PBST)
            }
        }

I believe my problem is here

Name (PBIF, Package (0x0D)
{
One,
0x1130, (note: edited with my battery specs)
0x1130, (idem)
One,
0x2AF8, (idem)
Zero,
Zero,
0x40,
0x40,
"BAT",
"0001",
"LION",
"NOTEBOOK"
})

I think i should change de warning and low battery capacity from Zero to an "X" value but don't know well which value to use, i'm going in the right direction????

bye
 
How to patch DSDT for working battery status

Only fields in EC need patching. No need to change CreateWordField...

Yes, I know that. I try to find Field in EC. But I can't find EC in this dsdt. I try to search Device (H_EC) Device (EC0) Device (EC), but I can't find. Then, I try to search Device (BAT0), and it can be found.

Then, I find nothing in Device (BAT0), but in Methond (_BIF) and Methond (_BST). I find they call Method (ECG9) and Method (ECG6). Then, I see these CreateWordField (), I am not sure if I should change them. So, I ask for your help.
 
How to patch DSDT for working battery status

Hi
Just for checking, this is my entire BAT0 dsdt section

...

I think i should change de warning and low battery capacity from Zero to an "X" value but don't know well which value to use, i'm going in the right direction????

bye

Please use a code block for large code snippets. It would be helpful if you could go back and edit your prior posts with large code/log blocks. Also, filter your log results so as not to expose private items such as your email address, etc.

Did you ever insert the debug code requested previously?

I would try removing these lines from _BST. They don't make much sense:
Code:
                    And (Local1, 0x8000, Local7)
                    If (LEqual (Local7, 0x8000))
                    {
\rmdt.p3("Force store 0xFFFFFFFF due to Local7", Local7, Local1)
                        Store (0xFFFFFFFF, Local1)
                    }
 
How to patch DSDT for working battery status

Yes, I know that. I try to find Field in EC. But I can't find EC in this dsdt. I try to search Device (H_EC) Device (EC0) Device (EC), but I can't find. Then, I try to search Device (BAT0), and it can be found.

Then, I find nothing in Device (BAT0), but in Methond (_BIF) and Methond (_BST). I find they call Method (ECG9) and Method (ECG6). Then, I see these CreateWordField (), I am not sure if I should change them. So, I ask for your help.

Search for EmbeddedControl. If you find nothing, no need to patch any multibyte fields.
 
How to patch DSDT for working battery status

Search for EmbeddedControl. If you find nothing, no need to patch any multibyte fields.

Yes, I have searched EmbeddedControl at first time. But result is 0 .

So, for this dsdt, I need not to change it, then it can run battery status well?
 
How to patch DSDT for working battery status

Yes, I have searched EmbeddedControl at first time. But result is 0 .

So, for this dsdt, I need not to change it, then it can run battery status well?

It may need other patches (Mutex with non-zero SyncLeve), but none for multi-byte EC fields (since it doesn't use EC).
 
How to patch DSDT for working battery status

Please use a code block for large code snippets. It would be helpful if you could go back and edit your prior posts with large code/log blocks. Also, filter your log results so as not to expose private items such as your email address, etc.

Did you ever insert the debug code requested previously?

I would try removing these lines from _BST. They don't make much sense:
Code:
                    And (Local1, 0x8000, Local7)
                    If (LEqual (Local7, 0x8000))
                    {
\rmdt.p3("Force store 0xFFFFFFFF due to Local7", Local7, Local1)
                        Store (0xFFFFFFFF, Local1)
                    }

OK i'll do it all

And the section PBIF... should i edit it with my battery specs values??? or leave like it is now?


thanks
 
Back
Top