vemu.

interface

UseVemuResult

Everything useVemu returns: emulator status, board selection, program/run controls, video + UART wiring callbacks, and the peripheral inspector surface.

interface UseVemuResult

Fields

NameTypeDescription
statusVemuStatusCurrent emulator lifecycle state.
boardsBoardInfo[]Boards compiled into the loaded runtime.
selectedBoardstringId of the currently selected board (empty string until boards are listed).
setSelectedBoardDispatch<SetStateAction<string>>Select a board by id; instantiates a fresh (non-running) machine for it.
selectedHasDisplaybooleanStatic display capability of the selected board (false when unknown).
hasVideobooleanTrue once the running machine has produced at least one video frame.
ipsstringHuman-readable simulated clock speed (e.g. "4.2 MHz"); empty while not running.
loadProgram(data: Uint8Array, kind: ProgramKind, boardOverride?: string) => voidLoad a program (ROM/ELF/binary) and start running, optionally switching board first.
loadLinux(kernel: Uint8Array, initrd: Uint8Array, boardOverride?: string) => voidBoot a Linux kernel + initramfs (arm64) and start running, optionally switching board first. Uses the wasm `newLinux` factory: the board builder generates the DTB and bootargs, so only the raw kernel `Image` and `initrd` bytes are passed. UART wiring is identical to loadProgram.
loadRiscvLinux( firmware: Uint8Array, image: Uint8Array, initrd: Uint8Array, boardOverride?: string, ) => voidBuild + start a RISC-V Linux machine from OpenSBI firmware + kernel Image + initramfs (the `vemu_riscv64_virt` board), optionally switching board.
loadUicr(data: Uint8Array) => booleanLoad a raw UICR image (uicr.bin) into the running machine's UICR region. Returns false when no machine is built or the board has no UICR. Not persisted - re-apply after loading a new program image.
loadWithFiles( files: Array<{ id: string; bytes: Uint8Array; addr?: number; kind?: ProgramKind }>, boardOverride?: string, cmdline?:...Build + start a machine from a board-declared set of file slots (the generic path behind every board's loader UI). Each entry pairs a slot id with its bytes plus an optional load-address override and program `kind`. Supersedes loadProgram/loadLinux/loadRiscvLinux for the slot-based UI.
stop() => voidPause the run loop (status returns to "ready").
reset() => voidReset the machine and restart with the last loaded program.
eraseAll() => voidDiscard the current machine and rebuild the selected board with empty flash.
setDraw(cb: (f: VemuFrame) => void) => voidRegister the callback that renders video frames (wired up by `VemuCanvas`).
setUartSink(cb: (b: Uint8Array) => void) => voidRegister the sink for UART output bytes (wired up by `VemuTerminal`).
setTerminalClear(cb: () => void) => voidRegister a callback that clears the terminal UI (wired up by `VemuTerminal`); invoked on `reset()` / `eraseAll()` so a reboot starts from a clean screen.
sendUart(bytes: Uint8Array) => voidSend UART input bytes to the running machine.
peripheralListstring[]Names of inspectable peripherals exposed by the current machine.
peripheralEventsPeripheralEvent[]Rolling buffer (last 100) of peripheral events emitted by the machine.
peripheralErrorstring | nullBuild/exposure error to surface in the peripheral panel, or null.
snapshotVersionnumberMonotonic counter that bumps when inspector snapshots should be re-pulled.
getPeripheralSnapshot(name: string) => PeripheralSnapshot | nullPull the current snapshot for a peripheral by name (null if unavailable).
sendPeripheralCommand(name: string, cmd: { name: string; params: Record<string, string> }) => voidSend a command to a peripheral's inspector.
sendUartRx(target: string, bytes: number[], timing?: TimingSpec) => voidDeliver UART RX bytes to a named UART, optionally at a precise virtual time (deterministic timed delivery). Absent `timing` is immediate.
clockHznumberGuest clock in Hz (cycles/sec), or 0 when unknown.