AppleRAIDUserClient.cpp [plain text]
#include "AppleRAID.h"
#define super IOUserClient
OSDefineMetaClassAndStructors(AppleRAIDUserClient, IOUserClient);
bool
AppleRAIDUserClient::initWithTask(task_t owningTask,void *security_id , UInt32 type)
{
IOLogUC("AppleRAIDUserClient::initWithTask()\n");
if (!super::initWithTask(owningTask, security_id , type))
return false;
if (!owningTask)
return false;
fTask = owningTask;
fProvider = NULL;
fDead = false;
return true;
}
bool
AppleRAIDUserClient::start(IOService * provider)
{
IOLogUC("AppleRAIDUserClient::start()\n");
if(!super::start(provider))
return false;
fProvider = OSDynamicCast(AppleRAID, provider);
if (!fProvider)
return false;
return true;
}
void
AppleRAIDUserClient::stop(IOService * provider)
{
IOLogUC("AppleRAIDUserClient::stop()\n");
super::stop(provider);
}
IOReturn
AppleRAIDUserClient::open(void)
{
IOLogUC("AppleRAIDUserClient::open()\n");
if (!fProvider)
return kIOReturnNotAttached;
if (!fProvider->open(this))
return kIOReturnExclusiveAccess;
return kIOReturnSuccess;
}
IOReturn
AppleRAIDUserClient::close(void)
{
IOLogUC("AppleRAIDUserClient::close()\n");
if (!fProvider)
return kIOReturnNotAttached;
if (fProvider->isOpen(this))
fProvider->close(this);
return kIOReturnSuccess;
}
IOReturn
AppleRAIDUserClient::clientClose(void)
{
IOLogUC("AppleRAIDUserClient::clientClose()\n");
close();
if (fTask)
fTask = NULL;
fProvider = NULL;
terminate();
return kIOReturnSuccess;
}
IOReturn
AppleRAIDUserClient::clientDied(void)
{
IOReturn ret = kIOReturnSuccess;
IOLogUC("AppleRAIDUserClient::clientDied()\n");
fDead = true;
ret = super::clientDied();
return ret;
}
IOReturn
AppleRAIDUserClient::message(UInt32 type, IOService * provider, void * argument)
{
IOLogUC("AppleRAIDUserClient::message()\n");
switch ( type )
{
default:
break;
}
return super::message(type, provider, argument);
}
bool
AppleRAIDUserClient::finalize(IOOptionBits options)
{
bool ret;
IOLogUC("AppleRAIDUserClient::finalize()\n");
ret = super::finalize(options);
return ret;
}
bool
AppleRAIDUserClient::terminate(IOOptionBits options)
{
bool ret;
IOLogUC("AppleRAIDUserClient::terminate()\n");
ret = super::terminate(options);
return ret;
}
IOExternalMethod *
AppleRAIDUserClient::getTargetAndMethodForIndex(IOService ** target, UInt32 index)
{
IOLogUC("AppleRAIDUserClient::getTargetAndMethodForIndex(index = %d)\n", (int)index);
static const IOExternalMethod sMethods[kAppleRAIDUserClientMethodMaxCount] =
{
{ NULL, (IOMethod) &AppleRAIDUserClient::open, kIOUCScalarIScalarO, 0, 0 },
{ NULL, (IOMethod) &AppleRAIDUserClient::close, kIOUCScalarIScalarO, 0, 0 },
{ NULL, (IOMethod) &AppleRAID::getListOfSets, kIOUCScalarIStructO, 1, 0xffffffff },
{ NULL, (IOMethod) &AppleRAID::getSetProperties, kIOUCStructIStructO, kAppleRAIDMaxUUIDStringSize, 0xffffffff },
{ NULL, (IOMethod) &AppleRAID::getMemberProperties, kIOUCStructIStructO, kAppleRAIDMaxUUIDStringSize, 0xffffffff },
{ NULL, (IOMethod) &AppleRAID::updateSet, kIOUCStructIStructO, 0xffffffff, 0xffffffff }
};
if (index < (UInt32)kAppleRAIDUserClientMethodMaxCount)
{
if (index == kAppleRAIDClientOpen || index == kAppleRAIDClientClose)
{
*target = this;
}
else
{
*target = fProvider;
}
return (IOExternalMethod *) &sMethods[index];
}
return NULL;
}