Partager via


Implement Your Device Driver (Compact 2013)

3/26/2014

After you have completed the steps in Plan Your Device Driver, you can begin implementing your device driver. The easiest way to begin this implementation is to start with an existing sample device driver, modify it to fit your design, and add functionality to support your hardware. When you have completed an initial device driver implementation, see Build and Test Your Device Driver for the steps to build your device driver.

Because each device driver can be very different in architecture, the interfaces it supports, its size, the complexity of its implementation, and the kind of hardware it supports, no single step-by-step procedure for device driver development applies to all device drivers. Your device hardware may generate interrupts or may be a polled device. It may support direct memory access (DMA), and you may be able to turn it on and off for power management support. Applications may require your device driver to manage multiple open instances across multiple devices, or your driver may support only one open instance on one hardware device.

For this reason, this guide focuses on the most frequently used scenarios:

  • Porting a sample stream driver to start your device driver project
  • Managing device driver context
  • Adding support for interrupt handling
  • Marshaling data between caller and device driver address spaces
  • Adding support for DMA
  • Supporting device interfaces
  • Supporting power management

Not all implementation tasks in this article may apply to your device driver. Choose from the topics in this guide that apply to your particular device driver design. Each topic provides pointers to reference documentation that explains the relevant APIs in more detail. Some topics refer you to a sample device driver that provides a working example of the functionality that is explained in the topic; you can study this example code to understand how to implement the functionality that you need while you learn how to use the APIs more effectively.

In This Section

  • Port the Sample Stream Driver
    Describes how to copy the sample stream driver to your OS design as a starting point for your device driver implementation.
  • Manage Device Driver Context
    Shows how device drivers use contexts to manage multiple open instances and multiple devices, and provides example code that shows how to create and return a device context and an open context.
  • Add Interrupt Handling Functionality
    Describes how device drivers use interrupt service routines (ISRs) and interrupt service threads (ISTs) to process interrupts to service their devices.
  • Support Direct Memory Access
    Describes three ways that you can use DMA to transfer data between memory and the device, and from memory to memory.
  • Support Power Management
    Describes how you can add power management support to your device driver to reduce power consumption on your device.

See Also

Concepts

Device Driver Developer Guide