{"id":24517442,"url":"https://github.com/johannst/rv64i-linux-user-no-std","last_synced_at":"2025-03-15T11:10:02.698Z","repository":{"id":132563792,"uuid":"564496785","full_name":"johannst/rv64i-linux-user-no-std","owner":"johannst","description":"rv64i linux userspace no_std","archived":false,"fork":false,"pushed_at":"2022-11-13T14:13:40.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T01:36:32.611Z","etag":null,"topics":["nostd","nostdlib","qemu","risc-v","riscv","rust","syscall"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johannst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-10T21:04:21.000Z","updated_at":"2022-11-13T14:26:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"01ece0f7-0be4-4d42-9841-380c3fa3b2f2","html_url":"https://github.com/johannst/rv64i-linux-user-no-std","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannst%2Frv64i-linux-user-no-std","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannst%2Frv64i-linux-user-no-std/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannst%2Frv64i-linux-user-no-std/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannst%2Frv64i-linux-user-no-std/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johannst","download_url":"https://codeload.github.com/johannst/rv64i-linux-user-no-std/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719399,"owners_count":20336607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nostd","nostdlib","qemu","risc-v","riscv","rust","syscall"],"created_at":"2025-01-22T01:34:00.544Z","updated_at":"2025-03-15T11:10:02.688Z","avatar_url":"https://github.com/johannst.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# riscv64i `#[no_std]` Linux user space example\n\nThis repository serves to my later self as reference to document some\n`#[no_std]` and inline assembly features as well as cargo configurations.\n\nIt builds a `riscv64i` Linux user space binary which invokes some syscalls\naccording to the Linux [syscall(2)\nABI](https://man7.org/linux/man-pages/man2/syscall.2.html) for riscv.\n\n```txt\nArch/ABI    Instruction           System  Ret  Ret  Error    Notes\n                                  call #  val  val2\n───────────────────────────────────────────────────────────────────\nriscv       ecall                 a7      a0   a1   -\n\nArch/ABI      arg1  arg2  arg3  arg4  arg5  arg6  arg7  Notes\n──────────────────────────────────────────────────────────────\nriscv         a0    a1    a2    a3    a4    a5    -\n```\nThe syscalls are implemented in [lib.rs](src/lib.rs).\n\nWhen building, cargo runs the [build.rs](build.rs) script before building the\ncrate itself, which in this case generates some rust code for the syscall\nnumbers from the riscv C headers.\n\nLooking into [.cargo/config](.cargo/config) we actually build for the\n`riscv64imac-unknown-none-elf` rather than the `riscv64gc-unknown-linux-gnu`\ntarget, as our goal is to build a `risv64*i*` binary and that way we just have\nto disable a few more extensions :^).\n\nThe binary can be automatically run in the QEMU user space emulator with `cargo\nrun`, this is because the `runner` is specified in\n[.cargo/config](.cargo/config).\n\n## Requirements\n- `riscv64-linux-gnu-gcc` toolchain for parsing syscall numbers in\n  [build.rs](build.rs)\n- `riscv64imac-unknown-none-elf` rustc target to generate riscv target code\n  (`rustup target add riscv64imac-unknown-none-elf`)\n- `qemu-riscv64` QEMU userspace emulator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannst%2Frv64i-linux-user-no-std","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohannst%2Frv64i-linux-user-no-std","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannst%2Frv64i-linux-user-no-std/lists"}