IODMAController.cpp [plain text]
#include <IOKit/IODMAController.h>
#define super IOService
OSDefineMetaClassAndAbstractStructors(IODMAController, IOService);
const OSSymbol *IODMAController::createControllerName(UInt32 phandle)
{
#define CREATE_BUF_LEN 48
char buf[CREATE_BUF_LEN];
snprintf(buf, CREATE_BUF_LEN, "IODMAController%08X", (uint32_t)phandle);
return OSSymbol::withCString(buf);
}
IODMAController *IODMAController::getController(IOService *provider, UInt32 dmaIndex)
{
OSData *dmaParentData;
const OSSymbol *dmaParentName;
IODMAController *dmaController;
dmaParentData = OSDynamicCast(OSData, provider->getProperty("dma-parent"));
if (dmaParentData == 0) return NULL;
dmaParentName = createControllerName(*(UInt32 *)dmaParentData->getBytesNoCopy());
if (dmaParentName == 0) return NULL;
dmaController = OSDynamicCast(IODMAController, IOService::waitForService(IOService::nameMatching(dmaParentName)));
return dmaController;
}
bool IODMAController::start(IOService *provider)
{
if (!super::start(provider)) return false;
_provider = provider;
return true;
}
void IODMAController::registerDMAController(IOOptionBits options)
{
OSData *phandleData;
phandleData = OSDynamicCast(OSData, _provider->getProperty("AAPL,phandle"));
_dmaControllerName = createControllerName(*(UInt32 *)phandleData->getBytesNoCopy());
setName(_dmaControllerName);
registerService(options | ((options & kIOServiceAsynchronous) ? 0 : kIOServiceSynchronous));
}
void IODMAController::completeDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand)
{
dmaES->completeDMACommand(dmaCommand);
}
void IODMAController::notifyDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp)
{
dmaES->notifyDMACommand(dmaCommand, status, actualByteCount, timeStamp);
}