OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 6:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 2:42 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
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?


Top
 Profile  
 
 Post subject: Re: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 2:59 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
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.


Top
 Profile  
 
 Post subject: Re: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 3:08 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
So, to set the address, I send a the setup packet with bmRequestType field, bmRequest set to 5, etc?


Top
 Profile  
 
 Post subject: Re: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 3:18 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
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.


Top
 Profile  
 
 Post subject: Re: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 3:57 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
And each "stage" is a separate transfer descriptor?


Top
 Profile  
 
 Post subject: Re: USB transfer descriptors
PostPosted: Fri Jul 28, 2017 4:32 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 202 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group