Contribute
Register

[solved] T450 DUAL Battery Status help

Status
Not open for further replies.
The problem is I don't know where to look. STA of BAT1 always returns 0xB for couple of times and then returns 0x1f whether it is single or double battery.

How long does it take for it to return a valid value?
(eg. check the time stamps of the "couple of times")

However with double battery some cold boots results in premature BIF calls which causes this error.

What do you mean by "premature _BIF" calls?
The battery kext only calls _BIF/_BST if _STA returns "battery present".
Code:
    fProvider->getBatterySTA();
    if (fBatteryPresent)
    {
        if (fUseBatteryExtendedInformation)
            fProvider->getBatteryBIX();
        else
            fProvider->getBatteryBIF();
        if (fUseBatteryExtraInformation)
            fProvider->getBatteryBBIX();
        fProvider->getBatteryBST();
    }
    else
    {
        //rehabman: added to correct power source Battery if boot w/ no batteries
        DebugLog("!fBatteryPresent\n");
        fACConnected = true;
        setExternalConnected(fACConnected);
        setFullyCharged(false);
        clearBatteryState(true);
    }

Note that SSDT-BATC.dsl will call _BST no matter what _STA returned. Same goes for _BIF...

Code:
            Method(_BST)
            {
...
                // gather battery data from BAT0
                Local0 = ^^BAT0._BST()
                Local2 = ^^BAT0._STA()

Code:
            Method(_BIF)
            {
...
                // gather and validate data from BAT0
                Local0 = ^^BAT0._BIF()
                Local2 = ^^BAT0._STA()
 
What do you mean by "premature _BIF" calls?
The battery kext only calls _BIF/_BST if _STA returns "battery present".

If you check the logs, you will see that even though both BAT1 and BAT2 is return 0xB, kext saying that STA is retuning 0x1F.
Code:
2017-02-20 14:55:38.498693+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: Version 0.1.4 starting on OS X Darwin 16.4.
2017-02-20 14:55:38.499704+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: setBatterySTA: battery_status = 0x1f
2017-02-20 14:55:38.499712+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: getBatteryBIF called
2017-02-20 14:55:38.499721+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: validateObject return 0x0
2017-02-20 14:55:38.499996+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: { "BAT1 STA BNUM", 0x0, }
2017-02-20 14:55:38.500248+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Return Disabled BAT1_STA" //BAT1 (1)
2017-02-20 14:55:38.500473+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Entering BAT2_STA"
2017-02-20 14:55:38.500710+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: { "BAT2 STA BNUM", 0x0, }
2017-02-20 14:55:38.501043+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Return Disabled BAT2_STA" //BAT2 (1)
You see kext is saying that
Code:
ACPIBatteryManager: setBatterySTA: battery_status = 0x1f

But both BAT1 and BAT2 STA is returning 0xB. Why ACPIBatteryManager is getting 0x1F even though both batteries says that they aren't ready yet? It shouldn't get 0x1F at all. Only reason I can think of is since ACPIBatteryManager loads previous than ACPIDebug so debug code isn't available. So somehow it somehow sets BNUM to 0x1 and then _STA returns 0x1F. Since ACPIDebug isn't loaded yet, I couldn't see that log. But it doesn't make sense. It is like it is reading somewhere from cache or something.

Final observation: I have finally found the reason. ACPIBatteryManager reads STA from NVRAM. Previous boot sets
Code:
fakesmc-key-BATP-flag =0x0
ACPIBatteryManager thinks that battery is present when it calls

fProvider->getBatterySTA();

However this is not true at all. If I delete fakesmc-key-BATP-flag key from nvram.plist. Shut down the laptop and wait little bit. When I cold boot, I get this log

Code:
2017-02-21 14:59:51.473508+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: getBatterySTA called
2017-02-21 14:59:51.473641+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: setBatterySTA: battery_status = 0xb
2017-02-21 14:59:51.473644+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: !fBatteryPresent
2017-02-21 14:59:51.473647+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: clearBatteryState: do_update = true

You see ACPIBatteryManager thinks that laptop doesn't have a battery and it does clearBatteryState with do_update=true So in couple of seconds I see battery bar with x icon then it correctly updates the bar. I have tried 5 times. Deleting the key and forcing the update fixes this problem. I think to fix this problem ACPIBatteryManager shouldn't read battery present from NVRAM or should clearBatteryState no matter what.

I think to key to this problem is BATP flag. In the meantime, how can I prevent ACPIBatteryManager or FakeSMC to set BATP flag? I want to remove that flag everytime I reboot my machine.
 
Last edited:
If you check the logs, you will see that even though both BAT1 and BAT2 is return 0xB, kext saying that STA is retuning 0x1F.
Code:
2017-02-20 14:55:38.498693+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: Version 0.1.4 starting on OS X Darwin 16.4.
2017-02-20 14:55:38.499704+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: setBatterySTA: battery_status = 0x1f
2017-02-20 14:55:38.499712+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: getBatteryBIF called
2017-02-20 14:55:38.499721+0300 0xa0       Default     0x0                  0      kernel: (ACPIBatteryManager) ACPIBatteryManager: validateObject return 0x0
2017-02-20 14:55:38.499996+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: { "BAT1 STA BNUM", 0x0, }
2017-02-20 14:55:38.500248+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Return Disabled BAT1_STA" //BAT1 (1)
2017-02-20 14:55:38.500473+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Entering BAT2_STA"
2017-02-20 14:55:38.500710+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: { "BAT2 STA BNUM", 0x0, }
2017-02-20 14:55:38.501043+0300 0xb3       Default     0x0                  0      kernel: (ACPIDebug) ACPIDebug: "Return Disabled BAT2_STA" //BAT2 (1)
You see kext is saying that
Code:
ACPIBatteryManager: setBatterySTA: battery_status = 0x1f

Yes... it is as per design. BATC._STA will return 0x1f if *either* of the battery objects return 0x1F.
 
I agree to disagree. None of the batteries are returning x1f. Neither BAT1 nor BAT2. You can check the logs if you want to check by yourself. Please check the log again. Since BATP is set 0 macOS doesn't bother to get STA from DSDT but gets from NVRAM. Which messes everything. Deleting BATP from NVRAM forces detection and it works again. I think under the hood it skips STA if it sees BATP set in NVRAM. Is it possible for your kext to get real STA from DSDT. Because your current method gets proxied I guess and gets value from NVRAM which is old value. For now I will use a script to delete BATP value from NVRAM with nvram -d but if you can fix it in the kext it could be better.
 
I agree to disagree. None of the batteries are returning x1f....

Code for BATC._STA:
Code:
            Method(_STA)
            {
                // call original _STA for BAT0 and BAT1
                // result is bitwise OR between them
                Return(^^BAT0._STA() | ^^BAT1._STA())
            }

Return is a bitwise OR between BAT0 and BAT1 _STA.
The only way for BATC to return 0x1f is if one of BAT0 or BAT1._STA returns 0x1f.
If both BAT0 and BAT1 _STA were returing 0x0F, result would be 0x0F.

Note: ACPIBatteryManager does nothing with NVRAM. It only uses ACPI to get battery status....

Note 2: Keep in mind you cannot rely on the relative order of ACPIDebug vs. ACPIBatteryManager logs. Logs created with RMDT calls are stored internally in ACPI at the time of the RMDT.PUSH and are written to to the kernel log *later* when ACPIDebug.kext gets a chance to retrieve them.
 
Last edited:
I have checked your kext and FakeSMC. Yes they don't have BATP reference. However something is setting this. When this key is present, STA returns 0x1f. However if this key is not present, battery first becomes disabled then after couple of seconds it becomes available. As you can see from my logs. I don't know the reason but I do know that deleting BATP key fixes my problem.
 
I have checked your kext and FakeSMC. Yes they don't have BATP reference. However something is setting this. When this key is present, STA returns 0x1f. However if this key is not present, battery first becomes disabled then after couple of seconds it becomes available. As you can see from my logs. I don't know the reason but I do know that deleting BATP key fixes my problem.

I think you are mis-interpreting the debug output from ACPIDebug.

(eg. bad assumption about relative order between ACPIDebug output and ACPIBatteryManager output).

Note also that your patched DSDT has changes made to _STA in both BAT1 and BAT2 (you removed the code checking BNUM).
Also, simulating Windows Vista ("Windows 2006") may not be the best choice.
 
Last edited:
Finally solved. No kext patch or nvram editing needed. It was because SSDT-BATC was not generic enough for every scenario. Basically I renamed BAT1 to BAT2 and BAT2 to BAT1 in SSDT-BATC so that battery disabling if clause came into effect. During first boot, if it can't detect batteries, battery icon turns into chargin state with 0 percentage. Then after 10-12 second later, battery manager kicks in and update the values. I am pasting my current DSDT file maybe you can add another if clause to handle my case as well.

Code:
DefinitionBlock ("", "SSDT", 2, "hack", "BATC", 0x00000000)
{
    External (_SB_.PCI0.LPCB.H_EC, DeviceObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._BIF, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._BST, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._HID, UnknownObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._STA, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._BIF, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._BST, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._HID, UnknownObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._STA, MethodObj)    // 0 Arguments (from opcode)
    External (BAT1, DeviceObj)    // (from opcode)
    External (BAT1._HID, StrObj)    // (from opcode)
    External (BAT2, DeviceObj)    // (from opcode)
    External (BAT2._HID, StrObj)    // (from opcode)

    Scope (_SB.PCI0.LPCB.H_EC)
    {
        Device (BATC)
        {
            Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
            Name (_UID, 0x02)  // _UID: Unique ID
            Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                Store (Zero, ^^BAT2._HID)
                Store (Zero, ^^BAT1._HID)
            }

            Method (CVWA, 3, NotSerialized)
            {
                If (Arg2)
                {
                    Divide (Multiply (Arg0, 0x03E8), Arg1, , Arg0)
                }

                Return (Arg0)
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Return (Or (^^BAT2._STA (), ^^BAT1._STA ()))
            }

            Name (B0CO, Zero)
            Name (B1CO, Zero)
            Name (B0DV, Zero)
            Name (B1DV, Zero)
            Method (_BST, 0, NotSerialized)  // _BST: Battery Status
            {
                Store (^^BAT2._BST (), Local0)
                Store (^^BAT2._STA (), Local2)
                If (LEqual (0x1F, Local2))
                {
                    Store (DerefOf (Index (Local0, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }
                }

                Store (^^BAT1._BST (), Local1)
                Store (^^BAT1._STA (), Local3)
                If (LEqual (0x1F, Local3))
                {
                    Store (DerefOf (Index (Local1, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }
                }

                If (LAnd (LNotEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (Local1, Local0)
                    Store (Local3, Local2)
                    Store (Zero, Local3)
                }

                If (LAnd (LEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (DerefOf (Index (Local0, Zero)), Local4)
                    Store (DerefOf (Index (Local1, Zero)), Local5)
                    If (LOr (LEqual (Local4, 0x02), LEqual (Local5, 0x02)))
                    {
                        Store (0x02, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, One), LEqual (Local5, One)))
                    {
                        Store (One, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, 0x05), LEqual (Local5, 0x05)))
                    {
                        Store (0x05, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, 0x04), LEqual (Local5, 0x04)))
                    {
                        Store (0x04, Index (Local0, Zero))
                    }

                    Add (CVWA (DerefOf (Index (Local0, One)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, One)), B1DV, B1CO), Index (Local0, One))
                    Add (CVWA (DerefOf (Index (Local0, 0x02)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x02)), B1DV, B1CO), Index (Local0, 0x02))
                    Divide (Add (DerefOf (Index (Local0, 0x03)), DerefOf (Index (Local1, 0x03))), 0x02, , Index (Local0, 0x03))
                }

                Return (Local0)
            }

            Method (_BIF, 0, NotSerialized)  // _BIF: Battery Information
            {
                Store (^^BAT2._BIF (), Local0)
                Store (^^BAT2._STA (), Local2)
                If (LEqual (0x1F, Local2))
                {
                    Store (DerefOf (Index (Local0, One)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }

                    Store (DerefOf (Index (Local0, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }

                    Store (DerefOf (Index (Local0, 0x04)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }
                }

                Store (^^BAT1._BIF (), Local1)
                Store (^^BAT1._STA (), Local3)
                If (LEqual (0x1F, Local3))
                {
                    Store (DerefOf (Index (Local1, One)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }

                    Store (DerefOf (Index (Local1, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }

                    Store (DerefOf (Index (Local1, 0x04)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }
                }

                If (LAnd (LNotEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (Local1, Local0)
                    Store (Local3, Local2)
                    Store (Zero, Local3)
                }

                If (LAnd (LEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (LNot (DerefOf (Index (Local0, Zero))), B0CO)
                    Store (LNot (DerefOf (Index (Local1, Zero))), B1CO)
                    Store (One, Index (Local0, Zero))
                    Store (DerefOf (Index (Local0, 0x04)), B0DV)
                    Store (DerefOf (Index (Local1, 0x04)), B1DV)
                    Add (CVWA (DerefOf (Index (Local0, One)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, One)), B1DV, B1CO), Index (Local0, One))
                    Add (CVWA (DerefOf (Index (Local0, 0x02)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x02)), B1DV, B1CO), Index (Local0, 0x02))
                    Divide (Add (B0DV, B1DV), 0x02, , Index (Local0, 0x04))
                    Add (CVWA (DerefOf (Index (Local0, 0x05)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x05)), B1DV, B1CO), Index (Local0, 0x05))
                    Add (CVWA (DerefOf (Index (Local0, 0x06)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x06)), B1DV, B1CO), Index (Local0, 0x06))
                }

                Return (Local0)
            }
        }
    }
}

Finally I can sleep after weeks. See you in next macOS release :)
 
Finally solved. No kext patch or nvram editing needed. It was because SSDT-BATC was not generic enough for every scenario. Basically I renamed BAT1 to BAT2 and BAT2 to BAT1 in SSDT-BATC so that battery disabling if clause came into effect. During first boot, if it can't detect batteries, battery icon turns into chargin state with 0 percentage. Then after 10-12 second later, battery manager kicks in and update the values. I am pasting my current DSDT file maybe you can add another if clause to handle my case as well.

Code:
DefinitionBlock ("", "SSDT", 2, "hack", "BATC", 0x00000000)
{
    External (_SB_.PCI0.LPCB.H_EC, DeviceObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._BIF, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._BST, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._HID, UnknownObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT1._STA, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._BIF, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._BST, MethodObj)    // 0 Arguments (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._HID, UnknownObj)    // (from opcode)
    External (_SB_.PCI0.LPCB.H_EC.BAT2._STA, MethodObj)    // 0 Arguments (from opcode)
    External (BAT1, DeviceObj)    // (from opcode)
    External (BAT1._HID, StrObj)    // (from opcode)
    External (BAT2, DeviceObj)    // (from opcode)
    External (BAT2._HID, StrObj)    // (from opcode)

    Scope (_SB.PCI0.LPCB.H_EC)
    {
        Device (BATC)
        {
            Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
            Name (_UID, 0x02)  // _UID: Unique ID
            Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                Store (Zero, ^^BAT2._HID)
                Store (Zero, ^^BAT1._HID)
            }

            Method (CVWA, 3, NotSerialized)
            {
                If (Arg2)
                {
                    Divide (Multiply (Arg0, 0x03E8), Arg1, , Arg0)
                }

                Return (Arg0)
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Return (Or (^^BAT2._STA (), ^^BAT1._STA ()))
            }

            Name (B0CO, Zero)
            Name (B1CO, Zero)
            Name (B0DV, Zero)
            Name (B1DV, Zero)
            Method (_BST, 0, NotSerialized)  // _BST: Battery Status
            {
                Store (^^BAT2._BST (), Local0)
                Store (^^BAT2._STA (), Local2)
                If (LEqual (0x1F, Local2))
                {
                    Store (DerefOf (Index (Local0, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }
                }

                Store (^^BAT1._BST (), Local1)
                Store (^^BAT1._STA (), Local3)
                If (LEqual (0x1F, Local3))
                {
                    Store (DerefOf (Index (Local1, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }
                }

                If (LAnd (LNotEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (Local1, Local0)
                    Store (Local3, Local2)
                    Store (Zero, Local3)
                }

                If (LAnd (LEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (DerefOf (Index (Local0, Zero)), Local4)
                    Store (DerefOf (Index (Local1, Zero)), Local5)
                    If (LOr (LEqual (Local4, 0x02), LEqual (Local5, 0x02)))
                    {
                        Store (0x02, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, One), LEqual (Local5, One)))
                    {
                        Store (One, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, 0x05), LEqual (Local5, 0x05)))
                    {
                        Store (0x05, Index (Local0, Zero))
                    }
                    ElseIf (LOr (LEqual (Local4, 0x04), LEqual (Local5, 0x04)))
                    {
                        Store (0x04, Index (Local0, Zero))
                    }

                    Add (CVWA (DerefOf (Index (Local0, One)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, One)), B1DV, B1CO), Index (Local0, One))
                    Add (CVWA (DerefOf (Index (Local0, 0x02)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x02)), B1DV, B1CO), Index (Local0, 0x02))
                    Divide (Add (DerefOf (Index (Local0, 0x03)), DerefOf (Index (Local1, 0x03))), 0x02, , Index (Local0, 0x03))
                }

                Return (Local0)
            }

            Method (_BIF, 0, NotSerialized)  // _BIF: Battery Information
            {
                Store (^^BAT2._BIF (), Local0)
                Store (^^BAT2._STA (), Local2)
                If (LEqual (0x1F, Local2))
                {
                    Store (DerefOf (Index (Local0, One)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }

                    Store (DerefOf (Index (Local0, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }

                    Store (DerefOf (Index (Local0, 0x04)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local2)
                    }
                }

                Store (^^BAT1._BIF (), Local1)
                Store (^^BAT1._STA (), Local3)
                If (LEqual (0x1F, Local3))
                {
                    Store (DerefOf (Index (Local1, One)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }

                    Store (DerefOf (Index (Local1, 0x02)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }

                    Store (DerefOf (Index (Local1, 0x04)), Local4)
                    If (LOr (LNot (Local4), LEqual (Ones, Local4)))
                    {
                        Store (Zero, Local3)
                    }
                }

                If (LAnd (LNotEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (Local1, Local0)
                    Store (Local3, Local2)
                    Store (Zero, Local3)
                }

                If (LAnd (LEqual (0x1F, Local2), LEqual (0x1F, Local3)))
                {
                    Store (LNot (DerefOf (Index (Local0, Zero))), B0CO)
                    Store (LNot (DerefOf (Index (Local1, Zero))), B1CO)
                    Store (One, Index (Local0, Zero))
                    Store (DerefOf (Index (Local0, 0x04)), B0DV)
                    Store (DerefOf (Index (Local1, 0x04)), B1DV)
                    Add (CVWA (DerefOf (Index (Local0, One)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, One)), B1DV, B1CO), Index (Local0, One))
                    Add (CVWA (DerefOf (Index (Local0, 0x02)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x02)), B1DV, B1CO), Index (Local0, 0x02))
                    Divide (Add (B0DV, B1DV), 0x02, , Index (Local0, 0x04))
                    Add (CVWA (DerefOf (Index (Local0, 0x05)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x05)), B1DV, B1CO), Index (Local0, 0x05))
                    Add (CVWA (DerefOf (Index (Local0, 0x06)), B0DV, B0CO), CVWA (DerefOf (Index (Local1, 0x06)), B1DV, B1CO), Index (Local0, 0x06))
                }

                Return (Local0)
            }
        }
    }
}

Finally I can sleep after weeks. See you in next macOS release :)

This is not the current SSDT-BATC.dsl as checked into the ACPIBatteryManager github repo anyway...
Any changes/suggestions/etc must be submitted based on the SSDT-BATC.dsl that is on github.
 
Fine. I am taking about this if clause

Code:
                // find primary and secondary battery
                If (0x1f != Local2 && 0x1f == Local3)
                {
                    // make primary use BAT1 data
                    Local0 = Local1 // BAT1._BST result
                    Local2 = Local3 // BAT1._STA result
                    Local3 = 0  // no secondary battery

There should be another if clause for other way around. And also for below one

Code:
                // find primary and secondary battery
                If (0x1f != Local2 && 0x1f == Local3)
                {
                    // make primary use BAT1 data
                    Local0 = Local1 // BAT1._BIF result
                    Local2 = Local3 // BAT1._STA result
                    Local3 = 0  // no secondary battery
                }
 
Status
Not open for further replies.
Back
Top