ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IOMemoryCursor |
Inherits from: | |
Declared In: |
A mechanism to convert memory references to physical addresses.
IOMemoryCursor declares the super class that all
specific memory cursors must inherit from, but a memory cursor can be created without a specific format subclass by just providing a segment function to the initializers. This class does the difficult stuff of dividing a memory descriptor into a physical scatter/gather list appropriate for the target hardware.
A driver is expected to create a memory cursor and configure it to the limitations of its DMA hardware; for instance the memory cursor used by the FireWire SBP-2 protocol has a maximum physical segment size of 2^16 - 1 but the actual transfer size is unlimited. Thus it would create a cursor with a maxSegmentSize of 65535 and a maxTransfer size of UINT_MAX. It would also provide a SegmentFunction that can output a pagelist entry.
Below is the simplest example of a SegmentFunction:
void IONaturalMemoryCursor::outputSegment(PhysicalSegment segment, void * outSegments, UInt32 outSegmentIndex) { ((PhysicalSegment *) outSegments)[outSegmentIndex] = segment; }
Generates a physical scatter/gather list given a memory descriptor.
Primary initializer for the IOMemoryCursor class.
Creates and initializes an IOMemoryCursor in one operation.
genPhysicalSegments |
Generates a physical scatter/gather list given a memory descriptor.
public
virtual UInt32 genPhysicalSegments( IOMemoryDescriptor *descriptor, IOByteCount fromPosition, void *segments, UInt32 maxSegments, UInt32 maxTransferSize = 0, IOByteCount *transferSize = 0);
descriptor
IOMemoryDescriptor that describes the data associated with an I/O request.
fromPosition
Starting location of the I/O within a memory descriptor.
segments
Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction without interpretation by the cursor.
maxSegments
Maximum number of segments that can be written to segments array.
maxTransferSize
Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
transferSize
Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor.
initWithSpecification |
Primary initializer for the IOMemoryCursor class.
public
virtual bool initWithSpecification( SegmentFunction outSegFunc, IOPhysicalLength maxSegmentSize = 0, IOPhysicalLength maxTransferSize = 0, IOPhysicalLength alignment = 1);
outSegFunc
SegmentFunction to call to output one physical segment.
maxSegmentSize
Maximum allowable size for one segment. Defaults to 0.
maxTransferSize
Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
alignment
Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
Returns true if the inherited classes and this instance initialize successfully.
withSpecification |
Creates and initializes an IOMemoryCursor in one operation.
public
static IOMemoryCursor * withSpecification( SegmentFunction outSegFunc, IOPhysicalLength maxSegmentSize = 0, IOPhysicalLength maxTransferSize = 0, IOPhysicalLength alignment = 1);
outSegFunc
SegmentFunction to call to output one physical segment.
maxSegmentSize
Maximum allowable size for one segment. Defaults to 0.
maxTransferSize
Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
alignment
Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
Returns a new memory cursor if successfully created and initialized, 0 otherwise.
Factory function to create and initialize an IOMemoryCursor in one operation. For more information, see initWithSpecification.
SegmentFunction |
public
typedef void ( *SegmentFunction)( PhysicalSegment segment, void *segments, UInt32 segmentIndex);
segment
The physical address and length that is next to be output.
segments
Base of the output vector of DMA address length pairs.
segmentIndex
Index to output 'segment' in the 'segments' array.
Pointer to a C function that outputs a single physical segment to an element in the array as defined by the segments and segmentIndex parameters.
PhysicalSegment |
public
struct PhysicalSegment { IOPhysicalAddress location; IOPhysicalLength length; };
A physical address/length pair.
alignMask |
protected
IOPhysicalLength alignMask;
Currently unused. Reserved for automated aligment restriction code.
maxSegmentSize |
protected
IOPhysicalLength maxSegmentSize;
maxTransferSize |
protected
IOPhysicalLength maxTransferSize;
Maximum size of a transfer that this memory cursor is allowed to generate.
outSeg |
protected
SegmentFunction outSeg;
IOPhysicalSegment |
#define IOPhysicalSegment IOMemoryCursor::PhysicalSegment
Backward compatibility define for the old non-class scoped type definition. See PhysicalSegment.
OutputSegmentFunc |
#define OutputSegmentFunc IOMemoryCursor::SegmentFunction
Backward compatibility define for the old non-class scoped type definition. See SegmentFunction.
|
Last Updated: 2008-12-19