Jump to content

AppleACPIBatteryManager/AppleSmartBatteryManager For Lion


  • Please log in to reply
175 replies to this topic

#61
sebern

sebern

    InsanelyMac Protégé

  • Members
  • Pip
  • 3 posts
Zprood,

I try again to fix my DSDT and now I was able to integrate your fix and
compile DSDT with no errors :) . I can now use good old VoodooBattery
with Lion ACPIPlatform kext instead of SL ones to get battery status.

Thanks for providing and sharing such a solution. I attached my fixed DSDT,
maybe helpful for someone.

Happy new year,

Sebastian

Attached File  DSDT_b1b2.aml.zip   32.04KB   53 downloads

#62
smartie77

smartie77

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 370 posts
  • Gender:Male
  • Location:Dortmund, Germany
  • Interests:Apple Software, iOS , OSX86, Creativity and a lot of non-tech stuff.
Hi, I have a Toshiba Laptop which works great with Snow and Lion ; The DSDT is fixed for almost everything working like usb,sleep,hpet,lpc and so on and tested over months usage with no problems; OSX works problem-free with SMBIOS of MacBookPro5.1 ( Core2Duo Speedstep vanilla ) but this Battery Thing with Lion is the last open issue for me. My BAT1 Entries in DSDT look very different from your example code and I don't want to mess my otherwise working file.

Can you figure out what I need to change in order to have working battery kexts in Lion with original apple acpi and pci kexts ( I don't want to mix Snow and Lion files ).

Thanks :king:

The complete dsdt that I use in OSX is attached as file.

Here only Battery section :

Device (BAT1)
{
Name (_HID, EisaId ("PNP0C0A"))
Name (_UID, One)
Name (_PCL, Package (0x01)
{
_SB
})
Name (BMDL, Zero)
Method (_STA, 0, NotSerialized)
{
If (ECOK ())
{
If (^^EC0.BAL0)
{
Sleep (0x14)
Return (0x1F)
}
Else
{
Sleep (0x14)
Return (0x0F)
}
}
Else
{
Sleep (0x14)
Return (0x1F)
}
}





Method (_BIF, 0, NotSerialized)
{
Name (STAT, Package (0x0D)
{
One,
0x1770,
0x1770,
One,
0x2A30,
0x0258,
0xB4,
0x0108,
0x0EC4,
"PA3533U ",
"41167",
"Li-Ion",
"TOSHIBA"
})
Name (CMMA, Buffer (0x0C) {})
CreateByteField (CMMA, Zero, APN1)
CreateByteField (CMMA, One, APN2)
CreateByteField (CMMA, 0x02, APN3)
CreateByteField (CMMA, 0x03, APN4)
CreateByteField (CMMA, 0x04, APN5)
CreateByteField (CMMA, 0x05, APN6)
CreateByteField (CMMA, 0x06, APN7)
CreateByteField (CMMA, 0x07, APN8)
CreateByteField (CMMA, 0x08, APN9)
CreateByteField (CMMA, 0x09, Z00A)
CreateByteField (CMMA, 0x0A, Z00B)
CreateByteField (CMMA, 0x0B, Z00C)
Store (PHMR (0xACF8), APN1)
Store (PHMR (0xADF8), APN2)
Store (PHMR (0xAEF8), APN3)
Store (PHMR (0xAFF8), APN4)
Store (PHMR (0xB0F8), APN5)
Store (PHMR (0xB1F8), APN6)
Store (PHMR (0xB2F8), APN7)
Store (PHMR (0xB3F8), APN8)
Store (PHMR (0xB4F8), APN9)
Store (PHMR (0xB5F8), Z00A)
Store (PHMR (0xB6F8), Z00B)
Store (PHMR (0xB7F8), Z00C)
Store (CMMA, Index (STAT, 0x09))
If (ECOK ())
{
Store (^^EC0.BDN0, Local0)
Store (Local0, BMDL)
Store (^^EC0.BFC0, BFC1)
Sleep (0x14)
Store (^^EC0.BDC0, Index (STAT, One))
Sleep (0x14)
Store (^^EC0.BDV0, Index (STAT, 0x04))
Sleep (0x14)
}
Else
{
Store ("Li-Ion", Index (STAT, 0x0B))
Store (BFC1, Index (STAT, One))
}

If (BFC1)
{
Divide (BFC1, 0x64, Local0, Local1)
Multiply (Local1, 0x0A, Local1)
Store (Local1, Index (STAT, 0x05))
Divide (BFC1, 0x64, Local0, Local1)
Multiply (Local1, 0x03, Local1)
Store (Local1, Index (STAT, 0x06))
Store (BFC1, Index (STAT, 0x02))
}

Return (STAT)
}

Method (_BST, 0, NotSerialized)
{
Name (PBST, Package (0x04)
{
Zero,
0xFFFFFFFF,
0xFFFFFFFF,
0x2A30
})
Store (0x2A30, Local3)
If (ECOK ())
{
Sleep (0x14)
Store (^^EC0.BST0, BST1)
Sleep (0x14)
Store (^^EC0.BRC0, Local2)
Sleep (0x14)
Store (^^EC0.BPV0, Local3)
Sleep (0x14)
}

Store (BST1, Index (PBST, Zero))
Store (Zero, Index (PBST, One))
Store (Local2, Index (PBST, 0x02))
Store (Local3, Index (PBST, 0x03))
If (ECOK ())
{
If (LNotEqual (^^EC0.BDN0, BMDL))
{
Notify (BAT1, 0x81)
}
}

Return (PBST)
}
}

Device (DMAC)
{
Name (_HID, EisaId ("PNP0200"))
Name (_CRS, ResourceTemplate ()
{
IO (Decode16,
0x0000, // Range Minimum
0x0000, // Range Maximum
0x01, // Alignment
0x20, // Length
)
IO (Decode16,
0x0081, // Range Minimum
0x0081, // Range Maximum
0x01, // Alignment
0x11, // Length
)
IO (Decode16,
0x0093, // Range Minimum
0x0093, // Range Maximum
0x01, // Alignment
0x0D, // Length
)
IO (Decode16,
0x00C0, // Range Minimum
0x00C0, // Range Maximum
0x01, // Alignment
0x20, // Length
)
DMA (Compatibility, NotBusMaster, Transfer8_16, )
{4}
})
}

Attached Files



#63
LIMITER

LIMITER

    InsanelyMac Protégé

  • Members
  • Pip
  • 20 posts
Hello,

Attached is the original and patched (fully working) DSDT for Lenovo B550 (G550?).

Attached File  dsdt.aml.zip   11.18KB   63 downloads
Attached File  dsdt-batteryfix.aml.zip   11.27KB   151 downloads


Thanks to all that made this awesome driver and to Zprood for the great tutorial !!!

#64
flip360

flip360

    InsanelyMac Protégé

  • Members
  • PipPip
  • 87 posts
  • Gender:Male
  • Location:Skopje

I created a complete dsl instruction file of all the edits I did to get SmartBatteryManager working on Lion for my Asus M60J, but should be applicable to all the Asus Core i3/i5/i7 notebooks. From what I've seen so far, all the Asus Core i notebooks have identical battery dsdt.

The Lion dsdt edits instruction file is at the bottom of my post# 95 in glsy's thread under the name Asus_Coreix_Lion_Edits. I have also included a full dsdt of my Asus M60J on Lion in case they don't understand a particular instruction.

http://www.insanelym...dpost&p=1771830


Thanks for the instructions buddy, working battery here at last :)

Cheers

#65
Neo_01

Neo_01

    InsanelyMac Protégé

  • Members
  • PipPip
  • 56 posts
I attach my DSDT file I'm not an expert someone could please patch the file.
Thanks

Attached Files

  • Attached File  DSDT.zip   16.78KB   5 downloads


#66
Neo_01

Neo_01

    InsanelyMac Protégé

  • Members
  • PipPip
  • 56 posts

I attach my DSDT file I'm not an expert someone could please patch the file.
Thanks


Sorry, Could you please help me to patch the file?
Thanks in advice

#67
Neo_01

Neo_01

    InsanelyMac Protégé

  • Members
  • PipPip
  • 56 posts

Sorry, Could you please help me to patch the file?
Thanks in advice


Could you please indicate me what I have to do??
Thanks

#68
Neo_01

Neo_01

    InsanelyMac Protégé

  • Members
  • PipPip
  • 56 posts
I attach the dsdt file modified according the indications but the compiler show me a lot of errors could you please help me.
Thanks

Attached Files



#69
Micky1979

Micky1979

    I realized that I am lucky

  • Moderators
  • 1,817 posts
  • Gender:Male
  • Location:a 100m dal Tevere, vicino a Peppe

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.





Also screenshots:



Original link address:
http://bbs.pcbeta.co...935509-1-1.html
http://bbs.pcbeta.co...935582-1-1.html





Hello Zprood,

I am having trouble getting the patch to the battery and the LID,
can you help me?
I attach dsdt

Attached Files



#70
jazzyguy

jazzyguy

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 188 posts
  • Gender:Male
  • Location:USA
Out of curiosity, how are we supposed to know which items need to be turned into 8 bit?

#71
xmen107

xmen107

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts
Ok, sorry my mistake, now tested on Snow Leopard and both work well without making alterations in my dsdt. Thank you for your excellent work. In Lion did not work for me, I do not know why, but ok.

#72
joe2108

joe2108

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 102 posts
I'm still confuse with this DSDT fix cause no line in my DSDT like that, could you patch my dsdt, thanks before

DSDT Vostro 3350Attached File  DSDT.aml.zip   17.38KB   7 downloads

#73
ludacrisvp

ludacrisvp

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 374 posts
  • Gender:Male
  • Location:USA
You may be interested to know that voodoo battery works perfectly out of the box on mountain lion dp1 on the same laptop that had lion battery issues. I did not fix my dsdt for lion.

#74
Chinmaya

Chinmaya

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
  • Gender:Male
  • Location:India
  • Interests:Hackintoshs, gadgets etc.

Try this one:


@Zprood

i have successfully edited my DSDT, converted registers to 8 bit, battery is being detected, but not properly.
i have attached screenshots and my dsdt.

Problem is that i am getting
1. Charge Remaining wrong figures
2. Amperes remaining in -ve figures
3. Battery at 20:00 remaining at full charge.

Please help me to rectify these errors.

Thanks in advance.

Attached Files



#75
vlad.s

vlad.s

    InsanelyMac Protégé

  • Members
  • Pip
  • 2 posts
  • Gender:Male
  • Location:Sibiu, Romania
Hello,

I have a Lenovo Ideapad Y560 i7. I tried to apply this battery patch to my dsdt but it looks different thank the one in the example. Could someone please take a look and help me?
Thank you!

Attached Files

  • Attached File  dsdt.zip   36.85KB   5 downloads


#76
prescolt

prescolt

    InsanelyMac Protégé

  • Members
  • Pip
  • 8 posts
dear Zprood
my DSDT don't have any string like post 1, please help me to fix it
my laptop is thinkpad T420
thank Zprood so much

Attached Files



#77
BugsB

BugsB

    InsanelyMac Deity

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,513 posts
  • Gender:Male
  • Location:Kauai, Hawai'i
Question: why not include patches known to be required for Hackbooks into Apple's PowerManagement Sources as has been done before (last time I know of in Leopard) instead of all this complicated DSDT stuff, which in addition is different for each Laptop .. ?? The modded PM.bundle worked so well back then in all sorts of mobile PCs ..

#78
// KURU

// KURU

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
Hello everybody!

I tried several times to follow your instructions, but I get lost after a while...
my laptop is an HP dv5 1120el.
I checked also other topics to get my DSDT fixed but I'm not able to edit it properly.

Is there any DSDT wizard who can check and fix my extracted dsdt.aml ?
Hope so :-D

Thank you ...have a nice day!
[K]

Can't attach with uploader, here's the file: http://www.mediafire...rmycuzry1uoamg4

#79
ruki250

ruki250

    InsanelyMac Protégé

  • Members
  • PipPip
  • 57 posts
  • Gender:Not Telling
Help me please!!!!!! :help: I don't understand how to fix!!!! this is my dsdt file!!!!
Attached File  dsdt.aml.zip   21.37KB   0 downloads

Thanx in advance!!!!!

#80
RehabMan

RehabMan

    InsanelyMac Legend

  • Coders
  • 1,452 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars
@zprood,

First of all nice work on this kext. But there was a bug that was bothering me (and others) so I decided to tackle it. The bug was as follows:

- shutdown your computer
- remove all batteries
- boot computer and run Mac OS X
- click on battery status in menu bar

bug: Observe that it shows No Batteries Available, Power Source: Battery

Cute, eh? No batteries but running on battery...

The fix was to add a couple of lines to pollBatteryState:

		if (fBatteryPresent) {
			fProvider->getBatteryBIF();
			fProvider->getBatteryBST();
		} else {
			setFullyCharged(false);
			clearBatteryState(true);
			//rehabman: added to correct power source Battery if boot w/ no batteries
			fACConnected = true;
			setExternalConnected(fACConnected);
		}

I have posted a build (and source) with this fix over at the ProBook forum on tonymacx86.com.

Here is the link: http://www.tonymacx8...html#post414347

If you're still watching this thread and working on this kext, perhaps you'll want to patch-in my fix.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy