danos/README.md

88 lines
3.5 KiB
Markdown

# DanOS
Codename: Shodan
Version: 1
A small resilient operating system, written from scratch in Zig.
## 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 lifecyle 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 shortend 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](https://github.com/tristanisham/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
```sh
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/`, and the initial-ramdisk at `zig-out/boot/`.
## Run
Boot it in QEMU with OVMF (opens a display window):
```sh
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
```sh
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/`](docs/README.md) — start with [`docs/README.md`](docs/README.md).
## Logo
San Serif Text "Dan OS" with a black karate belt around it.