Device driver

On this page 7

A device driver is a software component that lets the operating system control a specific piece of hardware by translating generic requests, such as read a block or send a packet, into the exact register writes, commands and data transfers that the device understands. In operating systems, drivers are the boundary between the kernel’s uniform abstractions and the enormous variety of real hardware.

Without drivers, every application would need to know the details of every disk controller, graphics card and network adapter. With them, programs call standard interfaces, the kernel routes each call to the right driver, and the driver deals with the hardware. Because most drivers run with full kernel privileges, they are also one of the most common sources of crashes and security vulnerabilities.

How a device driver works

A driver sits between a kernel subsystem above it and the hardware bus below it. When the system starts or a device is plugged in, the bus driver enumerates the device and reports its identifiers, the kernel matches those identifiers against installed drivers, and the chosen driver’s probe or initialization routine claims the device, maps its registers and allocates buffers.

During normal operation, the driver receives requests from the kernel, programs the device, and waits for completion. Modern devices signal completion through an interrupt, and many transfer data directly to memory through direct memory access (DMA), so the CPU only sets up the transfer and handles the result. Drivers also implement power management, putting the device into low-power states when it is idle and restoring it on resume from sleep mode.

The table lists the core mechanisms a typical driver uses to communicate with hardware.

MechanismPurposeTypical example
Memory-mapped I/ORead and write device registersConfiguring a network controller
InterruptsDevice signals an event to the CPUA packet has arrived
Direct memory accessDevice moves data without the CPUDisk reads into a buffer
PollingCPU checks device status repeatedlyVery high-rate networking or storage
Firmware loadingDriver uploads code to the deviceWireless adapters and GPUs
Mechanisms used by drivers

Kernel-mode and user-mode drivers

The most important design decision for a driver is where it runs. A driver in kernel space has direct access to memory and hardware and offers the lowest overhead, but a bug can corrupt the whole system and cause a kernel panic or a blue screen. A driver in user space runs as an isolated process and can crash without taking down the operating system, at the cost of extra context switches.

AspectKernel-mode driverUser-mode driver
PrivilegeFull kernel accessLimited to granted resources
PerformanceHighest, no boundary crossingsLower, more context switches
Failure impactCan crash the whole systemUsually restarts in isolation
Typical devicesStorage, network, GPU corePrinters, scanners, some USB devices
Examples of frameworksWindows KMDF, Linux kernel modulesWindows UMDF, macOS DriverKit, Linux UIO
Kernel-mode versus user-mode drivers

Operating systems are steadily moving drivers out of the kernel where performance allows. Microkernel designs push almost all drivers into user space by default, while monolithic kernels such as Linux keep most drivers in the kernel but isolate risky parts through sandboxed frameworks.

Types of drivers and the driver stack

Drivers are rarely single, independent programs. Most systems organize them into a layered driver stack in which each layer adds a well-defined function. A USB storage stick, for example, involves a host controller driver, a USB core, a storage class driver and a file system on top.

Driver typeRoleExample
Bus driverDiscovers devices and manages the busPCI Express, USB host controller
Class driverGeneric support for a device classUSB mass storage, HID keyboards
Function driverMain driver for a specific deviceA particular Wi-Fi chipset
Filter driverInspects or modifies requests in the stackAntivirus and encryption layers
Virtual driverEmulates hardware that does not existVirtual network adapters, RAM disks
Common driver categories

Class drivers are why many devices work without installation. Keyboards, mice, flash drives, webcams and many audio devices follow standard USB class specifications, so the operating system’s built-in generic driver handles them. Only devices with unique features need a vendor-specific function driver.

Installation, signing and updates

Modern operating systems control which drivers may load, because a malicious driver has the same power as the kernel. Driver signing requires code to carry a trusted digital signature, and on current Windows and macOS releases unsigned kernel drivers are blocked by default. Secure Boot extends this chain of trust to the earliest stages of startup.

The decision table summarizes how to obtain and maintain drivers in common situations.

SituationRecommended sourceReason
Standard peripheralsBuilt-in operating system driverTested and updated with the system
Graphics cards for gaming or designCurrent vendor driverPerformance and application fixes
Business laptopsManufacturer-validated packageMatched to firmware and power settings
Servers and storageCertified version from the support matrixStability outweighs new features
Unknown downloaded installersAvoidCommon route for malware
Choosing a driver source

Common problems and misconceptions

Driver issues tend to look like hardware faults, which makes them easy to misdiagnose. Experienced administrators check the driver first whenever a problem appears after an update or only under specific workloads.

  • Newer is not always better. A driver update can introduce regressions, so stable systems often keep a known-good version.
  • A device that appears in the system can still use the wrong driver, for example a generic display driver with no hardware acceleration.
  • Random system crashes often trace back to a single faulty driver, identifiable from crash dump analysis.
  • Drivers are not firmware. Firmware runs on the device itself, while the driver runs on the host and talks to that firmware.
  • Vulnerable signed drivers can be abused by attackers to gain kernel access, which is why systems maintain driver blocklists.

In everyday language

A computer and its devices do not speak the same language. The operating system says something general, such as print this page, but each printer expects its own detailed instructions. A device driver is the interpreter between the two.

Every piece of hardware needs one, although many are already built into the system, which is why a new mouse simply works. When a driver is missing or faulty, the device misbehaves or disappears, even if the hardware itself is perfectly fine.

Seen in the real world

An engineering office upgrades its workstations to a new operating system release. Afterwards, several machines freeze briefly when engineers rotate large 3D models, and two of them restart with a system error during rendering.

The IT technician reads the crash dumps and finds that every failure points to the graphics driver installed automatically during the upgrade. The workstation vendor publishes a certified driver version tested with the engineers’ design software. After deploying that version to all machines and pausing automatic driver updates for the graphics card, the freezes and restarts stop. The hardware was never at fault; the fix was choosing the right driver for the workload.