AppleCudaUserClient.cpp [plain text]
#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);
else
result = false;
if (result == false) {
IOLog("AppleCudaUserClient: provider start failed\n");
}
return (result);
}
IOReturn
AppleCudaUserClient::clientClose(void)
{
detach(theInterface);
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("AppleCudaUserClient::setProperties WakeOnRing %d\n", myBool);
return kIOReturnSuccess;
}
if( (data = OSDynamicCast( OSData, dict->getObject("FileServer")))) {
UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
theInterface->setFileServerMode(myBool);
IOLog("AppleCudaUserClient::setProperties FileServer %d\n", myBool != 0);
return kIOReturnSuccess;
}
if( (data = OSDynamicCast( OSData, dict->getObject("SleepNow")))) {
UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
if (myBool)
{
theInterface->demandSleepNow();
IOLog("AppleCudaUserClient::setProperties SleepNow\n");
}
return kIOReturnSuccess;
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoWake")))) {
UInt32 newTime;
IOByteCount len = data->getLength();
if (len == 4)
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->setWakeTime(newTime * 1000);
IOLog("AppleCudaUserClient::setProperties AutoWake 0x%08lx\n", newTime);
return kIOReturnSuccess;
}
if( (data = OSDynamicCast( OSData, dict->getObject("AutoPower")))) {
UInt32 newTime;
IOByteCount len = data->getLength();
if (len == 4)
newTime = *((UInt32*)data->getBytesNoCopy());
else
newTime = 0;
theInterface->setPowerOnTime(newTime);
IOLog("AppleCudaUserClient::setProperties AutoPower 0x%08lx\n", newTime);
return kIOReturnSuccess;
}
}
return(kIOReturnBadArgument);
}