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