How can I access my USB keyboard/mouse ?
Keyboards and mice are what the USB standard calls HID (Human Interface Device) class devices, and follow a special superset of the USB standard. Once you have a driver for a HID device, all USB HID devices will work with it, including mice, keyboards, joysticks, game controllers, and so forth. The HID standard is built on top of lower-level USB APIs to send and receive data packets across the wire, but provides a translation layer that interprets the USB data so that the HID layer could conceivably be implemented on top of other protocols (Like PS/2 or serial).
For early stages, you can probably ignore the fact that those devices are USB. Virtually every chipsets will offer a good old PS/2 emulation of the USB human interface devices, so you can use I/O port 0x60 like the rest of us ...
How can I boot from an USB flash disk ?
This is only possible with BIOS that support booting from USB devices and with sticks that supports to be bootable. If possible,
http://www.ncsu.edu/project/runt/ suggests that simply putting your 512 bytes as the boot sector of the USB's FAT partition would be enough ...
How to add USB support in my kernel ?
As a first step, you'll need to provide a driver for the USB Host Controller, which appears as a PCI device (iirc) and will allow you to enumerate devices on the USB bus and send packets to the identified devices. Documentation about
Open Host Controller Interface,
Universal Host Controller Interface and
Extended Host Controller Interface are available freely. Your USB-aware chipset should support one of these three. Some computer may have support for more than one of these standards (there are computer with UHCI for USB 1.1 and EHCI for high-speed USB 2.0 using the same USB ports)
any information about whether both OHCI & EHCI can be found on a single mother board are welcome, as well as information about whether a EHCI driver will work on UHCI hardware
Once you know what devices are present, you'll have to identify a device-specific driver that will match that hardware. For some devices (webcams, scanners, etc), this may require a vendor-specific driver while other devices (USB keychains, HID etc) have to adhere to class standards. This means that one can write a generic USB storage driver that will work with all possible keychains, embedded mp3 players, flash card readers, etc.
USB uses a tree topology, with non-leaf devices in the tree providing hub class services. The tree can be up to 16 levels deep, with each hub theoretically providing up to 16 devices. The "root" of the tree is not considered a hub for some reason. Before you can start talking to devices on the USB, you will want to be able to enumerate all devices. Fortunately, the USB standard requires that all devices, including hubs, are self-describing.
Don't forget that USB devices are hot-pluggable, that is they can be added and removed at any time while the system is running.
Where can I find additional information about USB?
- At
USB.org, or more particularly
The USB 2.0 Specification, where you can download the official Universal Serial Bus Revision 2.0 specification, which defines the hardware and software. This is by far the best place to start, although not light reading. You may also find a wealth of information regarding the HID standard
here. - In the Linux kernel (though things tends to be confusing there, and you have to be careful with educating yourself from Linux sources if your project isn't GPL'ed).
- In
Intel chipsets manuals, for instance.
Usb in a Nutshell may also interrest you. It looks like a really good tutorial giving all the required knowledge to understand any other USB documentation/sourcecode in a couple of HTML pages ...any link to a description of USBstorage, USBprinter, HID, USB vendor list, etc. is of course welcome ;)
- Notes for an USB Tutorial (comments are welcome)
Categories: CollectedKnowledge, HardWareBus
Related Threads on the forum
discusses the feasability of booting from an USB memory stick
suggests a few startup links about USB
explained by Schol-R-Lea
PypeClicker and Df collection of links about USB

USB