Drivers & buses
Polled hardware, one vtable per bus.
Most NebOS drivers are polled rather than interrupt-driven: storage, USB and every NIC are serviced from process context. That trades latency and CPU time for simple, single-owner state and a kernel that stays easy to reason about on old hardware.
Driver inventory
Every driver in the tree is small enough to read in one sitting. The table below is the quickest way to find the one responsible for a device.
| Subsystem | Driver | Bus / access | Service model |
|---|---|---|---|
| Floppy | disk.c | ISA FDC + DMA channel 2 | IRQ 6; FAT operations set sys_fs_busy |
| PATA | ata.c | Legacy ports or PCI native BARs | Polled PIO, DRQ wait per sector |
| SATA | ahci.c | PCI AHCI MMIO | Polled, READ/WRITE DMA EXT |
| USB | usb.c + uhci.c ohci.c ehci.c xhci.c | PCI I/O ports or MMIO | Polled; hotplug watcher in the WM loop |
| Network | e1000e.c r8168.c ne2000.c asix.c | PCI or USB | Polled, one active receiver |
| PS/2 | mouse.c, io.c | i8042 | IRQ 1 keyboard, IRQ 12 mouse; polling fallback |
| Serial | serial.c | 16550 UART, COM1 | IRQ 4 ring buffer + polled transmitter |
| Thermal | thermal.c | Intel DTS MSR | Sampled once a second from the scheduler tick |
| Board sensors | it87.c, tpec.c | Super I/O, ThinkPad EC | Polled read-only |
PCI & discovery
pci.c walks bus/device/function and exposes BAR and capability access. The USB scan checks all functions: real PIIX3/PIIX4/VIA layouts put the USB function at 0:07.2 or 0:01.2, not 0:07.0. Controllers with unassigned BARs are ignored rather than driven at address zero.
MMIO regions are mapped through paging_map_mmio(). PCI
interrupts are disabled before touching MMIO, so every driver polls
its own status registers. lspci lists every function;
with a filter it prints BAR type, size and address details.
Storage
blkdev.c is a small registry of block
devices. Each device exposes sector read/write plus geometry; FAT and
the format command sit above that interface and never talk to a
controller directly. Devices are named floppy0,
ide0, sata0 and so on; partitions append
p1, p2.
struct blk_dev. The floppy still needs IRQ 6, but ATA
and AHCI are polled; a FAT operation takes sys_fs_busy
so the scheduler does not switch away mid-transfer.
Floppy
disk.c drives the 8272-compatible FDC
through ISA DMA channel 2, with the single-sector DMA buffer at
0x4000. Retries handle the usual real-hardware flakiness.
The second floppy slot can hold root.img.
PATA
ata.c uses the legacy command block or the PCI IDE interface's native BARs. Multi-sector PIO waits for DRQ before every sector because drives drop it between sectors; it polls the command-block status rather than the alternate-status BAR, and falls back to single-sector commands when a bridge leaves DRQ pending.
SATA/AHCI
ahci.c drives the first AHCI controller
only, with no IRQs and no NCQ. It does COMRESET, IDENTIFY through the
shared ata_identify_parse(), and READ/WRITE DMA EXT
through a page-allocated bounce buffer. A disk added after boot needs
a rescan; there is no COMRESET hotplug.
USB stack
usb.c is controller-agnostic. It handles
enumeration, descriptor parsing, hub recursion, bus scans, per-controller
addresses, the hotplug watcher and interrupt-IN consumers. Each host
controller implements the usb_hcd_ops vtable in
usb_hcd.h.
| Controller | Transport | Instances | Implementation notes |
|---|---|---|---|
| UHCI | PCI I/O ports | 1 | Frame list at 0x3000; control QH plus one QH per interrupt slot. |
| OHCI | PCI MMIO | up to 4 | HCCA from the page allocator, static ED/TD sets, TDs start at CC = NotAccessed. |
| EHCI | PCI MMIO | up to 4 | Async QH/qTD schedule, page-allocated descriptors, polling only, no periodic list. |
| xHCI | PCI MMIO | — | USB2 root ports only; USB3 SuperSpeed devices are not handled. |
Hubs are class-9 devices: usb.c sets their configuration,
powers every downstream port (honouring bPwrOn2PwrGood),
resets and waits for PORT_ENABLE, then enumerates
recursively. This is what makes the X201's internal PCH hubs work.
Hotplug watches root ports; a device behind a hub is only found when a
full scan runs (lsusb also bumps the USB generation so
usbhid re-attaches).
Input
usbhid.c gives every HID class-3 interface with an interrupt-IN endpoint one of the six USB interrupt slots. Boot interfaces (subclass 1, protocol 1/2) are used as-is; other class-3 interfaces are classified by reading their HID report descriptor. Composite receivers and several devices can coexist; mouse reports from all slots are merged.
- Mouse. Three-byte boot reports: buttons in
b0 & 7, signeddx/dy. HID's +y is flipped to the PS/2 convention. - Keyboard. Eight-byte boot reports (modifier + six keycodes). Reports are diffed and decoded through a HID-usage → scancode-set-1 table, then injected with
io_inject_scancode(). - Repeat. A boot keyboard only reports changes, so
io.cadds software typematic repeat (500 ms delay, 33 ms rate). - PS/2. The i8042 path shares the cursor and keyboard code; the BIOS legacy USB emulation is disabled because the kernel owns the devices.
mouseinfo shows the active backend and whether a USB
keyboard is attached. Headless regression tests inject mouse motion
and keys through QMP and verify the result with screen dumps.
Serial
serial.c drives the 16550 at COM1, 115200
8N1, with an IRQ-driven receive ring buffer. It is used for the boot
trace, the netlog mirror source, XMODEM transfers, the dbg
monitor and the KXE2 kexec receiver.
The transmitter is polled, so a machine without a serial port still
boots normally. serial_puthex and
serial_putdec are the structured dump helpers used by
drivers.
Sensors, power & thermals
- DTS. thermal.c reads
IA32_THERM_STATUSon an allowlist of Core/Core 2, Nehalem/Westmere and Bonnell models. TjMax comes fromIA32_TEMPERATURE_TARGETon Nehalem and later; Bonnell uses a table. - IT87xx. it87.c reads the Super I/O temperatures and fan tachometers on the ASUS AT3IONT-I. Nothing is written to fan control.
- ThinkPad EC. tpec.c is gated on an SMBIOS Lenovo/IBM match and reads temperatures and fan mode through ports
0x62/0x66. It drains pending output bytes and uses bounded waits; nothing is written. - MTRRs. mtrr.c manages write-combining ranges for the framebuffer and reports the effective mapping.
sensors prints DTS values on the 90/100/125 °C scales,
board sensors and EC registers; power prints ratios,
effective MHz and C-state residency.
Panic screen
On a ring-0 fault, panic.c draws straight into the framebuffer — bypassing the shadow buffer and the WM — and mirrors the same data to COM1 before halting. The banner includes the vector and error code, GPRs, control registers, current pid/name, uptime, instruction bytes and stack return-address candidates in the kernel image.
Faults from ring 3 do not halt: the process is killed with a short
message in its terminal and serial log. There is no interactive
debugger on screen; the dbg kernel command drives a
serial monitor instead.
Limits
- Polling. USB, storage and network drivers consume CPU time while waiting; there is no IRQ-driven data path outside PS/2, serial and the PIT.
- EHCI. High-speed root ports only; no split transactions for low/full-speed devices behind a high-speed hub.
- xHCI. USB2 root ports only; USB3 SuperSpeed devices are not handled.
- HID. Report IDs are not handled, absolute pointers/tablets are ignored, and there is no wheel support.
- AHCI. First controller only, no hotplug after boot, disks above 2 TB are clamped to 32-bit LBA.
- Storage serialization. A FAT/floppy operation sets
sys_fs_busyand stalls process switching for its duration; the PIT keeps ticking.
Source map
pci.c,pci.h— enumerationblkdev.c— block registrydisk.c— floppy / DMAata.c,ahci.c— PATA/SATAusb.c,usb_hcd.h— USB coreuhci.c,ohci.c,ehci.c,xhci.cusbhid.c,mouse.c,io.c— inputserial.c,serial_ring_buf.cthermal.c,it87.c,tpec.c,mtrr.cpanic.c,timer.S— fatal exceptions