USB transfer descriptors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

USB transfer descriptors

Post by mariuszp »

I am confused exactly what is put in the buffers for USB transfer descriptors like in OHCI or EHCI. Is it the full packet including the PID, ADDR etc fields? Or is it the contents of a DATA stage if any? Or what else?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: USB transfer descriptors

Post by BrightLight »

You put the data that is to be sent to the device. For example, for a USB setup transfer descriptor, the buffer will contain a USB setup packet. For a data-out transfer descriptor, the buffer will contain the data payload. The data-in transfer descriptors work the same way; the device will send you the data payload you requested, nothing more.

Edit for clarification: No, you don't put any extra fields in the buffer to be sent to the device, and the device as well will never send you extra fields that are not part of the actual data transfer. All USB transfer descriptors have fields that define which address/endpoint should receive the data payload, and the USB host controller is responsible for delivering the data to the proper endpoint on the proper device.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: USB transfer descriptors

Post by mariuszp »

So, to set the address, I send a the setup packet with bmRequestType field, bmRequest set to 5, etc?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: USB transfer descriptors

Post by BrightLight »

I don't remember the exact values and parameters for each setup request because I define them as constants in my code, but generally yes, to set the device address you perform a control operation, which involves a setup stage, optional data stages and a status stage.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: USB transfer descriptors

Post by mariuszp »

And each "stage" is a separate transfer descriptor?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: USB transfer descriptors

Post by BrightLight »

Yes. You make a setup transaction using a descriptor with a SETUP PID, which is different for each type of USB host controller. The data buffer of the SETUP descriptor will contain a setup packet. Then, after the device receives it successfully, you (optionally, according to the specific request) send/receive data to/from the device using another descriptors with IN/OUT PIDs. Then, after that is successful, you send/receive a status packet, which can be either an IN/OUT descriptor depending on the data stages. The USB spec has more information on this.

Something else to keep in mind is that you cannot send/receive data in one descriptor that is larger than the device's maximum packet size. For a sample device with a maximum packet size of 8 bytes, to send 32 bytes of data to said device, you'll need 4 different descriptors, each transferring 8 bytes of data.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Post Reply