You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
903 B
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 教程 02 - 执行初始化
## tl;dr
我们拓展了`boot.S`在第一次启动的时候调用Rust代码。在Rust的代码中先清零了[bss] section然后通过调用`panic()`挂起CPU。再次运行`make qemu`看看新增加的代码是怎么运行的。
## 值得注意的变化
- 链接脚本linker script中有了更多的section。
- `.rodata`, `.data`
- `.bss`
- `_start()`:
- 当核心不是`core0`第0号核心的时候挂起该CPU核心。
- `core0`会调用Rust的函数`runtime_init()`。
- `runtime_init.rs`内的`runtime_init()`
- 清零了`.bss` section.
- 它调用了`kernel_init()`, 这个函数又调用了`panic!()`, panic函数最终把`core0`和其他核心一样挂起了。
[bss]: https://en.wikipedia.org/wiki/.bss
## 相比之前的变化diff
请检查[英文版本](README.md#diff-to-previous),这是最新的。