Table of Contents

Driver glossary

These notes give the background on the hardware, operating system and build concepts that Writing a driver and the contributor page on the Driver manifest build on, for a reader who has not written a driver before. Each page explains the concept on its own, then closes with how Cosmos applies it. The table groups them in four parts: how a driver reaches a device, how the device and the driver signal each other, the buses, then how a kernel comes to carry a driver and picks one for each device. Interrupt context also builds on two scheduling notes from the contributor documentation, preemption and the instruction boundary.

Concept Summary
MMIO and port I/O Reaching device registers through memory or ports, and how mappings cache them
Physical addresses Virtual against physical addresses, physical contiguity, and the alignment devices require
DMA Devices reading and writing memory themselves: bus mastering, coherence, 32-bit limits
Memory barriers Ordering CPU loads and stores so a device sees them in order
Descriptor rings Circular descriptor arrays shared with a device: ownership, head and tail, doorbells
Interrupt delivery IRQs, acknowledging the device, edge and level triggering, INTx against MSI-X
Interrupt context Why a handler cannot wait, why a driver's handler must not allocate, and how its work is split
Buses and enumeration Enumerable buses, platform devices described by firmware, and the node tree
Firmware handoff What UEFI configures before the kernel runs, and what Cosmos keeps
PCI The PCI function, its configuration space, class codes, capabilities and BARs
Hot-plug Devices arriving and leaving at run time, and surprise removal
Virtio Paravirtual devices: transports, the status handshake, feature negotiation and virtqueues
USB Interfaces, endpoints, transfer types, polled interrupt endpoints, enumeration, the three host controller interfaces with their companions and hubs, the HID boot protocol
PS/2 and the 8042 controller The 8042 controller, its two ports, commands, acknowledgements and scanning
Source generators Compiler plug-ins that add code at build time, in place of reflection, and how build properties reach them
Trimming and feature switches Leaving unreachable code out of the image, and build-time switches that make a branch unreachable
Driver matching Match tables, specificity and rank, and a deterministic last key when several drivers fit one device