| ★ wanayoo — archive 1999 http://developer.apple.com/hardware/usb/usbmacos.htm | Nouvelle recherche | Portail wanayoo |
The software that supports USB devices in the Mac OS environment includes a USB Interface Module (UIM), a USB Manager, a USB Services Library (USL), and USB class drivers.
The Figure shows the components that make up the USB software architecture on the Macintosh computer. Release version 1.0 of the Macintosh USB software provides only class driver support for a USB keyboard, mouse, and hub.
The UIM is a native driver "ndrv" code fragment, as defined in "Designing Macintosh PCI Cards and Drivers." In addition to supporting the data export guidelines for ndrvs, the UIM provides USB specific data exports that define the UIM driver entry points and descriptor structures built for devices on the USB.
The UIM provides the upper layers of the USB software with a hardware abstraction layer to the USB host controller interface hardware. The UIM communicates directly with the USB controller hardware to set up the appropriate communication links with the USB devices on the bus. The UIM also provides root hub simulation.
OpenFirmware builds a Name Registry entry for the host controller and matching UIM during hardware bring up time, prior to booting the operating system. The USB Manager uses the information in the Name Registry to communicate with the UIM. Once the UIM is loaded and begins hub simulation, the USB Manager determines that a hub is present and loads the hub driver. At this point, the hub driver begins monitoring all USB device activity at the USB hub simulation provided by the UIM.
A UIM is required for every USB bus controller implementation installed in the host. For example, multiple UIMs would be required on a host which has both a built-in USB host controller interface and a USB controller interface on a PCI card. Developers designing PCI, Card Bus, or any other controller interface to the USB need to provide a UIM for their card interface. For information regarding the APIs needed for UIM software development, send email to the Apple USB evangelist at USB@apple.com.
The USB Manager performs driver matching and loading services and communicates internally with other components of the Macintosh USB host software to identify devices on the USB. The USB Manager also provides services that Mac OS and applications use to determine the status of devices, handle power management tasks, notify the user or other applications about USB devices being attached to or removed from the USB.
An example of a service that the USB Manager can provide for a client is when a client makes a request to find a keyboard. The USB Manager determines if a keyboard is installed and returns the appropriate response. If a keyboard is installed, the client can ask where the class driver is for that keyboard. The USB Manager then points to the code fragment that contains the class driver for keyboards. The client then communicates with the keyboard through the class driver. The keyboard class driver communicates with the keyboard interface through the USB Services Library. The API for the USB Manager is included in Chapter 5, "USB Manager Reference.".
The hub driver provides support for the USB software architecture by monitoring the connection and removal of devices on the USB at a hub. This process is referred to an device ennumeration. When the hub driver recognizes that a device has been plugged into the bus at a given port ID on a hub, it notifies the USB system software. The USL notifies the USB Manager, which in turn builds the Name Registry entry for the device and binds the appropriate class driver with that device. When the hub driver finds a device, it notifies the USB Manager that a device has been found. The USB Manager loads the appropriate class driver based on the class and subclass and other information found in the device configuration or interface configuration descriptor for the device.
Addtional information about the process os bus enumeration is described in Chapter 9 of the Universal Serial Bus Specification.
A USB device must have a USB class driver or drivers for every interface (function) the device supports to operate properly on the Macintosh computer. Macintosh USB class drivers are ndvr native code fragments and as such follow the guidelines specified for creating Macintosh native drivers in the PCI Cards and Drivers documentation. USB class drivers provide a driver descriptor structure that the USB Manager uses to build a driver entry in the driver Name Registry.
The USB Manager matches drivers to device interfaces by initially examining the product ID and vendor ID fields in the device descriptor for the device. To ensure proper device and driver matching, additional information regarding the device is examined if none or more than one driver matches the product ID and vendor ID values for the device. Detailed information about how USB class driver and device matching is accomplished is in the Universal Serial Bus Common Class Specification which can be found at <http://www.usb.org>.
There are several classes of drivers defined by various USB specifications, and new classes are being proposed all the time. The Macintosh USB software includes HID class drivers for the HID interfaces in the USB keyboard and mouse. The keyboard and mouse drivers are loaded by a compound class driver, which is loaded by the hub driver when the keyboard and mouse are found on the USB.
A USB device includes an interface or interfaces, which are defined in device descriptor data structures associated with the device. The interfaces are like sub devices within the device, each having a function specified by numerical class and sub class identifiers. Interfaces also define how a function in a device is accessed by the host system. The functional features of the device are accessed by the USL when given an interface reference.
The Macintosh system software maintains a driver dispatch table for USB class drivers that defines among other things the driver initialization routine, driver gestalt, and the driver callback notification routine. For more information, see the driver descriptor structure defined in the USBServices.lib.h file.
The USB Services library is the programming interface that USB device drivers use to communicate with the USB on a Macintosh computer. The USL provides the services necessary to find a device with the appropriate interface, open an interface to the device, open the device, instantiate the appropriate pipe connections, determine device status, and perform read and write transactions with the device. For additional information about the USL, see Chapter 4, "USB Services Library Reference."
|
The Apple Store | Hot News | About Apple | Products | Support Design & Publishing | Education | Developer | Where to Buy | Home Contact Us - Developer Site Map Copyright © 2000 Apple Computer, Inc. All rights reserved. |