Operating System written for me
Go to file
Daniel Samson 6a687fbc2b
iommu: AMD-Vi backend behind the vendor-neutral core
The second hardware backend. The IOMMU core, DMA-region capabilities, and
per-device enforcement are unchanged; this adds AMD-Vi (IVRS) as an
alternative to Intel VT-d (DMAR) under the same Backend vtable.

- parseIvrs records the IOMMU control-register base from the first IVHD;
  the platform layer gains iommu_is_amd, and the core picks the backend by
  vendor at init. VT-d and AMD-Vi are mutually exclusive on real hardware.
- iommu-amd.zig: a 2 MiB device table (every DTE zeroed = deny-all until a
  device is claimed), AMD native-format page tables (4 KiB leaves), a
  command buffer (INVALIDATE_DEVTAB_ENTRY / INVALIDATE_IOMMU_PAGES /
  COMPLETION_WAIT) and an event log for faults. The DTE forwards
  interrupts unmapped, so MSI passthrough works exactly as on VT-d.
- The boot log and the iommu self-test are now vendor-aware.

**UNTESTED on real AMD hardware** — danos is developed on Intel, so this
is validated only against QEMU's amd-iommu, and every log line and doc
says so. QEMU quirk handled: its amd-iommu does not observe the
COMPLETION_WAIT store form, but consumes the command ring synchronously on
the tail-register write, so invalidations are already applied by the time
we poll — the backend warns once and proceeds.

Cases: amd-iommu (detection + scratch-domain walker) and
amd-iommu-usb-storage (full storage stack through AMD device-table
translation with per-grant capabilities), both green. 106/106.

This completes the IOVA/IOMMU-enforcement track: per-device DMA domains on
both vendors, with buffers reachable only through delegated capabilities.
2026-07-26 18:31:27 +01:00
boot reorg: move test fixtures to test/system/services (source + boot volume) 2026-07-23 00:11:07 +01:00
docs device-manager: data-driven driver matching via /etc/devices.csv 2026-07-26 16:43:13 +01:00
etc init: data-driven boot service list via /etc/init.csv 2026-07-26 17:13:51 +01:00
library iommu: DMA-region capabilities — per-grant reachability, protocol flag-day 2026-07-26 18:31:27 +01:00
system iommu: AMD-Vi backend behind the vendor-neutral core 2026-07-26 18:31:27 +01:00
test iommu: AMD-Vi backend behind the vendor-neutral core 2026-07-26 18:31:27 +01:00
tools boot: the capsule — one-file system image first, manifest and walk as fallbacks 2026-07-21 18:57:33 +01:00
usr/share/fonts assets: add font families under usr/share/fonts 2026-07-14 18:39:23 +01:00
.editorconfig editorconfig 2026-07-12 16:09:11 +01:00
.gitattributes gitattributes 2026-07-12 16:09:18 +01:00
.gitignore gitignore: /var/log — real-hardware log pulls stay out of the tree 2026-07-21 20:09:29 +01:00
README.md re-org docs 2026-07-23 00:25:34 +01:00
build.zig iommu: per-device domains with interim DMA-pool enforcement 2026-07-26 18:31:27 +01:00
build.zig.zon started project with basic efi setup 2026-07-01 18:32:56 +01:00

README.md

DanOS

Codename: Shodan

A very small resilient operating system.

Zen of DanOS:

  • Resilient Micro-Kernel Architecture.
    • Every process run in an isolated user space not kernel space.
    • Processes cannot take down the entire OS with it when they die or is killed
  • Stable public runtime library, private OS ABI.
    • Keeps a stable runtime for user space processes between OS versions (great for backwards compatibility)
    • Allows the underlying OS to be changed without effecting applications
    • Provides a boundary to enable compatibility between OS's e.g. POSIX, MUSL etc
  • Drivers are just isolated processes in user space.
    • Thin binaries that can be restarted like applications.
    • Useful during driver development.
    • Drivers can claim MMIO / ports
    • Driver resources (e.g. IRQ/Port/MMIO) claims are automatically cleaned up if the driver dies or is killed
    • Drivers can also hook into the process lifecycle to clean up or reset hardware
  • No legacy to deal with
    • Zig code uses a clean coding style (Zen of Zig)
    • Favor reading code over writing code.
    • No magic numbers.
    • No shortened names unless its for ABI compatibility or acronyms
  • Inter-Process Communication (IPC)
    • Publish and subscribe to Asynchronous Messages
    • Talk to services and processes synchronously

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 or zigup will pick up .zig-version automatically.
  • QEMU (qemu-system-x86_64) — to run and test the kernel. On macOS, brew install qemu also bundles the OVMF firmware below.
  • OVMF UEFI firmware — the edk2-ovmf package (Arch), ovmf (Debian/Ubuntu), or edk2-ovmf (Fedora); on macOS it ships inside the Homebrew qemu formula. 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 a FHS-shaped zig-out/ that is the danos filesystem and the boot volume: the UEFI bootloader at zig-out/EFI/BOOT/BOOTX64.efi, the kernel at zig-out/system/kernel, init at zig-out/system/services/init, drivers under zig-out/system/drivers/, the test fixtures under zig-out/test/system/services/, and the initial-ramdisk at zig-out/boot/.

Release media

zig build release-x86-64

Produces zig-out/danos-x86-64.iso, a hybrid ISO that boots flashed raw to a USB stick (balenaEtcher, dd) or burned to optical media — see docs/release-iso.md. zig build check-iso-image validates it without booting.

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 why behind the code live in docs/ — start with docs/README.md.

For the hardware needed to run DanOS — minimum specs plus a plain-language guide matching Intel/AMD CPU generations by name — see docs/system-requirements.md.

San Serif Text "Dan OS" with a black karate belt around it.