run.ps1 would not start at all: it declared a -Debug parameter, which CmdletBinding already provides, and PowerShell refuses to load a script with a duplicate parameter name before running a line of it. Renamed to -Gdb, which is what it does anyway. All three scripts are now checked to parse and bind their parameters. The kernel panicked on the second boot with the same disk. The filesystem tests assumed an empty disk and failed on the files the previous boot had left -- which is precisely what a persistent filesystem is supposed to do. They clean up after themselves now, so starting the machine twice works. Both were invisible to the existing tests: test.ps1 calls build.ps1 and qemu directly rather than through run.ps1, and it deletes data.img before every run. Neither is how someone uses the system. Verified by booting twice against the same disk -- both passes reach the shell -- and by re-running both suites: 37 kernel tests and 13 shell commands. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| boot | ||
| include/aster | ||
| kernel | ||
| tools | ||
| user | ||
| .gitignore | ||
| build.ps1 | ||
| plan.md | ||
| README.md | ||
| run.ps1 | ||
| status.md | ||
| test.ps1 | ||
Aster
A 64-bit operating system kernel built from nothing. No Linux, no BSD, no GRUB, no Limine, no libc. The bootloader, the kernel and the first user program are all in this repository, and every line of them is ours.
What works today
Aster boots to a shell you can type at.
/ $ ls /bin
9488 init
21248 ash
9344 ps
/ $ write /tmp/note.txt hello
/ $ cat /tmp/note.txt
hello
/ $ free
memory: 522764 KiB total, 1208 KiB used, 521556 KiB free
uptime: 8.4 s
running: 3 processes, 4 threads
boot own two-stage BIOS loader: A20, E820 map, ACPI discovery,
ELF64 parsing, 4-level page tables, long mode
cpu GDT with TSS and IST stacks, 256-vector IDT, decoded exception
reporting, ACPI tables, LAPIC, IOAPIC, calibrated LAPIC timer
memory buddy page allocator, 4-level paging with W^X enforced,
slab-backed kmalloc, direct map of all physical memory
threads preemptive priority scheduler, sleeping, blocking wait queues,
spinlocks, mutexes, semaphores, condition variables
userspace ring 3, SYSCALL/SYSRET, per-process address spaces, validated
ELF loading, 19 system calls, processes with exit codes
ipc capabilities that cannot gain rights, synchronous endpoints,
lock-free single-producer rings
drivers PCI over ECAM, PS/2 keyboard, block layer, AHCI/SATA
files AsterFS: write-ahead journal, extents, directories, survives
a remount and replays after an unclean shutdown
userland init, the ash shell, ps, and libaster -- no library to link
Every boot runs 37 self-tests and a ring-3 program; tools/shell_test.ps1
types thirteen commands into the running system and checks each answer. The
build fails if any of them fails.
Building
Requires LLVM (Clang and LLD), NASM,
QEMU and Python 3. Nothing needs to be on PATH —
build.ps1 finds them.
winget install LLVM.LLVM NASM.NASM SoftwareFreedomConservancy.QEMU
.\build.ps1 # cross-compile to x86_64-elf and assemble the image
.\run.ps1 # boot it in QEMU
.\test.ps1 # boot headless and verify the output
test.ps1 fails on a panic, a triple fault, a missing completion marker, or
silence on the serial port. run.ps1 -Debug waits for GDB on port 1234.
Layout
boot/ stage1.asm 512-byte MBR: load stage 2 and nothing else
stage2.asm A20, E820, RSDP, ELF loading, long mode
kernel/
arch/ entry.asm first instructions: stack, .bss, kmain
isr.asm 256 interrupt stubs into one uniform frame
syscall_entry.asm SYSCALL: the stack switch the CPU skips
gdt.c idt.c cpu.c
mm/ pmm.c buddy allocator over the E820 map
vmm.c 4-level page tables, W^X, direct map
heap.c slab caches and kmalloc
sched/ sched.c priority round-robin, preemption
switch.asm the context switch
sync.c mutexes, semaphores, condition variables
ipc/ cap.c ipc.c capabilities, endpoints, rings
fs/ asterfs.c journal, extents, directories
core/ main.c panic.c syscall.c process.c elf.c test.c
dev/ serial.c console.c pic.c timer.c acpi.c apic.c
pci.c keyboard.c block.c ahci.c
include/aster/ the kernel's own headers; no system headers
user/ libaster.h the entire user runtime, in one header
init.c first process: sets up /bin, starts the shell
ash.c the shell
ps.c hello.c programs
tools/ mkimage.py assembles the bootable image
shell_test.ps1 drives the shell over serial and checks it
diagnose.ps1 boot diagnosis: faults, resets, where it died
Design
Message-oriented core. Isolated units of work communicate through
bounded rings rather than shared mutable state. Memory is region-based, and
drivers are intended to run outside the privileged core wherever the
hardware allows it. Phase 7 builds this; see plan.md.
Higher-half kernel. The kernel lives at 0xFFFFFFFF80000000 and is
mapped into every address space. Switching processes exchanges only the
lower half of the page tables, so a kernel mapping made once is visible
everywhere with no synchronisation.
Validate, then trust. Every ACPI table is checksummed before a field is
read. Every ELF header is bounds-checked before a segment is mapped. Every
user pointer is checked for range, canonicality and page permissions before
it is dereferenced — and only copy_from_user and copy_to_user are
permitted to dereference one at all.
Tests assert behaviour. "It booted" is not a passing test. The suite checks that two threads which never yield still interleave, that a mutex loses no increments across a deliberate context switch inside its critical section, and that the kernel refuses a kernel pointer handed to it from ring 3.
Measured
Under QEMU with TCG, no KVM, on one emulated CPU:
endpoint round trip 20000 messages in 28 ms ~700k msg/s, 1.4 us each
ring push+pop 200000 pairs in 50 ms ~4M pairs/s
Numbers are produced by the kernel's own benchmark on every boot, not quoted from elsewhere.
Status
Aster is usable but not finished. It has no network, no SMP, no pipes, and
no way to build a root image on the host -- programs still travel inside
the kernel and are written to disk on first boot. It has been run only
under QEMU; real hardware is next. plan.md lays out what remains and
status.md says where the work currently stands.