Jump to content

ACPIThermal driver development.


  • Please log in to reply
26 replies to this topic

#1
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

  • Members
  • PipPip
  • 87 posts
  • Gender:Male
  • Location:Ukraine
Before 10.7 I have used AppleACPIThermal.kext for thermal zones, but I in lion this driver has loosed ability to work with active cooling on my notebook(hp 6720).

So after lot of tries to fix this in DSDT i has decided to develop own driver and see what is going on ...

The problem was in _ALx methods in thermal zone - them returns NULL in lion(in snow they works as expected), but must return fan devices list.
Any ideas about this behavior?

So I have added methods to thermal zone in DSDT:
- EALx - to enable cooling for _ACx
- DALx - to disable cooling for _ACx

(Thermal Zones TZ1 and TZ2 in my DSDT came from SSDT)

And added use of them to my driver.
Now I have tested driver in lion and snow - works good, I have active cooling on my laptop.

The only things implemented in driver at this moment:
1. Check zone temperature.
2. Get _ACx values, and if need enable/disable cooling form them with EACx/DACx methods(_ALx - not used at this moment)
Also thermal zone driver, may be, need to implement some actions for passive cooling(such as cpu throttling) - but i do not know how...

Any suggestions and fixes are welcome =)

Also this driver is diqused projectosx.

Attached Files



#2
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Hello, Third Smile!

First, thank you for this driver.

Now, I have KP with this driver (no specific info, just kernel trap blah blah). I implemented EAL/DALs as you've said, and I also examined source, but I could nto find any error which could cause KP. I'll attach my DSDT (8710p, but same BIOS and DSDT as in 65xx series). CPU is Penryn, but I think it should not be of any significant value here (as I drop SSDT's and include TZ SSDT with my DSDT).

Best regards, --py

Attached Files

  • Attached File  DSDT.txt   665.14KB   14 downloads


#3
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,409 posts
  • Gender:Male
  • Location:Tru, Venezuela

Now, I have KP with this driver (no specific info, just kernel trap blah blah).

Hi, I also had those KPs before. I think you should try to correct the dependencies for Lion in the info.plist.

#4
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Hi juanerson!

Thanks, I solved KP, but driver won't load (it cannot allocate AppleACPIThermalZone class). Of course, setting IOClass to anything else (like ACPIThermal, as default) yields the same KP.

#5
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Sorry, it seems that my DSDT is much more crappy than I expected. I managed to get driver working ;)

(TMP not working, and some methods causing KPs on ACPIPlatform ...)

#6
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,409 posts
  • Gender:Male
  • Location:Tru, Venezuela
Are you using Lion's vanilla AppleACPIPlatform.kext?

#7
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Yes. Why?

#8
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,409 posts
  • Gender:Male
  • Location:Tru, Venezuela
Because it is required for to works with this driver... are needed all vanilla ACPI-Family .kexts. Just for records.

#9
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
I'm using them (all vanilla, 10.7.2). In fact, I tried to resolve problem, and I currently have two problems (and will try to fix them):
* CRT and AL* functions are panicking (most probably in TZ2, which manages graphics). By extracting those values on windows I'm able to proceed (they shoudl be constants all the time).
* TMP always returns 16. I'll try to implement ThirdSmile's 16-bit fix, and post results here.

Crappy HP DSDT ... :@

#10
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

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

Hi, I also had those KPs before. I think you should try to correct the dependencies for Lion in the info.plist.


Dependencies in driver are correct(and incorrect dependencies can not be reason of KP - it is just requirements to load).

Hi juanerson!

Thanks, I solved KP, but driver won't load (it cannot allocate AppleACPIThermalZone class). Of course, setting IOClass to anything else (like ACPIThermal, as default) yields the same KP.


Of course, there are no KP - because driver is not loading(because of incorrect dependencies).


Because it is required for to works with this driver... are needed all vanilla ACPI-Family .kexts. Just for records.


It is not required(this driver must work with old ACPIPlatform.kext as well), but I am using all vanilla kexts when testing it(10.7.x, 10.6.7, 10.6.8).

About KP: probably reason can be in wrong return from ACPI methods(When debuging driver, I have KP when I have tried to use 32bit value as 16bit one)...

Try to use driver from attachment ACPIThermal-test1 and post your IOReg(from IORegistryExplorer) - it will output(to IORegistry) values from _ACx and _TMP methods in ThermalZone devices.


Also try too use ACPIThermal-test2 (it is the same driver as in first post, but all values from ACPI are treat as 64bit values - this can reduce number of KP).


Upd:

Also about debuging driver - you can add some logging to see at what place in driver KP occurs.
For example:
If you are suspecting some part of code in KP, so you can add IOLog("Begin part\n") before it and IOLog("End Part\n") after it - and if you are right and error is here you will see only phrase "Begin part" in KP log but no corresponding "End part" after it.
In this way we can finout mistakes in driver and fix them.

Attached Files



#11
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
OK, so far I just want driver to report properly TMP value in IOREG (so just added empty EAL/DALs and set _ACx to zero). After that I will plug in fan control code.

KPs gone. But, my TMP is always 16, because C0EE method always return 0 (even with 16-bit fix you already suggested on 6520 thread). I tried your 64-bit driver, but it still returns 0. I examined the C0EE code but have no idea why it returns 0 (maybe it cannot access operating region?!) ...

Best regards,

#12
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,409 posts
  • Gender:Male
  • Location:Tru, Venezuela

Dependencies in driver are correct(and incorrect dependencies can not be reason of KP - it is just requirements to load).

Of course, there are no KP - because driver is not loading(because of incorrect dependencies).

With hight respect my friend:

1) No, dependencies are incorrect in the original Info.plist inside the driver extension. Therefore is causing the KP, and the reason is the mismatch with AppleACPIPlatform version running from /S/L/E and/or main prelinked kernel caché.

2) I think some people are mixing the terms? Because in "IOKitPersonalities" if you have a wrong "CFBundleIdentifier" entry like "AppleACPIThermalZone" or "XYZClass", the driver will not load due to mismatch with the binary itself, or I am wrong?.

3) Then, from I know Dependencies = OSBundleLibraries, and Nothing More.

It is not required(this driver must work with old ACPIPlatform.kext as well), but I am using all vanilla kexts when testing it(10.7.x, 10.6.7, 10.6.8).

About KP: probably reason can be in wrong return from ACPI methods(When debuging driver, I have KP when I have tried to use 32bit value as 16bit one)...

4) I see you have all vanilla like me. Good, because AppleACPIPlatform.kext depend of ACPI and PCI Family drivers, included in his dependencies you know. I mean, for me is very important this point, specially After wake up from Sleep, because ACPIThermal.kext will not load again if not satisfied the same dependencies of AppleACPIPlatform.

5) Please Remember, Now we have the same structural code in DSDT for ThermalZones with your adaptations, But from the beginning was not like that. So, in that moment, how is possible I didn't get it a wrong ACPI bad code return, KP, etc? If as I said, I could load your driver, Even before the last fix (16-bit), and Just only by writing the right dependencies, not a big deal.

Anyway, Thank You Again for your excellent driver!

#13
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

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

With hight respect my friend:

1) No, dependencies are incorrect in the original Info.plist inside the driver extension. Therefore is causing the KP, and the reason is the mismatch with AppleACPIPlatform version running from /S/L/E and/or main prelinked kernel caché.

2) I think some people are mixing the terms? Because in "IOKitPersonalities" if you have a wrong "CFBundleIdentifier" entry like "AppleACPIThermalZone" or "XYZClass", the driver will not load due to mismatch with the binary itself, or I am wrong?.

3) Then, from I know Dependencies = OSBundleLibraries, and Nothing More.

4) I see you have all vanilla like me. Good, because AppleACPIPlatform.kext depend of ACPI and PCI Family drivers, included in his dependencies you know. I mean, for me is very important this point, specially After wake up from Sleep, because ACPIThermal.kext will not load again if not satisfied the same dependencies of AppleACPIPlatform.

5) Please Remember, Now we have the same structural code in DSDT for ThermalZones with your adaptations, But from the beginning was not like that. So, in that moment, how is possible I didn't get it a wrong ACPI bad code return, KP, etc? If as I said, I could load your driver, Even before the last fix (16-bit), and Just only by writing the right dependencies, not a big deal.

Anyway, Thank You Again for your excellent driver!


I am new in osx driver development, but I think dependencies are correct - see IOKit Fundamentals at page 64.

About where dependencies in my driver - I taken them from ACPIBatteryMonitor (which i have used as one of samples at begining of work)

1) AppleACPIPlatform - What are you talking about? There are no dependency to this bundle. It is separate driver NOT plugin for AppleACPIPlatform - and it has no direct relation with AppleACPIPlatform (about legacy AppleACPIThermal - it is plugin)

2) Yes, Pasa Yildirim corected not only dependencies, but also bundle identifiers.

3) Read IOKit Fundamentals. Answer to that post is here (error was not in dependencies! the error was in driver code).

4) read answer to 1.

5) "last fix (16-bit)" does not fix any bug - it only allows driver do not panic when return from ACPI is bigger as it must be(in other words - when return wfom ACPI in invalid). The only changes is: replace unsigned16BitValue method call by unsigned64BitValue and change in type of some variables.

#14
Pasa Yildirim

Pasa Yildirim

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Can anybody post its DSDT, which is working with ACPIThermal (as I said, my dsdt is almost the same as 65xx series DSDT).

In windows I checked fields within OperationRegion, theyre correct ...

#15
juanerson

juanerson

    InsanelyMac Legend

  • Local Moderators
  • 1,409 posts
  • Gender:Male
  • Location:Tru, Venezuela

1) AppleACPIPlatform - What are you talking about? There are no dependency to this bundle. It is separate driver NOT plugin for AppleACPIPlatform - and it has no direct relation with AppleACPIPlatform (about legacy AppleACPIThermal - it is plugin)

Yes, was my fault in this point... I meant "IOACPIFamily" dependency. So, the correct one to avoid the KP (capture) is:
<key>com.apple.iokit.IOACPIFamily</key>	<string>1.0.0d1</string>
That's what I am talking about. And please... I am just trying to help in this thread :D NO more. Good Luck.

#16
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

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

Yes, was my fault in this point... I meant "IOACPIFamily" dependency. So, the correct one to avoid the KP (capture) is:

<key>com.apple.iokit.IOACPIFamily</key>	<string>1.0.0d1</string>
That's what I am talking about. And please... I am just trying to help in this thread :D


Yes it will work with such dependencies too, but - this change only probably(because now target platform is 10.6+) will allow to use this driver on systems older than 10.4(IOACPIFamily version 1.2.0 corresponds to osx 10.4)

Also this can not reduce number of KP - because dependency version means minimum version of bundle required to be loaded before driver, for it correct work and can not be reason of KP(except cases when dependency version is lower as required by bundle)

So I did not think that there is need of such change in driver dependencies list.

About concret KP, the error is "page fault"(form photo) - I think it is because of: wrong try to interpret some object as another completely different object(for example if ACPI return something like package instead of something like number), such error can occur.

Anyway, thanks for comments - in discussing we can do more ;)

#17
verleihnix

verleihnix

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
Hi All,

I've got rid of kp's loading the kext. (edited dependencies- thanks to juanerson)
Here is a new DSDT with bat working and ThirdSmiles tz inserts as well as ioreg with acpithermal.kext loaded.
Fan doesn't work. Found this in console:
com.apple.kextd: Kext id com.apple.driver.AppleACPIThermal not found; removing personalities from kernel.
Also in in zip the info.plist from acpithermal.

Attached File  nc6510b.zip   413.53KB   4 downloads

#18
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

  • Members
  • PipPip
  • 87 posts
  • Gender:Male
  • Location:Ukraine
1. You have changed not only dependencies - you have changed bundle ids. So driver is not loading because of wrong bundle ids that did not correspond to binaries.
2. ACPIThermal is not loaded at all - see your IOReg.
3. In post above I have written how you can try to determine place in which KP occurs - just try too add some logging.

Also I will say one more time AppleACPIThermal(by Apple) and ACPIThermal(by me) - are completely different drivers, DO NOT MIX THEM.

#19
verleihnix

verleihnix

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
ioreg with ACPIThermal_test1.kext loaded

Attached File  nc6510b.ioreg.zip   359.56KB   6 downloads

ACPIThermal_test2.kext causes kp

#20
ThirdSmile

ThirdSmile

    InsanelyMac Protégé

  • Members
  • PipPip
  • 87 posts
  • Gender:Male
  • Location:Ukraine
IOReg with test1 - looks promising.

Try this - probably it will panic too, but I have added some logging - so photo of KP screen and last messages in kernel log(you can see it in Console.app) would be useful to find-out the reason of KP.

Also - no need to install it, you can try using kextload utility:
[codebox]sudo chown -R 0:0 ACPIThermal.kext
sudo kextload ACPIThermal.kext[/codebox]

Good luck.

Attached Files







0 user(s) are reading this topic

0 members, 0 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