Files
LithosAnanake/src/starkernel
Robert Allan JamesandClaude Sonnet 5 736627510b Fix riscv64 boot crash: add missing kernel stack trampoline
kernel_main on riscv64 ran directly on EDK2's UEFI boot-time stack, with
no dedicated stack switch — amd64 has always had a kernel_entry.S
trampoline for exactly this reason (its own comment: "the FORTH
interpreter + DOE experiment loop can easily exceed that depth").
aarch64 happens to get away without one because its firmware's default
stack is apparently larger, but that was never a guarantee.

On riscv64 the VM bootstrap's call depth (27 word-registration modules
-> physics/SSM init -> Tripod capsule birth) overflowed that small
stack, corrupting a return address and producing a wild jump / page
fault right after vm_init_with_host() returned — reproduced consistently
across the 2026-08-01 DoE campaign logs.

- src/starkernel/arch/riscv64/kernel_entry.S (new): RISC-V stack-switch
  trampoline mirroring amd64's, giving the kernel a dedicated 2 MiB BSS
  stack before anything deep runs.
- kernel_main.c: riscv64 now builds kernel_main_impl (invoked via the
  trampoline) instead of kernel_main directly, same pattern as amd64.
- Makefile.starkernel: wires the new file into the riscv64 build.
- uefi_loader.c: RAW_LOG() was silently a no-op on every non-amd64 arch;
  added a real raw-UART writer for riscv64 (QEMU virt's uart8250 at MMIO
  0x10000000) so existing loader diagnostics actually produce output.

Verified: all three architectures boot clean to [Hera] ok> in the
required order (amd64, aarch64, riscv64); logs and DoE CSVs from these
runs included.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-02 06:59:48 -04:00
..
2026-08-01 07:49:56 -04:00

src/starkernel/

LithosAnanke — the bare-metal UEFI kernel that boots StarForth directly on hardware (amd64/aarch64/riscv64). Built only via Makefile.starkernel; the only valid acceptance test is the three-arch QEMU boot (see .claude/CLAUDE.md), never make test.

  • kernel_main.c — kernel entry point, driving the boot milestones (console init, PMM, VMM, interrupts, timers, kmalloc heap, VM bootstrap).
  • repl.c — kernel REPL.
  • doe_log.c — kernel-side DoE (Design of Experiments) metrics logging.

Subdirectories:

  • arch/{amd64,aarch64,riscv64}/ — per-architecture support (APIC/GIC/ PLIC interrupt controller, timers, boot/ISR assembly).
  • boot/ — UEFI loader, ELF loading, kernel command-line parsing.
  • capsule/ — capsule birth/run/load/validate pipeline.
  • hal/ — hardware-abstraction-layer implementation (console, framebuffer, VT100, memory, host services).
  • hash/ — XXHash64 content-addressing implementation.
  • math/ — kernel-build Q48.16 fixed-point arithmetic.
  • memory/ — physical/virtual memory managers and the kernel heap.
  • pci/ — PCI bus enumeration.
  • virtio/ — VirtIO block device driver.
  • vm/ — kernel VM subsystem (bootstrap, core interpreter, parity logging, capsule arena).

See include/starkernel/README.md for the corresponding headers.