Each hardware device has unique control mechanisms, register layouts, and command sets. The OS cannot contain code for every possible device — it would be enormous and impossible to maintain.
A device driver is a software module that translates generic OS I/O commands into device-specific instructions, acting as the intermediary between the OS and hardware.
- OS sends a generic I/O request (e.g., “read sector 120”) to the driver
- Driver translates this into device-specific commands and register writes
- Driver writes commands to the device controller’s registers
- Driver may set up DMA transfers or prepare for interrupt notification
- On completion, driver processes the interrupt and updates OS state
- Runs in kernel mode with privileged access
- Device-specific but presents uniform interface to OS
- Handles device initialization, error detection, and status reporting
- Four main types: character, block, network, and virtual drivers
- Built from: O System, Device Controller
- Builds into: O Request to Hardware Operation, O Software Structure
- Related: Character Driver, Block Driver, Network Driver
- Contrasts with: O Software (lives in user space, not kernel)
- A buggy driver can cause kernel panics or system crashes
- Driver must handle concurrent requests properly (reentrant code)
- Missing drivers result in “unknown device” errors
- Driver version must match kernel version exactly