Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IODMACommand help needed.



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

 

 

" Build a man a fire - he's warm for a day. Set a man on fire - he's warm for the rest of his life!"

 

Peter Young
Senior Software Engineer
Remove .nospam from address
email@hidden

HighWater Designs Ltd
1-6 St. George's Business Park,
Alstone Lane, Cheltenham,
Gloucestershire, GL51 8HF UK

Registered in England and Wales No 2111605. VAT No GB 448 485117

 

 

 

 


No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.467 / Virus Database: 269.7.6/814 - Release Date: 21/05/2007 14:01

 _______________________________________________
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



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.