Jump to content

HP DVx ACPI 3.x/4.x Battery Driver (10.6/10.7)


gsly
 Share

229 posts in this topic

Recommended Posts

NIXin/JBraddock, I confirmed my suspicion about just renaming the class files to get some of the 3rd party software to work. XCode's refactoring is {censored} so I had to rename the classes and a LOT of other stuff in the project to enable me to build "AppleSmartBatteryManager" vs. "AppleACPIBatteryManager". After removing the latter and installing the former, I was able to see data in iStat (unhacked) and coconutBattery as you can see:

 

post-60978-1312586734_thumb.png

 

EDIT: Added compiled versions for the renamed driver in original post.

 

Hi gsly, I've modified the source code of AppleACPIBatteryManager to enable it in 64 bit mode and it works perfect, but I don't quite understand how to change the AppleACPIBatteryManager to the AppleSmartBatteryManager, and I just rename every classes name, and build it without any error, but the OSX do not load it. The source is attached below. I am really appreciated if you get some time to fixed it out.

Thanks

AppleACPIBatteryManager.zip

Link to comment
Share on other sites

  • 2 weeks later...
Any progress on the project?

Good luck and keep up the great work :(

I haven't had a lot of time the past few weeks. I'm in the middle of 2 streams, the first one is doing some dis-assembly/debugging to see what Apple changed in the ACPI platform driver that causes previous code to fail. (There is more to it than just the EC access others have found). The second stream is looking into getting the native battery driver to work, or to just build the missing SMBusController controller class that Apple does not provide the source to in order to build the Apple SmartBattery driver.

Link to comment
Share on other sites

I made some progress last night on the Lion issues, and surprise surprise, it looks like its another bug in HP's code not mine ;)

 

It appears that the new Apple ACPI platform kext for 10.7.x installs exception handlers on the ACPI methods/devices and bugs that were previously ignored in 10.6 are being caught in 10.7. It also appears they are using the ACPICA AML parser (psparse) so I might be able to use those tools to hunt down any other DSDT bugs as well, although its unknown what version Apple is using...

 

Anyway, the issue is in the SMRD (SMBus Read) method as seen in this ACPI parsing stack error trace:

 

ACPI Exception: AE_BAD_PARAMETER, Returned by Handler for [EmbeddedControl] (...)
ACPI Error (psparse-0632): Method parse/execution failed [\_SB_.PCI0.LPCB.EC__.SMRD] (...), AE_BAD_PARAMETER
ACPI Error (psparse-0632): Method parse/execution failed [\_SB_.BAT0.UPBX] (...), AE_BAD_PARAMETER
ACPI Error (psparse-0632): Method parse/execution failed [\_SB_.BAT0._BIX] (...), AE_BAD_PARAMETER
AppleSmartBatteryManager::getBatteryBIX: evaluateObject error 0xe00002bc

 

As you can see, _BIX calls UPBX that calls SMRD that fails. As SMRD is a fundamental function that wraps the various protocols and returns from the SMBus, it causes all of the calls to the Smart Battery System (SBS) to fail and eventually the evaluateObject() call in the battery kext fails as you can see here:

 

post-60978-1316100224_thumb.jpg

 

Now I just have to debug HP's code :)

Link to comment
Share on other sites

i change smw0 that have 16 bit value to 8 bite and and add this to SMRD section:

How long it will take until you will realize we discuss here a different driver and the goal is to use EC's SMBus method instead EC's battery registers that you are trying to mix?

Link to comment
Share on other sites

How long it will take until you will realize we discuss here a different driver and the goal is to use EC's SMBus method instead EC's battery registers that you are trying to mix?

i know this post is about what.know need to you speak Discourteous with me.

i have limited knowledge i know but i don't need to you Remind me it in this way.

this is just report about what i doing and result .

nobody force you to read my post and answer to it.

i suggest when you see my name above a post just skip it .

Link to comment
Share on other sites

Yes! Got it working in Lion 10.7 (GM) although I don't see why I had to do this after re-reading the ACPI SMBus specifications and looking at a MacBookPro6,1 functionality again.

 

Anyway, as previously reported by bcc9, the Apple ACPI platform device driver throws an exception if any of the registers in the EC are accessed using anything other than byte access (8-bit). As the SMBus is accessed through the EC, we must also use byte access even though the SMBus specification allows 16-bit word access.

 

So I rewrote the portions of the SMBus Read/Write (SMRD/SMWR) methods that read/write SMBus Words and Blocks (Strings) to do it via bytes (8-bit) and now all of the existing battery methods work again, allowing the driver to work again as you can see:

 

post-60978-1316296862_thumb.png

 

I still need to see why the driver isn't loading on boot (might be my Lion install) and clean up some debugged and do a little more testing so hang in there for a bit more!

Link to comment
Share on other sites

Yes! Got it working in Lion 10.7 (GM) although I don't see why I had to do this after re-reading the ACPI SMBus specifications and looking at a MacBookPro6,1 functionality again.

 

Anyway, as previously reported by bcc9, the Apple ACPI platform device driver throws an exception if any of the registers in the EC are accessed using anything other than byte access (8-bit). As the SMBus is accessed through the EC, we must also use byte access even though the SMBus specification allows 16-bit word access.

 

So I rewrote the portions of the SMBus Read/Write (SMRD/SMWR) methods that read/write SMBus Words and Blocks (Strings) to do it via bytes (8-bit) and now all of the existing battery methods work again, allowing the driver to work again as you can see:

 

post-60978-1316296862_thumb.png

 

I still need to see why the driver isn't loading on boot (might be my Lion install) and clean up some debugged and do a little more testing so hang in there for a bit more!

thanks.

i am currently use your smart battery driver it load without problem in lion.i try many time to fix 16 bit in ec and smrd but without success .i am waiting for your dsdt fix to find my mistake.(the university of hakintosh)

Link to comment
Share on other sites

i got it working on my acer laptop, it use a different access to the battery (no smbus)

i have some bugs still to sort, no time to discharge but working percentage and i get an "error collecting informations" on energy tab of sysinfo.

just dsdt job to make it working, i include mine, original and after the mod for someone who want to look at it and enhance. just run a diff to see what changed.

i'm not available for assistance, so pls do not IM, all i know is here.

i'm using the acpi version of the kext with:

UseExtendedBatteryInformationMethod=false

UseExtraBatteryInformationMethod=false

 

dsdt_ec_8bit.zip

Link to comment
Share on other sites

Yes! Got it working in Lion 10.7 (GM) although I don't see why I had to do this after re-reading the ACPI SMBus specifications and looking at a MacBookPro6,1 functionality again.

Great news!

Waiting to see the new SMBus read/write methods, it may save my time implementing PECI access withing ACPI :(

Link to comment
Share on other sites

gsly,

 

I'm using MacBookPro6,2 identifier for My Asus Core i7 notebook.

 

Looks like My Asus Notebook uses an ACPI Battery control method:

 

asusm60jacpibattery.png

 

 

 

But, it's using ACPI 2.0

 

asusm60jacpiinfo.png

 

 

 

Not sure I can use your ACPI 3.x/4.x method.

 

Also, what is your device SMRD? I don't seem to have it at all in my dsdt.

Link to comment
Share on other sites

Great news!

Waiting to see the new SMBus read/write methods, it may save my time implementing PECI access withing ACPI ;)

They should be transferable to any system that uses an SMBus written to the standard with the exception of the timing bits. Note the HP functions do a brute force retry/sleep loop that doesn't look ideal, but perhaps the SMBus chipset is that unreliable :(

 

 

 

Indeed awesome news!

:)

Can I buy you a beer gsly? ;)

I never turn down free beer NIXin ;)

 

See original post for the new methods. Hopefully you can follow what I did and update the auto-patcher library. There may be some things I renamed, modified from the stock BIOS but you'll figure it out (let me know!)

 

 

 

 

gsly,

 

I'm using MacBookPro6,2 identifier for My Asus Core i7 notebook.

 

Looks like My Asus Notebook uses an ACPI Battery control method:

...

But, it's using ACPI 2.0

...

Not sure I can use your ACPI 3.x/4.x method.

 

Also, what is your device SMRD? I don't seem to have it at all in my dsdt.

You should be able to use the 3.x method. Look at the ACPI 2.x documents on the site referenced in the original post to see if the _BIF and _BST were defined in that revision of the standard. (I'm sure they were but I haven't looked)

 

SMRD is a method in the EC device. If you don't have an SMBus/SBS, you'll have to determine what registers in your EC are wired directly to the battery controller and modify your _BIF and _BST methods to return the data outlined in the ACPI specification.

Link to comment
Share on other sites

Interesting. I've applied your DSDT fixes for Lion. But it wasn't working so i switched to the debug version and apparently there isn't anything either.

 

My kext is in S/L/E and not E/E

 

Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Version 2011.0802 starting
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager::setPowerState: which = 0x1
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.

 

That's all i get. Ideas?

 

Also, I'm on a HP Envy 15 1150-nr. F2B. A Bios.

 

DSDT Attached incase you want to look at it.

 

dsdtmod2lxbat.zip

Link to comment
Share on other sites

thanks gsly work perfect for me .just rename ECON to ECOK.(my system default)

Thanks for the feedback. What HP model and BIOS version is this?

 

 

It works perfect, thank you gsly.

Thanks for the feedback.

Link to comment
Share on other sites

Interesting. I've applied your DSDT fixes for Lion. But it wasn't working so i switched to the debug version and apparently there isn't anything either.

 

My kext is in S/L/E and not E/E

 

Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Version 2011.0802 starting
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager::setPowerState: which = 0x1
Sep 22 16:38:38 localhost kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.

 

That's all i get. Ideas?

 

Also, I'm on a HP Envy 15 1150-nr. F2B. A Bios.

 

DSDT Attached incase you want to look at it.

 

dsdtmod2lxbat.zip

Ah! You are the tester I've been looking for! Your system claims it supports two batteries and the original code didn't really handle this case (well). Try putting the battery in the other bay and see if it works.

 

Your other option is to remove either BAT0 or BAT1 depending on which one corresponds to your preferred battery bay :(

 

I think I could add the code to support multiple batteries, but I don't have a test platform nor do I know how prevalent 2+ battery bays are to warrant the time (I've got other ideas and issues to tackle first)

 

 

 

More important for me would be if your kext could have ability to put computer to sleep on low battery: for example on 5% battery level while is on battery power would tell to system (terminal command):

osascript -e 'tell application "System Events" to sleep'

possible ?

Thanks again

As I posted previously, the function of the driver is to provide power details to the power management system and its that system that determines when to initiate a system sleep. The problem is that when the power management system issues a sleep request, older kexts/applications that do not respond to the request prevent the sleep from completing. I suspect some of the older "core" kexts we use like VoodooPS2/etc are the actual problem. Now that I have Lion working, I'm going to do some testing related to this...

 

However, I've also been thinking that we *could* deviate from Apple's way and and have the battery driver initiate the forced sleep (not idle sleep like PM as that can be cancelled) when it calculates its at the low/critical values.

 

See http://developer.apple.com/library/mac/#qa...340/_index.html

See http://support.apple.com/kb/ht1776

Link to comment
Share on other sites

Ah! You are the tester I've been looking for! Your system claims it supports two batteries and the original code didn't really handle this case (well). Try putting the battery in the other bay and see if it works.

 

Your other option is to remove either BAT0 or BAT1 depending on which one corresponds to your preferred battery bay :)

 

I think I could add the code to support multiple batteries, but I don't have a test platform nor do I know how prevalent 2+ battery bays are to warrant the time (I've got other ideas and issues to tackle first)

 

 

Unfortunately as much as i would like to test for you, I do not have the other battery. I bought this laptop without the Extra "Slice" Battery. It weighs like 1.75kg for just a battery. :( I did however managed to get an output from the debug kext. I think Lion was using the cache so i had to delete the kext, reboot then install the kext and reboot again. This is the output i have.

 

Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager: Version 2011.0802 starting
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::setPowerState: which = 0x1
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery: Using ACPI extended battery information method _BIX
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery: Using ACPI extra battery information method BBIX
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::clearBatteryState: do_update = false
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::rebuildLegacyIOBatteryInfo called
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x2
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x1
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::getBatterySTA called
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatterySTA: battery_status = 0x1f
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::getBatteryBIX called
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager: Version 2011.0802 starting
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager: Battery Supported Count(s) 2.
Sep 22 22:11:12 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::setPowerState: which = 0x1
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBIX: acpibat_bix size = 20
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::getBatteryBBIX called
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: acpibat_bbix size = 16
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fManufacturerAccess	= 0x0
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fBatteryMode		   = 0x6001
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAtRateTimeToFull	  = 0xffff (min)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAtRateTimeToEmpty	 = 0xffff (min)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fTemperature		   = 0xc0f (0.1K)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fVoltage			   = 0x3043 (mV)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fCurrent			   = 0x3 (mA)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAverageCurrent		= 0x1 (mA)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fRelativeStateOfCharge = 0x60 (%)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAbsoluteStateOfCharge = 0x4d (%)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fRemainingCapacity	 = 0xe5b (mAh)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fRunTimeToEmpty		= 0xffff (min)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAverageTimeToEmpty	= 0xffff (min)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fAverageTimeToFull	 = 0x2d3c (min)
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fManufactureDate	   = 0x3b9b
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBBIX: fManufacturerData size = 0xf
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::unpackDate: packedDate = 0x3b9b
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBatteryManager::getBatteryBST called
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit	   = 0x1
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus	= 0x0
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate	 = 0x3
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0xe5b
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage  = 0x3043
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0x3
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery: Battery is charged.
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::constructAppleSerialNumber called
Sep 22 22:11:13 Zanes-MacBook-Pro kernel[0]: AppleSmartBattery::rebuildLegacyIOBatteryInfo called

 

So i'm assuming my battery is actually BAT1?

Link to comment
Share on other sites

Hi gsly;

 

Here is the debug output with your new kext. I run both with true and false set none seems to do the trick.

I am also including my dsdt as it is today.

 

On Battery, it show 20:00 to discharge time left but 0% if I change time left to percentage

 

Once again thanks for your help

g53

Sorry for the delay on this. Your DSDT does some different calculations based on what it detects so you are going to have to work through this yourself. I added some comments to your DSDT on what I could figure out without actual hardware. Basically, you just need to determine what units/values the battery hardware is returning to the DSDT methods and then make sure they match the ACPI specification.

 

DSDTG53SW.zip

 

Unfortunately as much as i would like to test for you, I do not have the other battery. I bought this laptop without the Extra "Slice" Battery. It weighs like 1.75kg for just a battery. :( I did however managed to get an output from the debug kext. I think Lion was using the cache so i had to delete the kext, reboot then install the kext and reboot again.

...

So i'm assuming my battery is actually BAT1?

I'd say it's BAT0 as that is the lowest _UID value and first in the DSDT (it depends on how the Apple function enumerates the devices). Easy way to find out, make _STA for one of the devices return 0x00 (no battery present) in that device and see which one the driver doesn't see :) Then rip out all the code for the battery you don't have...

Link to comment
Share on other sites

I'd say it's BAT0 as that is the lowest _UID value and first in the DSDT (it depends on how the Apple function enumerates the devices). Easy way to find out, make _STA for one of the devices return 0x00 (no battery present) in that device and see which one the driver doesn't see :D Then rip out all the code for the battery you don't have...

 

Done. I returned 0x00 for BAT1 and true enough the driver detected my battery. So i believe BAT0 is the internal battery. Everything else works great! :P

 

Sorry i couldn't test the dual battery solution for you though, But lets hope we get another HP Envy 15 user with the Slice battery. I'm going to make a guide so that people can get OS X their Envy's too. Thanks for helping with the battery solution! :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...