diff options
-rw-r--r-- | README.md | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -1,15 +1,30 @@ # riscv64i `#[no_std]` Linux user space example -This repository serves as reference to my later self as starting point for -`#[no_std]` rust code and to document some cargo configurations. +This repository serves to my later self as reference to document some +`#[no_std]` and inline assembly features as well as cargo configurations. -It builds a riscv64i Linux user space binary which invokes some syscalls +It builds a `riscv64i` Linux user space binary which invokes some syscalls according to the Linux [syscall(2) ABI](https://man7.org/linux/man-pages/man2/syscall.2.html) for riscv. -When running `cargo run` the binary will be executed using the QEMU riscv user -space emulator as configured in [.cargo/config](.cargo/config). +```txt +Arch/ABI Instruction System Ret Ret Error Notes + call # val val2 +─────────────────────────────────────────────────────────────────── +riscv ecall a7 a0 a1 - + +Arch/ABI arg1 arg2 arg3 arg4 arg5 arg6 arg7 Notes +────────────────────────────────────────────────────────────── +riscv a0 a1 a2 a3 a4 a5 - +``` +The syscalls are implemented in [lib.rs](src/lib.rs). + +When building, cargo runs the [build.rs](build.rs) script before building the +crate itself, which in this case generates some rust code for the syscall numbers from the riscv C headers. + +The binary can be automatically run in the QEMU user space emulator by with `cargo run`, this is because the `runner` is specified in [.cargo/config](.cargo/config). ## Requirements -To run this example the QEMU riscv64 user space emulator (`qemu-riscv64`) is -required. +- `riscv64-linux-gnu-gcc` toolchain +- `rustup target add riscv64imac-unknown-none-elf` rust target +- `qemu-riscv64` QEMU userspace emulator |