Share via


Stream Drivers (Compact 7)

3/12/2014

Windows Embedded Compact includes the stream interface API, which makes it possible for software modules to interact with peripherals as if they were files. A stream driver (sometimes referred to as a stream interface driver) is any driver that exposes the stream interface, regardless of the type of the device that the driver controls. The stream interface is appropriate for any I/O device that can be considered a data source or a data sink.

Stream Interface API

The stream interface functions are designed to closely match the semantics of file system APIs such as ReadFile, WriteFile, and IOControl. Device functionality presented through the stream interface is exposed to applications through the file system; that is, applications interact with the driver by opening specially named files in the file system.

The stream interface consists of thirteen functions as shown in the following table.

Stream interface function name Description

XXX_Init (Device Manager)

Initializes the device.

XXX_Open (Device Manager)

Opens the device.

XXX_Close (Device Manager)

Closes the device.

XXX_Read (Device Manager)

Reads data from the device

XXX_Write (Device Manager)

Writes data to the device.

XXX_Seek (Device Manager)

Moves the data pointer in the device.

XXX_IOControl (Device Manager)

Sends a command to the device.

XXX_Cancel (Device Manager)

Cancels all pending asynchronous I/O requests.

XXX_Deinit (Device Manager)

De-initializes the device

XXX_PreDeinit (Device Manager)

Prepares the device driver for de-initialization.

XXX_PreClose (Device Manager)

Prepares the device driver for a close operation.

XXX_PowerDown (Device Manager)

Ends power to the device

XXX_PowerUp (Device Manager)

Restores power to the device.

The XXX prefix is a placeholder: replace XXX with the prefix for a specific device driver implementation. Alternately, some drivers may use undecorated entry point names that do not have the XXX prefix. For more about stream interface functions, see Stream Interface Driver Reference.

When to Create a Stream Driver

Consider using a stream driver design for a new device driver implementation if any one of the following is true:

  • Your device driver manages a peripheral that produces or consumes streams of data as its primary function. For example, applications typically access storage, serial port, and audio devices through stream drivers. An example of a device that is not a good candidate for a stream driver is a display device, because it does not produce or consume data by using traditional stream-oriented file system methods.
  • Applications that use your device driver are currently implemented to access device functionality through a file system interface.
  • You are starting your device driver development with an existing Windows Embedded Compact 7 sample driver that is a stream driver.
  • You are porting your device driver from another operating system. Because the stream interface approach is common to many operating systems, you may find it easiest to port an existing device driver to Windows Embedded Compact 7 by adapting it to the stream interface.

Sample Stream Driver

Microsoft provides source code for a sample stream driver at %_WINCEROOT%\Platform\BSPTemplate\Src\Drivers\Streamdriver. For more information about using this sample driver to develop a new device driver, see Implement Your Device Driver.

For More Information About Stream Drivers

Windows Embedded Compact 7 documentation includes detailed reference material for the design and implementation of stream interface drivers. If you are creating a stream driver, make sure that you read the topics described in the following table.

Topic Description

Stream Interface Driver Functions

Explains each of the stream interface driver functions, describing syntax, parameters, and return values.

Device Manager Functions

Device Manager functions for loading stream drivers, issuing I/O controls to devices, and handling asynchronous read, write, and I/O control operations.

File I/O Functions

File system functions that applications use to access stream devices, including CreateFile, ReadFile, and WriteFile.

See Also

Concepts

Stream Drivers and Native Drivers