AppleCudaUserClient.cpp [plain text]
#include <IOKit/IOMessage.h>
#include "AppleCudaUserClient.h"
#ifndef NULL
#define NULL 0
#endif
#define super IOUserClient
OSDefineMetaClassAndStructors(AppleCudaUserClient, IOUserClient)
AppleCudaUserClient*
AppleCudaUserClient::withTask(task_t owningTask)
{
AppleCudaUserClient *client;
client = new AppleCudaUserClient;
if (client != NULL)
{
if (client->init() == false)
{
client->release();
client = NULL;
}
}
if (client != NULL)
{
client->fTask = owningTask;
}
return ( client );
}
bool
AppleCudaUserClient::start(IOService *provider)
{
bool result = false;
theInterface = OSDynamicCast(AppleCuda, provider);
if (theInterface != NULL)
{
result = super::start( provider );
if ( result == false )
{
IOLog( "%s::start - provider start failed\n", getName() );
}
}
return( result );
}
IOReturn
AppleCudaUserClient::clientClose(void)
{
if ( theInterface ) {
detach( theInterface );
theInterface = NULL;
}
return( kIOReturnSuccess );
}
IOReturn
AppleCudaUserClient::clientDied(void)
{
return( clientClose() );
}
IOReturn
AppleCudaUserClient::connectClient(IOUserClient *client)
{
return( kIOReturnSuccess );
}
IOReturn
AppleCudaUserClient::registerNotificationPort(mach_port_t port, UInt32 type)
{
return( kIOReturnUnsupported );
}
IOReturn
AppleCudaUserClient::setProperties( OSObject * properties )
{
OSDictionary * dict;
dict = OSDynamicCast( OSDictionary, properties );
if ((dict) && (theInterface != NULL))
{
OSData *data;
if( (data = OSDynamicCast( OSData, dict->getObject( "WakeOnRing" )) ) )
{
UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
IOLog("%s::setProperties WakeOnRing %d (NOT SUPPORTED)\n",getName(), myBool);
return( kIOReturnUnsupported );
}
if( (data = OSDynamicCast( OSData, dict->getObject("FileServer")) ) )
{
UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
theInterface->setFileServerMode( myBool );
return( kIOReturnSuccess );
}
if( (data = OSDynamicCast( OSData, dict->getObject( "SleepNow" )) ) )
{
UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
if ( myBool )
{
theInterface->demandSleepNow();
IOLog( "%s::setProperties SleepNow\n", getName() );
}
return( kIOReturnSuccess );
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoWake")) ) )
{
UInt32 newTime;
IOByteCount len = data->getLength();
if ( len == sizeof( UInt32 ) )
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->messageClients(kIOPMUMessageLegacyAutoWake, (void *)newTime);
return( kIOReturnSuccess );
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoWakePriv"))))
{
UInt32 newTime;
IOByteCount len = data->getLength();
if ( len == sizeof( UInt32 ) )
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->setWakeTime( newTime * 1000 );
return( kIOReturnSuccess );
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoPower")) ) )
{
UInt32 newTime;
IOByteCount len = data->getLength();
if (len == sizeof( UInt32 ) )
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->messageClients(kIOPMUMessageLegacyAutoPower, (void *)newTime);
return( kIOReturnSuccess );
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoPowerPriv"))))
{
UInt32 newTime;
IOByteCount len = data->getLength();
if (len == sizeof( UInt32 ) )
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->setPowerOnTime( newTime );
return( kIOReturnSuccess );
}
}
return( kIOReturnBadArgument );
}