Frequently Asked Question

How does the kernel talk to hardware? What is a device driver?

A device driver is the kernel code that knows how to talk to one specific kind of hardware: a particular network chip, a USB storage class, an NVMe controller, a GPU. It exposes that hardware to the rest of the kernel through one of a small number of well-defined interfaces, struct file_operations for character devices, struct block_device_operations for disks, struct net_device_ops for network interfaces, so the upper layers don't care which vendor made the chip.

Drivers ship either built into the kernel (compiled with =y in the kernel config) or as loadable modules. When you plug in a USB device, the kernel reads its vendor/product IDs, looks up a matching driver in the module database, loads the .ko file, and the driver registers itself with the bus subsystem.

Video

Further reading and video