Merge branch 'main' of github.com:LearningOS/rust-based-os-comp2022 into main

This commit is contained in:
Yu Chen
2022-07-11 09:55:10 +08:00
8 changed files with 32 additions and 13 deletions

View File

@@ -20,10 +20,10 @@ else ifeq ($(CHAPTER), 8)
endif
randomize:
find user/src/bin -name "*.rs" | xargs sed -i 's/OK/OK$(RAND)/g'
find user/src/bin -name "*.rs" | xargs sed -i 's/passed/passed$(RAND)/g'
find check -name "*.py" | xargs sed -i 's/OK/OK$(RAND)/g'
find check -name "*.py" | xargs sed -i 's/passed/passed$(RAND)/g'
find user/src/bin -name "*.rs" | xargs perl -pi -e s,OK,OK$(RAND),g
find user/src/bin -name "*.rs" | xargs perl -pi -e s,passed,passed$(RAND),g
find check -name "*.py" | xargs perl -pi -e s,OK,OK$(RAND),g
find check -name "*.py" | xargs perl -pi -e s,passed,passed$(RAND),g
test: randomize
python3 overwrite.py $(CHAPTER)

View File

@@ -18,7 +18,7 @@
目前,实验主要支持 Ubuntu18.04/20.04 操作系统。使用 Windows10 和 macOS 的读者,可以安装一台 Ubuntu18.04 虚拟机或 Docker
进行实验。也可基于 **gihub classroom with codespaces** 进行开发。
进行实验。也可基于 **github classroom with codespaces** 进行开发。
Github Classroom方式进行在线OS 环境配置

View File

@@ -59,10 +59,6 @@
获取本章代码:
.. code-block:: console
获取本章代码:
.. code-block:: console
$ git clone ``gitaddr of github-classroom-build-lab0-0``

View File

@@ -118,6 +118,12 @@ println! 宏是由标准库 std 提供的,且会使用到一个名为 write
分析被移除标准库的程序
-----------------------------
首先安装 cargo-binutils 工具集:
.. code-block:: console
$ cargo install cargo-binutils
$ rustup component add llvm-tools-preview
我们可以通过一些工具来分析目前的程序:
.. code-block:: console

View File

@@ -162,11 +162,15 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
如果你觉得理解 Rust 宏有困难,把它当成黑盒就好!
学习rust宏的参考链接: `The Little Book of Rust Macros <https://veykril.github.io/tlborm/introduction.html>`_
首先封装一下对 ``SYSCALL_WRITE`` 系统调用。
.. code-block:: rust
// os/src/main.rs
const SYSCALL_WRITE: usize = 64;
pub fn sys_write(fd: usize, buffer: &[u8]) -> isize {
@@ -178,6 +182,8 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
.. code-block:: rust
// os/src/console.rs
struct Stdout;
impl Write for Stdout {
@@ -196,20 +202,31 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
.. code-block:: rust
#[macro_export]
// os/src/console.rs
macro_rules! print {
($fmt: literal $(, $($arg: tt)+)?) => {
$crate::console::print(format_args!($fmt $(, $($arg)+)?));
}
}
#[macro_export]
macro_rules! println {
($fmt: literal $(, $($arg: tt)+)?) => {
print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
}
}
// os/src/main.rs
#![no_std]
#![no_main]
#[macro_use]
mod console;
mod lang_items;
...
接下来,我们调整一下应用程序,让它发出显示字符串和退出的请求:
.. code-block:: rust

0
os7-ref/src/link_app.S Normal file
View File

0
os8-ref/src/link_app.S Normal file
View File

View File

@@ -71,7 +71,7 @@
3. 完成第二步后你的rustings实验练习 的 github repository 会被自动建立好点击此github repository的链接就可看到你要完成的实验了。
4. 在你的第一个实验练习的网页的中上部可以看到一个醒目的 `code` 绿色按钮,点击后,可以进一步看到 `codespace` 标签和醒目的 `create codesapce on main` 绿色按钮。请点击这个绿色按钮就可以进入到在线的ubuntu +vscode环境中
4. 在你的第一个实验练习的网页的中上部可以看到一个醒目的 `code` 绿色按钮,点击后,可以进一步看到 `codespace` 标签和醒目的 `create codesapce on edu` 绿色按钮。请点击这个绿色按钮就可以进入到在线的ubuntu +vscode环境中
5. 再按照下面的环境安装提示在vscode的 `console` 中安装配置开发环境rustc等工具。注也可在vscode的 `console` 中执行 ``make codespaces_setenv`` 来自动安装配置开发环境(执行``sudo``需要root权限仅需要执行一次