Hi guys,
Peemard, first, don't be discouraged by the comments that you might not wish to start so early in to USB. Though I agree with the comments of it being difficult and probably not something a three day old should be starting with, I will tell you that the USB was my most enjoyable part of the whole project. Therefore, if you wish to start USB now, for the joy of it, this would be a perfect time to do so, though keep in mind that a successful implementation will need other parts of the OS system already implemented.
As for which controller to start with, I have mixed feelings about this. The UHCI and OHCI were released first, nearly 30 years ago though. OHCI in September of 1995 and UHCI two months later. Though most modern emulators will still support these two controllers, most hardware will not. xHCI, announced in September of 2007, is still 15 years old, though USB version 3.2 which takes advantage of xHCI, is more recent, only 5 years ago.
To decided which controller you would like to start with, ask yourself one question: Will I be testing my code on real hardware or using emulation exclusively?
If your answer is emulation, I suggest the UHCI and OHCI as your beginning. One controller was built to use the hardware with little software intervention, while the other was completely the opposite. It would be a good learning experience to code for both of them to learn the difference. Also, the Bochs emulator, which I'm glad to have had a big part of during that time, will produce a nice debug log file, which is quite helpful in the beginning of your development.
Next, in my humble opinion, completely skip the EHCI. Again, IMHO, it was a hodge-podge piece of hardware put together to allow higher speed devices, but still be backward compatible with UHCI and OHCI. Other than reading over the subject, getting an idea of what it does, I would completely skip the EHCI.
xHCI, in my opinion, finally got the interface correct. xHCI will support all speeds using this one interface. However, to do so, unlike the UHCI and OHIC where there was a single bit indicating the different speed, xHCI needs quite a bit of setup before allowing that specific speed.
As mentioned before, you also have to watch out for hubs, both external and "internal", the internal more commonly known as RMHs, or Rate Matching Hubs.
A note about these RMHs: The EHCI only handles High Speed devices. The EHCI will *not* communicate with a Full or Low speed device. Therefore, the EHCI's card was designed to have companion controllers, either OHCI or UHCI, to pass on the Full- and Low-speed device traffic. Therefore, each EHCI adapter card had all of the EHCI components *and* at least one, though usually more than one OHCI or UHCI component. These got a little expensive. Now, since an External Hub can have any speed device plugged in to it, the Hub has to handle the speed difference. Therefore, if you plug a High-Speed Hub into an EHCI and then plug all other devices into the HUB, the EHCI adapter card no longer needs the added UHCI or OHCI components. Even better, if you place the external hub directly on the EHCI adapter card, this guarantees that the lower speed controllers are no longer needed. This dramatically decreased the cost as well as the circuity of the EHCI adapter card. The drawback for you and I, as the developer, it is now a requirement that we have a HUB driver in our USB tool box. We can't even get to the Low-speed mouse without it. Another reason to completely skip the EHCI.
As mentioned before, you will also need to have a working PCI parser, to even find the USB controller, let alone know what to do with it. This means you need to study the PCI as well.
With thanks, and as mentioned, my book covers this from the beginning. It starts by describing the PCI enough to find the USB controllers, determine which type it is, and how to find other information about the controller. The next section shows how to setup and use each of the four controllers, each part independent of another. The next section shows how to enumerate different devices in general while the next section goes into detail about types of devices, such as Mice, Keyboards, MSDs (Mass Storage Devices) such as thumb drives, External Hubs, Printers, etc.
Again, I believe the USB was/is the most enjoyable part of this hobby of ours and highly recommend that you put it high on your TODO list.
Though, lately I have been quite busy with other things, I do try to frequent this forum at least once a day and give help when needed. There are others here with substantial knowledge of the USB, that can help as well. Feel free to post your questions.
Thank you and above all, enjoy the process of this hobby we have.
Ben
-
http://www.fysnet.net/the_universal_serial_bus.htm