USB helps connect the enterprise

Universal Serial Bus (USB) is an open industry standard providing a simple and inexpensive way to connect up to 127 devices to a single computer port. With USB, many computer peripherals, such as keyboards, mice, digital cameras, digital scanners, bar-code readers, modems, and specialty printers can all run at the same time.

By Bill Kyle January 1, 2001

Universal Serial Bus (USB) is an open industry standard providing a simple and inexpensive way to connect up to 127 devices to a single computer port. With USB, many computer peripherals, such as keyboards, mice, digital cameras, digital scanners, bar-code readers, modems, and specialty printers can all run at the same time.

USB is a dynamically reconfigurable serial bus with an elementary data rate of 12 Mbps, and is based on off-the-shelf, low-cost microcontroller technology. Its modular, layered software protocol supports sophisticated device drivers and application programs.

A USB driver on Win32 Driver Model (WDM) platforms is known as a client driver. It is a layered driver, meaning that it is layered above the hub drivers and does not access the hardware directly. Instead, the client driver makes requests to another driver, which carries out the requests. This layered relationship is referred to as a driver stack and is a common architecture for WDM drivers.

A USB driver on Win32 Driver Model is known as a client driver
meaning that it is layered above the hub drivers and does not
access the hardware directly.

Drivers, standards

At the bottom of the driver stack is the driver that controls the USB hub (see figure). There are two standards for these hub controller drivers: Intel’s Universal Host Controller Interface (UHCI) and the industry standard Open Host Controller

Interface (OHCI). Most machines built around Intel-designed motherboards use an UHCI controller, while most add-in cards and other motherboards use OHCI controllers. Although differences exist in the way the hub operates, these differences are not important to the client driver.

The most important element of the Microsoft-written components of the driver stack is the USB bus driver, usbd.sys , through which client drivers perform all communication. Usbd.sys presents an interface to client drivers that allow clients to perform USB transfers without having to know the intricacies of a particular hub controller.

USB driver detects device

The USB client driver performs two major tasks: device enumeration and device operation. During device enumeration, the client driver obtains all the configuration information it needs from the USB device, including relevant descriptors, and performs other tasks, such as selecting a configuration. During normal operation of the device, requests from user programs are handled and communication is performed with the device.

There is a distinct series of actions that are always performed when a device is plugged in, and it is crucial that the device handle these actions correctly.

When the host detects a new device, the first action it performs is to send a GET_DESCRIPTOR command for the device descriptor on the default control endpoint. The device will begin returning the descriptor on the default endpoint, but it is important to know that the operating system will read only one packet of the descriptor. After receiving one packet, apparently to confirm that the device is working, a zero length OUT packet is sent to terminate the transfer. If the device does not correctly handle the situation of an aborted transfer of a descriptor, the device will not enumerate.

The second step the host performs during enumeration is sending a SET_ADDRESS request on the default endpoint. This is performed automatically by the operating system and the device merely needs to accept the request.

The next step the host performs is sending another GET_DESCRIPTOR command for the device descriptor. On this request, however, the host will obtain all 18 bytes of the device descriptor. The operating system will use information in the descriptor to determine what device driver to load. The idVendor, idProduct and bDeviceClass fields are all used by the operating system to load drivers. The final step the host performs before handing control over to the device driver is obtaining the configuration descriptor. At this point, the operating system will load the device driver that it selects to control the new device.

USB is a modern bus standard that supports a vast range of peripherals; however, the complexity of the drivers is likewise increased. Commercially available device driver toolkits (such as bSquare’s WinDK and USB Extension) make the development of drivers an easier task than just using the DDK.

We will soon see new peripherals using USB hastening the acceptance of the bus into the mainstream.

Author Information
Bill Kyle, director of marketing, Platform Technologies bSquare Corp. (Bellevue, Wash.)