| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
Hi, I am converting the IOMemoryCursor based DMA in my IOKit PCI
driver, for my company's PCI interface cards, to use IODMACommand. I create the IODMACommand instance during driver startup: queue->MemCmdP
= IODMACommand::withSpecification ( &newSegment, 32, 0,
IODMACommand::kMapped, 0, 1 ); if (
(void*)NULL == queue->MemCmdP ) return
( 0 ); I release the IODMACommand during driver shutdown: if (
(IODMACommand*)NULL != MemCmdP ) MemCmdP->release
( ); Before creating the ScatterGather list I associated the data
buffer with the IODMACommand: MemCmdP->setMemoryDescriptor
( MemDescP ); I the call gen32IOVMSegments() to create ScatterGather
entries: TableUsed =
255; IOReturn ret =
MemCmdP->gen32IOVMSegments ( (UInt64*)&( StartPoint ),
(IODMACommand::Segment32 *)Entry, &TableUsed ); switch ( ret ) { //
Yay! Generated segments correctly. case
kIOReturnSuccess: break; //
Lots of possible reasons for failure. case
kIOReturnOverrun: IOLog
( "build(): gen32IOVMSegments() returned kIOReturnOverrun\n" ); return
( ret ); case
kIOReturnMessageTooLarge: IOLog ( "build(): gen32IOVMSegments()
returned kIOReturnMessageTooLarge\n" ); return ( ret ); case
kIOReturnNotReady: IOLog
( "build(): gen32IOVMSegments() returned kIOReturnNotReady\n" ); return
( ret ); case
kIOReturnBadArgument: IOLog ( "build():
gen32IOVMSegments() returned kIOReturnBadArgument\n" ); return
( ret ); } if ( 0L ==
TableUsed ) return
( kIOReturnNoMemory ); This is the API for my custom Segment function which is
provided during IODMACommand:withSpecification() call: bool HWPlot_DmaQueue::newSegment ( IODMACommand
*MemCmdP, IODMACommand::Segment64 Segment, void *Segments, UInt32 SegmentIndex
) { // Custom ScatterGather
list builder function. IOLog (
"HWPlot_DmaQueue::newSegment(0x%p, [ %ld, %ld ], 0x%p, %ld): -
Called\n", MemCmdP,
(UInt32)Segment.fIOVMAddr, (UInt32)Segment.fLength, Segments, SegmentIndex ); ... return ( true
); } I Map the data buffer into memory as follows: Entry->MemDescP
= IOMemoryDescriptor::withAddressRange ( (mach_vm_address_t)Entry->Buffer,
(mach_vm_size_t)Entry->BuffLen,
kIODirectionNone, ( hwplot->userClient )->fTask ); if (
(IOMemoryDescriptor*)NULL == Entry->MemDescP ) return
( kIOReturnCannotWire ); if (
kIOReturnSuccess != ( Entry->MemDescP )->prepare ( kIODirectionOutIn ) ) { if
( (IOMemoryDescriptor*)NULL != Entry->MemDescP ) Entry->MemDescP->release
( ); return
( kIOReturnCannotWire ); } I Unmap the data buffer from memory as follows: if (
(IOMemoryDescriptor*)NULL != Entry->MemDescP ) { result
= Entry->MemDescP->complete ( ); Entry->MemDescP->release
( ); } My problem is newSegment does not get called so that I can
create my ScatterGather list. The Apple sample code uses one of the 9
predefined functions but does NOT demonstrate use of a custom segmenting
function, such as I need. Any ideas how I get my segment function called? I note from the header file IODMACommand.h that the segment
function is a C function. Is a static C++ function allowed as it was for
IOMemoryCursor? I would expect an ScatterGather list of, worst case, 1 entry
per 4k page giving approx 230 entries per 1000Kb. When I used an IOMemoryCursor I get this behaviour, albeit
very slow. With the IODMACommand method I consistently get
kIOReturnOverrun errors at 255 entries. What am I missing or doing wrong? I also had linker/loader related errors as I had missing OSDependencies
which this list helped me resolve, but these dependencies were not listed
anywhere. Thanks, Peter Young
No virus found in this outgoing message. | |||||||||||||
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-drivers mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-drivers/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.