mariuszp wrote:
I am extremely confused about how Queue Heads are supposed to be structured in EHCI.
Don't be disappointed, EHCI is probably the most confusing one of the four common types.
mariuszp wrote:
I create one queue head per endpoint, correct?
You may create as many or as few as you wish. However, due to some of the fields within the queue head, yes, you must create one for each endpoint.
mariuszp wrote:
The queue heads must be joined together into a ring (using the "horizontal link pointer"), correct?
Each Queue Head has a "transfer overlay" area, and a current TD pointer. So the question is: what values do i initialize the transfer overlay / current TD fields with when there are no transfer descriptors in the queue yet? Do I just initialize them all to zero such that the "active" bit in the TD is clear? And when I want to transfer something, do I create a TD and just place it's physical address into "current TD" field, leaving the transfer overlay alone? And when done, what does EHCI do with the descriptor; how is it removed from the queue and how do I add a new one without race conditions with the hardware?
The overlay is not initialized by the user, but by the controller *after* a TD is executed. Before a TD is executed, only the first 4 DWORDs of the Queue Head need to be initialized. Once the first TD linked within this Queue Head is executed, then the remaining DWORDs will be written by the controller.
Might I suggest a good book on the subject?
http://www.fysnet.net/the_universal_serial_bus.htmThis book contains information for all four controller types, how to initialize them, how to create a working USB stack, and shows detailed examples on how to enumerate devices, such as Mice, Keyboards, USB thumb drives, etc. I've heard the author will even let you send him an email asking questions, once you have read the applicable chapters and tried the process yourself first.
The book also has example source code, available upon request with proof of purchase.
Anyway, EHCI is probably the most difficult one to program. Be sure that the device you are trying to enumerate is actually a high-speed device. If it is a low- or full-speed device, you won't get the EHCI to work at all... (unless there are no companion controllers).
Ben