Writing Windows WDM Device Drivers

A device driver has many jobs to do, some mandatory and others optional. In this chapter, I will give an overview of these jobs, so you know what tasks your driver will have to implement. I will also describe the big picture to show the different types of device drivers and the environment in which drivers run. If possible, you should consider writing a driver that uses one of the Windows Driver Model system drivers, as it simplifies your work and makes it fit in.
Choosing how to implement your driver is one of the most crucial decisions you will need to make. You need to know which jobs it must perform and which tasks it can offload to a class driver. If you are writing a driver for a Universal Serial Bus (USB) device, it soon becomes obvious that you should use the USB class driver. However, if you are going to support Power Management, it is best to decide this at the start as it may well effect the rest of your design.
Here are some of the jobs that a device driver can do:
Initialize itself
Create and delete devices
Process Win32 requests to open and close a file handle
Process Win32 Input/Output (I/O) requests
Serialize access to hardware
Talk to hardware
Call other drivers
Cancel I/O requests
Time-out I/O requests
Cope if a hot-pluggable device is added or removed
Handle Power Management requests
Report to administrators using Windows Management Instrumentation and NT events