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()



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>)



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.