Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation tutorial 3 #167

Merged
merged 7 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 02_runtime_init/README.CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
[bss]: https://en.wikipedia.org/wiki/.bss

## 相比之前的变化(diff)
请检查[英文版本](README.md#diff-to-previous),这是最新的。

Please check [the english version](README.md#diff-to-previous), which is kept up-to-date.
35 changes: 35 additions & 0 deletions 03_hacky_hello_world/README.CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 教程 03 - Hacky Hello World

## tl;dr

- 介绍全局的`println!()`宏以便尽早启用"printf debugging"。
- 为了保持教程长度合理,打印函数目前 "滥用" 了 QEMU 属性,该属性允许我们在没有正确设置的情况下使用树莓派的`UART`。
- 在接下来的教程中将逐步使用真实硬件的`UART`。

## 值得注意的补充

- `src/console.rs`为控制台命令和通过`console::console()`对内核控制台的全局访问引入了接口`Traits`。
- `src/bsp/raspberrypi/console.rs` 实现QEMU仿真UART的接口。
- 紧急处理程序使用新的`println!()`以显示用户错误消息。
- 有一个新的Makefile目录`make test`,用于自动测试。它在`QEMU`中引导编译后的内核,并检查内核生成的预期输出字符串。
- 在本教程中,它检查字符串`Stopping here`,该字符串由`panic!()`在`main.rs`的末尾。

## 测试一下

QEMU不再以汇编模式运行。从现在起,它将显示`console`的输出。

```console
$ make qemu
[...]

Hello from Rust!
Kernel panic!

Panic location:
File 'src/main.rs', line 126, column 5

Stopping here.
```

## 相比之前的变化(diff)
请检查[英文版本](README.md#diff-to-previous),这是最新的。