A user-space process can now touch real hardware directly, capability-gated by the device tree — the microkernel driver model. - src/kernel/devsvc.zig: flattens the discovered device tree into an id-indexed snapshot + a claim table at boot (devsvc.init from main.zig). - Syscalls 11-13: dev_enumerate (snapshot the table), dev_claim (take exclusive ownership), mmio_map (map a claimed device's MMIO window into the caller's AS and return the register base). The claim is the capability: mmio_map refuses any device the caller doesn't own. - paging.mapUserDeviceInto: maps device MMIO strong-uncacheable (PCD|PWT) and marks each leaf with a device_grant PTE bit; freeSubtree skips pmm.free on those leaves, so tearing down a driver never returns MMIO frames to the RAM pool (the teardown hazard). MMIO grants live in a distinct arena, PML4[226] (Task.dev_map_next), so device pages widen no kernel mapping. - lib/dev.zig: user enumerate/claim/mmioMap wrappers; shared DeviceDesc/ResDesc in danos (root.zig). sbin/hpetd.zig: finds the HPET, claims it, maps its registers, enables the counter (an MMIO write) and reads it (0xF0) — proving read+write passthrough to real hardware. - Tests: `hpet` (driver reads the counter advancing from ring 3) and `iopass` (device-granted frame survives address-space teardown). Suite 33/33. irq_bind/irq_ack (IRQ-as-message) are stubbed (-1) pending; notifyFromIsr (M7) is the hook they'll use.
DanOS
Codename: Shodan Version: 1
A small operating system, written from scratch in Zig — a bootloader (src/boot/)
and a microkernel (src/kernel/), sharing a neutral handoff contract (src/root.zig).
It boots x86-64 via UEFI, and so far has a framebuffer console, a physical frame
allocator, its own paging with W^X permissions, interrupt/exception handling, a
LAPIC timer, a kernel heap, a fixed-priority preemptive scheduler, and in-kernel IPC
channels. See docs/ for how each piece works.
Prerequisites
- Zig 0.16.x — the build is pinned to this line (
.zig-version); other minor versions are rejected, because Zig makes breaking changes between releases pre-1.0. A toolchain manager such as zvm orzigupwill pick up.zig-versionautomatically. - QEMU (
qemu-system-x86_64) — to run and test the kernel. On macOS,brew install qemualso bundles the OVMF firmware below. - OVMF UEFI firmware — the
edk2-ovmfpackage (Arch),ovmf(Debian/Ubuntu), oredk2-ovmf(Fedora); on macOS it ships inside the Homebrewqemuformula. Both the build and the test harness probe the known Arch/Debian/Fedora/macOS layouts and use the first that exists, so no configuration is normally needed. Override with-Dovmf-code=/-Dovmf-vars=(build) if yours lives elsewhere. - Python 3 — for the QEMU integration test harness.
Build
zig build
Produces the UEFI bootloader (zig-out/bin/BOOTX64.efi) and the kernel ELF
(zig-out/bin/kernel).
Run
Boot it in QEMU with OVMF (opens a display window):
zig build run-x86-64
# distro with OVMF elsewhere:
zig build run-x86-64 -Dovmf-code=/path/OVMF_CODE.fd -Dovmf-vars=/path/OVMF_VARS.fd
Test
zig build test # host unit tests (the platform-independent shared code)
python3 test/qemu_test.py # QEMU integration tests: boots the kernel and asserts
# on its serial output (see docs/testing.md)
The integration harness builds and boots the kernel once per test case, checking memory, the frame allocator, paging (incl. NX and the null guard), the heap, interrupts, and exception handling. It exits non-zero on any failure, so it drops straight into CI.
Documentation
Design notes explaining the why behind the code live in
docs/ — start with docs/README.md.
Logo
San Serif Text "Dan OS" with a black karate belt around it.