A device driver is the kernel code that knows how to talk to one kind of hardware and presents it to the rest of the system through a common interface. Drivers make a disk, a network card or a camera look like something programs can use. They run with full privilege, so a driver's bug can bring down the whole machine.
Key concepts
- Driver model: the kernel defines how drivers register, find their devices and are told to start and stop.
- Device access: registers and buffers reached through memory-mapped or port I/O, with DMA moving data without the CPU.
- Interrupts: the device signals completion or events, and the driver handles them quickly, deferring heavy work.
- Interfaces to user space: character and block devices, network interfaces and files that expose controls.
- Power and hot-plug: devices appear, disappear and sleep, and the driver has to cope at any moment.
Vocabulary
- DMA: direct memory access, a device reading or writing memory on its own.
- MMIO: memory-mapped I/O, device registers that look like memory addresses.
- Bus: the connection a device sits on, such as PCI or USB, which lets the kernel discover it.
- Firmware blob: code the driver loads onto the device itself.
What to study, in order
- Operating-system basics and C, with attention to pointers, bit operations and concurrency.
- Write a trivial loadable module that logs when it loads and unloads, in a virtual machine.
- Add a character device with read and write operations backed by a buffer.
- Write a driver for a simple real or emulated device, using interrupts.
- Learn locking and memory rules for code that runs in interrupt context.