Jump to content

AppleACPIBatteryManager/AppleSmartBatteryManager For Lion


Zprood
 Share

182 posts in this topic

Recommended Posts

First Of All, Thanks these people for the battery driver:Chun-Nan, zenglg1977, gsly, bcc9, VIVXIX, weizh126. Cause without what they do can't get it work.Now start the topic.

 

Since apple changes some things on lion, the Appleacpibatterymanager does't work any more under the Lion, so people use roll backed next to get is work, but this has shortage. At the first, bcc9 found that lion reads battery info from EC by 8bit, and most laptop's EC region use 16bit to store battery information, so the legacy driver doesn't work include voodoo battery. This information is important for next.

 

The guy zenglg1977 takes some time to rewrite the sources code of Appleacpibatterymanager to make it work for lion. It is needed to edit the code of battery in the dsdt, so divide 16bit register into two 8bit can make sense. Like:

Before
//
Field (RAM, ByteAcc, Lock, Preserve)
	{
				Offset (0xE0),
		BSDC,   16,
		BSDV,   16,
		BSSN,   16
	}
//
Later
//
Field (RAM, ByteAcc, Lock, Preserve)
	{
				Offset (0xE0),
		SDC0,   8,
		SDC1,   8,
		SDV0,   8,
		SDV1,   8,
		SSN0,   8,
		SSN1,   8
	}
//

then, the transmit part can be done like this:

For example:

 

Before:
Multiply (BSDC, 0x0A, Local1)

Later:
Multiply (SDC1, 0x100, Local1)
Add (SDC0, Local1, Local1)
Multiply (Local1, 0x0A, Local1)

Before:
Store (BSDC, Local1)

Later:
Multiply (SDC1, 0x100, Local1)
Add (SDC0, Local1, Local1)

 

This way created by zenglg1977, after done with this can make it work.

But when compare VIVXIX with others method, i found his method is simple and easy to reach, it named "B1B2".

Here is his method:

1, create the "Method (B1B2, 2, NotSerialized)" as global:

Method (B1B2, 2, NotSerialized)
  {
	Or (ShiftLeft(Arg1,0x08), Arg0, Local0)
	Return (Local0)
} //for 16bit

  Method (B1B4, 4, NotSerialized)	
 {
	Or (ShiftLeft(Arg1,0x08), Arg0, Local0)
	Or (ShiftLeft(Arg2,0x10), Local0, Local0)
	Or (ShiftLeft(Arg3,0x18), Local0, Local0)
	Return (Local0)
  } //for 32bit

  Method (L1L4, 4, NotSerialized)//32*4=128
 {
	Or (ShiftLeft(Arg1,0x20), Arg0, Local0)
	Or (ShiftLeft(Arg2,0x40), Local0, Local0)
	Or (ShiftLeft(Arg3,0x60), Local0, Local0)
	Return (Local0)
  }//for 128bit

 

2, change the 16bit register into two 8bit register, like:

		 //BPV0,  
 SPV0,   8,
 SPV1,   8,

3, here is some collections of example editing work he finished before.

A:

//Store (^^EC0.BAC0, Local5)
  Store (B1B2(^^EC0.SAC0,^^EC0.SAC1), Local5)

 

B:

//Store (^^EC0.BDC0, Index (STAT, One))
  Store (B1B2(^^EC0.SDC0,^^EC0.SDC1), Index (STAT, One))

 

C:

//Multiply (BGU1, BFC1 ,Local2)
  Multiply (BGU1, B1B2 (BFC0, BFC1), Local2)

 

Some special parts as below:

D:

//If (^^EC0.BDC0 )
  If (B1B2(^^EC0.SDC0,^^EC0.SDC1))

 

E:

//If (LGreater (^^EC0.BAC0, 0xFB00))
  If (LGreater (B1B2(^^EC0.SAC0,^^EC0.SAC1), 0xFB00)

 

F:

//Store (^^EC0.BDC0, BFC1)  
  Store (^^EC0.SDC1, BFC1)
  Sleep (0x14)
  Store (^^EC0.SDC0, BFC0)

 

More about the sources code, zenglg1977 combines gsly's AppleSmartBatteryManger code into whole project, then people get two choice. And weizh126 plays a trick about battery cycle count in the _BIF method part, the _BIF just contains 13 items in the package and he adds "Zero" to it become 14, and store the cycle count register info in it, it sounds illegal, but it works.

 

Last, here is the sources code and attachments.

 

AppleBatteryManager_src.zip

AppleACPIBatteryManager.kext.zip

AppleSmartBatteryManager.kext.zip

 

Update for 10.7.3

AppleBatteryManager_src.zip

AppleSmartBatteryManager.kext.zip

AppleACPIBatteryManager.kext.zip

 

Also screenshots:

post-459659-1321807336_thumb.png

post-459659-1321807346_thumb.png

 

Original link address:

http://bbs.pcbeta.co...935509-1-1.html

http://bbs.pcbeta.co...935582-1-1.html

  • Like 8
Link to comment
Share on other sites

Works perfectamente !!! :D

 

EDIT: Found a niggle ...

 

Start with a fully charged battery, take out the adapter and before the remaining percentage gets to 96% plug back in the adapter ...

 

For some reason previous kexts like voodoo battery will automatically go back to 100% but this kext just stays at the current level (96%, 97%, 98% or 99%) but still say fully charged ...

Link to comment
Share on other sites

Works perfect, also shows the cycle info and the power tab in system profiler .But is it supposed to work with latest Appleacpiplatform.kext(10.7.2) or with the from SL(10.6.8). On my case work only with the one from 10.6.8, everything OK, but with the latest acpiplattform I can no infos at all.

Link to comment
Share on other sites

@fc Bayern:

It works both 10.6.8 10.7.2 too, do you correct your dsdt ? i have test it under 10.6.8 turn out works with 8bit register.

@DarwinX mindlessmissy

Maybe some things you do wrong, i mean the code edit in the battery device, some registers are placed in other place not EC.

 

For those battery indicator percentage shows problem, maybe can take a look this:

In my case, also some other users get this phenomenon, it is like below:

Store (^^EC0.BDC0, BFC1)

under _BIF method, note the BDC0 is in the EC region, but BFC1 also exists both Field (ERAM, ByteAcc, Lock, Preserve) and the Field (GNVS, AnyAcc, Lock, Preserve), but the right place should be the latter. So, the right way is like this:

divide BFC1 into two 8bit register under Field (GNVS, AnyAcc, Lock, Preserve), ignore the BFC1 under EC.
//BFC1,   16,  
BFC0,   8,
BFC1,   8,

--------------------------------------------------------

//Store (^^EC0.BDC0, BFC1)
Store (^^EC0.SDC1, BFC1)
Sleep (0x14)
Store (^^EC0.SDC0, BFC0)

 

The _BST method part:

A:
//If (BFC1)
If (B1B2(BFC0,BFC1))

B:
// Multiply (BGU1,BFC1, Local2)
Multiply (BGU1, B1B2(BFC0,BFC1), Local2)

 

EDIT:

If you have over 16bit battery register in the EC region of dsdt, you should take look of this, below are some examples.

 

For people get 32bit registers, like:

 

Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0), 
					SBCH,   32
				}

Solution:

A, you should add B1B4 first as global.

 Method (B1B4, 4, NotSerialized)///8*4=32
 {
	 Or (ShiftLeft (Arg1, 0x08), Arg0, Local0)
	 Or (ShiftLeft (Arg2, 0x10),Local0, Local0)
	 Or (ShiftLeft (Arg3, 0x18),Local0, Local0)
	 Return (Local0)
}

 

B, divide 32bit register into 4*8bit:

Before:

Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0), 
					SBCH,   32
				}

Later:

Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0), 
					BCH0,   8, 
					BCH1,   8, 
					BCH2,   8, 
					BCH3,   8
				}

 

C, edit the exists code. (PS: you should click "Update tree" first, if you use DSDT Editor.)

//Store (SBCH, BTYP)
Store (B1B4 (BCH0, BCH1, BCH2, BCH3), BTYP)

 

Also if you get 128bit register, you can do it in same way.

A, you should add B1B4 first as global.

 Method (L1L4, 4, NotSerialized)//32*4=128
 {
	 Or (ShiftLeft (Arg1, 0x20), Arg0, Local0)
	 Or (ShiftLeft (Arg2, 0x40),Local0, Local0)
	 Or (ShiftLeft (Arg3, 0x60),Local0, Local0)
	 Return (Local0)
 }
}

 

B, divide 128bit register into 16*8bit:

Before:

Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0), 
					SBMN,   128
				}

Later:

Field (ECOR, ByteAcc, NoLock, Preserve)
				{
							Offset (0xA0), 
					BMN0,   8, 
					BMN1,   8, 
					BMN2,   8, 
					BMN3,   8, 
					BMN4,   8, 
					BMN5,   8, 
					BMN6,   8, 
					BMN7,   8, 
					BMN8,   8, 
					BMN9,   8, 
					BMNA,   8, 
					BMNB,   8, 
					BMNC,   8, 
					BMND,   8, 
					BMNE,   8, 
					BMNF,   8
				}

 

C, edit the exists code. (PS: you should click "Update tree" first, if you use DSDT Editor.)

//Store (SBMN, Index (Arg1, 0x0C))
Store (L1L4 (B1B4 (BMN0, BMN1, BMN2, BMN3), B1B4 (BMN4, BMN5, 
							BMN6, BMN7), B1B4 (BMN8, BMN9, BMNA, BMNB), B1B4 (BMNC, BMND, BMNE, 
							BMNF)), Index (Arg1, 0x0C))

 

This code appears in the a little old laptop, but the way can be used by who get it. Credit @VIVXIX

More read here:http://bbs.pcbeta.com/viewthread-937628-1-1.html

  • Like 1
Link to comment
Share on other sites

@fc Bayern:

It works both 10.6.8 10.7.2 too, do you correct your dsdt ? i have test it under 10.6.8 turn out works with 8bit register.

@DarwinX mindlessmissy

Maybe some things you do wrong, i mean the code edit in the battery device, some registers are placed in other place not EC.

 

For those battery indicator percentage shows problem, maybe can take a look this:

In my case, also some other users get this phenomenon, it is like below:

Store (^^EC0.BDC0, BFC1)

under _BIF method, note the BDC0 is in the EC region, but BFC1 also exists both Field (ERAM, ByteAcc, Lock, Preserve) and the Field (GNVS, AnyAcc, Lock, Preserve), but the right place should be the latter. So, the right way is like this:

divide BFC1 into two 8bit register under Field (GNVS, AnyAcc, Lock, Preserve), ignore the BFC1 under EC.
//BFC1,   16,  
BFC0,   8,
BFC1,   8,

--------------------------------------------------------

//Store (^^EC0.BDC0, BFC1)
Store (^^EC0.SDC1, BFC1)
Sleep (0x14)
Store (^^EC0.SDC0, BFC0)

 

The _BST method part:

A:
//If (BFC1)
If (B1B2(BFC0,BFC1))

B:
// Multiply (BGU1,BFC1, Local2)
Multiply (BGU1, B1B2(BFC0,BFC1), Local2)

 

This code appears in the a little old laptop, but the way can be used by who get it. Credit @VIVXIX

 

No, I havent modify my dsdt yet, I ll try later on but have doubts it will turn well out(You know dsdt hacking isnt easy and fun at all). What to modify - the lines You ve posted in the first post???

Link to comment
Share on other sites

No, I havent modify my dsdt yet, I ll try later on but have doubts it will turn well out(You know dsdt hacking isnt easy and fun at all). What to modify - the lines You ve posted in the first post???

you just need to edit the code of battery part in the dsdt which includes the 16bit or higher register under EC region if you have, and change them as 8bit registesr.

Link to comment
Share on other sites

you just need to edit the code of battery part in the dsdt which includes the 16bit or higher register under EC region if you have, and change them as 8bit registesr.

 

As my ACPI coding expertise is simply non existent, would you mind taking a quick look at my DSDT.aml to see what I might have done wrong? :) Thank You.

 

DarwinX.aml.zipDarwinX.ioreg.zip

Link to comment
Share on other sites

you just need to edit the code of battery part in the dsdt which includes the 16bit or higher register under EC region if you have, and change them as 8bit registesr.

 

Zprood, here my dsdt:

dsdt.aml.zip

I have tried but no success, can't find the proposed lines

 

Can You see it pls(no battery modification made)

Thanks

Link to comment
Share on other sites

@Zprood

 

I tried to add method Method (B1B2 to my dsdt.aml

 

but I get compile errors :D

 

This is my dsdt.aml

 

I could not find field ram in my dsdt to edit them

 

dsdt.aml.zip

 

any help would be appreciated

 

or tell me what I have to edit

 

This is my ioreg battery is showing there only thing does not show in system info I get There was an error while gathering this information.

 

mymac.zip

Link to comment
Share on other sites

@Zprood

 

I tried to add method Method (B1B2 to my dsdt.aml

 

but I get compile errors :D

 

This is my dsdt.aml

 

I could not find field ram in my dsdt to edit them

 

dsdt.aml.zip

 

any help would be appreciated

 

or tell me what I have to edit

I wanna help, but your dsdt is the same situation i have good understanding on it. Also it doesn't match the 8bit and 16bit issue, i can't see 16bit register in the dsdt. Sorry.

Link to comment
Share on other sites

Thanks anyway :D

 

To make it work in my case I had to revert to appleacpiplatform from snowleopard

 

 

and now I get battery info in system profiler

 

 

Battery Information:

 

Model Information:

Serial Number: 02A-Z080417000473Z

Manufacturer: Fujitsu

Device Name: CP345705-01

Charge Information:

The battery's charge is below the critical level.: No

The battery's charge is below the warning level.: No

Charge Remaining (mAh): 1630

Fully Charged: No

Charging: Yes

Full Charge Capacity (mAh): 5418

Health Information:

Cycle Count: 54

Condition: Normal

Battery Installed: Yes

Amperage (mA): 1674

Voltage (mV): 11310

 

System Power Settings:

 

AC Power:

System Sleep Timer (Minutes): 10

Disk Sleep Timer (Minutes): 10

Display Sleep Timer (Minutes): 10

Automatic Restart on Power Loss: No

Wake on Clamshell Open: Yes

Wake on LAN: Yes

Current Power Source: Yes

Display Sleep Uses Dim: Yes

PrioritizeNetworkReachabilityOverSleep: 0

RestartAfterKernelPanic: 157680000

Battery Power:

System Sleep Timer (Minutes): 3

Disk Sleep Timer (Minutes): 10

Display Sleep Timer (Minutes): 3

Wake on Clamshell Open: Yes

Display Sleep Uses Dim: Yes

Reduce Brightness: Yes

RestartAfterKernelPanic: 157680000

 

Until I figure how to amend my dsdt this is easy solution for me.....

Link to comment
Share on other sites

More about the sources code, zenglg1977 combines gsly's AppleSmartBatteryManger code into whole project, then people get two choice. And weizh126 plays a trick about battery cycle count in the _BIF method part, the _BIF just contains 13 items in the package and he adds "Zero" to it become 14, and store the cycle count register info in it, it sounds illegal, but it works.

 

Thanx mate, I have tried this on my Lenovo G470 n' I have patched my DSDT. Batt is showing alright, info n' percentage are all okay. But I got 'Condition: Replace Now', what do I have to check?

 

Thanx

Link to comment
Share on other sites

Thanx mate, I have tried this on my Lenovo G470 n' I have patched my DSDT. Batt is showing alright, info n' percentage are all okay. But I got 'Condition: Replace Now', what do I have to check?

 

Thanx

check your dsdt carefully, it might be something wrong with your editing. I also have lenovo laptop, you should take a look of 1# and 6#.

Link to comment
Share on other sites

check your dsdt carefully, it might be something wrong with your editing. I also have lenovo laptop, you should take a look of 1# and 6#.

 

Ok, I've checked my dsdt n' now 'Condition: Replace Now' is gone. But now my laptop won't sleep (sleep was working fine before). Can you please take a look at my dsdt? Here I attached 2 version of my dsdt, without 8-bit batt patches and with 8-bit batt patches.

 

Thanx

Lenovo_G470_DSDT.zip

Link to comment
Share on other sites

 Share

×
×
  • Create New...