Skip to content

Commit 3d1287e

Browse files
committed
Merge branch 'main' of github.com:LearningOS/rust-based-os-comp2022 into main
2 parents 01b36b9 + 538b044 commit 3d1287e

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

ci-user/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ else ifeq ($(CHAPTER), 8)
2020
endif
2121

2222
randomize:
23-
find user/src/bin -name "*.rs" | xargs sed -i 's/OK/OK$(RAND)/g'
24-
find user/src/bin -name "*.rs" | xargs sed -i 's/passed/passed$(RAND)/g'
25-
find check -name "*.py" | xargs sed -i 's/OK/OK$(RAND)/g'
26-
find check -name "*.py" | xargs sed -i 's/passed/passed$(RAND)/g'
23+
find user/src/bin -name "*.rs" | xargs perl -pi -e s,OK,OK$(RAND),g
24+
find user/src/bin -name "*.rs" | xargs perl -pi -e s,passed,passed$(RAND),g
25+
find check -name "*.py" | xargs perl -pi -e s,OK,OK$(RAND),g
26+
find check -name "*.py" | xargs perl -pi -e s,passed,passed$(RAND),g
2727

2828
test: randomize
2929
python3 overwrite.py $(CHAPTER)

guide/source/0setup-devel-env.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
目前,实验主要支持 Ubuntu18.04/20.04 操作系统。使用 Windows10 和 macOS 的读者,可以安装一台 Ubuntu18.04 虚拟机或 Docker
21-
进行实验。也可基于 **gihub classroom with codespaces** 进行开发。
21+
进行实验。也可基于 **github classroom with codespaces** 进行开发。
2222

2323

2424
Github Classroom方式进行在线OS 环境配置

guide/source/chapter1/0intro.rst

-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@
5959

6060
获取本章代码:
6161

62-
.. code-block:: console
63-
64-
获取本章代码:
65-
6662
.. code-block:: console
6763
6864
$ git clone ``gitaddr of github-classroom-build-lab0-0``

guide/source/chapter1/2remove-std.rst

+6
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ println! 宏是由标准库 std 提供的,且会使用到一个名为 write
118118
分析被移除标准库的程序
119119
-----------------------------
120120

121+
首先安装 cargo-binutils 工具集:
122+
123+
.. code-block:: console
124+
$ cargo install cargo-binutils
125+
$ rustup component add llvm-tools-preview
126+
121127
我们可以通过一些工具来分析目前的程序:
122128

123129
.. code-block:: console

guide/source/chapter1/3mini-rt-usrland.rst

+20-3
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,15 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
162162

163163
如果你觉得理解 Rust 宏有困难,把它当成黑盒就好!
164164

165+
学习rust宏的参考链接: `The Little Book of Rust Macros <https://veykril.github.io/tlborm/introduction.html>`_
166+
165167

166168
首先封装一下对 ``SYSCALL_WRITE`` 系统调用。
167169

168170
.. code-block:: rust
169171
172+
// os/src/main.rs
173+
170174
const SYSCALL_WRITE: usize = 64;
171175
172176
pub fn sys_write(fd: usize, buffer: &[u8]) -> isize {
@@ -178,6 +182,8 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
178182

179183
.. code-block:: rust
180184
185+
// os/src/console.rs
186+
181187
struct Stdout;
182188
183189
impl Write for Stdout {
@@ -196,20 +202,31 @@ Rust 的 core 库内建了以一系列帮助实现显示字符的基本 Trait
196202

197203
.. code-block:: rust
198204
199-
#[macro_export]
205+
// os/src/console.rs
206+
200207
macro_rules! print {
201208
($fmt: literal $(, $($arg: tt)+)?) => {
202209
$crate::console::print(format_args!($fmt $(, $($arg)+)?));
203210
}
204211
}
205212
206-
#[macro_export]
207213
macro_rules! println {
208214
($fmt: literal $(, $($arg: tt)+)?) => {
209-
print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
215+
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
210216
}
211217
}
212218
219+
// os/src/main.rs
220+
221+
#![no_std]
222+
#![no_main]
223+
224+
#[macro_use]
225+
mod console;
226+
mod lang_items;
227+
228+
...
229+
213230
接下来,我们调整一下应用程序,让它发出显示字符串和退出的请求:
214231

215232
.. code-block:: rust

os7-ref/src/link_app.S

Whitespace-only changes.

os8-ref/src/link_app.S

Whitespace-only changes.

scheduling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
3.) 完成第二步后,你的rustings实验练习 的 github repository 会被自动建立好,点击此github repository的链接,就可看到你要完成的实验了。
7373

74-
4.) 在你的第一个实验练习的网页的中上部可以看到一个醒目的 `code` 绿色按钮,点击后,可以进一步看到 `codespace` 标签和醒目的 `create codesapce on main` 绿色按钮。请点击这个绿色按钮,就可以进入到在线的ubuntu +vscode环境中
74+
4.) 在你的第一个实验练习的网页的中上部可以看到一个醒目的 `code` 绿色按钮,点击后,可以进一步看到 `codespace` 标签和醒目的 `create codesapce on edu` 绿色按钮。请点击这个绿色按钮,就可以进入到在线的ubuntu +vscode环境中
7575

7676
5.) 再按照下面的环境安装提示在vscode的 `console` 中安装配置开发环境:rustc等工具。注:也可在vscode的 `console` 中执行 ``make codespaces_setenv`` 来自动安装配置开发环境(执行``sudo``需要root权限,仅需要执行一次)。
7777

0 commit comments

Comments
 (0)