ASUS NOTEBOOK. Working both in Snow Leopard 10.6.8 and Lion 10.7.2

Yes. Got gsly's AppleSmartBatteryManager to work on my Asus M60J.
In the interest of helping other Asus notebook owners with similar dsdts, I'll provide how I made it happen. But, it is not my intent to steal gsly's glory. All this was made possible thanks to him. I'm only adapting his project to my Asus notebook. Also thanks to bcc9 for deriving the formula for taking a 16-bit reference and breaking it down into high-byte and low-byte to do byte (8-bit) references.
Back in post# 47, gsly provided abundant comments for another Asus notebook dsdt, the G53S. My BAT0 dsdt is nearly identical. So, all those comments on that Asus dsdt were really helpful in helping me figuring out what was going on with my own dsdt. Thanks gsly for doing that.
My Asus doesn't seem to use much SMBus access to the battery register sensors. It's making much use of EC access to the battery registers.
The Asus notebook BAT0 dsdt is quite different from the HP BAT0 dsdt. It has several more Method subroutines and it does all kinds of calculations based on what it detects. In the end, it does quite a good job of returning the battery values in accordance with the ACPI 3.x specs. The problem is that it was set to convert the units mAh to mWh and 2 things were happening wrong with that conversion. Design Capacity and Last Full Charge Capacity were kept in mAh and were 1000 times too small while the Current Capacity was converted to mWh. That created remaining percentages of over 115,000% and the inability to calculate remaining time. So, my goal was to prevent the conversion and fix it so it returns mAh units.
If the original Methods FBIF, CBIF and CBST in your Asus dsdt look like below, then the modification should work for you.
CODE
// If the Methods FBIF, CBIF and CBST in your original Asus notebook battery look like below, the
// recommended modifications shoud work for you
Method (FBIF, 5, NotSerialized)
{
Store (Arg0, PUNT)
Store (Arg1, Local1)
Store (Arg2, Local2)
If (LEqual (PUNT, 0x00))
{
Multiply (Local1, 0x0A, Local1)
Multiply (Local2, 0x0A, Local2)
}
Store (Arg0, Index (PBIF, 0x00))
Store (Local1, Index (PBIF, 0x01))
Store (Local2, Index (PBIF, 0x02))
Store (Local2, LFCC)
Store (Arg3, Index (PBIF, 0x03))
Store (Arg4, Index (PBIF, 0x04))
Divide (Local1, 0x0A, Local3, Local5)
Store (Local5, Index (PBIF, 0x05))
Divide (Local1, 0x64, Local3, Local6)
Store (Local6, Index (PBIF, 0x06))
Store (Local6, LOW2)
Divide (Local1, 0x64, Local3, Local7)
Store (Local7, Index (PBIF, 0x07))
Store (Local7, Index (PBIF, 0x08))
}
Method (CBIF, 0, NotSerialized)
{
If (PUNT)
{
Store (DerefOf (Index (PBIF, 0x04)), Local0)
Add (Local0, 0x01F4, Local0)
Divide (Local0, 0x03E8, Local1, DVOT)
Store (Zero, Index (PBIF, 0x00))
Multiply (DerefOf (Index (PBIF, 0x01)), DVOT, Index (PBIF, 0x01
))
Multiply (DerefOf (Index (PBIF, 0x02)), DVOT, Index (PBIF, 0x02
))
Multiply (DerefOf (Index (PBIF, 0x05)), DVOT, Index (PBIF, 0x05
))
Multiply (DerefOf (Index (PBIF, 0x06)), DVOT, Index (PBIF, 0x06
))
Multiply (DerefOf (Index (PBIF, 0x07)), DVOT, Index (PBIF, 0x07
))
Multiply (DerefOf (Index (PBIF, 0x08)), DVOT, Index (PBIF, 0x08
))
}
}
Method (CBST, 0, NotSerialized)
{
If (PUNT)
{
Multiply (DerefOf (Index (PBST, 0x01)), DVOT, Index (PBST, 0x01
))
Multiply (DerefOf (Index (PBST, 0x02)), DVOT, Index (PBST, 0x02
))
}
}
1) IN SNOW LEOPARD
-mWh Units
If you're fine with having the units in mWh, then all you need to do is change Store (Zero, Index (PBIF, 0x00)) to Store (One, Index (PBIF, 0x00)) in the Method CBIF. That's it! iStat will report a battery current about 10 times too high, but the capacity values and remaining times and percentages will all be accurate.
-mAh Units
This is the preferred unit in Mac OS X. It requires a little editing of Methods FBIF, CBIF and CBST. For some reason, when retrieving values in mAh, the capacities will be 1.85% too small. 1.85% doesn't sound like much, but my capacities are in the 4000 mAh range. That was causing them to be about 79 mAh too small compared to the mAh values in Windows 7 with BatteryEater Pro. It was also causing a little percentage anomaly. Percentages would go straight from 100% down to 97% when discharging and straight from 97% to 100% when recharging, never seeing 98% and 99%. That's why I'm applying a 1.85% correction (that's times 185 divided by 10,000)
Here's the Mehod FBIF, CBIF and CBST edits to accurately have to units in mAh. Just replace your Methods FBIF, CBIF and CBST with my corrected ones.
Asus_SnowLeo_Corrected.dsl.zip 1.05K
24 downloads
2) LION 10.7.2
-mAh Units
Okay. I was in for a surprise on this one. My battery EC registers are all 16-bit at Offset (0xA0) from B0VL to B0DV. They're all mirrored by B1VL to B1DV also 16-bit. But those B1xx variables are never executed in the conditional loops, so the battery EC registers that matter are the B0xx. I converted all of those to 8-bit reference based on bcc9's method.
I did this for the all 8 battery B0xx registers and one B0SN register. With all that conversion to 8-bit, gsly's AppleSmartBattery was still working flawless in Snow Leopard, as a testimony that my 8-bit conversion was done correctly. But it wasn't working Lion, all I had was 0, -1 and unknown for the values.
Then I made a puzzling discovery. I discovered that the only reason why the Fill Battery Information Method (Method FBIF) or Method _BIF was failing in Lion, was not because the battery EC registers were accessed in 16-bit, but because the Method that extracts the Battery OEM information string (Method BIF9) has an incompatibility with Lion and that alone was causing the whole Method FBIF or Method _BIF to fail. There's something incompatible with this Method BIF9
CODE
Method (BIF9, 0, NotSerialized)
{
Name (BSTR, Buffer (0x20) {})
Store (SMBR (RDBL, BADR, 0x21), Local0)
If (LNotEqual (DerefOf (Index (Local0, Zero)), Zero))
{
Store (MNAM, BSTR)
Store (Zero, Index (BSTR, 0x04))
}
Else
{
Store (DerefOf (Index (Local0, 0x02)), BSTR)
Store (Zero, Index (BSTR, DerefOf (Index (Local0, One))))
}
Return (BSTR)
}
I don't know how to fix that one.
*** EDIT 26 Nov **: SOLVED!! With the help of gsly rewriting Method SMBR to read Word and Block (string) 8-bit at a time, combined with deleting one line in Method SMBR, SmartBattery fully works now in Lion and can extract the battery name string without crashing.
Below is my dsdt corrected for Lion on my Asus M60J. Attached are also the complete edit instructions that should apply to all Asus core i3/i5/i7 Notebooks.
Asus_Coreix_Lion_Edits.zip 3.5K
122 downloads
AsusM60J_Lion.zip 39.26K
95 downloads