AppleUHCItdMemoryBlock.cpp [plain text]
#include <IOKit/usb/IOUSBLog.h>
#include "AppleUSBUHCI.h"
#include "AppleUHCItdMemoryBlock.h"
#include "AppleUHCIListElement.h"
#define super IOBufferMemoryDescriptor
OSDefineMetaClassAndStructors(AppleUHCItdMemoryBlock, IOBufferMemoryDescriptor);
AppleUHCItdMemoryBlock*
AppleUHCItdMemoryBlock::NewMemoryBlock(void)
{
AppleUHCItdMemoryBlock *me = new AppleUHCItdMemoryBlock;
IOByteCount len;
if (!me)
USBError(1, "AppleUHCItdMemoryBlock::NewMemoryBlock, constructor failed!");
if (me && !me->initWithOptions(kIOMemorySharingTypeMask, kUHCIPageSize, kUHCIPageSize))
{
USBError(1, "AppleUHCItdMemoryBlock::NewMemoryBlock, initWithOptions failed!");
me->release();
return NULL;
}
me->prepare();
me->_sharedLogical = (UHCITransferDescriptorSharedPtr)me->getBytesNoCopy();
bzero(me->_sharedLogical, kUHCIPageSize);
me->_sharedPhysical = me->getPhysicalSegment(0, &len);
return me;
}
UInt32
AppleUHCItdMemoryBlock::NumTDs(void)
{
return TDsPerBlock;
}
IOPhysicalAddress
AppleUHCItdMemoryBlock::GetPhysicalPtr(UInt32 index)
{
IOPhysicalAddress ret = NULL;
if (index < TDsPerBlock)
ret = _sharedPhysical + (index * sizeof(UHCITransferDescriptorShared));
return ret;
}
UHCITransferDescriptorSharedPtr
AppleUHCItdMemoryBlock::GetLogicalPtr(UInt32 index)
{
UHCITransferDescriptorSharedPtr ret = NULL;
if (index < TDsPerBlock)
ret = &_sharedLogical[index];
return ret;
}
AppleUHCItdMemoryBlock*
AppleUHCItdMemoryBlock::GetNextBlock(void)
{
return _nextBlock;
}
void
AppleUHCItdMemoryBlock::SetNextBlock(AppleUHCItdMemoryBlock* next)
{
_nextBlock = next;
}