{"id":13632412,"url":"https://github.com/Ko-oK-OS/xv6-rust","last_synced_at":"2025-04-18T02:33:00.085Z","repository":{"id":46535603,"uuid":"346264481","full_name":"Ko-oK-OS/xv6-rust","owner":"Ko-oK-OS","description":"🦀️ Re-implement xv6-riscv in Rust","archived":false,"fork":false,"pushed_at":"2023-01-03T02:36:58.000Z","size":7972,"stargazers_count":285,"open_issues_count":3,"forks_count":23,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-01T22:53:16.427Z","etag":null,"topics":["risc-v","rust","xv6-riscv"],"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/Ko-oK-OS.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}},"created_at":"2021-03-10T07:08:00.000Z","updated_at":"2024-07-23T14:31:48.000Z","dependencies_parsed_at":"2023-02-01T05:00:28.287Z","dependency_job_id":null,"html_url":"https://github.com/Ko-oK-OS/xv6-rust","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/Ko-oK-OS%2Fxv6-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ko-oK-OS%2Fxv6-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ko-oK-OS%2Fxv6-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ko-oK-OS%2Fxv6-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ko-oK-OS","download_url":"https://codeload.github.com/Ko-oK-OS/xv6-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223772200,"owners_count":17199970,"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":["risc-v","rust","xv6-riscv"],"created_at":"2024-08-01T22:03:02.578Z","updated_at":"2024-11-09T00:31:16.572Z","avatar_url":"https://github.com/Ko-oK-OS.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# xv6-rust\n## Introduction\n\n![](run.png)\n\nThis is a try to implement xv6 OS in pure Rust. \n\nWhat's more, we are desired to add something new features into our OS, like network and GUI.  \n\nThe further goal of this project is to support multiple architecture and multiple boards, finally making our OS running in our own CPU.   \n\nFor the purpose of supporting the feature of Rust language, I also intend to use `async/await` feature to implement kernel thread scheduler renewedly.  \n\nDue to the complexity of the project and the busy course-work, I think it's hard to complete above work independently, so I'm sincerely hope others can interest on this project and join our teams.\n\n## Start  \n### QEMU\n**Linux**:  \n```\nwget https://download.qemu.org/qemu-5.0.0.tar.x  \ntar xvJf qemu-5.0.0.tar.xz  \ncd qemu-5.0.0  \n./configure --target-list=riscv32-softmmu,riscv64-softmmu   \nmake -j$(nproc)  \nsudo make install  \n```\nIf you find some errors when building, you can slove by following hints:  \n- `ERROR: pkg-config binary 'pkg-config' not found` : `sudo apt-get install pkg-config`           \n- `ERROR: glib-2.48 gthread-2.0 is required to compile QEMU`: `sudo apt-get install libglib2.0-dev`       \n- `ERROR: pixman \u003e= 0.21.8 not present`: `sudo apt-get install libpixman-1-dev` \n\n### Rust\nYou need download rust to start our environment. We suggest you to use official shell:  \n```\ncurl https://sh.rustup.rs -sSf | sh\n```\nIf you fail because of slow network speed. You can try this to speed up:   \n```\nexport RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static\nexport RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup\ncurl https://sh.rustup.rs -sSf | sh\n```\n\nIf you have finished these, you can test your environment by following commands:  \n```\nsource $HOME/.cargo/env  \nrustc --version\n```\nIn addition,  we'd better change the package mirror address crates.io used by the package manager cargo to the mirror server of the University of Science and Technology of China to speed up the download of the tripartite library. We open (create a new file if it doesn't exist) ~/.cargo/config and modify the content to:  \n```\n[source.crates-io]\nregistry = \"https://github.com/rust-lang/crates.io-index\"\nreplace-with = 'ustc'\n[source.ustc]\nregistry = \"git://mirrors.ustc.edu.cn/crates.io-index\"\n```\nBesides,  you also update some tools in rust:\n\n```\nrustup target add riscv64gc-unknown-none-elf\ncargo install cargo-binutils\nrustup component add llvm-tools-preview\n```\n\nFinally, you run this OS on your machine by excuteing following commands:  \n\n```\ngit clone https://github.com/Ko-oK-OS/xv6-rust.git\ncd xv6-rust\ngit submodule update --init --recursive\nmake run\n```\n\n## GDB Usage\nTo use gdb to debug, we need to download `riscv64-unkonown-elf-gdb` and `tmux`.\n\n### GDB Download\n- [Ubuntu](https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14.tar.gz)\n- [CentOS](https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-centos6.tar.gz)\n- [macOS](https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-apple-darwin.tar.gz)\n- [Windows](https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-w64-mingw32.zip)\n\nWe support gdb in OS kernel, you can exectue this command in `xv6-rust/kernel` directory:   \n```shell\nmake debug\n```\nAnd then you can debug this programe step by step. \n\n## Schedule\n\n- Virtual Memory and Management   \n    - [x] Virtulal Memory Map\n    - [x] Kernel Allocator(Buddy System Allocator)  \n    - [x] Load ELF Files From Memory\n- Traps,Interrupts, and drivers\n    - [x] Kernel Trap\n    - [x] Users Trap\n    - [x] UART Drivers\n    - [x] Machine-Mode Timer Interrupt\n    - [x] Virtio Disk Drivers\n    - [x] PCI and E1000 Drivers\n- Locking\n    - [x] Spinlock\n    - [x] Sleeplock\n- Process and Scheduing\n    - [x] Process\n    - [x] Scheduing\n    - [x] Muti-Core Support\n    - [x] Syscall\n- File System\n    - [x] Mkfs\n    - [x] Buffer Layer\n    - [x] Log Layer\n    - [x] SuperBlock Layer\n    - [x] Inode Layer\n    - [x] Bitmap Layer\n    - [x] File Descriptor Layer\n    - [x] File Path\n    - [x] Pipe \n    - [x] Syscall\n- NetWork\n    - [x] PCI and E1000 Initialize\n    - [x] Protocol Headers\n    - [ ] Network Card Driver\n    - [ ] Syscall\n- Device Driver\n    - [x] Virtio Disk\n    - [x] Uart/Console\n    - [x] PCI\n\n## Differences\n### Fs\n- [x] Remove `FILE_TABLE`\n- [x] Use `Arc` instead of `refs`, `Arc::clone()` will plat the same role of `refs++`\n- [ ] User `enum FileInner` to separate files of various file types\n\n### Scheduler\n- [ ] Use `VecDeque` instead of raw array.\n\n### Process\n- [ ] Use `BTreeMap` to maintain open files in `Process`\n- [ ] Add `Thread` in Kernel Process\n\n## Expected Future\n- [ ] More Clear Memory Model\n- [ ] Better Scheduler\n- [ ] SD Card Driver Support\n- [ ] Network Support(Use `smoltcp` to simplify design)\n- [ ] Async IO Support\n\n## Docs\n\n[项目设计文档](docs/项目设计文档.pdf)\n\n## References\n\n- [Building a stupid Mutex in the Rust](https://medium.com/@Mnwa/building-a-stupid-mutex-in-the-rust-d55886538889)  \n- [Rust源码分析：std::sync::Mutex](https://zhuanlan.zhihu.com/p/50006335)   \n- [buddy_system_allocator](https://github.com/rcore-os/buddy_system_allocator)  \n- [Write a OS in Rust](https://os.phil-opp.com)  \n- [rCore-Tutorial-v3](https://rcore-os.github.io/rCore-Tutorial-Book-v3/index.html)\n- [rCore-Tutorial](https://rcore-os.github.io/rCore-Tutorial-deploy/)  \n- [xv6-riscv](https://github.com/mit-pdos/xv6-riscv)\n- [xv6-riscv-rust](https://github.com/Jaic1/xv6-riscv-rust)\n- [rCore](https://github.com/rcore-os/rCore)\n\n## License\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKo-oK-OS%2Fxv6-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKo-oK-OS%2Fxv6-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKo-oK-OS%2Fxv6-rust/lists"}