Compare commits

...

5 Commits

Author SHA1 Message Date
27Onion Nebell
97cf5c6f35 Merge b760d2914b into 2b444d3262 2024-02-01 13:38:07 +00:00
Philipp Oppermann
2b444d3262 Merge pull request #1274 from acyanbird/main
change some format errors for chinese edition minimal kernel
2024-01-30 18:03:55 +01:00
acyanbird
b118828956 change some format errors 2024-01-28 23:59:17 +00:00
27Onion Nebell
b760d2914b starting translation for esperanto 2022-10-08 16:09:34 +08:00
27Onion Nebell
4641b51239 starting translation for esperanto 2022-10-08 16:05:28 +08:00
4 changed files with 39 additions and 6 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -175,3 +175,21 @@ translated_content_notice = "이것은 커뮤니티 멤버가 <strong><a href=\"
translated_by = "번역한 사람 : " translated_by = "번역한 사람 : "
translation_contributors = "With contributions from" translation_contributors = "With contributions from"
word_separator = "와" word_separator = "와"
# Esperanto
[languages.eo]
title = "Writing an OS in Rust"
description = "This blog series creates a small operating system in the Rust programming language. Each post is a small tutorial and includes all needed code."
[languages.eo.translations]
lang_name = "Esperanto"
toc = "Enhavtabelo"
all_posts = "« Ĉiuj Afiŝoj"
comments = "Komentoj"
comments_notice = "Bonvolu lasi viajn komentojn en la Angla se eble."
readmore = "legu&nbsp;pli&nbsp;»"
not_translated = "(Ĉi tiu afiŝo ankoraŭ ne estas tradukita. )"
translated_content = "Tradukita Enhavo:"
translated_content_notice = "Ĉi tiu estas komunuma traduko de la <strong><a href=\"_original.permalink_\">_original.title_</a></strong> enhavo. Ĝi eble estas nekompleta, malmoderna aŭ enhavas erarojn. Bonvolu raporti ajnajn problemojn!!"
translated_by = "Traduko de"
translation_contributors = "Kun kontribuoj de"
word_separator = "kaj"

13
blog/content/_index.eo.md Normal file
View File

@@ -0,0 +1,13 @@
+++
template = "edition-2/index.html"
+++
<h1 style="visibility: hidden; height: 0px; margin: 0px; padding: 0px;">Skribas OS en Rust</h1>
<div class="front-page-introduction">
Ĉi tiu blogserio kreas malgrandan operaciumon (OS) en la [Rust programlingvo](https://www.rust-lang.org/). Ĉiu afiŝo estas malgranda lernilo kaj inkluzivas la tutan bezonatan kodon, do vi povas sekvi se vi volas. La fontkodo ankaŭ haveblas en la responda [Github-deponejo](https://github.com/phil-opp/blog_os).
Plej Lasta Afiŝo: <!-- latest-post -->
</div>

View File

@@ -15,7 +15,7 @@ translation_contributors = ["JiangengDong"]
在这篇文章中,我们将基于 **x86架构**the x86 architecture使用 Rust 语言,编写一个最小化的 64 位内核。我们将从上一章中构建的[独立式可执行程序][freestanding-rust-binary]开始,构建自己的内核;它将向显示器打印字符串,并能被打包为一个能够引导启动的**磁盘映像**disk image 在这篇文章中,我们将基于 **x86架构**the x86 architecture使用 Rust 语言,编写一个最小化的 64 位内核。我们将从上一章中构建的[独立式可执行程序][freestanding-rust-binary]开始,构建自己的内核;它将向显示器打印字符串,并能被打包为一个能够引导启动的**磁盘映像**disk image
[freestanding Rust binary]: @/edition-2/posts/01-freestanding-rust-binary/index.md [freestanding-rust-binary]: @/edition-2/posts/01-freestanding-rust-binary/index.md
<!-- more --> <!-- more -->
@@ -157,7 +157,9 @@ Nightly 版本的编译器允许我们在源码的开头插入**特性标签**
禁用 SIMD 产生的一个问题是,`x86_64` 架构的浮点数指针运算默认依赖于 SIMD 寄存器。我们的解决方法是,启用 `soft-float` 特征,它将使用基于整数的软件功能,模拟浮点数指针运算。 禁用 SIMD 产生的一个问题是,`x86_64` 架构的浮点数指针运算默认依赖于 SIMD 寄存器。我们的解决方法是,启用 `soft-float` 特征,它将使用基于整数的软件功能,模拟浮点数指针运算。
为了让读者的印象更清晰,我们撰写了一篇关于 [禁用 SIMD][disabling SIMD](@/edition-2/posts/02-minimal-rust-kernel/disable-simd/index.zh-CN.md) 的短文。 为了让读者的印象更清晰,我们撰写了一篇关于 [禁用 SIMD][disabling SIMD] 的短文。
[disabling SIMD]: @/edition-2/posts/02-minimal-rust-kernel/disable-simd/index.zh-CN.md
现在,我们将各个配置项整合在一起。我们的目标配置清单应该长这样: 现在,我们将各个配置项整合在一起。我们的目标配置清单应该长这样:
@@ -225,10 +227,10 @@ error[E0463]: can't find crate for `core`
#### `build-std` 选项 #### `build-std` 选项
此时就到了cargo中 [`build-std` 特性][`build-std` feature] 登场的时刻,该特性允许你按照自己的需要重编译 `core` 等标准crate而不需要使用Rust安装程序内置的预编译版本。 但是该特性是全新的功能,到目前为止尚未完全完成,所以它被标记为 "unstable" 且仅被允许在 [nightly Rust 编译器][nightly Rust compilers] 环境下调用。 此时就到了cargo中 [`build-std` 特性][`build-std` feature] 登场的时刻,该特性允许你按照自己的需要重编译 `core` 等标准crate而不需要使用Rust安装程序内置的预编译版本。 但是该特性是全新的功能,到目前为止尚未完全完成,所以它被标记为 "unstable" 且仅被允许在 [Nightly Rust 编译器][Nightly Rust compilers] 环境下调用。
[`build-std` feature]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std [`build-std` feature]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std
[nightly Rust compilers]: #安装 Nightly Rust [Nightly Rust compilers]:https://os.phil-opp.com/zh-CN/minimal-rust-kernel/#an-zhuang-nightly-rust
要启用该特性,你需要创建一个 [cargo 配置][cargo configuration] 文件,即 `.cargo/config.toml`,并写入以下语句: 要启用该特性,你需要创建一个 [cargo 配置][cargo configuration] 文件,即 `.cargo/config.toml`,并写入以下语句:
@@ -347,7 +349,7 @@ pub extern "C" fn _start() -> ! {
使用 `unsafe` 语句块要求程序员有足够的自信,所以必须强调的一点是,**肆意使用 unsafe 语句块并不是 Rust 编程的一贯方式**。在缺乏足够经验的前提下,直接在 `unsafe` 语句块内操作裸指针,非常容易把事情弄得很糟糕;比如,在不注意的情况下,我们很可能会意外地操作缓冲区以外的内存。 使用 `unsafe` 语句块要求程序员有足够的自信,所以必须强调的一点是,**肆意使用 unsafe 语句块并不是 Rust 编程的一贯方式**。在缺乏足够经验的前提下,直接在 `unsafe` 语句块内操作裸指针,非常容易把事情弄得很糟糕;比如,在不注意的情况下,我们很可能会意外地操作缓冲区以外的内存。
在这样的前提下,我们希望最小化 `unsafe ` 语句块的使用。使用 Rust 语言,我们能够将不安全操作将包装为一个安全的抽象模块。举个例子,我们可以创建一个 VGA 缓冲区类型,把所有的不安全语句封装起来,来确保从类型外部操作时,无法写出不安全的代码:通过这种方式,我们只需要最少的 `unsafe` 语句块来确保我们不破坏**内存安全**[memory safety](https://en.wikipedia.org/wiki/Memory_safety))。在下一篇文章中,我们将会创建这样的 VGA 缓冲区封装。 在这样的前提下,我们希望最小化 `unsafe` 语句块的使用。使用 Rust 语言,我们能够将不安全操作将包装为一个安全的抽象模块。举个例子,我们可以创建一个 VGA 缓冲区类型,把所有的不安全语句封装起来,来确保从类型外部操作时,无法写出不安全的代码:通过这种方式,我们只需要最少的 `unsafe` 语句块来确保我们不破坏**内存安全**[memory safety](https://en.wikipedia.org/wiki/Memory_safety))。在下一篇文章中,我们将会创建这样的 VGA 缓冲区封装。
## 启动内核 ## 启动内核
@@ -396,7 +398,7 @@ cargo install bootimage
### 在 QEMU 中启动内核 ### 在 QEMU 中启动内核
现在我们可以在虚拟机中启动内核了。为了在[ QEMU](https://www.qemu.org/) 中启动内核,我们使用下面的命令: 现在我们可以在虚拟机中启动内核了。为了在[QEMU](https://www.qemu.org/) 中启动内核,我们使用下面的命令:
```bash ```bash
> qemu-system-x86_64 -drive format=raw,file=target/x86_64-blog_os/debug/bootimage-blog_os.bin > qemu-system-x86_64 -drive format=raw,file=target/x86_64-blog_os/debug/bootimage-blog_os.bin