SlopOS
Development

Adding A Driver

How to add or extend a kernel driver

Drivers live in the driver subsystem unless they are architecture primitives that belong in OSTD or platform-table parsers that belong in ACPI support.

Placement

Driver kindLikely home
ACPI table parserACPI support crate
Raw CPU/MMIO primitiveOSTD
PCI, MSI, VirtIO, input, TTY, platform driverDriver subsystem
Device-facing syscall serviceKernel service bridge
File descriptor integrationFilesystem and driver file ops

Driver Rules

  • Keep unsafe in OSTD. Use safe MMIO, port I/O, DMA, and PCI helpers.
  • Prefer MSI-X, then MSI. Legacy interrupt modes are not the supported VirtIO path.
  • Register IRQ callbacks through OSTD IRQ line APIs.
  • Use WaitQueue or event-based wakeups for blocking I/O.
  • Keep interrupt handlers short; defer protocol work to scheduler-backed tasks when possible.
  • Add hermetic tests for pure logic and QEMU tests for hardware integration.

Boot Integration

Platform drivers usually connect through boot ordering. Boot steps should state whether hardware is mandatory or optional. Mandatory platform components should panic early with a clear message; optional devices should log and leave the subsystem disabled.

Test Strategy

RiskTest
Register parsingHost or kernel unit tests
IRQ routingKernel tests with synthetic callbacks
DMA queue behaviorHermetic tests plus QEMU device tests
Blocking I/OPoll/select and wakeup tests
Error cleanupProbe failure and teardown tests

Run at least:

just test FILTER='slopos_drivers::*'
just check-framekernel

just check-framekernel needs a prior just build.

On this page