mirror of
https://github.com/LearningOS/rust-based-os-comp2022.git
synced 2026-05-09 15:21:27 +08:00
update guide
This commit is contained in:
@@ -126,7 +126,7 @@ Rust 开发环境配置
|
||||
Qemu 模拟器安装
|
||||
----------------------------------------
|
||||
|
||||
我们需要使用 Qemu 5.0.0 版本进行实验,为此,从源码手动编译安装 Qemu 模拟器:
|
||||
我们需要使用 Qemu 7.0.0 版本进行实验,为此,从源码手动编译安装 Qemu 模拟器:
|
||||
|
||||
.. attention::
|
||||
|
||||
@@ -141,11 +141,11 @@ Qemu 模拟器安装
|
||||
# 下载源码包
|
||||
# 如果下载速度过慢可以使用我们提供的百度网盘链接:https://pan.baidu.com/s/1z-iWIPjxjxbdFS2Qf-NKxQ
|
||||
# 提取码 8woe
|
||||
wget https://download.qemu.org/qemu-5.0.0.tar.xz
|
||||
wget https://download.qemu.org/qemu-7.0.0.tar.xz
|
||||
# 解压
|
||||
tar xvJf qemu-5.0.0.tar.xz
|
||||
tar xvJf qemu-7.0.0.tar.xz
|
||||
# 编译安装并配置 RISC-V 支持
|
||||
cd qemu-5.0.0
|
||||
cd qemu-7.0.0
|
||||
./configure --target-list=riscv64-softmmu,riscv64-linux-user
|
||||
make -j$(nproc)
|
||||
|
||||
@@ -169,10 +169,10 @@ Qemu 模拟器安装
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# 请注意,qemu-5.0.0 的父目录可以随着你的实际安装位置灵活调整
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-5.0.0
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-5.0.0/riscv64-softmmu
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-5.0.0/riscv64-linux-user
|
||||
# 请注意,qemu-7.0.0 的父目录可以随着你的实际安装位置灵活调整
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0/riscv64-softmmu
|
||||
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0/riscv64-linux-user
|
||||
|
||||
随后即可在当前终端 ``source ~/.bashrc`` 更新系统路径,或者直接重启一个新的终端。
|
||||
|
||||
@@ -188,38 +188,38 @@ Qemu 模拟器安装
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S
|
||||
cd rCore-Tutorial-Code-2022S
|
||||
git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
cd rust-based-os-comp2022
|
||||
|
||||
我们先运行不需要处理用户代码的 ch1 分支:
|
||||
我们先运行不需要处理用户代码的裸机操作系统 ``os1`` :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git checkout ch1
|
||||
cd os
|
||||
cd os1
|
||||
LOG=DEBUG make run
|
||||
|
||||
如果你的环境配置正确,你应当会看到如下输出:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
[rustsbi] RustSBI version 0.2.0-alpha.4
|
||||
[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0
|
||||
.______ __ __ _______.___________. _______..______ __
|
||||
| _ \ | | | | / | | / || _ \ | |
|
||||
| |_) | | | | | | (----`---| |----`| (----`| |_) || |
|
||||
| / | | | | \ \ | | \ \ | _ < | |
|
||||
| |\ \----.| `--' |.----) | | | .----) | | |_) || |
|
||||
| _| `._____| \______/ |_______/ |__| |_______/ |______/ |__|
|
||||
|
||||
[rustsbi] Implementation: RustSBI-QEMU Version 0.0.1
|
||||
[rustsbi-dtb] Hart count: cluster0 with 1 cores
|
||||
[rustsbi] misa: RV64ACDFIMSU
|
||||
[rustsbi] mideleg: ssoft, stimer, sext (0x222)
|
||||
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
|
||||
[rustsbi] pmp0: 0x80000000 ..= 0x800fffff (rwx)
|
||||
[rustsbi] pmp1: 0x80000000 ..= 0x807fffff (rwx)
|
||||
[rustsbi] pmp2: 0x0 ..= 0xffffffffffffff (---)
|
||||
[rustsbi] enter supervisor 0x80200000
|
||||
[rustsbi] Implementation : RustSBI-QEMU Version 0.1.1
|
||||
[rustsbi] Platform Name : riscv-virtio,qemu
|
||||
[rustsbi] Platform SMP : 1
|
||||
[rustsbi] Platform Memory : 0x80000000..0x88000000
|
||||
[rustsbi] Boot HART : 0
|
||||
[rustsbi] Device Tree Region : 0x87000000..0x87000ef2
|
||||
[rustsbi] Firmware Address : 0x80000000
|
||||
[rustsbi] Supervisor Address : 0x80200000
|
||||
[rustsbi] pmp01: 0x00000000..0x80000000 (-wr)
|
||||
[rustsbi] pmp02: 0x80000000..0x80200000 (---)
|
||||
[rustsbi] pmp03: 0x80200000..0x88000000 (xwr)
|
||||
Hello, world!
|
||||
[DEBUG] .rodata [0x80203000, 0x80205000)
|
||||
[ INFO] .data [0x80205000, 0x80206000)
|
||||
|
||||
@@ -43,15 +43,14 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch1
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
运行本章代码,并设置日志级别为 ``TRACE``:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os1
|
||||
$ make run LOG=TRACE
|
||||
|
||||
|
||||
|
||||
@@ -24,10 +24,8 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch2
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Test-2022S.git user
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022
|
||||
|
||||
上面的指令会将测例仓库克隆到代码仓库下并命名为 ``user`` ,注意 ``/user`` 在代码仓库的 ``.gitignore`` 文件中,因此不会出现 ``.git`` 文件夹嵌套的问题,并且你在代码仓库进行 checkout 操作时也不会影响测例仓库的内容。
|
||||
|
||||
@@ -35,7 +33,7 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os2
|
||||
$ make run LOG=INFO
|
||||
|
||||
批处理系统自动加载并运行了所有的用户程序,尽管某些程序出错了:
|
||||
@@ -98,7 +96,7 @@
|
||||
|
||||
.. code-block::
|
||||
|
||||
── os
|
||||
── os2
|
||||
│ ├── Cargo.toml
|
||||
│ ├── Makefile (修改:构建内核之前先构建应用)
|
||||
│ ├── build.rs (新增:生成 link_app.S 将应用作为一个数据段链接到内核)
|
||||
|
||||
@@ -18,16 +18,14 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch3
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Test-2022S.git user
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
在 qemu 模拟器上运行 `lab1(os3)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os3-ref>`_ :
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os3-ref
|
||||
$ make run
|
||||
|
||||
运行代码,看到用户程序交替输出信息:
|
||||
@@ -134,12 +132,12 @@
|
||||
Panicked at src/task/mod.rs:98 All applications completed!
|
||||
|
||||
|
||||
本章代码树
|
||||
---------------------------------------------
|
||||
`lab1(os3)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os3-ref>`_
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
── os
|
||||
── os3-ref
|
||||
├── build.rs
|
||||
├── Cargo.toml
|
||||
├── Makefile
|
||||
|
||||
@@ -16,46 +16,24 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch4
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Test-2022S.git user
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
或许你之前已经克隆过了仓库,只希望从远程仓库更新,而非再克隆一次:
|
||||
在 qemu 模拟器上运行 `lab2(os4)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os4-ref>`_ :
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
# 你可以将 upstream 改为你喜欢的名字
|
||||
$ git remote add upstream https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
# 更新仓库信息
|
||||
$ git fetch upstream
|
||||
# 查看已添加的远程仓库;应该能看到已有一个 origin 和新添加的 upstream 仓库
|
||||
$ git remote -v
|
||||
# 根据需求选择以下一种操作即可
|
||||
# 在本地新建一个与远程仓库对应的分支:
|
||||
$ git checkout -b ch4 upstream/ch4
|
||||
# 本地已有分支,从远程仓库更新:
|
||||
$ git checkout ch4
|
||||
$ git merge upstream/ch4
|
||||
# 将更新推送到自己的远程仓库
|
||||
$ git push origin ch4
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os4-ref
|
||||
$ make run
|
||||
|
||||
|
||||
本章代码树
|
||||
-----------------------------------------------------
|
||||
`lab2(os4)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os4-ref>`_
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
├── os
|
||||
├── os4-ref
|
||||
│ ├── ...
|
||||
│ └── src
|
||||
│ ├── ...
|
||||
@@ -91,7 +69,7 @@
|
||||
├── linker.ld(修改:将所有应用放在各自地址空间中固定的位置)
|
||||
└── ...
|
||||
|
||||
cloc os
|
||||
cloc os4-ref
|
||||
-------------------------------------------------------------------------------
|
||||
Language files blank comment code
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@@ -23,20 +23,18 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch5
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Test-2022S.git user
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
请仿照ch4的做法将代码在本地更新并push到自己的实验仓库中。
|
||||
|
||||
注意:user仓库有对ch5的测例更新,请重新clone或者使用git pull等获取。
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
在 qemu 模拟器上运行`lab3(os5)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os5-ref>`_ :
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os5-ref
|
||||
$ make run
|
||||
|
||||
待内核初始化完毕之后,将在屏幕上打印可用的应用列表并进入shell程序:
|
||||
@@ -98,13 +96,13 @@
|
||||
child process pid = 3, exit code = 100
|
||||
Shell: Process 2 exited with code 0
|
||||
|
||||
本章代码树
|
||||
--------------------------------------
|
||||
`lab3(os5)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os5-ref>`_
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
├── os
|
||||
├── os5-ref
|
||||
├── build.rs(修改:基于应用名的应用构建器)
|
||||
├── ...
|
||||
└── src
|
||||
|
||||
@@ -13,15 +13,14 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch6
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
在 qemu 模拟器上运行本章代码参考框架:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os6-ref
|
||||
$ make run
|
||||
|
||||
内核初始化完成之后就会进入shell程序,在这里我们运行一下本章的测例 ``ch6b_filetest_simple`` :
|
||||
@@ -42,8 +41,8 @@
|
||||
Shell: Process 2 exited with code 0
|
||||
>>
|
||||
|
||||
本章代码树
|
||||
-----------------------------------------
|
||||
easy-fs和 `lab4(os6)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os6-ref>`_
|
||||
-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block::
|
||||
:linenos:
|
||||
|
||||
@@ -14,15 +14,14 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch7
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
在 qemu 模拟器上运行 `os7参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os7-ref>`_ :
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os7-ref
|
||||
$ make run
|
||||
|
||||
进入shell程序后,可以运行管道机制的简单测例 ``ch7b_pipetest``, ``ch7b_pipetest`` 需要保证父进程通过管道传输给子进程的字符串不会发生变化。
|
||||
@@ -57,12 +56,12 @@
|
||||
Shell: Process 2 exited with code 0
|
||||
>>
|
||||
|
||||
本章代码树
|
||||
-----------------------------------------
|
||||
`os7参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os7-ref>`_
|
||||
-----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
── os
|
||||
── os7-ref
|
||||
└── src
|
||||
├── ...
|
||||
├── fs
|
||||
|
||||
@@ -88,18 +88,16 @@
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Code-2022S.git
|
||||
$ cd rCore-Tutorial-Code-2022S
|
||||
$ git checkout ch8
|
||||
$ git clone https://github.com/LearningOS/rCore-Tutorial-Test-2022S.git user
|
||||
$ git clone https://github.com/LearningOS/rust-based-os-comp2022.git
|
||||
$ cd rust-based-os-comp2022/
|
||||
|
||||
记得更新测例仓库的代码。
|
||||
|
||||
在 qemu 模拟器上运行本章代码:
|
||||
在 qemu 模拟器上运行本章代码 `lab5(os8)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os8-ref>`_ :
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd os
|
||||
$ cd os8-ref
|
||||
$ make run
|
||||
|
||||
内核初始化完成之后就会进入 shell 程序,我们可以体会一下线程的创建和执行过程。在这里我们运行一下本章的测例 ``ch8b_threads`` :
|
||||
@@ -147,7 +145,7 @@
|
||||
平时,每个哲学家进行思考,饥饿时便试图拿起其左右最靠近他的筷子,只有在他拿到两只筷子时才能进餐。进餐完毕,放下筷子继续思考。
|
||||
|
||||
|
||||
本章代码树
|
||||
本章的 `lab5(os8)参考框架: <https://github.com/LearningOS/rust-based-os-comp2022/tree/main/os8-ref>`_ 代码树
|
||||
-----------------------------------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'rCore-Tutorial-Guide-2022S'
|
||||
copyright = 'OS2022Spring'
|
||||
project = 'Open-Source-OS-Tutorial-Summer-of-Code-2022'
|
||||
copyright = 'OS2022Summer'
|
||||
author = 'Yifan Wu'
|
||||
language = 'zh_CN'
|
||||
html_search_language = 'zh'
|
||||
|
||||
Reference in New Issue
Block a user