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 |
| eMMC | sdhci.c | Intel Braswell SDHCI, PCI 00:10.0 (8086:2294) | Polled PIO, 1-bit/25 MHz; no DMA/IRQ |
| 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 |
| Touchpad | i2c.c, touchpad.c | LPSS DesignWare I2C, slave 0x15 | Polled input register every 25 ms; no GPIO interrupt driver |
| 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 / EC | it87.c, tpec.c, ec.c, cros_ec.c | Super I/O, ThinkPad H8 EC, Chrome OS EC (temps, fans, battery, AC, switches) | Polled; EC battery-index/FIFO/page-selector writes only |
| Wall clock | rtc.c | CMOS RTC ports 0x70/0x71 | Read/write under the BKL; update-cycle retries and a 1970–2069 two-digit year window |
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, mmc0 and so on; partitions append
p1, p2.
struct blk_dev. The floppy still needs IRQ 6, but ATA,
AHCI and SDHCI 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.
eMMC/SDHCI
sdhci.c drives the Intel Braswell MMC
function at PCI 00:10.0 (8086:2294, class
0805), the HP Chromebook's eMMC. It resets the SDHCI
host, selects the 1.8 V rail and Host Control 2's 1.8 V signalling,
runs a 400 kHz initialization clock, then CMD0/1/2/3/7/16 and CMD8
to read EXT_CSD (SEC_COUNT at 212,
CACHE_SIZE at 249), and switches to a 25 MHz data clock.
Sector I/O is CMD17/CMD24 through the polled PIO buffer port at
1-bit/25 MHz; there is no DMA, IRQ, bus-width/high-speed switch or
hotplug. The eMMC appears as mmc0, and
format mmc0 writes an MBR + FAT partition exactly like
an IDE/SATA disk. The write path flushes the card cache with CMD6
FLUSH_CACHE when EXT_CSD reports one.
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. Halts and waits for HCH around HCRST; EP0 max packet comes from the port speed; EP0 stages are encoded as one TD per stage (EDK2 style) because chained control TDs stall on Braswell. |
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.
I2C touchpad
The HP Chromebook 11 G5 EE has no PS/2 port: its Elan touchpad is a HID-over-I2C device on LPSS I2C6. The LPSS I2C functions are hidden from PCI in ACPI mode, so touchpad.c scans the two firmware BAR windows for a DesignWare component and i2c.c drives that controller in fast mode, polled and without interrupts.
- Probe. Slave address
0x15: reset (0x0100), consume the 2-byte acknowledgement, read the HID descriptor, select absolute mode (0x0300 = 1) and wake the device (0x0800). Resetting last leaves it silent until the next power cycle. - Reports. The Elan vendor report
0x5Dcarries a finger bitmask and five bytes per finger (X/Y high bits, X low, Y low, size, pressure). Successive absolute positions become PS/2 deltas; the clickpad bit becomes the left button. - Polling. The report GPIO has no driver yet, so the input register is read every 25 ms. Back-to-back reads stall the device, which is why the poll is throttled rather than run flat out.
- Discovery.
touchpadprints the probe result;mouseinfolists the Elan vendor/product ID next to the PS/2 and USB backends.
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, 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, Bonnell and Airmont/Braswell models. TjMax comes fromIA32_TEMPERATURE_TARGETon Nehalem/Westmere; Airmont uses coretemp's 90 °C table (the kernel does not read the MSR before the IDT exists), and Bonnell uses the 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 the shared ACPI EC protocol in ec.c (ports
0x62/0x66, command0x80read /0x81write, OBF/IBF waits, stale-byte drain, bounded polls). Battery/AC state comes from0x38/0x39(present, charging, discharging),0x46bit 4 (AC online), and the page-selected 16-byte window at0xA0..0xAF;0x81selects the battery and page (0 dynamic, 1 mode, 2 design, 5 manufacturer, 6 model). That page selector is the only EC write, and it is restored when it changed. - Chrome EC. cros_ec.c probes the Chrome OS EC, gated on the ACPI memory version, the
'E','C'memmap id and the device feature bits; it skips the probe when the ThinkPad EC is present. Its ACPI window0x20..0xFFmirrors memmap0x00..0xDF: temperature sensors0x00..0x0f/0x18..0x1f(raw − 73 °C), fans0x10..0x17(0xffffabsent), switches0x30(lid/power button), and the battery block0x40..0x7f(AC/present/charging flags at0x4c, voltage/rate/remaining/design/last-full/cycle count, and the 8-byte strings).EC_ACPI_MEM_BATTERY_INDEX0x12selects the battery and waits forBATT_INDEX0x4e;EC_ACPI_MEM_STRINGS_FIFO0x16returns longer strings when supported. The Cyan full-charge workaround is applied, and the units are mAh/mA. power_src.c picks the ThinkPad backend first, then the Chrome EC;SYS_CROS_EC_SENSORS(107) exposes the EC temperature/fan/switch snapshot. - 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 both EC types; powerinfo prints the
source (thinkpad or chrome ec), the AC
adapter, battery model/manufacturer/serial, capacities, voltage,
rate and cycle count through SYS_POWER_INFO;
power prints ratios, effective MHz and C-state hints.
The WM top bar shows the AC adapter state and the first present
battery with a valid percentage next to the CPU temperature on
both ThinkPads and Chromebooks; machines without an EC show neither.
Wall clock (RTC)
rtc.c talks to the MC146818-compatible
CMOS clock through ports 0x70/0x71. Reads honour the
register-B BCD/binary and 12/24-hour modes, retry when the
update-in-progress bit is set, and decode the hour's PM flag. The
RTC only stores a two-digit year, so the kernel expands it over a
1970–2069 window (70–99 → 1900s, 00–69 → 2000s); a board whose
dead battery left 1980 or 1990 therefore reads correctly instead of
being pushed a century forward. Writes validate the calendar (leap
years included), raise the register-B SET bit, preserve the mode
bits and write the computed weekday. On ACPI machines the FADT
century register (offset 108, normally CMOS 0x32) is
written as well, so the firmware and other operating systems see
the intended century; boards without ACPI get no arbitrary NVRAM
write.
SYS_RTC_GET/SYS_RTC_SET (104/105) expose
the full struct sys_datetime; the older
SYS_RTC_HMS/SYS_RTC_DATETIME calls remain
the small read-only views. The WM’s top-bar date/time is a click
target that opens bin/settime; its Sync NTP
button fetches UTC through SYS_NTP_SYNC (106), backed
by the SNTP client in ntp.c, and writes
it with SYS_RTC_SET. The date command
prints the same clock in the classic Linux format.
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.
- eMMC. Polled 1-bit/25 MHz PIO; no DMA, IRQ, CMD6 bus-width/high-speed/DDR switch or hotplug. Only the eMMC function is driven; the SDIO/SD functions and SD card reader are not.
- Storage serialization. A FAT/floppy operation sets
sys_fs_busyand stalls process switching for its duration; the PIT keeps ticking. - EC. The Chrome EC path uses the ACPI v2 memmap only: no MEC host-command interface, EC SCI events, charger current/voltage, charging limit or EC firmware version. The ThinkPad H8 path is limited to its page-selected battery window and has no SCI handler. Battery/AC is polled by the WM once a second.
- Suspend. There is no S0ix/suspend path; package C-states and the EC sleep handshake remain firmware-managed.
Source map
pci.c,pci.h— enumerationblkdev.c— block registrysdhci.c,sdhci.h— Intel Braswell eMMCdisk.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— inputi2c.c,i2c.h— DesignWare/LPSS I2C mastertouchpad.c,touchpad.h— Elan HID-over-I2C touchpadserial.c,serial_ring_buf.cthermal.c,it87.c,tpec.c,ec.c,cros_ec.c,power_src.c,mtrr.crtc.c— CMOS wall clock read/writepanic.c,timer.S— fatal exceptions