Skip to content
KarpelesLabPublic

About

A multiplatform emulator in pure Rust, built bottom-up on a generic framework: x86, ARM, RISC-V, m68k and 8/16-bit machines described by config files, with a JIT, snapshots and a gdb stub.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

rsemu

CI crates.io docs.rs License: MIT

A multiplatform emulator in pure Rust, built from the bottom up.

rsemu is an emulator — the thing you point at a ROM or a disk image and run. It is built on a generic framework, and that framework comes first: address spaces, clock domains, wires, devices, buses and a translation IR, then CPU cores, PCI, USB, storage and NICs on top of them, then machines described by a config file rather than compiled in.

If you want a NES, you write a .machine file. If you want four heterogeneous CPUs sharing one RAM region across three bus fabrics, you write a stranger .machine file. Nothing in rsemu needs patching to allow either.

Starting low costs time before the first ROM boots. It buys what every emulator that started at the top eventually wishes it had: one memory model, one clock, one snapshot format, one debugger, shared by every machine ever added.

Try it

$ cargo run --features machine-apple1 -- run apple1
RSMON
>FF00
FF00: D8 A2 FF 9A A9 7F 8D 12

rsemu machines lists the machines your build has; rsemu run <machine> --media <slot>=<image> runs one. No guest image is shipped — you bring your own ROM, cartridge, kernel or disk.

What it runs

Early, but it runs things. A machine is a .machine file under machines/, described rather than compiled in.

Family Machines Where it stands
Nintendo nes-ntsc, nes-pal, gameboy, snes-ntsc, snes-pal NES passes AccuracyCoin 141/141; Game Boy passes blargg's CPU suite
Sega sms-ntsc, sms-pal Master System: Z80, VDP, PSG, Sega mapper
8-bit computers apple1, beneater-6502 interactive over a terminal
Commodore Amiga amiga-a500 … amiga-a4000t, amiga-cd32 boot Kickstart and Workbench from your own ROMs
Apple Macintosh mac-plus, mac-classic boot Apple's ROM and System software
PC pc-at, pc64, q35, q35-linux, q35-uefi FreeDOS on pc-at; Linux on q35-linux, also SMP
RISC-V and AArch64 riscv-virt, arm64-virt (and -smp) boot Linux, single and dual processor
ARM embedded stm32f205, stm32f407, stm32f427, stm32f469, stm32l476, stm32l496, stm32l4s5, stm32c011, stm32h743, stm32h753, stm32u575, stm32u585, stm32u585-tz, stm32wb55, stm32wb35, nrf52832, nrf52840, samd51j20a, rp2350a, arm926 run vendor HAL firmware; the WB boards include a model of the BLE coprocessor; rp2350a boots Raspberry Pi's own mask ROM into pico-sdk firmware
Raspberry Pi raspi0 a Pi Zero (BCM2835, ARM1176JZF-S): the SeedSigner OS card boots Linux to its init process
Espressif esp32, esp32s3 the Blockstream Jade and Jade Plus parts (two Xtensa cores each): an ESP-IDF app image boots straight off the flash, with no Espressif ROM shipped

Plus a set of small synthetic boards that give one subsystem somewhere to run (nvme-mini, xhci-mini, usb-mini, …).

CPU cores: MOS 6502/65C02, WDC 65C816, Zilog Z80, Sharp SM83, Sony SPC700, Intel x86 (8086 to x86-64), Motorola 680x0 with the 68881/68882, MIPS R3000A, SuperH SH-4A, RISC-V RV64GC, and ARM (ARMv5TE, ARMv6KZ and ARMv7-A, ARMv6-M/v7-M/v8-M, AArch64). Each ships with a conformance suite and a known-failures ledger; the measured results are in docs/status.md.

Design, in brief

  • Pure Rust, no foreign code. The baseline build depends on nothing; every dependency is feature-gated.
  • Deterministic by default. Runs are bit-reproducible across hosts and execution engines, which is what makes save states, record/replay and the regression suite possible.
  • Time follows the crystals. Clock domains are exact integer ratios of their oscillator; no floats in the time path.
  • Accuracy is measured, against published conformance suites.
  • Generic first. No device type appears in a core:: signature.
  • no_std + alloc core, multithreaded by design, and it runs in the browser: wasm32-unknown-unknown is a CI target.
  • unsafe is quarantined to seven named subsystems.
  • One crate, one feature per component. A NES build links a 6502 and nothing else.

The reasoning behind each is in docs/design.md.

Build

cargo build              # library + the rsemu binary
cargo test --all-features
cargo run -- --version

cargo build --no-default-features   # no_std core, as CI checks it

scripts/check.sh         # everything CI gates on, per commit

MSRV is 1.91. WebAssembly, the C ABI, fuzzing and the dependency list are in docs/building.md; the browser demo is in web/README.md.

Documentation

docs/status.md conformance results per CPU core, and the machine list
docs/boards.md the boards that boot third-party software, and where each one stops
docs/execution.md interpreter, translation IR and JIT backends, hardware acceleration
docs/design.md the design principles, in full
docs/building.md gates, fuzzing, WebAssembly, the C ABI, dependencies
docs/README.md the index of primary sources, and a page per CPU, device and board
ROADMAP.md the architecture, the machine description language, the phase plan
CONTRIBUTING.md read before your first patch

License and provenance

MIT — see LICENSE.

rsemu is written clean-room from hardware documentation. MIT cannot absorb GPL'd code, so copyleft sources are off limits to contributors — the QEMU source tree above all, along with Bochs, DOSBox, MAME, VICE, Dolphin, PCSX2 and every other GPL/LGPL emulator. We work from datasheets, ISA manuals, the NESdev wiki, Pan Docs and real hardware; permissively licensed code is welcome with its attribution intact. Benchmarking against a GPL emulator is fine — that is black-box use, not derivation. TianoCore EDK II is readable: it is BSD-2-Clause-Patent, so it is a reference rather than a hazard, and it is the one substantial open firmware implementation that is not copyleft. SeaBIOS, coreboot and QEMU's firmware are not.

No guest image is shipped and none will be. Kernels, BIOS images, cartridges and conformance corpora are fetched by scripts/fetch-testdata.sh into an ignored directory and gated behind an environment variable — running a GPL binary as an emulated guest is ordinary use, while redistributing one from this repository would not be. The one firmware here is src/fw/pcbios, which is ours.

See CONTRIBUTING.md before your first patch, and ROADMAP.md §1 for the full policy.

About

A multiplatform emulator in pure Rust, built bottom-up on a generic framework: x86, ARM, RISC-V, m68k and 8/16-bit machines described by config files, with a JIT, snapshots and a gdb stub.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages