Skip to the content ForoHackers
Log inJoin

Device drivers: start here

Device drivers
#3377 · · Quote · Report

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

  1. Operating-system basics and C, with attention to pointers, bit operations and concurrency.
  2. Write a trivial loadable module that logs when it loads and unloads, in a virtual machine.
  3. Add a character device with read and write operations backed by a buffer.
  4. Write a driver for a simple real or emulated device, using interrupts.
  5. Learn locking and memory rules for code that runs in interrupt context.

Related tags

#kernels #linux #embedded-linux #c #firmware

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply