RCore-Tutorial-v3 - Let's write an OS which can run on RISC-V in Rust from zero!

Overview

rCore-Tutorial-v3

rCore-Tutorial version 3.5. See the Documentation in Chinese.

Official QQ group number: 735045051

news

  • 2021.11.20: Now we are updating our labs. Please checkout chX-dev Branches for our current new labs. (Notice: please see the [Dependency] section in the end of this doc)

Overview

This project aims to show how to write an Unix-like OS running on RISC-V platforms from scratch in Rust for beginners without any background knowledge about computer architectures, assembly languages or operating systems.

Features

  • Platform supported: qemu-system-riscv64 simulator or dev boards based on Kendryte K210 SoC such as Maix Dock
  • OS
    • concurrency of multiple processes
    • preemptive scheduling(Round-Robin algorithm)
    • dynamic memory management in kernel
    • virtual memory
    • a simple file system with a block cache
    • an interactive shell in the userspace
  • only 4K+ LoC
  • A detailed documentation in Chinese in spite of the lack of comments in the code(English version is not available at present)

Run our project

TODO:

Working in progress

Now we are still updating our project, you can find latest changes on branches chX-dev such as ch1-dev. We are intended to publish first release 3.5.0 after completing most of the tasks mentioned below.

Overall progress: ch7

Completed

  • automatically clean up and rebuild before running our project on a different platform
  • fix power series application in early chapters, now you can find modulus in the output
  • use UPSafeCell instead of RefCell or spin::Mutex in order to access static data structures and adjust its API so that it cannot be borrowed twice at a time(mention & .exclusive_access().task[0] in run_first_task)
  • move TaskContext into TaskControlBlock instead of restoring it in place on kernel stack(since ch3), eliminating annoying task_cx_ptr2
  • replace llvm_asm! with asm!
  • expand the fs image size generated by rcore-fs-fuse to 128MiB
  • add a new test named huge_write which evaluates the fs performance(qemu~500KiB/s k210~50KiB/s)
  • flush all block cache to disk after a fs transaction which involves write operation
  • replace spin::Mutex with UPSafeCell before SMP chapter
  • add codes for a new chapter about synchronization & mutual exclusion(uniprocessor only)

Todo(High priority)

  • support Allwinner's RISC-V D1 chip
  • bug fix: we should call find_pte rather than find_pte_create in PageTable::unmap
  • bug fix: check validity of level-3 pte in find_pte instead of checking it outside this function
  • use old fs image optionally, do not always rebuild the image
  • add new system calls: getdents64/fstat
  • shell functionality improvement(to be continued...)
  • give every non-zero process exit code an unique and clear error type
  • effective error handling of mm module

Todo(Low priority)

  • rewrite practice doc and remove some inproper questions
  • provide smooth debug experience at a Rust source code level
  • format the code using official tools

Crates

We will add them later.

Comments
  • error[E0557]: feature has been removed

    error[E0557]: feature has been removed

    平台:WSL2 操作系统: Ubuntu18.04/Ubuntu20.04 Rust版本:rustc 1.49.0

    在每次rCore-Tutorial-v3 os中进行make run时,都会提示: error[E0557]: feature has been removed --> src/main.rs:6:12 | 6 | #![feature(const_in_array_repeat_expressions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed | = note: removed due to causing promotable bugs

    error: aborting due to previous error

    For more information about this error, try rustc --explain E0557. error: could not compile os

    opened by Michael-Unix 15
  • [rustsbi-panic] system shutdown scheduled due to RustSBI panic

    [rustsbi-panic] system shutdown scheduled due to RustSBI panic

    个人环境

    $ uname -a
    Linux arch 5.12.5-arch1-1 #1 SMP PREEMPT Wed, 19 May 2021 10:32:40 +0000 x86_64 GNU/Linux
    
    $ rustc --version
    rustc 1.54.0-nightly (1c6868aa2 2021-05-27)
    
    $ qemu-riscv64 -version
    qemu-riscv64 version 6.0.0
    
    $ qemu-system-riscv64 -version
    QEMU emulator version 6.0.0
    

    配置过程参考了文档 第零章:操作系统概述 » 实验环境配置

    rust 配置了nightly 版本,相应的工具已经安装(riscv64gc-unknown-none-elf, cargo-binutils --vers ~0.2, llvm-tools-preview, rust-src),有一个小小的问题是 那个 cargo-binutils 的版本一定要是 0.2 吗?虽然不知道为什么,但我还是按照文档的要求装了0.2 版的

    qemu-riscv64 的版本比文档的高,文档为 5.0.0

    错误描述

    重现步骤

    $ git clone [email protected]:rcore-os/rCore-Tutorial-v3.git
    $ cd rCore-Tutorial-v3/os
    $ make run
    

    错误输出

    known-linux-gnu (installed)
    [kearney@arch os]$ make run
    (rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add riscv64gc-unknown-none-elf
    riscv64gc-unknown-none-elf (installed)
    cargo install cargo-binutils --vers ~0.2
        Updating `https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git` index
         Ignored package `cargo-binutils v0.2.0` is already installed, use --force to override
    rustup component add rust-src
    info: component 'rust-src' is up to date
    rustup component add llvm-tools-preview
    info: component 'llvm-tools-preview' for target 'x86_64-unknown-linux-gnu' is up to date
    Platform: qemu
        Finished release [optimized] target(s) in 0.01s
    [rustsbi] RustSBI version 0.2.0-alpha.1
    .______       __    __      _______.___________.  _______..______   __
    |   _  \     |  |  |  |    /       |           | /       ||   _  \ |  |
    |  |_)  |    |  |  |  |   |   (----`---|  |----`|   (----`|  |_)  ||  |
    |      /     |  |  |  |    \   \       |  |      \   \    |   _  < |  |
    |  |\  \----.|  `--'  |.----)   |      |  |  .----)   |   |  |_)  ||  |
    | _| `._____| \______/ |_______/       |__|  |_______/    |______/ |__|
    
    [rustsbi] Platform: QEMU (Version 0.2.0)
    [rustsbi] misa: RV64ACDFIMSU
    [rustsbi] mideleg: 0x222
    [rustsbi] medeleg: 0xb1ab
    [rustsbi-dtb] Hart count: cluster0 with 1 cores
    [rustsbi] Kernel entry: 0x80200000
    [rustsbi-panic] hart 0 panicked at 'invalid instruction, mepc: 000000008000004c, instruction: 0000000030200073', platform/qemu/src/main.rs:484:17
    [rustsbi-panic] system shutdown scheduled due to RustSBI panic
    

    正常的结果

    文档里的 GIF 图显示 make run 之后会加载内核,进入用户 shell

    期望的结果

    正常加载内核,进入 shell

    opened by BackMountainDevil 9
  • error[E0658]: use of unstable library feature 'asm'

    error[E0658]: use of unstable library feature 'asm'

    I meet an error when I excuted "make run": error[E0658]: use of unstable library feature 'asm': inline assembly is not stable enough for use and is subject to change --> ~/.cargo/git/checkouts/riscv-ab2abd16c438337b/11d43cf/src/asm.rs:10:23

    opened by PatrickFFung 7
  • [chp 2 & rust] 是否可以将其在cargo工作空间重构?

    [chp 2 & rust] 是否可以将其在cargo工作空间重构?

    在做chp2的实验时,我尝试将user和os都置于cargo工作空间下,试图重构(非linux,macOS环境下)。但是遇到了如下问题:

    .cargo/config.toml文件如果分别置于members目录(此处为/osuser)的话,无法编译通过。但如果将.cargo/config.toml置于根目录的话user可以编译通过。

    我的代码在这里,刚入门rust和学习操作系统,望指教。

    opened by PeterWrighten 6
  • docker make run failed

    docker make run failed

    使用项目下的Dockerfile构建镜像成功,运行起来之后/mnt/os目录下make run报错:

    warning: unused borrow that must be used
       --> /mnt/easy-fs/src/layout.rs:419:9
        |
    419 |         &mut bytes[..name.len()].copy_from_slice(name.as_bytes());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the borrow produces a value
        |
        = note: `#[warn(unused_must_use)]` on by default
    help: use `let _ = ...` to ignore the resulting value
        |
    419 |         let _ = &mut bytes[..name.len()].copy_from_slice(name.as_bytes());
        |         +++++++
    
       Compiling bare-metal v0.2.5
       Compiling virtio-drivers v0.1.0 (https://github.com/rcore-os/virtio-drivers#2b3c6cfd)
    warning: `easy-fs` (lib) generated 1 warning
       Compiling regex v1.5.4
       Compiling riscv-target v0.1.2
       Compiling riscv v0.6.0
       Compiling riscv v0.6.0 (https://github.com/rcore-os/riscv#b6c469f0)
       Compiling k210-hal v0.2.0 (https://github.com/wyfcyx/k210-hal#ea121c91)
    error[E0432]: unresolved imports `embedded_hal::digital::OutputPin`, `embedded_hal::digital::StatefulOutputPin`, `embedded_hal::digital::InputPin`, `embedded_hal::digital::ToggleableOutputPin`
     --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/gpio.rs:8:29
      |
    8 | use embedded_hal::digital::{OutputPin, StatefulOutputPin, InputPin, ToggleableOutputPin};
      |                             ^^^^^^^^^  ^^^^^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^^^^^^^^^^^^ no `ToggleableOutputPin` in `digital`
      |                             |          |                  |
      |                             |          |                  no `InputPin` in `digital`
      |                             |          no `StatefulOutputPin` in `digital`
      |                             no `OutputPin` in `digital`
    
    error[E0432]: unresolved imports `embedded_hal::digital::InputPin`, `embedded_hal::digital::OutputPin`
     --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/gpiohs.rs:6:29
      |
    6 | use embedded_hal::digital::{InputPin, OutputPin};
      |                             ^^^^^^^^  ^^^^^^^^^ no `OutputPin` in `digital`
      |                             |
      |                             no `InputPin` in `digital`
    
    error[E0432]: unresolved import `embedded_hal::prelude`
      --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/lib.rs:30:27
       |
    30 |     pub use embedded_hal::prelude::*;
       |                           ^^^^^^^ could not find `prelude` in `embedded_hal`
    
    error[E0405]: cannot find trait `Read` in module `serial`
       --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/serial.rs:100:14
        |
    100 | impl serial::Read<u8> for Rx<UARTHS> {
        |              ^^^^ not found in `serial`
        |
    help: consider importing one of these items
        |
    9   | use crate::serial::serial::nb::Read;
        |
    9   | use embedded_hal::i2c::blocking::Read;
        |
    9   | use embedded_hal::serial::nb::Read;
        |
    
    error[E0405]: cannot find trait `Write` in module `serial`
       --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/serial.rs:114:14
        |
    114 | impl serial::Write<u8> for Tx<UARTHS> {
        |              ^^^^^ not found in `serial`
        |
    help: consider importing one of these items
        |
    9   | use core::fmt::Write;
        |
    9   | use crate::serial::serial::blocking::Write;
        |
    9   | use crate::serial::serial::nb::Write;
        |
    9   | use crate::stdout::Write;
        |
          and 4 other candidates
    
    error[E0405]: cannot find trait `Read` in module `serial`
       --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/serial.rs:200:27
        |
    200 | impl<UART: UartX> serial::Read<u8> for Rx<UART> {
        |                           ^^^^ not found in `serial`
        |
    help: consider importing one of these items
        |
    9   | use crate::serial::serial::nb::Read;
        |
    9   | use embedded_hal::i2c::blocking::Read;
        |
    9   | use embedded_hal::serial::nb::Read;
        |
    
    error[E0405]: cannot find trait `Write` in module `serial`
       --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/serial.rs:215:27
        |
    215 | impl<UART: UartX> serial::Write<u8> for Tx<UART> {
        |                           ^^^^^ not found in `serial`
        |
    help: consider importing one of these items
        |
    9   | use core::fmt::Write;
        |
    9   | use crate::serial::serial::blocking::Write;
        |
    9   | use crate::serial::serial::nb::Write;
        |
    9   | use crate::stdout::Write;
        |
          and 4 other candidates
    
    error[E0405]: cannot find trait `FullDuplex` in module `embedded_hal::spi`
      --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/spi.rs:69:25
       |
    69 | impl embedded_hal::spi::FullDuplex<u8> for Spi<SPI0> {
       |                         ^^^^^^^^^^ not found in `embedded_hal::spi`
       |
    help: consider importing this trait
       |
    3  | use embedded_hal::spi::nb::FullDuplex;
       |
    
    error[E0405]: cannot find trait `Write` in module `embedded_hal::serial`
      --> /root/.cargo/git/checkouts/k210-hal-1069b16e3180bc3a/ea121c9/src/stdout.rs:11:30
       |
    11 |     T: embedded_hal::serial::Write<u8>,
       |                              ^^^^^ not found in `embedded_hal::serial`
       |
    help: consider importing one of these items
       |
    2  | use core::fmt::Write;
       |
    2  | use embedded_hal::i2c::blocking::Write;
       |
    2  | use embedded_hal::serial::blocking::Write;
       |
    2  | use embedded_hal::serial::nb::Write;
       |
         and 1 other candidate
    
    Some errors have detailed explanations: E0405, E0432.
    For more information about an error, try `rustc --explain E0405`.
    error: could not compile `k210-hal` due to 9 previous errors
    Makefile:58: recipe for target 'kernel' failed
    make: *** [kernel] Error 101
    
    opened by hitzhangjie 6
  • Cargo.toml 里面作者 吴亦凡 名称是否考虑移除呢?

    Cargo.toml 里面作者 吴亦凡 名称是否考虑移除呢?

    cargo toml 文件里面有关于吴亦凡的著名,是否考虑移除?

    [package]
    name = "os"
    version = "0.1.0"
    authors = ["Yifan Wu <[email protected]>"]
    edition = "2018"
    
    opened by bluetianx 6
  • Get `Could not allocate dynamic translator buffer` on Ubuntu 18.04/20.04 with `make docker`

    Get `Could not allocate dynamic translator buffer` on Ubuntu 18.04/20.04 with `make docker`

    Any ideas?

    Ubuntu 20.04 was installed by multipass as a vm. Logs:

    root@eternal-buck:/home/ubuntu/rCore-Tutorial-v3# cat /etc/issue
    Ubuntu 20.04.2 LTS \n \l
    
    root@eternal-buck:/home/ubuntu/rCore-Tutorial-v3# make docker
    docker run --rm -it --mount type=bind,source=/home/ubuntu/rCore-Tutorial-v3,destination=/mnt dinghao188/rcore-tutorial
    root@9f61a9655d71:/# cd mnt
    root@9f61a9655d71:/mnt# cd os
    
    root@9f61a9655d71:/mnt/os# make run
    info: syncing channel updates for 'nightly-2021-01-30-x86_64-unknown-linux-gnu'
    info: latest update on 2021-01-30, rust version 1.51.0-nightly (b12290861 2021-01-29)
    .....
    
    Could not allocate dynamic translator buffer
    Makefile:67: recipe for target 'run-inner' failed
    make: *** [run-inner] Error 1
    
    root@e4fb5cbf909a:/mnt/os# qemu-system-riscv64 --version
    QEMU emulator version 5.0.0
    Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
    
    opened by qiukun 6
  • [Question] 执行 sbi shutdown 以后,后面的语句还能被执行吗?

    [Question] 执行 sbi shutdown 以后,后面的语句还能被执行吗?

    代码出自 https://github.com/rcore-os/rCore-Tutorial-v3/blob/ch1/os/src/sbi.rs#L37

    pub fn shutdown() -> ! {
        sbi_call(SBI_SHUTDOWN, 0, 0, 0);
        panic!("It should shutdown!"); // <- 这里还能被执行到吗?
    }
    
    opened by mingyang91 5
  • fix: make run with error in description

    fix: make run with error in description

    error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the 'nightly-2021-12-15-x86_64-unknown-linux-gnu' toolchain
    Makefile:42: recipe for target 'env' failed
    

    环境:

    • 使用实验指导中的vmware硬盘镜像
    • 机器是 x86-64

    使用最新的rCore-Tutorial-v3ch2分支执行make run存在报错。 修改rust-toolchain中的版本运行正常nightly-2021-12-14

    opened by ScarboroughCoral 4
  • the method `configure` exists for struct `k210_pac::UARTHS`, but its trait bounds were not satisfied

    the method `configure` exists for struct `k210_pac::UARTHS`, but its trait bounds were not satisfied

    当我参考 https://rcore-os.github.io/rCore-Tutorial-Book-v3/chapter0/5setup-devel-env.html 配置环境完成之后进行编译,报错如下:

    error[E0599]: the method `configure` exists for struct `k210_pac::UARTHS`, but its trait bounds were not satisfied
        --> src/drivers/block/sdcard.rs:725:24
         |
    725  |     peripherals.UARTHS.configure(115_200.bps(), &clocks);
         |                        ^^^^^^^^^ method cannot be called on `k210_pac::UARTHS` due to unsatisfied trait bounds
         |
        ::: /home/wang/.cargo/git/checkouts/k210-pac-19d36f600eb54ac3/8f99c1c/src/lib.rs:1028:1
         |
    1028 | pub struct UARTHS {
         | -----------------
         | |
         | doesn't satisfy `k210_pac::UARTHS: SerialExt`
         | doesn't satisfy `k210_pac::UARTHS: serial::closed_trait::UartX`
    ...
    1050 |     pub struct RegisterBlock {
         |     ------------------------
         |     |
         |     doesn't satisfy `_: serial::closed_trait::UartX`
         |     doesn't satisfy `k210_pac::uarths::RegisterBlock: SerialExt`
         |
         = note: the following trait bounds were not satisfied:
                 `k210_pac::UARTHS: serial::closed_trait::UartX`
                 which is required by `k210_pac::UARTHS: SerialExt`
                 `&k210_pac::UARTHS: serial::closed_trait::UartX`
                 which is required by `&k210_pac::UARTHS: SerialExt`
                 `&mut k210_pac::UARTHS: serial::closed_trait::UartX`
                 which is required by `&mut k210_pac::UARTHS: SerialExt`
                 `k210_pac::uarths::RegisterBlock: serial::closed_trait::UartX`
                 which is required by `k210_pac::uarths::RegisterBlock: SerialExt`
                 `&k210_pac::uarths::RegisterBlock: serial::closed_trait::UartX`
                 which is required by `&k210_pac::uarths::RegisterBlock: SerialExt`
                 `&mut k210_pac::uarths::RegisterBlock: serial::closed_trait::UartX`
                 which is required by `&mut k210_pac::uarths::RegisterBlock: SerialExt`
    
    error[E0599]: the method `constrain` exists for struct `k210_pac::SPI0`, but its trait bounds were not satisfied
         --> src/drivers/block/sdcard.rs:728:32
          |
    728   |     let spi = peripherals.SPI0.constrain();
          |                                ^^^^^^^^^ method cannot be called on `k210_pac::SPI0` due to unsatisfied trait bounds
          |
         ::: /home/wang/.cargo/git/checkouts/k210-pac-19d36f600eb54ac3/8f99c1c/src/lib.rs:19849:1
          |
    19849 | pub struct SPI0 {
          | ---------------
          | |
          | doesn't satisfy `k210_pac::SPI0: SPI01`
          | doesn't satisfy `k210_pac::SPI0: SPIExt`
    ...
    19871 |     pub struct RegisterBlock {
          |     ------------------------
          |     |
          |     doesn't satisfy `k210_pac::spi0::RegisterBlock: SPI01`
          |     doesn't satisfy `k210_pac::spi0::RegisterBlock: SPIExt`
          |
          = note: the following trait bounds were not satisfied:
                  `k210_pac::SPI0: SPI01`
                  which is required by `k210_pac::SPI0: SPIExt`
                  `&k210_pac::SPI0: SPI01`
                  which is required by `&k210_pac::SPI0: SPIExt`
                  `&mut k210_pac::SPI0: SPI01`
                  which is required by `&mut k210_pac::SPI0: SPIExt`
                  `k210_pac::spi0::RegisterBlock: SPI01`
                  which is required by `k210_pac::spi0::RegisterBlock: SPIExt`
                  `&k210_pac::spi0::RegisterBlock: SPI01`
                  which is required by `&k210_pac::spi0::RegisterBlock: SPIExt`
                  `&mut k210_pac::spi0::RegisterBlock: SPI01`
                  which is required by `&mut k210_pac::spi0::RegisterBlock: SPIExt`
    
    error[E0277]: the trait bound `k210_pac::SPI0: SPI01` is not satisfied
       --> src/drivers/block/sdcard.rs:730:19
        |
    730 |     let info = sd.init().unwrap();
        |                   ^^^^ the trait `SPI01` is not implemented for `k210_pac::SPI0`
        |
        = note: required because of the requirements on the impl of `SPI` for `SPIImpl<k210_pac::SPI0>`
    
    error[E0277]: the trait bound `k210_pac::SPI0: SPI01` is not satisfied
       --> src/drivers/block/sdcard.rs:729:14
        |
    163 |     pub fn new(spi: X, spi_cs: u32, cs_gpionum: u8/*, dmac: &'a DMAC, channel: dma_channel*/) -> Self {
        |     ------------------------------------------------------------------------------------------------- required by `SDCard::<X>::new`
    ...
    729 |     let sd = SDCard::new(spi, SD_CS, SD_CS_GPIONUM);
        |              ^^^^^^^^^^^ the trait `SPI01` is not implemented for `k210_pac::SPI0`
        |
        = note: required because of the requirements on the impl of `SPI` for `SPIImpl<k210_pac::SPI0>`
    
    error[E0599]: the method `read_sector` exists for struct `MutexGuard<'_, SDCard<SPIImpl<k210_pac::SPI0>>>`, but its trait bounds were not satisfied
       --> src/drivers/block/sdcard.rs:748:23
        |
    748 |         self.0.lock().read_sector(buf,block_id as u32).unwrap();
        |                       ^^^^^^^^^^^ method cannot be called on `MutexGuard<'_, SDCard<SPIImpl<k210_pac::SPI0>>>` due to unsatisfied trait bounds
        |
       ::: /home/wang/.cargo/git/checkouts/k210-soc-069e4fc1d9165bc2/09a0742/src/spi.rs:52:1
        |
    52  | pub struct SPIImpl<IF> {
        | ---------------------- doesn't satisfy `SPIImpl<k210_pac::SPI0>: SPI`
        |
        = note: the following trait bounds were not satisfied:
                `SPIImpl<k210_pac::SPI0>: SPI`
    
    error[E0599]: the method `write_sector` exists for struct `MutexGuard<'_, SDCard<SPIImpl<k210_pac::SPI0>>>`, but its trait bounds were not satisfied
       --> src/drivers/block/sdcard.rs:751:23
        |
    751 |         self.0.lock().write_sector(buf,block_id as u32).unwrap();
        |                       ^^^^^^^^^^^^ method cannot be called on `MutexGuard<'_, SDCard<SPIImpl<k210_pac::SPI0>>>` due to unsatisfied trait bounds
        |
       ::: /home/wang/.cargo/git/checkouts/k210-soc-069e4fc1d9165bc2/09a0742/src/spi.rs:52:1
        |
    52  | pub struct SPIImpl<IF> {
        | ---------------------- doesn't satisfy `SPIImpl<k210_pac::SPI0>: SPI`
        |
        = note: the following trait bounds were not satisfied:
                `SPIImpl<k210_pac::SPI0>: SPI`
    
    error: aborting due to 6 previous errors
    
    Some errors have detailed explanations: E0277, E0599.
    For more information about an error, try `rustc --explain E0277`.
    error: could not compile `os`
    
    To learn more, run the command again with --verbose.
    make: *** [Makefile:60: kernel] Error 101
    
    opened by wangzhankun 4
  • fix(BlockCache): Vec as aligned buf

    fix(BlockCache): Vec as aligned buf

    use a Vec allocated from buddy system to make sure it's at least 512 bytes aligned, so that the buf passed to VirtIOBlock::read_block does not across any two physical pages. And it's more efficient since you do not need to move the 512B buf when creating Arc<Mutex<BlockCache>> More detailed info at here.

    opened by Direktor799 3
  • syscall调用号增加建议

    syscall调用号增加建议

    起因是这样的,我在为RustUserShell增加TAB键补全功能,但是发现对于FS的操作中没有列出文件的接口,我想增加一个枚举,让Read功能可以读取列表并以“文件”形式返回。但对于该枚举的取值,我需要你们的建议,或者以其他的方式去实现也行,我可以为此Issue提交PR,谢谢同学们! 我想加一行这个: const SYSCALL_FS_LS: usize = 65;

    opened by codychau 0
  • fix(os): fix kstack leak issues

    fix(os): fix kstack leak issues

    Hi there, this is my first contribution for rCore, if there is any problem, please feel free to let me know, thanks.

    The kstack_id is not recycled when KernelStack is dropped, which leads to kstack leak issue. Ch8 branch, and branches after that, are also affected by this issue.

    Signed-off-by: Xuewei Niu [email protected]

    opened by justxuewei 0
  • ch3-lab分支代码缺失,需要完善实验框架及相应测试用例

    ch3-lab分支代码缺失,需要完善实验框架及相应测试用例

    ch3-lab分支代码缺失,需要完善实验框架及相应测试用例

    在 rCore-Tutorial-Book-v3 中关于第三章实践作业有如下引用所示的表述,但是查看rCore-Tutorial-v3 ch3-lab分支,发现并没有给出同rCore-Tutorial-Code-2022S/ch3rust-based-os-comp2022 main/os3-ref/一样的框架

    • 说明:
      • 相关结构已在框架中给出,只需添加逻辑实现功能需求即可。

    且也没有测试任务中要求的新增系统调用fn sys_task_info(ti: *mut TaskInfo) -> isize相关的测试用例, 需要添加测试用例包括但不限于如rCore-Tutorial-Test-2022A main/user/src/bin/ch3_taskinfo.rs等。

    feat(lab3/Time-sharing OS): Add an syscall named sys_task_info这是我在ch3 TimeSharing OS的基础上完成第三章Lab的 commit,希望在ch3-lab分支需要哪些文件新增哪些内容方面有所帮助

    相关issue:第三章实验的文档表述相关问题

    opened by gfgafn 0
  • fix(Makefile)-fix-mount-errors-in-windows

    fix(Makefile)-fix-mount-errors-in-windows

    If you feel this is unnecessary, please close this pull request. :)

    • In PowerShell, the pwd command does not accept the current path string in the same way as bash. Therefore, this pull request uses ifeq in the Makefile to branch the command.

    There are several possible options for the command.

    (Option1) alias pwd -> Get-Location and considering the profile override maybe we should use Get-Location instead of pwd

    PWD_CMD := powershell -NoProfile -Command "Write-Output $$(Get-Location)"
    

    (Option2) Instead of PowerShell, we may want to use the following command.

    PWD_CMD := cmd /c "echo %CD%"
    

    (Another option) Differences in this kind of shell can be left to docker. Using docker-compose.yml

    version: "3.9"
    
    services:
      app:
        build:
          context: ./ # Dockerfile/URL Path
          dockerfile: Dockerfile
        image: dinghao188/rcore-tutorial:dev # as image name
        tty: true # == `docker -t`
        stdin_open: true # == `docker -i`
        volumes:
          - ./:/mnt/
    

    2022-08-25 (2)

    2022-08-25 (1)

    opened by SARDONYX-sard 2
Releases(v3.5.0)
  • v3.5.0(Oct 17, 2021)

    We want to publish our first release to save our current progress since we are trying to add a new chapter to this project, many significant or minor changes will be added as well.

    Please ignore Source Code(zip/tar.gz), just download rCore-Tutorial3.5.0.tar.gz and extract it. You can find all code in code/ch<X>, and the documentation can be found in docs/index.html.

    Source code(tar.gz)
    Source code(zip)
    rCore-Tutorial3.5.0.tar.gz(15.61 MB)
Owner
rCore OS
THU Rust operating system workshop. (mirror: https://gitee.com/rcore-os)
rCore OS
Tutorial for rCore OS step by step (3rd edition)

rCore-Tutorial V3(开发中) 本教学仓库是继 rCore_tutorial V2 后重构的 V3 版本。 本文档的目标主要针对「做实验的同学」,我们会对每章结束后提供完成的代码,你的练习题只需要基于我们给出的版本上增量实现即可,不需要重新按照教程写一遍。 而对想完整实现一个 rCor

rCore OS 419 Dec 30, 2022
Let's write an OS which can run on ARM in Rust from scratch

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. news 2021.11.20: Now we are updating our labs. Please checkout chX-dev

rCore OS 10 Dec 17, 2022
Let's write an OS which can run on x86_64 in Rust from scratch

rCore-Tutorial-v3 rCore-Tutorial version 3.5. See the Documentation in Chinese. news 2021.11.20: Now we are updating our labs. Please checkout chX-dev

rCore OS 6 Apr 1, 2022
Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.

Distrod - WSL2 Distros with Systemd! Distrod is a systemd-based meta-distro for WSL2 that allows you to install Ubuntu, Arch Linux, Gentoo and many ot

Takaya Saeki 1.6k Jan 9, 2023
Baremetal Backtracing on RISC-V

It provides a simple but useful backtrace in baremetal machine, basically it links DWARF info into the binary and print them when backtrace the program. Currently it only supports RISC-V architecture, but I did not see any barrier to make it available in other architectures like x86.

JohnWeston 3 Jun 25, 2021
Cute tiny operating system for RISC-V. ฅ•ω•ฅ

MoeOS ⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄ ٩(^ᴗ^)۶欢迎参观MoeOS的仓库,MoeOS是一个小巧可爱(并不)的操作系统,目前全力支持RISC-V中。 (*≧▽≦)因为还只是一个玩具操作系统,就别要求她能做太多事情啦!现在功能还不完善,会慢慢加的! 编译 呐,你想给我找个家么? 目前MoeOS

Rui Li 30 Nov 11, 2022
A RISC-V and unix-like operating system developed just for fun.

Orca 虎鲸 A RISC-V and unix-like operating system developed just for fun. Schedule [*] bootloader (use RustSBI-qemu) [ ] linker & stack [ ] memory alloc

Mr.Z 4 May 29, 2022
Learn to write an embedded OS in Rust

Operating System development tutorials in Rust on the Raspberry Pi

Rust Embedded 9.9k Jan 6, 2023
Examples on how to write Windows kernel drivers in Rust

windows-kernel-rs Note: this is still work in progress! This is a Windows kernel framework in Rust that consists of windows-kernel-sys, a crate that p

S.J.R. van Schaik 77 Dec 28, 2022
A language-based OS to run Rust on bare metal

RustOS A simple, language-based OS. Current features: Simple VGA for seeing output Some Rust libraries (core, alloc, collections) already in Working (

null 402 Dec 8, 2022
A language-based OS to run Rust on bare metal

RustOS A simple, language-based OS. Current features: Simple VGA for seeing output Some Rust libraries (core, alloc, collections) already in Working (

null 79 Dec 3, 2022
A library that makes it VERY easy to run Holochain as a library, from your own binary, with great defaults

embedded-holochain-runner A library that makes it VERY easy to run Holochain as a library, from your own binary, with great defaults How it will work

Sprillow 14 Jul 23, 2022
A lightweight microkernel/IPC based operating system built with Rust which is not a clone of any existing operating system

Noble Operating System Noble is a lightweight microkernel and IPC based operating system built with Rust which is not a clone of any existing operatin

Revolution Xenon 3 Jan 10, 2022
A Rust-based userland which also adds compile-time assurances to seL4 development.

ferros Overview A Rust library to add extra assurances to seL4 development. ferros provides smart type-safe wrappers around seL4 features with an emph

Auxon Corporation 68 Dec 25, 2022
A comparison of operating systems written in Rust

Rust OS comparison A comparison of operating systems written in Rust. There are several open source operating systems written in Rust. Most of them ar

Markus Kohlhase 492 Jan 8, 2023
An OS kernel written in rust. Non POSIX

"Tifflin" Experimental Kernel (and eventually Operating System) This is an experiment in writing an OS Kernel in rust (http://rust-lang.org). Mostly t

John Hodge (Mutabah) 618 Jan 8, 2023
A hobby operating system, in Rust

intermezzOS: kernel intermezzOS is a hobby operating system. This repository is for its kernel. See the website for more. License This project is dual

intermezzOS 1.3k Jan 1, 2023
A Rust version of the Weenix OS

Reenix This is the start of a unix like operating system written in Rust. It is based on the Weenix Operating system written for Brown's CS167/9. At t

Alex Light 311 Dec 22, 2022
A tiny 32 bit kernel written in Rust

rustboot A tiny 32 bit kernel written in Rust. I was inspired to download Rust and try to do this after seeing zero.rs - a stub that lets Rust program

Charlie Somerville 1.5k Dec 30, 2022