Stream interface drivers are dynamic-link libraries (DLLs) that typically are loaded, controlled, and unloaded by a special application called the Device Manager. In contrast to native device drivers, which have special single-purpose interfaces, stream interface drivers all use the same interface and expose a common set of functions, the stream interface functions.
Stream interface drivers are designed for peripheral devices connected to a Windows CE–based platform. Examples of these devices are modems, printers, digital cameras, and PC Cards. All peripheral devices must be attached through external connectors, such as serial ports or PC Card sockets. Therefore, device drivers for peripheral devices are like printer drivers for desktop computers: both run as user-mode processes that access the services of built-in hardware to control their devices. Device drivers for serial devices use the serial port. Device drivers for PC Cards use the PC Card Services library; in turn, the PC Card Services library controls the PC Card socket hardware. Because of these interdependencies, a stream interface driver often uses a native device driver—specifically, the native device driver for the external connector to which the peripheral is attached—in order to interact with the peripheral. However, stream interface drivers can interact directly with a peripheral if that peripheral is mapped to some portion of the system’s memory space, as do stream interface drivers for devices that are often built into a Windows CE–based system, such as speakers and microphones.
The primary task of a stream interface driver is to expose the services of a peripheral to applications by presenting the device as a special file in the file system. This is similar to other operating systems, such as UNIX, which exposes peripheral devices by means of special files in the file system \Dev directory. Although Windows CE does not have a direct analog to the UNIX \Dev directory, the device files in Windows CE are stored in the \Windows directory, and a special naming convention differentiates the device files from ordinary files.
Despite the generic characteristics of stream interface drivers, they can be implemented in different ways. For example, even though stream interface drivers typically are designed by independent hardware vendors (IHVs) for peripheral devices, OEMs who customize Windows CE–based platforms sometimes write stream interface drivers for certain built-in devices. In addition, although stream interface drivers are usually loaded and unloaded by the Device Manager, sometimes applications perform the loading and unloading.
Application-specific stream interface drivers present resources in ways that an application can readily use. Peripheral devices are the most common resource used by application-specific stream interface drivers, but almost any resource, such as memory, process lists, or TCP/IP ports, can be presented in terms of a stream interface driver. For example, a company that makes Global Positioning System (GPS) receivers could make two versions of the receiver: one that is built into a PC Card and one that connects to an external serial port. Rather than adding complexity to the application that uses the GPS receiver so that the application can use either type of receiver, the company could write a device driver that repackages the services of one type of receiver in the interface of the other type. Thus, the application would not need to distinguish between the two types of receiver connected to the platform; both types would react identically to the application despite the different access methods used for serial and PC Card devices.
The following sections describe how to write stream interface drivers in greater detail. Included are explanations of the system architecture for stream interface drivers, device file names, the Device Manager, entry points, and the relationship of a stream interface driver to a device and to applications.