From a7cfc562e95b930c0963f6846a0775848ab1abeb Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 9 Apr 2023 19:49:35 +0200 Subject: [PATCH 01/13] Fix: Add back title and description for translated sites --- blog/config.toml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/blog/config.toml b/blog/config.toml index cdf6ee34..ca8230fb 100644 --- a/blog/config.toml +++ b/blog/config.toml @@ -51,6 +51,9 @@ translation_contributors = "With contributions from" word_separator = "and" # Chinese (simplified) +[languages.zh-CN] +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.zh-CN.translations] lang_name = "Chinese (simplified)" toc = "目录" @@ -66,6 +69,9 @@ translation_contributors = "With contributions from" word_separator = "和" # Chinese (traditional) +[languages.zh-TW] +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.zh-TW.translations] lang_name = "Chinese (traditional)" toc = "目錄" @@ -81,6 +87,9 @@ translation_contributors = "With contributions from" word_separator = "和" # Japanese +[languages.ja] +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.ja.translations] lang_name = "Japanese" toc = "目次" @@ -96,6 +105,9 @@ translation_contributors = "With contributions from" word_separator = "及び" # Persian +[languages.fa] +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.fa.translations] lang_name = "Persian" toc = "فهرست مطالب" @@ -111,6 +123,9 @@ translation_contributors = "With contributions from" word_separator = "و" # Russian +[languages.ru] +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.ru.translations] lang_name = "Russian" toc = "Содержание" @@ -126,6 +141,9 @@ translation_contributors = "With contributions from" word_separator = "и" # French +[languages.fr] +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.fr.translations] lang_name = "French" toc = "Table des matières" @@ -141,6 +159,9 @@ translation_contributors = "With contributions from" word_separator = "et" # Korean +[languages.ko] +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.ko.translations] lang_name = "Korean" toc = "목차" From a7f4647e73838a11520ff2899f71b15713a7a918 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 9 Apr 2023 19:50:58 +0200 Subject: [PATCH 02/13] Fix link syntax --- blog/content/edition-2/posts/02-minimal-rust-kernel/index.fa.md | 2 +- blog/content/edition-2/posts/02-minimal-rust-kernel/index.ja.md | 2 +- blog/content/edition-2/posts/02-minimal-rust-kernel/index.ko.md | 2 +- blog/content/edition-2/posts/12-async-await/index.ja.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.fa.md b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.fa.md index a4f9b94f..95422fba 100644 --- a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.fa.md +++ b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.fa.md @@ -323,7 +323,7 @@ build-std-features = ["compiler-builtins-mem"] در پشت صحنه، این پرچم [ویژگی `mem`] از کریت `compiler_builtins` را فعال می‌کند. اثرش این است که صفت `[no_mangle]#` بر روی [پیاده‌سازی `memcpy` و بقیه موارد] از کریت اعمال می‌شود، که آن‌ها در دسترس لینکر قرار می‌دهد. شایان ذکر است که این توابع در حال حاضر [بهینه نشده‌اند]، بنابراین ممکن است عملکرد آ‌ن‌ها در بهترین حالت نباشد، اما حداقل صحیح هستند. برای `x86_64` ، یک pull request باز برای [بهینه سازی این توابع با استفاده از دستورالعمل‌های خاص اسمبلی][memcpy rep movsb] وجود دارد. [ویژگی `mem`]: https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/Cargo.toml#L51-L52 -[پیاده‌سازی `memcpy` و بقیه موارد]: (https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/src/mem.rs#L12-L69) +[پیاده‌سازی `memcpy` و بقیه موارد]: https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/src/mem.rs#L12-L69 [بهینه نشده‌اند]: https://github.com/rust-lang/compiler-builtins/issues/339 [memcpy rep movsb]: https://github.com/rust-lang/compiler-builtins/pull/365 diff --git a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ja.md b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ja.md index deb3e1ac..0d2b3c42 100644 --- a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ja.md +++ b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ja.md @@ -317,7 +317,7 @@ build-std-features = ["compiler-builtins-mem"] このとき、裏で`compiler_builtins`クレートの[`mem`機能][`mem` feature]が有効化されています。これにより、このクレートの[`memcpy`などの実装][`memcpy` etc. implementations]に`#[no_mangle]`アトリビュートが適用され、リンカがこれらを利用できるようになっています。 [`mem` feature]: https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/Cargo.toml#L51-L52 -[`memcpy` etc. implementations]: (https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/src/mem.rs#L12-L69) +[`memcpy` etc. implementations]: https://github.com/rust-lang/compiler-builtins/blob/eff506cd49b637f1ab5931625a33cef7e91fbbf6/src/mem.rs#L12-L69 この変更をもって、私達のカーネルはコンパイラに必要とされているすべての関数の有効な実装を手に入れたので、コードがもっと複雑になっても変わらずコンパイルできるでしょう。 diff --git a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ko.md b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ko.md index b95aefe1..41b7b878 100644 --- a/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ko.md +++ b/blog/content/edition-2/posts/02-minimal-rust-kernel/index.ko.md @@ -99,7 +99,7 @@ UEFI 표준으로 동작하는 최신 기기들도 가상 BIOS를 지원하기 지난 포스트에서 우리는 `cargo`를 통해 freestanding 실행파일을 만들었었는데, 호스트 시스템의 운영체제에 따라 프로그램 실행 시작 지점의 이름 및 컴파일 인자들을 다르게 설정해야 했습니다. 이것은 `cargo`가 기본적으로 _호스트 시스템_ (여러 분이 실행 중인 컴퓨터 시스템) 을 목표로 빌드하기 때문이었습니다. 우리의 커널은 다른 운영체제 (예를 들어 Windows) 위에서 실행될 것이 아니기에, 호스트 시스템에 설정 값을 맞추는 대신에 우리가 명확히 정의한 _목표 시스템 (target system)_ 을 목표로 컴파일할 것입니다. ### Rust Nightly 설치하기 {#installing-rust-nightly} -Rust는 _stable_, _beta_ 그리고 _nightly_ 이렇게 세 가지의 채널을 통해 배포됩니다. Rust Book에 [세 채널들 간의 차이에 대해 잘 정리한 챕터]((https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#choo-choo-release-channels-and-riding-the-trains))가 있습니다. 운영체제를 빌드하기 위해서는 _nightly_ 채널에서만 제공하는 실험적인 기능들을 이용해야 하기에 _nightly_ 버전의 Rust를 설치하셔야 합니다. +Rust는 _stable_, _beta_ 그리고 _nightly_ 이렇게 세 가지의 채널을 통해 배포됩니다. Rust Book에 [세 채널들 간의 차이에 대해 잘 정리한 챕터](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#choo-choo-release-channels-and-riding-the-trains)가 있습니다. 운영체제를 빌드하기 위해서는 _nightly_ 채널에서만 제공하는 실험적인 기능들을 이용해야 하기에 _nightly_ 버전의 Rust를 설치하셔야 합니다. 여러 버전의 Rust 언어 설치 파일들을 관리할 때 [rustup]을 사용하는 것을 강력 추천합니다. rustup을 통해 nightly, beta 그리고 stable 컴파일러들을 모두 설치하고 업데이트할 수 있습니다. `rustup override set nightly` 명령어를 통해 현재 디렉토리에서 항상 nightly 버전의 Rust를 사용하도록 설정할 수 있습니다. `rust-toolchain`이라는 파일을 프로젝트 루트 디렉토리에 만들고 이 파일에 `nightly`라는 텍스트를 적어 놓아도 같은 효과를 볼 수 있습니다. `rustc --version` 명령어를 통해 현재 nightly 버전이 설치되어 있는지 확인할 수 있습니다 (출력되는 버전 넘버가 `-nightly`라는 텍스트로 끝나야 합니다). diff --git a/blog/content/edition-2/posts/12-async-await/index.ja.md b/blog/content/edition-2/posts/12-async-await/index.ja.md index 3941a628..ec44efe5 100644 --- a/blog/content/edition-2/posts/12-async-await/index.ja.md +++ b/blog/content/edition-2/posts/12-async-await/index.ja.md @@ -58,7 +58,7 @@ translation_contributors = ["asami-kawasaki", "Foo-x"] [コールスタック]: https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%BC%E3%83%AB%E3%82%B9%E3%82%BF%E3%83%83%E3%82%AF [コンテキスト・スイッチ (context switch)]: https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%82%B9%E3%82%A4%E3%83%83%E3%83%81 -コールスタックは非常に大きくなる可能性があるため、OSは通常、各タスクのスイッチでコールスタックの内容をバックアップする代わりに、各タスクに個別のコールスタックを設定します。このような独立したスタックを持つタスクは、[_thread of execution_](略して**スレッド**)と呼ばれます。タスクごとに独立したスタックを使用することで、コンテキスト・スイッチの際に保存する必要があるのはレジスタの内容だけになります(プログラム・カウンタとスタック・ポインタを含む)。この方法を取ることで、コンテキスト・スイッチの性能上のオーバーヘッドが最小限になります。これは、コンテキスト・スイッチが1秒間に100回も行われることがあるため、非常に重要なことです。 +コールスタックは非常に大きくなる可能性があるため、OSは通常、各タスクのスイッチでコールスタックの内容をバックアップする代わりに、各タスクに個別のコールスタックを設定します。このような独立したスタックを持つタスクは、[略して**スレッド**][_thread of execution_]と呼ばれます。タスクごとに独立したスタックを使用することで、コンテキスト・スイッチの際に保存する必要があるのはレジスタの内容だけになります(プログラム・カウンタとスタック・ポインタを含む)。この方法を取ることで、コンテキスト・スイッチの性能上のオーバーヘッドが最小限になります。これは、コンテキスト・スイッチが1秒間に100回も行われることがあるため、非常に重要なことです。 [_thread of execution_]: https://ja.wikipedia.org/wiki/%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89_(%E3%82%B3%E3%83%B3%E3%83%94%E3%83%A5%E3%83%BC%E3%82%BF) From d2c6b281c8b5b642bccae9999f3a247ebcee7f07 Mon Sep 17 00:00:00 2001 From: GINTOAHC Date: Mon, 17 Apr 2023 18:14:39 +0800 Subject: [PATCH 03/13] fix(translation zh-TW): typo --- .../edition-2/posts/01-freestanding-rust-binary/index.zh-TW.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.zh-TW.md b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.zh-TW.md index 4494d478..09143037 100644 --- a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.zh-TW.md +++ b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.zh-TW.md @@ -383,7 +383,7 @@ error: linking with `cc` failed: exit code: 1 cargo rustc -- -C link-args="-e __start" ``` -`-e` 表示肉口點的函式名稱,然後由於 macOS 上所有的函式都會加上前綴 `_`,我們需要設置入口點為 `__start` 而不是 `_start`。 +`-e` 表示入口點的函式名稱,然後由於 macOS 上所有的函式都會加上前綴 `_`,我們需要設置入口點為 `__start` 而不是 `_start`。 接下來會出現另一個連結器錯誤: From 739d9e1a3cd63f4d4367d66241c4b6bf0ebf2709 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 29 Apr 2023 12:30:08 +0200 Subject: [PATCH 04/13] Update 'Heap Allocation' post to remove `alloc_error_handler` The unstable feature was removed. Allocation errors are reported as normal panics now. --- .../posts/10-heap-allocation/index.md | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/blog/content/edition-2/posts/10-heap-allocation/index.md b/blog/content/edition-2/posts/10-heap-allocation/index.md index 75dfdbf4..d3ba5094 100644 --- a/blog/content/edition-2/posts/10-heap-allocation/index.md +++ b/blog/content/edition-2/posts/10-heap-allocation/index.md @@ -223,18 +223,12 @@ The reason that the `alloc` crate is disabled by default in `#[no_std]` crates i ``` error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait. - -error: `#[alloc_error_handler]` function required, but not found ``` -The first error occurs because the `alloc` crate requires a heap allocator, which is an object that provides the `allocate` and `deallocate` functions. In Rust, heap allocators are described by the [`GlobalAlloc`] trait, which is mentioned in the error message. To set the heap allocator for the crate, the `#[global_allocator]` attribute must be applied to a `static` variable that implements the `GlobalAlloc` trait. - -The second error occurs because calls to `allocate` can fail, most commonly when there is no more memory available. Our program must be able to react to this case, which is what the `#[alloc_error_handler]` function is for. +The error occurs because the `alloc` crate requires a heap allocator, which is an object that provides the `allocate` and `deallocate` functions. In Rust, heap allocators are described by the [`GlobalAlloc`] trait, which is mentioned in the error message. To set the heap allocator for the crate, the `#[global_allocator]` attribute must be applied to a `static` variable that implements the `GlobalAlloc` trait. [`GlobalAlloc`]: https://doc.rust-lang.org/alloc/alloc/trait.GlobalAlloc.html -We will describe these traits and attributes in detail in the following sections. - ### The `GlobalAlloc` Trait The [`GlobalAlloc`] trait defines the functions that a heap allocator must provide. The trait is special because it is almost never used directly by the programmer. Instead, the compiler will automatically insert the appropriate calls to the trait methods when using the allocation and collection types of `alloc`. @@ -329,32 +323,7 @@ static ALLOCATOR: Dummy = Dummy; Since the `Dummy` allocator is a [zero-sized type], we don't need to specify any fields in the initialization expression. -When we now try to compile it, the first error should be gone. Let's fix the remaining second error: - -``` -error: `#[alloc_error_handler]` function required, but not found -``` - -### The `#[alloc_error_handler]` Attribute - -As we learned when discussing the `GlobalAlloc` trait, the `alloc` function can signal an allocation error by returning a null pointer. The question is: how should the Rust runtime react to such an allocation failure? This is where the `#[alloc_error_handler]` attribute comes in. It specifies a function that is called when an allocation error occurs, similar to how our panic handler is called when a panic occurs. - -Let's add such a function to fix the compilation error: - -```rust -// in src/lib.rs - -#![feature(alloc_error_handler)] // at the top of the file - -#[alloc_error_handler] -fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! { - panic!("allocation error: {:?}", layout) -} -``` - -The `alloc_error_handler` function is still unstable, so we need a feature gate to enable it. The function receives a single argument: the `Layout` instance that was passed to `alloc` when the allocation failure occurred. There's nothing we can do to resolve the failure, so we just panic with a message that contains the `Layout` instance. - -With this function, the compilation errors should be fixed. Now we can use the allocation and collection types of `alloc`. For example, we can use a [`Box`] to allocate a value on the heap: +With this static, the compilation errors should be fixed. Now we can use the allocation and collection types of `alloc`. For example, we can use a [`Box`] to allocate a value on the heap: [`Box`]: https://doc.rust-lang.org/alloc/boxed/struct.Box.html @@ -380,11 +349,11 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! { Note that we need to specify the `extern crate alloc` statement in our `main.rs` too. This is required because the `lib.rs` and `main.rs` parts are treated as separate crates. However, we don't need to create another `#[global_allocator]` static because the global allocator applies to all crates in the project. In fact, specifying an additional allocator in another crate would be an error. -When we run the above code, we see that our `alloc_error_handler` function is called: +When we run the above code, we see that a panic occurs: ![QEMU printing "panicked at `allocation error: Layout { size_: 4, align_: 4 }, src/lib.rs:89:5"](qemu-dummy-output.png) -The error handler is called because the `Box::new` function implicitly calls the `alloc` function of the global allocator. Our dummy allocator always returns a null pointer, so every allocation fails. To fix this, we need to create an allocator that actually returns usable memory. +The panic occurs because the `Box::new` function implicitly calls the `alloc` function of the global allocator. Our dummy allocator always returns a null pointer, so every allocation fails. To fix this, we need to create an allocator that actually returns usable memory. ## Creating a Kernel Heap From 5d633005122d2805ecb8f3fdd3050317aa5b88be Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 29 Apr 2023 12:30:50 +0200 Subject: [PATCH 05/13] Fix markdown syntax --- blog/content/edition-2/posts/10-heap-allocation/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/content/edition-2/posts/10-heap-allocation/index.md b/blog/content/edition-2/posts/10-heap-allocation/index.md index d3ba5094..41ba489e 100644 --- a/blog/content/edition-2/posts/10-heap-allocation/index.md +++ b/blog/content/edition-2/posts/10-heap-allocation/index.md @@ -214,7 +214,7 @@ Since we are compiling for a custom target, we can't use the precompiled version [unstable] build-std = ["core", "compiler_builtins", "alloc"] -```` +``` Now the compiler will recompile and include the `alloc` crate in our kernel. From e6b507e6d20f0bb55eff59f270922ea607dbe672 Mon Sep 17 00:00:00 2001 From: Wilfred Mallawa Date: Thu, 4 May 2023 14:51:45 +1000 Subject: [PATCH 06/13] posts/06-double-faults/index: fixup deprecated fn The code segment from the example uses the newer function whilst the text segment refers to the old/deprecated `set_cs` fn. Let's fix that. Signed-off-by: Wilfred Mallawa --- blog/content/edition-2/posts/06-double-faults/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/content/edition-2/posts/06-double-faults/index.md b/blog/content/edition-2/posts/06-double-faults/index.md index 6cc1a0d4..d65ff5ce 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.md +++ b/blog/content/edition-2/posts/06-double-faults/index.md @@ -374,9 +374,9 @@ pub fn init() { } ``` -We reload the code segment register using [`set_cs`] and load the TSS using [`load_tss`]. The functions are marked as `unsafe`, so we need an `unsafe` block to invoke them. The reason is that it might be possible to break memory safety by loading invalid selectors. +We reload the code segment register using [`CS::set_reg`] and load the TSS using [`load_tss`]. The functions are marked as `unsafe`, so we need an `unsafe` block to invoke them. The reason is that it might be possible to break memory safety by loading invalid selectors. -[`set_cs`]: https://docs.rs/x86_64/0.14.2/x86_64/instructions/segmentation/fn.set_cs.html +[`CS::set_reg`]: https://docs.rs/x86_64/0.14.5/x86_64/instructions/segmentation/struct.CS.html#method.set_reg [`load_tss`]: https://docs.rs/x86_64/0.14.2/x86_64/instructions/tables/fn.load_tss.html Now that we have loaded a valid TSS and interrupt stack table, we can set the stack index for our double fault handler in the IDT: From 5e88b86d1edbe697ee5622964dbf1f0c18d53712 Mon Sep 17 00:00:00 2001 From: Demelari <9827644+Firenezz@users.noreply.github.com> Date: Fri, 5 May 2023 13:32:23 -0400 Subject: [PATCH 07/13] Fix some typos --- .../edition-2/posts/01-freestanding-rust-binary/index.fr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md index 838f2691..67a763a4 100644 --- a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md +++ b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md @@ -52,7 +52,7 @@ Par défaut, tous les crates Rust relient la [bibliothèque standard], qui dépe [bibliothèque standard]: https://doc.rust-lang.org/std/ [attribut `no std`]: https://doc.rust-lang.org/1.30.0/book/first-edition/using-rust-without-the-standard-library.html -Nous commencons par créer un nouveau projet d'application cargo. La manière la plus simple de faire est avec la ligne de commande : +Nous commençons par créer un nouveau projet d'application cargo. La manière la plus simple de faire est avec la ligne de commande : ``` cargo new blog_os --bin --edition 2018 @@ -75,7 +75,7 @@ Le fichier `Cargo.toml` contient la configuration de la crate, par exemple le no ### L'Attribut `no_std` -Pour l'instant, notre crate relie la bilbiothèque standard implicitement. Désactivons cela en ajoutant l'[attribut `no std`] : +Pour l'instant, notre crate relie la bibliothèque standard implicitement. Désactivons cela en ajoutant l'[attribut `no std`] : ```rust // main.rs From e0464fbd44404f148fcda46bc7f7a4a048cc4658 Mon Sep 17 00:00:00 2001 From: Demelari <9827644+Firenezz@users.noreply.github.com> Date: Fri, 5 May 2023 13:58:55 -0400 Subject: [PATCH 08/13] =?UTF-8?q?Fix=20and=20use=20"autoport=C3=A9"=20inst?= =?UTF-8?q?ead=20of=20"autonome"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edition-2/posts/01-freestanding-rust-binary/index.fr.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md index 67a763a4..0599a003 100644 --- a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md +++ b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md @@ -1,5 +1,5 @@ +++ -title = "Un binaire Rust autonome" +title = "Un binaire Rust autoporté" weight = 1 path = "fr/freestanding-rust-binary" date = 2018-02-10 @@ -47,7 +47,7 @@ Cet article décrit les étapes nécessaires pour créer un exécutable Rust aut ## Désactiver la Bibliothèque Standard -Par défaut, tous les crates Rust relient la [bibliothèque standard], qui dépend du système d'exploitation pour les fonctionnalités telles que les fils d'exécution, les fichiers ou le réseau. Elle dépend aussi de la bibliothèque standard de C `libc`, qui intéragit de près avec les services de l'OS. Comme notre plan est d'écrire un système d'exploitation, nous ne pouvons pas utiliser des bibliothèques dépendant de l'OS. Nous devons donc désactiver l'inclusion automatique de la bibliothèque standard en utilisant l'[attribut `no std`]. +Par défaut, toutes les crates Rust sont liées à la bibliothèque standard, qui repose sur les fonctionnalités du système d’exploitation telles que les threads, les fichiers et la connectivité réseau. Elle est également liée à la bibliothèque standard C, libc, qui interagit étroitement avec les services fournis par l'OS. Comme notre plan est d'écrire un système d'exploitation, nous ne pouvons pas utiliser des bibliothèques dépendant de l'OS. Nous devons donc désactiver l'inclusion automatique de la bibliothèque standard en utilisant l'[attribut `no std`]. [bibliothèque standard]: https://doc.rust-lang.org/std/ [attribut `no std`]: https://doc.rust-lang.org/1.30.0/book/first-edition/using-rust-without-the-standard-library.html @@ -58,7 +58,7 @@ Nous commençons par créer un nouveau projet d'application cargo. La manière l cargo new blog_os --bin --edition 2018 ``` -J'ai nommé le projet `blog_os`, mais vous pouvez bien-sûr choisir le nom qu'il vous convient. Le flag `--bin` indique que nous voulons créer un exécutable (contrairement à une bibliothèque) et le flag `--edition 2018` indique que nous voulons utiliser l'[édition 2018] de Rust pour notre crate. Quand nous lançons la commande, cargo crée la structure de répertoire suivante pour nous : +J'ai nommé le projet `blog_os`, mais vous pouvez bien sûr choisir le nom qu'il vous convient. Le flag `--bin` indique que nous voulons créer un exécutable (contrairement à une bibliothèque) et le flag `--edition 2018` indique que nous voulons utiliser l'[édition 2018] de Rust pour notre crate. Quand nous lançons la commande, cargo crée la structure de répertoire suivante pour nous : [édition 2018]: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/index.html From 0b6b053c543d24235d45f0a380d02fc57d1d878e Mon Sep 17 00:00:00 2001 From: Demelari <9827644+Firenezz@users.noreply.github.com> Date: Fri, 5 May 2023 14:04:49 -0400 Subject: [PATCH 09/13] =?UTF-8?q?Swap=20"bien-s=C3=BBr"=20for=20"bien=20s?= =?UTF-8?q?=C3=BBr"=20and=20"=C3=A9videmment"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edition-2/posts/01-freestanding-rust-binary/index.fr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md index 0599a003..2e132e99 100644 --- a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md +++ b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md @@ -29,7 +29,7 @@ Ce blog est développé sur [GitHub]. Si vous avez un problème ou une question, ## Introduction Pour écrire un noyau de système d'exploitation, nous avons besoin d'un code qui ne dépend pas de fonctionnalités de système d'exploitation. Cela signifie que nous ne pouvons pas utiliser les fils d'exécution, les fichiers, la mémoire sur le tas, le réseau, les nombres aléatoires, la sortie standard ou tout autre fonctionnalité nécessitant une abstraction du système d'exploitation ou un matériel spécifique. Cela a du sens, étant donné que nous essayons d'écrire notre propre OS et nos propres pilotes. -Cela signifie que nous ne pouvons pas utiliser la majeure partie de la [bibliothèque standard de Rust]. Il y a néanmoins beaucoup de fonctionnalités de Rust que nous _pouvons_ utiliser. Par exemple, nous pouvons utiliser les [iterators], les [closures], le [pattern matching], l'[option] et le [result], le [string formatting], et bien-sûr l'[ownership system]. Ces fonctionnalités permettent l'écriture d'un noyau d'une façon expressive et haut-niveau sans se soucier des [comportements indéfinis] ou de la [sécurité de la mémoire]. +Cela signifie que nous ne pouvons pas utiliser la majeure partie de la [bibliothèque standard de Rust]. Il y a néanmoins beaucoup de fonctionnalités de Rust que nous _pouvons_ utiliser. Par exemple, nous pouvons utiliser les [iterators], les [closures], le [pattern matching], l'[option] et le [result], le [string formatting], et bien sûr l'[ownership system]. Ces fonctionnalités permettent l'écriture d'un noyau d'une façon expressive et haut-niveau sans se soucier des [comportements indéfinis] ou de la [sécurité de la mémoire]. [option]: https://doc.rust-lang.org/core/option/ [result]:https://doc.rust-lang.org/core/result/ @@ -58,7 +58,7 @@ Nous commençons par créer un nouveau projet d'application cargo. La manière l cargo new blog_os --bin --edition 2018 ``` -J'ai nommé le projet `blog_os`, mais vous pouvez bien sûr choisir le nom qu'il vous convient. Le flag `--bin` indique que nous voulons créer un exécutable (contrairement à une bibliothèque) et le flag `--edition 2018` indique que nous voulons utiliser l'[édition 2018] de Rust pour notre crate. Quand nous lançons la commande, cargo crée la structure de répertoire suivante pour nous : +J'ai nommé le projet `blog_os`, mais vous pouvez évidemment choisir le nom qu'il vous convient. Le flag `--bin` indique que nous voulons créer un exécutable (contrairement à une bibliothèque) et le flag `--edition 2018` indique que nous voulons utiliser l'[édition 2018] de Rust pour notre crate. Quand nous lançons la commande, cargo crée la structure de répertoire suivante pour nous : [édition 2018]: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/index.html From 685f55dd317c87c92c8cde7cc9d399e262784ff0 Mon Sep 17 00:00:00 2001 From: Demelari <9827644+Firenezz@users.noreply.github.com> Date: Fri, 5 May 2023 14:40:12 -0400 Subject: [PATCH 10/13] =?UTF-8?q?Keep=20"fils=20d'ex=C3=A9cution"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edition-2/posts/01-freestanding-rust-binary/index.fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md index 2e132e99..620e28f8 100644 --- a/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md +++ b/blog/content/edition-2/posts/01-freestanding-rust-binary/index.fr.md @@ -47,7 +47,7 @@ Cet article décrit les étapes nécessaires pour créer un exécutable Rust aut ## Désactiver la Bibliothèque Standard -Par défaut, toutes les crates Rust sont liées à la bibliothèque standard, qui repose sur les fonctionnalités du système d’exploitation telles que les threads, les fichiers et la connectivité réseau. Elle est également liée à la bibliothèque standard C, libc, qui interagit étroitement avec les services fournis par l'OS. Comme notre plan est d'écrire un système d'exploitation, nous ne pouvons pas utiliser des bibliothèques dépendant de l'OS. Nous devons donc désactiver l'inclusion automatique de la bibliothèque standard en utilisant l'[attribut `no std`]. +Par défaut, toutes les crates Rust sont liées à la bibliothèque standard, qui repose sur les fonctionnalités du système d’exploitation telles que les fils d'exécution, les fichiers et la connectivité réseau. Elle est également liée à la bibliothèque standard C `libc`, qui interagit étroitement avec les services fournis par l'OS. Comme notre plan est d'écrire un système d'exploitation, nous ne pouvons pas utiliser des bibliothèques dépendant de l'OS. Nous devons donc désactiver l'inclusion automatique de la bibliothèque standard en utilisant l'[attribut `no std`]. [bibliothèque standard]: https://doc.rust-lang.org/std/ [attribut `no std`]: https://doc.rust-lang.org/1.30.0/book/first-edition/using-rust-without-the-standard-library.html From 06dd5edb3ffd0104d86da590f1d86540c338aacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20Lundstr=C3=B6m?= Date: Sat, 20 May 2023 23:12:33 +0300 Subject: [PATCH 11/13] Fix panic caused by misaligned pointer dereference --- blog/content/edition-2/posts/06-double-faults/index.fa.md | 2 +- blog/content/edition-2/posts/06-double-faults/index.ja.md | 2 +- blog/content/edition-2/posts/06-double-faults/index.ko.md | 2 +- blog/content/edition-2/posts/06-double-faults/index.md | 2 +- blog/content/edition-2/posts/06-double-faults/index.zh-CN.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blog/content/edition-2/posts/06-double-faults/index.fa.md b/blog/content/edition-2/posts/06-double-faults/index.fa.md index 4eeba4fa..151a0624 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.fa.md +++ b/blog/content/edition-2/posts/06-double-faults/index.fa.md @@ -49,7 +49,7 @@ pub extern "C" fn _start() -> ! { // trigger a page fault unsafe { - *(0xdeadbeef as *mut u64) = 42; + *(0xdeadbeef as *mut u8) = 42; }; // as before diff --git a/blog/content/edition-2/posts/06-double-faults/index.ja.md b/blog/content/edition-2/posts/06-double-faults/index.ja.md index 89c2c4aa..f640519d 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.ja.md +++ b/blog/content/edition-2/posts/06-double-faults/index.ja.md @@ -45,7 +45,7 @@ pub extern "C" fn _start() -> ! { // ページフォルトを起こす unsafe { - *(0xdeadbeef as *mut u64) = 42; + *(0xdeadbeef as *mut u8) = 42; }; // 前回同様 diff --git a/blog/content/edition-2/posts/06-double-faults/index.ko.md b/blog/content/edition-2/posts/06-double-faults/index.ko.md index 80954eec..3b549fc2 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.ko.md +++ b/blog/content/edition-2/posts/06-double-faults/index.ko.md @@ -48,7 +48,7 @@ pub extern "C" fn _start() -> ! { // 페이지 폴트 일으키기 unsafe { - *(0xdeadbeef as *mut u64) = 42; + *(0xdeadbeef as *mut u8) = 42; }; // 이전과 동일 diff --git a/blog/content/edition-2/posts/06-double-faults/index.md b/blog/content/edition-2/posts/06-double-faults/index.md index 6cc1a0d4..8d3c419f 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.md +++ b/blog/content/edition-2/posts/06-double-faults/index.md @@ -42,7 +42,7 @@ pub extern "C" fn _start() -> ! { // trigger a page fault unsafe { - *(0xdeadbeef as *mut u64) = 42; + *(0xdeadbeef as *mut u8) = 42; }; // as before diff --git a/blog/content/edition-2/posts/06-double-faults/index.zh-CN.md b/blog/content/edition-2/posts/06-double-faults/index.zh-CN.md index 8881c0ec..5cc089c7 100644 --- a/blog/content/edition-2/posts/06-double-faults/index.zh-CN.md +++ b/blog/content/edition-2/posts/06-double-faults/index.zh-CN.md @@ -47,7 +47,7 @@ pub extern "C" fn _start() -> ! { // trigger a page fault unsafe { - *(0xdeadbeef as *mut u64) = 42; + *(0xdeadbeef as *mut u8) = 42; }; // as before From cfd31a977d65ee838abe1190f3a1aa0baf7b2444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20Lundstr=C3=B6m?= Date: Wed, 31 May 2023 17:14:43 +0300 Subject: [PATCH 12/13] Repeat previous for post-08 --- .../edition-2/posts/08-paging-introduction/index.fa.md | 4 ++-- .../edition-2/posts/08-paging-introduction/index.ja.md | 4 ++-- blog/content/edition-2/posts/08-paging-introduction/index.md | 4 ++-- .../edition-2/posts/08-paging-introduction/index.zh-CN.md | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/blog/content/edition-2/posts/08-paging-introduction/index.fa.md b/blog/content/edition-2/posts/08-paging-introduction/index.fa.md index 27b0714e..a196d794 100644 --- a/blog/content/edition-2/posts/08-paging-introduction/index.fa.md +++ b/blog/content/edition-2/posts/08-paging-introduction/index.fa.md @@ -322,7 +322,7 @@ pub extern "C" fn _start() -> ! { blog_os::init(); // new - let ptr = 0xdeadbeaf as *mut u32; + let ptr = 0xdeadbeaf as *mut u8; unsafe { *ptr = 42; } // as before @@ -347,7 +347,7 @@ pub extern "C" fn _start() -> ! { ```rust // Note: The actual address might be different for you. Use the address that // your page fault handler reports. -let ptr = 0x2031b2 as *mut u32; +let ptr = 0x2031b2 as *mut u8; // read from a code page unsafe { let x = *ptr; } diff --git a/blog/content/edition-2/posts/08-paging-introduction/index.ja.md b/blog/content/edition-2/posts/08-paging-introduction/index.ja.md index 03be001c..f938067a 100644 --- a/blog/content/edition-2/posts/08-paging-introduction/index.ja.md +++ b/blog/content/edition-2/posts/08-paging-introduction/index.ja.md @@ -329,7 +329,7 @@ pub extern "C" fn _start() -> ! { blog_os::init(); // ここを追加 - let ptr = 0xdeadbeaf as *mut u32; + let ptr = 0xdeadbeaf as *mut u8; unsafe { *ptr = 42; } // ここはこれまでと同じ @@ -354,7 +354,7 @@ pub extern "C" fn _start() -> ! { ```rust // 注意:実際のアドレスは個々人で違うかもしれません。 // あなたのページフォルトハンドラが報告した値を使ってください。 -let ptr = 0x2031b2 as *mut u32; +let ptr = 0x2031b2 as *mut u8; // コードページから読み込む unsafe { let x = *ptr; } diff --git a/blog/content/edition-2/posts/08-paging-introduction/index.md b/blog/content/edition-2/posts/08-paging-introduction/index.md index ab1e8941..10bff5b5 100644 --- a/blog/content/edition-2/posts/08-paging-introduction/index.md +++ b/blog/content/edition-2/posts/08-paging-introduction/index.md @@ -316,7 +316,7 @@ pub extern "C" fn _start() -> ! { blog_os::init(); // new - let ptr = 0xdeadbeaf as *mut u32; + let ptr = 0xdeadbeaf as *mut u8; unsafe { *ptr = 42; } // as before @@ -341,7 +341,7 @@ We see that the current instruction pointer is `0x2031b2`, so we know that this ```rust // Note: The actual address might be different for you. Use the address that // your page fault handler reports. -let ptr = 0x2031b2 as *mut u32; +let ptr = 0x2031b2 as *mut u8; // read from a code page unsafe { let x = *ptr; } diff --git a/blog/content/edition-2/posts/08-paging-introduction/index.zh-CN.md b/blog/content/edition-2/posts/08-paging-introduction/index.zh-CN.md index f535bfb9..a3f60a8e 100644 --- a/blog/content/edition-2/posts/08-paging-introduction/index.zh-CN.md +++ b/blog/content/edition-2/posts/08-paging-introduction/index.zh-CN.md @@ -325,7 +325,7 @@ pub extern "C" fn _start() -> ! { blog_os::init(); // new - let ptr = 0xdeadbeaf as *mut u32; + let ptr = 0xdeadbeaf as *mut u8; unsafe { *ptr = 42; } // as before @@ -350,7 +350,7 @@ pub extern "C" fn _start() -> ! { ```rust // Note: The actual address might be different for you. Use the address that // your page fault handler reports. -let ptr = 0x2031b2 as *mut u32; +let ptr = 0x2031b2 as *mut u8; // read from a code page unsafe { let x = *ptr; } From f0fe3929abc14b7054673d6e36e482476394222b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 25 Jun 2023 14:12:40 +0200 Subject: [PATCH 13/13] Fix: Use correct category ID for comment threads of translated posts --- blog/templates/snippets.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blog/templates/snippets.html b/blog/templates/snippets.html index e722ecc4..e5cae6c4 100644 --- a/blog/templates/snippets.html +++ b/blog/templates/snippets.html @@ -13,9 +13,11 @@ {% macro giscus(search_term, lang) %} {% if lang != "en" %} {% set category = "Post Comments (translated)" %} + {% set category_id = "DIC_kwDOAlvePc4CPg4c" %} {% set category_path = "post-comments-translated" %} {% else %} {% set category = "Post Comments" %} + {% set category_id = "MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1" %} {% set category_path = "post-comments" %} {% endif %} @@ -36,7 +38,7 @@ data-repo="phil-opp/blog_os" data-repo-id="MDEwOlJlcG9zaXRvcnkzOTU3NTEwMQ==" data-category="{{ category }}" - data-category-id="MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMzMDE4OTg1" + data-category-id="{{ category_id }}" {% if search_term is number %} data-mapping="number" {% else %}