Introduction to the Windows CE Device Driver Kit

Like other operating systems, Windows CE implements software called device drivers, whose purpose is to interface with, or drive, built-in and peripheral hardware devices. A device driver links an operating system and a device, making it possible for the operating system to recognize the device and to present the device’s services to applications.

Windows CE supports a wide range of device drivers that you can customize for various Windows CE–based platforms. Windows CE also provides several models for driver development, including driver models from other operating systems. Because of this diversity of driver models, Windows CE accommodates almost any conceivable type of device, either as a built-in or as a peripheral device.

The Microsoft Windows CE Device Driver Kit supplies documentation enabling you to create device drivers for Windows CE. Currently, Windows CE offers four device driver models, two that are unique to Windows CE and two that are external models adapted from other operating systems. The two Windows CE–based models are the native device driver and the stream interface driver. The two external models are designed for universal serial bus (USB) drivers and network driver interface specification (NDIS) drivers.

The various driver models are differentiated only by the software interface that they support and not by the devices that they serve. The driver model determines the software interface that any given driver exports. Independent of the driver model, a device driver may either be monolithic or layered, meaning that it can implement its software interface directly in terms of actions on the device or separate the implementation of the software interface and the actions on the device into two layers. Many of the sample drivers provided by Microsoft use this layered organization because it reduces the amount of code that developers must write when porting the sample drivers to new devices. Device drivers can access their devices directly if the devices are mapped into system memory, or they may need to use the services of lower-level device drivers in order to access their devices. For example, device drivers for PC Card devices need to use the services of the PC Card socket driver to access PC Card devices. Finally, device drivers may be interrupt-driven, may be polled, or may not require status updates from their devices.

As their name suggests, native device drivers serve devices that are integral to a Windows CE–based platform. Native device drivers are designed specifically for low-level built-in hardware, such as keyboards, screens, and PC Card sockets. Because native device drivers generally have a strong connection to Windows CE–based platforms and each type of native device driver has a precise, specialized purpose, Microsoft provides support for native device drivers in the form of custom interfaces. This means that the majority of developers do not need to write native device drivers. The exceptions are OEMs who customize Windows CE for new platforms. They can either create their own native device drivers or port Microsoft sample native device drivers to their Windows CE–based platform. Native device drivers are always loaded when the Windows CE–based platform boots.

In contrast to native device drivers, which have custom interfaces, stream interface drivers are a generic type of device driver. Stream interface drivers are user-level dynamic-link libraries (DLLs) that implement a fixed set of functions, the stream interface functions, enabling an application to interact with a device through special files in the file system. Stream interface drivers support almost any kind of peripheral device that can be attached to a Windows CE–based platform. For example, developers have designed stream interface drivers to support a variety of peripherals, including pagers, printers, modems, bar-code scanners, and Global Positioning System (GPS) receivers.

The stream interface functions enable applications to interact with a device through special files in the file system. OEMs can also create stream interface drivers to serve devices that are designed as part of a Windows CE–based platform when Microsoft has not defined a specific interface for a particular type of device. For example, a Windows CE–based point-of-sale system might have a bar-code scanner built into the hardware of the system, but because Microsoft has not yet defined a custom interface for bar-code scanners, the device driver for the scanner would be a stream interface driver, rather than a native device driver.

Some common types of built-in devices, such as serial ports, use stream interface drivers because the functionality of the devices is well suited to the structure of a stream interface driver. OEMs sometimes write a few stream interface drivers for this reason. Peripheral manufacturers are responsible for providing stream interface device drivers so that their peripherals can be used with Windows CE.

A USB driver connects USB-compliant devices to Windows CE. Unlike stream interface drivers, however, USB drivers are not required to export any particular set of functions to applications. Depending on the device, a USB driver can export the stream interface functions, export a custom set of functions, or use existing Windows CE APIs to expose the functionality of the device. Using existing Windows CE APIs is appropriate for a pointing device or a mass-storage device, neither of which applications need to use directly. Windows CE has existing mechanisms, the input-event system and the Block Device Driver API, respectively, for managing these types of resource.

NDIS drivers are adapted from the Microsoft Windows NT® operating system. The NDIS driver is a driver model that enables networking protocols, such as the TCP/IP and the Infrared Data Association (IrDA) protocol, to be completely independent of the implementation details of device drivers for network interface cards (NICs).

The following illustration shows the current collection of driver models and device drivers.

The remainder of this guide explains in detail how to implement the device driver models.

The Device Driver Kit is packaged with two different products, the Microsoft® Windows® CE Platform Builder, which contains source code and libraries for OEMs who build custom Windows CE–based platforms, and the Windows CE Platform SDK, which contains the cross-compiler tools and libraries necessary to build software for Windows CE–based platforms. In addition, the Platform Builder includes source code for a number of sample device drivers.