Re: Manual sleep vs automatic sleep
Re: Manual sleep vs automatic sleep
- Subject: Re: Manual sleep vs automatic sleep
- From: Ethan Bold <email@hidden>
- Date: Wed, 13 Sep 2006 15:35:57 -0700
Hello-
This is not the optimal API-set to use to power manage your driver.
For one thing, this API does not guarantee proper sleep/wake ordering
between you and your provider.
Instead call:
IOService::PMinit()
IOService::joinPMtree()
IOService::registerPowerDriver()
And you can receive your sleep/wake notifications by overriding:
IOService::setPowerState()
I just quickly googeld for "setPowerState" and found this
IOPCIDevice.cpp example of signing up for power management.
http://darwinsource.opendarwin.org/Current/IOPCIFamily-34/IOPCIDevice.cpp
Your code will look very similar to that, except you only need two
power states (0 == off; 1 == on):
static IOPMPowerState powerStates[ kIOPCIDevicePowerStateCount ] =
{
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, IOPMPowerOn, IOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-Ethan
On Sep 13, 2006, at 10:12 AM, rohit dhamija wrote:
Hi All,
I have developed kext for my USB bulk device for Mac OS X 10.4.7 ppc
G5/Intel.
I need to save some context information before the system goes to
sleep mode. The user can either do a manual sleep (going top left ,
click apple button and then sleep) or automatic sleep ( it will
sleep as per the settings done in Energysaver )
Is there any difference b/w these two types of sleep ? Are there
various types of sleep that we need to handle ? Below is the peice
of code for handling sleep notification. But I am not sure if it
will cater all types of sleep - sleep manual as well automatic.
Please suggest.
// register sleep notification
_powerEventNotifier =
registerPrioritySleepWakeInterest(MyDriver::handlePowerEvent,this);
if (_powerEventNotifier) {
retain();
//
OReturn MyDriver::handlePowerEvent(void *target,void *refCon,
UInt32 messageType,IOService *provider,
void *messageArgument,vm_size_t argSize)
{
IOReturn err = kIOReturnUnsupported;
MyDriver *tmpSntl = OSDynamicCast(MyDriver, (OSObject*)target);
if(!tmpSntl)
{
DBLog(("\nMyDriver::handlePowerEvent, ERROR! provider invalid.\n"));
return err;
}
switch (messageType) {
case kIOMessageCanSystemSleep:
break;
case kIOMessageSystemWillSleep:
MYLOGIC_FOR_SAVING_CONTEXT();
err = kIOReturnSuccess;
break;
case kIOMessageSystemWillNotSleep:
break;
default:
err = kIOReturnUnsupported;
break;
}
return(err);
}
Thanks and Regards,
Rohit Dhamija
--
Rohit Dhamija(M) 9818446545
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden