IOFWUserClientPhysAddrSpace.cpp [plain text]
#include "IOFWUserClientPhysAddrSpace.h"
#define MIN(a,b) ((a < b) ? a : b)
OSDefineMetaClassAndStructors(IOFWUserClientPhysicalAddressSpace, IOFWPhysicalAddressSpace) ;
bool
IOFWUserClientPhysicalAddressSpace::initWithDesc(
IOFireWireBus* bus,
IOMemoryDescriptor* mem)
{
if (!IOFWPhysicalAddressSpace::initWithDesc(bus, mem))
return false ;
UInt32 currentOffset = 0 ;
IOByteCount length ;
mSegmentCount = 0 ;
while (0 != fMem->getPhysicalSegment(currentOffset, & length))
{
currentOffset += length ;
mSegmentCount++ ;
}
return true ;
}
void
IOFWUserClientPhysicalAddressSpace::free()
{
IOFWPhysicalAddressSpace::free() ;
}
UInt32
IOFWUserClientPhysicalAddressSpace::getSegmentCount()
{
return mSegmentCount ;
}
IOReturn
IOFWUserClientPhysicalAddressSpace::getSegments(
UInt32* ioSegmentCount,
IOPhysicalAddress outPages[],
IOByteCount outLength[])
{
UInt32 segmentCount = MIN(*ioSegmentCount, mSegmentCount) ;
IOReturn result = kIOReturnSuccess ;
IOByteCount currentOffset = 0 ;
for(UInt32 segment=0; segment < segmentCount; segment++)
{
outPages[segment] = fMem->getPhysicalSegment(currentOffset, & outLength[segment]) ;
currentOffset+= outLength[segment] ;
}
return result ;
}