Boot
Software built for another processor needs that processor, or an emulator someone else wrote and nobody on the team can read.
What it is
Software built for another processor needs that processor, or an emulator someone else wrote and nobody on the team can read.
The processor passes riscv-tests, compiled from the suite’s own source and run in the page, and the page names the hardware each test it leaves out would need.
The parts
A processor in plain JavaScript
The processor runs the base integer instructions of RISC-V, multiply and divide, and atomics, with machine mode, user mode, interrupts and traps. It runs in a Web Worker, so the page stays responsive, in one loop that allocates no memory per instruction.
A small machine around it
Around the processor is RAM, a serial port for the terminal, a timer and a register that powers off and restarts. Boot writes a device tree that describes the machine to Linux, and a few instructions of firmware jump to the kernel.
Time counted in instructions
The timer moves one tick for a fixed number of instructions. When the kernel has nothing to do, it waits for the next tick, and the page sleeps until then instead of running in a loop.
One instruction at a time
The inspector runs a small C program or the kernel one instruction at a time. It shows the registers, disassembles the next instructions the way llvm-objdump does, and counts every instruction by kind.