| Crates.io | libriscv |
| lib.rs | libriscv |
| version | 0.3.0 |
| created_at | 2025-12-20 09:49:16.101375+00 |
| updated_at | 2026-01-24 11:26:57.596572+00 |
| description | Safe wrapper for libriscv_sys, a fast RISC-V sandbox emulator |
| homepage | |
| repository | https://github.com/cijiugechu/libriscv |
| max_upload_size | |
| id | 1996278 |
| size | 56,072 |
libriscvSafe Rust wrapper around libriscv_sys, a fast RISC-V sandbox emulator.
Add the crate to your dependencies and run a RISC-V ELF:
use libriscv::{Machine, Options, SyscallRegistry};
let elf = std::fs::read("program").unwrap();
let options = Options::builder().build().unwrap();
let registry = SyscallRegistry::empty();
let mut machine = Machine::new(&elf, options, ®istry).unwrap();
machine.run(1_000_000).unwrap();
You can also define registries using the macros:
use libriscv::{syscall, syscall_registry, SyscallContext, SyscallResult};
#[syscall_registry]
mod host_syscalls {
use super::*;
#[syscall(id = 1)]
fn write(_ctx: &mut SyscallContext) -> SyscallResult<()> {
Ok(())
}
}
let registry = host_syscalls::registry().unwrap();
See examples/ for more usage patterns.
The directory examples/advanced/riscv_program is copied from the upstream repository.