I/O Systems & Device Management

a device driver

Think of a universal travel adapter. The wall sockets differ wildly from country to country, but the adapter presents one familiar plug to your laptop and quietly handles the local oddities behind it. A device driver is that adapter inside the operating system: a device-specific module that knows the exact registers and quirks of one piece of hardware, yet presents the same standard interface — open, read, write, close, and so on — that the rest of the kernel expects of every device.

Concretely, the driver sits at the bottom of the I/O stack, just above the controller. Above it is the device-independent I/O software (naming, buffering, error handling) that all devices share; the driver translates the generic requests from that layer into the precise sequence of register reads and writes this particular controller needs, and it contains the interrupt service routine for the device. So when a program calls read on a network card, the request flows down through the uniform layers until it reaches the network driver, which knows that this exact chip needs these exact commands in these exact registers. Drivers are why the same line of code can work an SSD, a USB stick, or a magnetic disk: each device has its own driver, but all expose the same interface upward.

Why it matters: drivers are the part of the OS that grows endlessly, since every new gadget needs one, and they are also the riskiest part. A driver runs in kernel mode with full privileges, so a buggy or malicious driver can crash or compromise the entire system — historically a leading cause of operating-system crashes. That is the tension at the heart of this design: the uniform interface above keeps applications simple and portable, while all the messy, dangerous device-specific knowledge is concentrated (and isolated, as much as possible) in the driver.

You plug in two different webcams. Each has its own driver, but both register as a standard video device. Your video-call app opens /dev/video0 and calls read the same way for either; the driver underneath turns those calls into that camera's specific commands.

Same uniform interface upward; device-specific commands downward — that is the driver.

A driver is software, not the device, and it runs with kernel privileges. The uniform interface it presents is a deliberate abstraction; the device's real, ugly details live only inside it — which is also why a faulty driver can take the whole OS down.

Also called
driverdevice-specific module驅動程式