# Bringing Sprite to i386 QEMU

Sprite began as a historically rich system with machine-specific assumptions
spread across its kernel, tools, and userland. The i386 bring-up has been a
steady process of making those assumptions explicit, bounded, and testable
while preserving the behavior that makes Sprite recognizable.

The first usable checkpoint was a reproducible BIOS/QEMU-PC boot: Clang and
LLD build a deterministic image, the i386 entry path establishes paging and
descriptors, and serial markers make failures diagnosable without privileged
host setup. From there, the kernel gained a bounded E820 page allocator,
per-process page directories, CR3 and TSS switching, normalized traps, and a
100 Hz round-robin scheduler. Fork, wait queues, signals, pipes, and process
teardown now have rollback paths instead of relying on implicit machine state.

Static ELF32 loading and ABI-selected Sprite/Unix syscall tables brought up a
small but real userland. The CRT, libc closure, `initsprite`, historical
`tcsh`, and `cat` run from protected user mode with checked pointer copies,
guarded stacks, independent text/data/heap mappings, and deterministic
arguments and environment.

The storage path followed the same pattern. ATA access is capacity-bounded and
supports arbitrary byte ranges, partial-sector read-modify-write, flush, and
recovery. A deterministic `mkofs` image preserves the historical 4 KiB OFS
layout. The serial console has canonical input, editing, blocking reads,
`select`, tty controls, pipelines, redirection, signals, and shell job control.

The distributed bring-up then separated portable contracts from QEMU details.
Three 64-byte node records identify a root server and two diskless clients.
Dual PCnet interfaces use bounded scatter/gather operations and independent
DMA rings. Native Ethernet routing, fixed-width RPC framing, fragmentation,
duplicate suppression, remote OFS handles, and cache invalidation let both
clients boot and share the server namespace.

The latest work is the recovery and IP boundary. Remote block requests carry a
server boot epoch and generation, so clients can reject stale state and reopen
persistent OFS identities after a controlled server restart. The matching
historical `ipServer` subtree is authenticated and pinned in provenance. Its
event and pseudo-device roles now sit behind bounded queues; explicit IPv4,
UDP, TCP, and ARP codecs feed a restartable service on the second PCnet
interface. The IP scenario exchanges UDP and TCP with loopback-only SLIRP
forwards, checks oversized datagram containment, closes TCP cleanly, restarts
the service, and repeats the exchange under QEMU TCG.

## Milestone ledger

Completed: source import and provenance; reproducible build and image;
i386 boot and kernel adaptation; baseline devices; regression handoff;
process/VM runtime; static ELF32 userland and syscalls; persistent OFS;
serial init and shell; the three-node platform and PCnet; native RPC and
distributed OFS; process migration; and boot-epoch-aware server recovery
(Milestones 1–14).

In progress: Milestone 15, Native IP Service. The wire, queue, ARP, transport,
restart, malformed-input, and live second-interface pieces are working. The
remaining exit work is the process-facing historical daemon/client path.

Todo: authenticated historical X11 libraries and runtime (16), remote X11
clients against isolated Xvfb (17), the local QEMU X11 desktop with graphics
and input backends (18), deterministic LFS and roll-forward recovery (19),
and the final OFS/LFS/X11/distributed integration matrix and handoff (20).

The project remains deliberately conservative: fixed-width wire and disk
formats, bounded queues and retries, no TAP requirement, no elevated runtime
privileges, and a host regression before each subsystem change. The result is
not merely a kernel that boots; it is a reproducible Sprite-shaped system that
can be inspected one milestone at a time.
