Projects

  1. 01TempleOS in Web BrowserTempleOS on an x86-64 PC emulated in Rust and WebAssemblyin development
↓

01 in development

TempleOS in Web Browser

Running TempleOS in a browser tab by emulating, piece by piece, the PC it was written for.

  1. the target
    TempleOS is the 64-bit operating system Terry A. Davis wrote, very nearly alone, over about a decade: kernel, compiler, editor and the HolyC language itself. Everything runs in ring 0 in a single address space, there is no networking, and the display is fixed at 640×480 in 16 colours. Those constraints keep the whole system small enough for one person to hold in their head. They also mean it expects plain, specific hardware and nothing else: a BIOS, a CD-ROM, the classic timer and interrupt chips, a PS/2 keyboard and VGA.
  2. why a new emulator
    Most in-browser x86 emulators stop at 32-bit protected mode. TempleOS does not boot without 64-bit long mode, so the CPU has to go further than they do: real mode for the BIOS, protected mode, paging, then the switch into long mode through the model-specific registers the loader writes.
  3. the cpu
    Written in Rust and compiled to WebAssembly with wasm-bindgen. Instruction decoding uses the iced-x86 crate; execution, segmentation, paging and the 16/32/64-bit register file are written for this project. A small test binary decodes the real boot sector bytes to check the executor against what the loader actually runs.
  4. the machine
    Around the CPU sits the rest of a PC: the 8259 interrupt controller, the 8254 timer, the CMOS clock, a PS/2 keyboard controller, a serial port mirrored to an on-page console, PCI configuration space so the firmware can enumerate devices, an IDE controller serving the original 2017 ISO as an ATAPI CD-ROM, and VGA drawn to a canvas with an 8×16 font. SeaBIOS, the firmware used by QEMU, does the early boot.
  5. where it is
    CPU and devices run under SeaBIOS. Next is carrying the TempleOS loader into the kernel and up to the blue-on-white desktop, then input and speed. The page has start, pause and step-a-thousand-instructions controls for exactly this stage.
stack
Rust · WebAssembly · wasm-bindgen · iced-x86 · SeaBIOS
machine
x86-64 CPU, PIC, PIT, CMOS, PS/2, UART, PCI, IDE/ATAPI, VGA
status
CPU and devices running; booting toward the desktop
illustration, not emulator output