Mailing Lists: Apple Mailing Lists

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

Re: length parameter of IOUSBPipe->write()



Hi,
	As far as I could tell, the number of bytes being transfered on
the bus was not correct.  The number of bytes being transfered on the bus
was equal to the size of the memory descriptor length and the "reqCount"
parameter was ignored (unless perhaps if the "reqCount" parameter was
zero).  The code I am refering to appears to say "While the number of
bytes transfered so far is less than reqCount, transfer X more bytes",
where X could be much greater than reqCount.  (The "reqCount" parameter is
passed in as "bufferSize").  This results in a greater number of bytes
being transfered on the bus.

	This is not a problem in that it is easily worked around by
calling memoryDescriptor->setLength().  However, at the very least the
documentation for that particular IOUSBPipe->Write() method is misleading
(it should say "the reqCount parameter may be ignored, use the memory
descriptor setLength() method to set the transfer length").  Otherwise, I
would be happy to offer a "fix" for the Darwin code in question if someone
else could verify that it needs a fix.

	-Dan

On Sun, 9 Jan 2005, David Ferguson wrote:

> Have you observed the wrong number of bytes being transferred on the USB bus?
>
>
> I think the code are referring to is using the length of a physical
> segment. Memory descriptors don't have to describe contiguous logical
> or physical address -- the USB software has to do a lot of work to
> "unscramble" this and put it into a form that the USB controllers
> (which do require contiguous logical address) can use.
>
> Regards,
>
> David Ferguson
>
> At 12:33 PM -0500 1/9/05, Daniel Sumorok wrote:
> >Hello,
> >
> >	I am developing an in-kernel usb device driver.  When I call the
> >following method, defined in IOUSBPipe.h, the "reqCount" parameter is
> >ignored.  Instead, it uses buffer->GetLength().
> >
> >virtual IOReturn Write(
> >     IOMemoryDescriptor * buffer,
> >     UInt32 noDataTimeout,
> >     UInt32 completionTimeout,
> >     IOByteCount reqCount,
> >     IOUSBCompletion * completion = 0);
> >
> >I think I traced the problem down to the
> >AppleUSBOHCI::CreateGeneralTransfer() method in AppleUSBOHCI_UIM.cpp
> >(from the Darwin source).  In this method, the "reqCount" parameter is
> >passed in as "bufferSize".  The following is an abridged excerpt from the
> >CreateGeneralTransfer() function:
> >
> >         transferOffset = 0;
> >         while (transferOffset < bufferSize)
> >         {
> >	  // Figure out what pages compromise the memory descriptor,
> >	  // and get the phsical address of those pates
> >           if (pageCount == 2)
> >	  {
> >	    // ...
> >             transferOffset += physicalAddresses[1].length;
> >           }
> >           transferOffset += physicalAddresses[0].length;
> >	  // ...
> >         }
> >
> >   It appears (to me) that the length of the transfer is set by the
> >   memory descriptor length, not the "reqCount" (or "bufferSize")
> >   parameters.  Even though the while() condition depends on the
> >   "bufferSize" variable, the body of the while loop uses on the size
> >   of the memory descriptor.  Is this the intended behavior?
> >
> >	-Dan
> >  _______________________________________________
> >Do not post admin requests to the list. They will be ignored.
> >Usb mailing list      (email@hidden)
> >Help/Unsubscribe/Update your Subscription:
> >http://lists.apple.com/mailman/options/usb/email@hidden
> >
> >This email sent to email@hidden
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden

References: 
 >USB (From: "nishino tetsuya" <email@hidden>)
 >length parameter of IOUSBPipe->write() (From: Daniel Sumorok <email@hidden>)
 >Re: length parameter of IOUSBPipe->write() (From: David Ferguson <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.