{"id":13668028,"url":"https://github.com/rustsbi/rustsbi-qemu","last_synced_at":"2025-04-05T08:03:33.946Z","repository":{"id":37442167,"uuid":"370114851","full_name":"rustsbi/rustsbi-qemu","owner":"rustsbi","description":"QEMU platform SBI support implementation, using RustSBI","archived":false,"fork":false,"pushed_at":"2024-10-18T14:08:57.000Z","size":504,"stargazers_count":136,"open_issues_count":6,"forks_count":32,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T07:01:37.718Z","etag":null,"topics":["embedded","risc-v","rust","rustsbi","sbi","sbi-specification"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustsbi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-05-23T17:26:56.000Z","updated_at":"2025-03-17T16:40:19.000Z","dependencies_parsed_at":"2023-02-17T03:01:00.445Z","dependency_job_id":"32c67f36-684f-41b2-a5ce-e6a9bbccb9d0","html_url":"https://github.com/rustsbi/rustsbi-qemu","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustsbi%2Frustsbi-qemu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustsbi%2Frustsbi-qemu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustsbi%2Frustsbi-qemu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustsbi%2Frustsbi-qemu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustsbi","download_url":"https://codeload.github.com/rustsbi/rustsbi-qemu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305919,"owners_count":20917204,"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":["embedded","risc-v","rust","rustsbi","sbi","sbi-specification"],"created_at":"2024-08-02T07:01:00.744Z","updated_at":"2025-04-05T08:03:33.917Z","avatar_url":"https://github.com/rustsbi.png","language":"Rust","funding_links":[],"categories":["Rust","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# QEMU support from RustSBI\n\nRustSBI is designed as a library to craft a bootable binary or ELF file. However, QEMU provides us a way to load ELF\nfile and implement simple SBI directly, thus RustSBI provides a bootable ELF file for this platform.\n\n## Try it out!\n\nTo prepare for environment, you should have Rust compiler and QEMU installed.\nYou may install Rust by [rustup](https://rustup.rs) or using vendor provided rustc and cargo packages.\nTo install QEMU, your may need to use package manager (e.g. apt, dnf etc.) from system distribution\nto get a proper QEMU software package.\n\nAfter environment prepared, compile and run with:\n\n```shell\ncargo qemu\n```\n\nWhen running `cargo qemu`, the test kernel will build and run. Expected output should be:\n\n```plaintext\n[rustsbi] RustSBI version 0.4.0-alpha.1, adapting to RISC-V SBI v1.0.0\n.______       __    __      _______.___________.  _______..______   __\n|   _  \\     |  |  |  |    /       |           | /       ||   _  \\ |  |\n|  |_)  |    |  |  |  |   |   (----`---|  |----`|   (----`|  |_)  ||  |\n|      /     |  |  |  |    \\   \\       |  |      \\   \\    |   _  \u003c |  |\n|  |\\  \\----.|  `--'  |.----)   |      |  |  .----)   |   |  |_)  ||  |\n| _| `._____| \\______/ |_______/       |__|  |_______/    |______/ |__|\n[rustsbi] Implementation     : RustSBI-QEMU Version 0.2.0-alpha.2\n[rustsbi] Platform Name      : riscv-virtio,qemu\n[rustsbi] Platform SMP       : 8\n[rustsbi] Platform Memory    : 0x80000000..0x88000000\n[rustsbi] Boot HART          : 6\n[rustsbi] Device Tree Region : 0x87e00000..0x87e01a8e\n[rustsbi] Firmware Address   : 0x80000000\n[rustsbi] Supervisor Address : 0x80200000\n[rustsbi] pmp01: 0x00000000..0x80000000 (-wr)\n[rustsbi] pmp02: 0x80000000..0x80200000 (---)\n[rustsbi] pmp03: 0x80200000..0x88000000 (xwr)\n[rustsbi] pmp04: 0x88000000..0x00000000 (-wr)\n\n _____         _     _  __                    _\n|_   _|__  ___| |_  | |/ /___ _ __ _ __   ___| |\n  | |/ _ \\/ __| __| | ' // _ \\ '__| '_ \\ / _ \\ |\n  | |  __/\\__ \\ |_  | . \\  __/ |  | | | |  __/ |\n  |_|\\___||___/\\__| |_|\\_\\___|_|  |_| |_|\\___|_|\n================================================\n| boot hart id          |                    6 |\n| smp                   |                    8 |\n| timebase frequency    |          10000000 Hz |\n| dtb physical address  |           0x87e00000 |\n------------------------------------------------\n[ INFO] Testing `Base`\n[ INFO] sbi spec version = 2.0\n[ INFO] sbi impl = RustSBI\n[ INFO] sbi impl version = 0x400\n[ INFO] sbi extensions = [Base, TIME, sPI, HSM, SRST]\n[ INFO] mvendor id = 0x0\n[ INFO] march id = 0x70200\n[ INFO] mimp id = 0x70200\n[ INFO] Sbi `Base` test pass\n[ INFO] Testing `TIME`\n[ INFO] read time register successfully, set timer +1s\n[ INFO] timer interrupt delegate successfully\n[ INFO] Sbi `TIME` test pass\n[ INFO] Testing `sPI`\n[ INFO] send ipi successfully\n[ INFO] Sbi `sPI` test pass\n[ INFO] Testing `HSM`\n[ INFO] Testing harts: [0, 1, 2, 3]\n[DEBUG] hart 0 started\n[DEBUG] hart 0 suspended nonretentive\n[DEBUG] hart 1 started\n[DEBUG] hart 1 suspended nonretentive\n[DEBUG] hart 2 started\n[DEBUG] hart 2 suspended nonretentive\n[DEBUG] hart 3 started\n[DEBUG] hart 3 suspended nonretentive\n[DEBUG] hart 0 resumed\n[DEBUG] hart 0 suspended retentive\n[DEBUG] hart 0 stopped\n[DEBUG] hart 1 resumed\n[DEBUG] hart 1 suspended retentive\n[DEBUG] hart 1 stopped\n[DEBUG] hart 2 resumed\n[DEBUG] hart 2 suspended retentive\n[DEBUG] hart 2 stopped\n[DEBUG] hart 3 resumed\n[DEBUG] hart 3 suspended retentive\n[DEBUG] hart 3 stopped\n[ INFO] Testing Pass: [0, 1, 2, 3]\n[ INFO] Testing harts: [4, 5, 7]\n[DEBUG] hart 4 started\n[DEBUG] hart 4 suspended nonretentive\n[DEBUG] hart 5 started\n[DEBUG] hart 5 suspended nonretentive\n[DEBUG] hart 7 started\n[DEBUG] hart 7 suspended nonretentive\n[DEBUG] hart 4 resumed\n[DEBUG] hart 4 suspended retentive\n[DEBUG] hart 4 stopped\n[DEBUG] hart 5 resumed\n[DEBUG] hart 5 suspended retentive\n[DEBUG] hart 5 stopped\n[DEBUG] hart 7 resumed\n[DEBUG] hart 7 suspended retentive\n[DEBUG] hart 7 stopped\n[ INFO] Testing Pass: [4, 5, 7]\n[ INFO] Sbi `HSM` test pass\n[ INFO] Testing `DBCN`\nHello, world!\n[ INFO] writing slice successfully\n[ INFO] reading 0 bytes from console\n[ INFO] Sbi `DBCN` test pass\n```\n\n## Run test kernel\n\n### Requirements\n\nYou should have `cargo-binutils` installed.\n\n```shell\ncargo install cargo-binutils\n```\n\n### Run\n\nRun with:\n\n```shell\ncargo test\n```\n\nIt will run RustSBI-QEMU with a test kernel. The test kernel will test all SBI functions,\nits command emulation and other features. If it succeeds, there would be output like:\n\n```plaintext\nrunning 1 test\n    Finished dev [unoptimized + debuginfo] target(s) in 0.14s\n   Compiling test-kernel v0.1.0 (D:\\RustProjects\\rustsbi-qemu\\test-kernel)\n    Finished dev [unoptimized + debuginfo] target(s) in 0.61s\ntest run_test_kernel ... ok\n\ntest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.31s\n```\n\n## Notes\n\n1. What kind of kernel does this project support?\n\n   The rustsbi-qemu project supports raw binary kernels for educational or\n   competition use. This project itself is only a showcase example illustrating how\n   implementations should use RustSBI, it does not include a Linux boot support.\n   You may visit downstream bootloader projects for a Linux capable bootloader.\n\n2. How to enable hypervisor H extension on QEMU?\n\n   You should use these following line of parameters:\n\n   ```rust\n       command.args(\u0026[\"-cpu\", \"rv64,x-h=true\"]);\n   ```\n\n   ... to enable H extension on QEMU software.\n\n   The H extension is enabled by default when QEMU version \u003e= 7.0.0.\n\n3. What is the minimum supported Rust version of this package?\n\n   You should build RustSBI-QEMU on nightly at least `rustc 1.66.0-nightly (a24a020e6 2022-10-18)`.\n\n## License\n\nThis project is licensed under Mulan PSL v2.\n\n```plaintext\nCopyright (c) 2021-2023 RustSBI Team\nRustSBI-QEMU is licensed under Mulan PSL v2.\nYou can use this software according to the terms and conditions of the Mulan PSL v2.\nYou may obtain a copy of Mulan PSL v2 at:\n         http://license.coscl.org.cn/MulanPSL2\nTHIS SOFTWARE IS PROVIDED ON AN \"AS IS\" BASIS, WITHOUT WARRANTIES OF ANY KIND,\nEITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,\nMERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.\nSee the Mulan PSL v2 for more details.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustsbi%2Frustsbi-qemu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustsbi%2Frustsbi-qemu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustsbi%2Frustsbi-qemu/lists"}