Friday, January 31, 2014

Windows Device Drivers

There are 3 basic types of drive in the classic Windows Driver Model (WDM):

(1) Function drivers are the primary drivers for devices.  They perform most of the works to service I/O requests.  They transform the Windows API call to low level device commands

(2) Bus drivers implement functions specific to a particular interfaces (e.g. USB, PCI, SCSI etc).  They are essentially low level function drivers for a particular system bus.  They enumerate devices attached to the bus and manage them

(3) Filter drivers do not manage devices.  They add processing to the command and data passing through them.  Relative to their position to the function drives in the stack, they are called either upper or lower filter drivers

driver stack:
I/O manager <-> upper filter driver <-> function driver <-> lower filter driver <-> HAL <-> hardware

Function and bus drivers are usually implemented as driver/mini-driver pairs - either class/miniclass or port/miniport drivers.  Class and port drivers are provided by Windows which standardize the high level functionality.  The mini-drivers are usually shipped by hardware vendors.

A class driver offers hardware agnostics support for specific type (or class) of devices.  For example, kbdclass.sys is the keyboard class driver from MS.

A port driver supports general I/O operations for a particular peripheral hardware interface.  For example, i8402prt.sys is the port driver for 8402 microcontroller used to connect to PS/2 keyboard.

Each device driver has an associated DRIVER_OBJECT.  The driver object points to the driver (PDRIVER_OBJECT) which can be used to locate its set of dispatch routines/

No comments: