From 4f0fa4e1b3332f940902f032087327e61c802799 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 27 Apr 2017 12:37:11 +0200 Subject: [PATCH 01/42] =?UTF-8?q?Pluralize=20content=20folder=20names=20(?= =?UTF-8?q?=E2=80=9Cpost=E2=80=9D=20->=20=E2=80=9Cposts=E2=80=9D,=20etc.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cross-compile-binutils.md | 0 .../cross-compile-libcore.md | 0 .../handling-exceptions-with-naked-fns.html | 0 .../{additional-resource => additional-resources}/set-up-gdb.md | 0 blog/content/{page => pages}/contact.md | 0 blog/content/{post => posts}/01-multiboot-kernel.md | 0 blog/content/{post => posts}/02-entering-longmode.md | 0 blog/content/{post => posts}/03-set-up-rust.md | 0 blog/content/{post => posts}/04-printing-to-screen.md | 0 blog/content/{post => posts}/05-allocating-frames.md | 0 blog/content/{post => posts}/06-page-tables.md | 0 blog/content/{post => posts}/07-remap-the-kernel.md | 0 blog/content/{post => posts}/08-kernel-heap.md | 0 blog/content/{post => posts}/09-handling-exceptions.md | 0 blog/content/{post => posts}/10-double-faults.md | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename blog/content/{additional-resource => additional-resources}/cross-compile-binutils.md (100%) rename blog/content/{additional-resource => additional-resources}/cross-compile-libcore.md (100%) rename blog/content/{additional-resource => additional-resources}/handling-exceptions-with-naked-fns.html (100%) rename blog/content/{additional-resource => additional-resources}/set-up-gdb.md (100%) rename blog/content/{page => pages}/contact.md (100%) rename blog/content/{post => posts}/01-multiboot-kernel.md (100%) rename blog/content/{post => posts}/02-entering-longmode.md (100%) rename blog/content/{post => posts}/03-set-up-rust.md (100%) rename blog/content/{post => posts}/04-printing-to-screen.md (100%) rename blog/content/{post => posts}/05-allocating-frames.md (100%) rename blog/content/{post => posts}/06-page-tables.md (100%) rename blog/content/{post => posts}/07-remap-the-kernel.md (100%) rename blog/content/{post => posts}/08-kernel-heap.md (100%) rename blog/content/{post => posts}/09-handling-exceptions.md (100%) rename blog/content/{post => posts}/10-double-faults.md (100%) diff --git a/blog/content/additional-resource/cross-compile-binutils.md b/blog/content/additional-resources/cross-compile-binutils.md similarity index 100% rename from blog/content/additional-resource/cross-compile-binutils.md rename to blog/content/additional-resources/cross-compile-binutils.md diff --git a/blog/content/additional-resource/cross-compile-libcore.md b/blog/content/additional-resources/cross-compile-libcore.md similarity index 100% rename from blog/content/additional-resource/cross-compile-libcore.md rename to blog/content/additional-resources/cross-compile-libcore.md diff --git a/blog/content/additional-resource/handling-exceptions-with-naked-fns.html b/blog/content/additional-resources/handling-exceptions-with-naked-fns.html similarity index 100% rename from blog/content/additional-resource/handling-exceptions-with-naked-fns.html rename to blog/content/additional-resources/handling-exceptions-with-naked-fns.html diff --git a/blog/content/additional-resource/set-up-gdb.md b/blog/content/additional-resources/set-up-gdb.md similarity index 100% rename from blog/content/additional-resource/set-up-gdb.md rename to blog/content/additional-resources/set-up-gdb.md diff --git a/blog/content/page/contact.md b/blog/content/pages/contact.md similarity index 100% rename from blog/content/page/contact.md rename to blog/content/pages/contact.md diff --git a/blog/content/post/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel.md similarity index 100% rename from blog/content/post/01-multiboot-kernel.md rename to blog/content/posts/01-multiboot-kernel.md diff --git a/blog/content/post/02-entering-longmode.md b/blog/content/posts/02-entering-longmode.md similarity index 100% rename from blog/content/post/02-entering-longmode.md rename to blog/content/posts/02-entering-longmode.md diff --git a/blog/content/post/03-set-up-rust.md b/blog/content/posts/03-set-up-rust.md similarity index 100% rename from blog/content/post/03-set-up-rust.md rename to blog/content/posts/03-set-up-rust.md diff --git a/blog/content/post/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen.md similarity index 100% rename from blog/content/post/04-printing-to-screen.md rename to blog/content/posts/04-printing-to-screen.md diff --git a/blog/content/post/05-allocating-frames.md b/blog/content/posts/05-allocating-frames.md similarity index 100% rename from blog/content/post/05-allocating-frames.md rename to blog/content/posts/05-allocating-frames.md diff --git a/blog/content/post/06-page-tables.md b/blog/content/posts/06-page-tables.md similarity index 100% rename from blog/content/post/06-page-tables.md rename to blog/content/posts/06-page-tables.md diff --git a/blog/content/post/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel.md similarity index 100% rename from blog/content/post/07-remap-the-kernel.md rename to blog/content/posts/07-remap-the-kernel.md diff --git a/blog/content/post/08-kernel-heap.md b/blog/content/posts/08-kernel-heap.md similarity index 100% rename from blog/content/post/08-kernel-heap.md rename to blog/content/posts/08-kernel-heap.md diff --git a/blog/content/post/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions.md similarity index 100% rename from blog/content/post/09-handling-exceptions.md rename to blog/content/posts/09-handling-exceptions.md diff --git a/blog/content/post/10-double-faults.md b/blog/content/posts/10-double-faults.md similarity index 100% rename from blog/content/post/10-double-faults.md rename to blog/content/posts/10-double-faults.md From 9940a598ab16519e514291057baa5000706304bd Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 27 Apr 2017 12:54:34 +0200 Subject: [PATCH 02/42] Create new config.toml for gutenberg --- blog/config.toml | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/blog/config.toml b/blog/config.toml index 75f944ef..0e23b80a 100644 --- a/blog/config.toml +++ b/blog/config.toml @@ -1,29 +1,13 @@ -baseurl = "http://os.phil-opp.com/" -languageCode = "en-us" title = "Writing an OS in Rust" -rssURI = "atom.xml" -copyright = "© 2016. All rights reserved." +description = "test" +base_url = "https://os.phil-opp.com.com" -PygmentsCodeFences = true -pygmentsuseclasses = true +highlight_code = true +highlight_theme = "monokai" +insert_anchor_links = true +generate_rss = true -uglyurls = true - -disableKinds = ["section", "taxonomy", "taxonomyTerm"] - -[author] - name = "Philipp Oppermann" - email = "dev@phil-opp.com" - -[params] - subtitle = "Philipp Oppermann's blog" - date_format = "Jan 2, 2006" - -[permalinks] - post = "/:slug.html" - old-posts = "/:slug.html" - additional-resource = "/:filename.html" - page = "/:filename.html" - -[blackfriday] - plainIDAnchors = true +[extra] +# Put all your custom variables here +subtitle = "Philipp Oppermann's blog" +author = { name = "Philipp Oppermann" } From f5255419695fb58b13dd600fa245131101a9ee7e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 27 Apr 2017 12:44:41 +0200 Subject: [PATCH 03/42] Fix front matter: Add description field and set slug --- blog/content/posts/01-multiboot-kernel.md | 3 ++- blog/content/posts/02-entering-longmode.md | 3 ++- blog/content/posts/03-set-up-rust.md | 2 ++ blog/content/posts/04-printing-to-screen.md | 2 ++ blog/content/posts/05-allocating-frames.md | 2 ++ blog/content/posts/06-page-tables.md | 3 ++- blog/content/posts/07-remap-the-kernel.md | 2 ++ blog/content/posts/08-kernel-heap.md | 2 ++ blog/content/posts/09-handling-exceptions.md | 2 ++ blog/content/posts/10-double-faults.md | 2 ++ 10 files changed, 20 insertions(+), 3 deletions(-) diff --git a/blog/content/posts/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel.md index f73171df..7fd37f7c 100644 --- a/blog/content/posts/01-multiboot-kernel.md +++ b/blog/content/posts/01-multiboot-kernel.md @@ -1,6 +1,7 @@ +++ title = "A minimal x86 kernel" -slug = "multiboot-kernel" +description = "" +url = "multiboot-kernel" date = "2015-08-18" aliases = [ "/2015/08/18/multiboot-kernel/", diff --git a/blog/content/posts/02-entering-longmode.md b/blog/content/posts/02-entering-longmode.md index 4c2e23bb..a8852153 100644 --- a/blog/content/posts/02-entering-longmode.md +++ b/blog/content/posts/02-entering-longmode.md @@ -1,6 +1,7 @@ +++ title = "Entering Long Mode" -slug = "entering-longmode" +description = "" +url = "entering-longmode" date = "2015-08-25" updated = "2015-10-29" aliases = [ diff --git a/blog/content/posts/03-set-up-rust.md b/blog/content/posts/03-set-up-rust.md index f184fc79..21e445cb 100644 --- a/blog/content/posts/03-set-up-rust.md +++ b/blog/content/posts/03-set-up-rust.md @@ -1,5 +1,7 @@ +++ title = "Set Up Rust" +description = "" +url = "set-up-rust" date = "2015-09-02" updated = "2017-04-12" aliases = [ diff --git a/blog/content/posts/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen.md index 90513b89..098ee121 100644 --- a/blog/content/posts/04-printing-to-screen.md +++ b/blog/content/posts/04-printing-to-screen.md @@ -1,5 +1,7 @@ +++ title = "Printing to Screen" +description = "" +slug = "printing-to-screen" date = "2015-10-23" updated = "2016-10-31" aliases = [ diff --git a/blog/content/posts/05-allocating-frames.md b/blog/content/posts/05-allocating-frames.md index 9a62410c..36107fca 100644 --- a/blog/content/posts/05-allocating-frames.md +++ b/blog/content/posts/05-allocating-frames.md @@ -1,5 +1,7 @@ +++ title = "Allocating Frames" +description = "" +slug = "allocating-frames" date = "2015-11-15" +++ diff --git a/blog/content/posts/06-page-tables.md b/blog/content/posts/06-page-tables.md index 6bc14bea..2ca426ee 100644 --- a/blog/content/posts/06-page-tables.md +++ b/blog/content/posts/06-page-tables.md @@ -1,6 +1,7 @@ +++ title = "Page Tables" -slug = "modifying-page-tables" +description = "" +slug = "page-tables" date = "2015-12-09" +++ diff --git a/blog/content/posts/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel.md index 1f1595d3..65f6003e 100644 --- a/blog/content/posts/07-remap-the-kernel.md +++ b/blog/content/posts/07-remap-the-kernel.md @@ -1,5 +1,7 @@ +++ title = "Remap the Kernel" +description = "" +slug = "remap-the-kernel" date = "2016-01-01" updated = "2016-03-06" +++ diff --git a/blog/content/posts/08-kernel-heap.md b/blog/content/posts/08-kernel-heap.md index a49e49b4..d6431d69 100644 --- a/blog/content/posts/08-kernel-heap.md +++ b/blog/content/posts/08-kernel-heap.md @@ -1,5 +1,7 @@ +++ title = "Kernel Heap" +description = "" +slug = "kernel-heap" date = "2016-04-11" +++ diff --git a/blog/content/posts/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions.md index 687f72cf..80dcafde 100644 --- a/blog/content/posts/09-handling-exceptions.md +++ b/blog/content/posts/09-handling-exceptions.md @@ -1,5 +1,7 @@ +++ title = "Handling Exceptions" +description = "" +slug = "handling-exceptions" date = "2017-03-26" +++ diff --git a/blog/content/posts/10-double-faults.md b/blog/content/posts/10-double-faults.md index 6b3fef53..6923e0a1 100644 --- a/blog/content/posts/10-double-faults.md +++ b/blog/content/posts/10-double-faults.md @@ -1,5 +1,7 @@ +++ title = "Double Faults" +description = "" +slug = "double-faults" date = "2017-01-02" +++ From 1f5cca277966d0f41e2279aa8268dea848ff1fb5 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 27 Apr 2017 12:52:43 +0200 Subject: [PATCH 04/42] Fix syntax of marker --- blog/content/posts/01-multiboot-kernel.md | 2 +- blog/content/posts/02-entering-longmode.md | 2 +- blog/content/posts/03-set-up-rust.md | 2 +- blog/content/posts/04-printing-to-screen.md | 2 +- blog/content/posts/05-allocating-frames.md | 2 +- blog/content/posts/06-page-tables.md | 2 +- blog/content/posts/07-remap-the-kernel.md | 2 +- blog/content/posts/08-kernel-heap.md | 2 +- blog/content/posts/09-handling-exceptions.md | 2 +- blog/content/posts/10-double-faults.md | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/blog/content/posts/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel.md index 7fd37f7c..d4584275 100644 --- a/blog/content/posts/01-multiboot-kernel.md +++ b/blog/content/posts/01-multiboot-kernel.md @@ -13,7 +13,7 @@ This post explains how to create a minimal x86 operating system kernel. In fact, [Rust]: http://www.rust-lang.org/ - + I tried to explain everything in detail and to keep the code as simple as possible. If you have any questions, suggestions or other issues, please leave a comment or [create an issue] on Github. The source code is available in a [repository][source code], too. diff --git a/blog/content/posts/02-entering-longmode.md b/blog/content/posts/02-entering-longmode.md index a8852153..a9428f4b 100644 --- a/blog/content/posts/02-entering-longmode.md +++ b/blog/content/posts/02-entering-longmode.md @@ -17,7 +17,7 @@ In the [previous post] we created a minimal multiboot kernel. It just prints `OK [protected mode]: https://en.wikipedia.org/wiki/Protected_mode [long mode]: https://en.wikipedia.org/wiki/Long_mode - + I tried to explain everything in detail and to keep the code as simple as possible. If you have any questions, suggestions, or issues, please leave a comment or [create an issue] on Github. The source code is available in a [repository][source code], too. diff --git a/blog/content/posts/03-set-up-rust.md b/blog/content/posts/03-set-up-rust.md index 21e445cb..96ea210d 100644 --- a/blog/content/posts/03-set-up-rust.md +++ b/blog/content/posts/03-set-up-rust.md @@ -17,7 +17,7 @@ In the previous posts we created a [minimal Multiboot kernel][multiboot post] an [long mode post]: {{% relref "02-entering-longmode.md" %}} [Rust]: https://www.rust-lang.org/ - + This blog post tries to set up Rust step-by-step and point out the different problems. If you have any questions, problems, or suggestions please [file an issue] or create a comment at the bottom. The code from this post is in a [Github repository], too. diff --git a/blog/content/posts/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen.md index 098ee121..ce23bd02 100644 --- a/blog/content/posts/04-printing-to-screen.md +++ b/blog/content/posts/04-printing-to-screen.md @@ -17,7 +17,7 @@ In the [previous post] we switched from assembly to [Rust], a systems programmin [raw pointers]: https://doc.rust-lang.org/book/raw-pointers.html [formatting macros]: https://doc.rust-lang.org/std/fmt/#related-macros - + This post uses recent unstable features, so you need an up-to-date nighly compiler. If you have any questions, problems, or suggestions please [file an issue] or create a comment at the bottom. The code from this post is also available on [Github][code repository]. diff --git a/blog/content/posts/05-allocating-frames.md b/blog/content/posts/05-allocating-frames.md index 36107fca..5ca709bf 100644 --- a/blog/content/posts/05-allocating-frames.md +++ b/blog/content/posts/05-allocating-frames.md @@ -7,7 +7,7 @@ date = "2015-11-15" In this post we create an allocator that provides free physical frames for a future paging module. To get the required information about available and used memory we use the Multiboot information structure. Additionally, we improve the `panic` handler to print the corresponding message and source line. - + The full source code is available on [Github][source repo]. Feel free to open issues there if you have any problems or improvements. You can also leave a comment at the bottom. diff --git a/blog/content/posts/06-page-tables.md b/blog/content/posts/06-page-tables.md index 2ca426ee..dbc2d87a 100644 --- a/blog/content/posts/06-page-tables.md +++ b/blog/content/posts/06-page-tables.md @@ -7,7 +7,7 @@ date = "2015-12-09" In this post we will create a paging module, which allows us to access and modify the 4-level page table. We will explore recursive page table mapping and use some Rust features to make it safe. Finally we will create functions to translate virtual addresses and to map and unmap pages. - + You can find the source code and this post itself on [Github][source repository]. Please file an issue there if you have any problems or improvement suggestions. There is also a comment section at the end of this page. Note that this post requires a current Rust nightly. diff --git a/blog/content/posts/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel.md index 65f6003e..7e08aa23 100644 --- a/blog/content/posts/07-remap-the-kernel.md +++ b/blog/content/posts/07-remap-the-kernel.md @@ -8,7 +8,7 @@ updated = "2016-03-06" In this post we will create a new page table to map the kernel sections correctly. Therefore we will extend the paging module to support modifications of _inactive_ page tables as well. Then we will switch to the new table and secure our kernel stack by creating a guard page. - + As always, you can find the source code on [Github]. Don't hesitate to file issues there if you have any problems or improvement suggestions. There is also a comment section at the end of this page. Note that this post requires a current Rust nightly. diff --git a/blog/content/posts/08-kernel-heap.md b/blog/content/posts/08-kernel-heap.md index d6431d69..559ce78a 100644 --- a/blog/content/posts/08-kernel-heap.md +++ b/blog/content/posts/08-kernel-heap.md @@ -12,7 +12,7 @@ In the previous posts we have created a [frame allocator] and a [page table modu [alloc]: https://doc.rust-lang.org/nightly/alloc/index.html [collections]: https://doc.rust-lang.org/nightly/collections/index.html - + As always, you can find the complete source code on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a comment section at the end of this page. diff --git a/blog/content/posts/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions.md index 80dcafde..41dba4bc 100644 --- a/blog/content/posts/09-handling-exceptions.md +++ b/blog/content/posts/09-handling-exceptions.md @@ -9,7 +9,7 @@ In this post, we start exploring CPU exceptions. Exceptions occur in various err [breakpoint exceptions]: http://wiki.osdev.org/Exceptions#Breakpoint - + As always, the complete source code is available on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a comment section at the end of this page. diff --git a/blog/content/posts/10-double-faults.md b/blog/content/posts/10-double-faults.md index 6923e0a1..77b725df 100644 --- a/blog/content/posts/10-double-faults.md +++ b/blog/content/posts/10-double-faults.md @@ -7,7 +7,7 @@ date = "2017-01-02" In this post we explore double faults in detail. We also set up an _Interrupt Stack Table_ to catch double faults on a separate kernel stack. This way, we can completely prevent triple faults, even on kernel stack overflow. - + As always, the complete source code is available on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. From 55b3378e8c55c1cdbedc8c898798d242daa9fdd6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:47:54 +0200 Subject: [PATCH 05/42] Description field is optional now --- blog/content/posts/01-multiboot-kernel.md | 1 - blog/content/posts/02-entering-longmode.md | 1 - blog/content/posts/03-set-up-rust.md | 1 - blog/content/posts/04-printing-to-screen.md | 1 - blog/content/posts/05-allocating-frames.md | 1 - blog/content/posts/06-page-tables.md | 1 - blog/content/posts/07-remap-the-kernel.md | 1 - blog/content/posts/08-kernel-heap.md | 1 - blog/content/posts/09-handling-exceptions.md | 1 - blog/content/posts/10-double-faults.md | 1 - 10 files changed, 10 deletions(-) diff --git a/blog/content/posts/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel.md index d4584275..f4017d4a 100644 --- a/blog/content/posts/01-multiboot-kernel.md +++ b/blog/content/posts/01-multiboot-kernel.md @@ -1,6 +1,5 @@ +++ title = "A minimal x86 kernel" -description = "" url = "multiboot-kernel" date = "2015-08-18" aliases = [ diff --git a/blog/content/posts/02-entering-longmode.md b/blog/content/posts/02-entering-longmode.md index a9428f4b..ff4dfacf 100644 --- a/blog/content/posts/02-entering-longmode.md +++ b/blog/content/posts/02-entering-longmode.md @@ -1,6 +1,5 @@ +++ title = "Entering Long Mode" -description = "" url = "entering-longmode" date = "2015-08-25" updated = "2015-10-29" diff --git a/blog/content/posts/03-set-up-rust.md b/blog/content/posts/03-set-up-rust.md index 96ea210d..8f268657 100644 --- a/blog/content/posts/03-set-up-rust.md +++ b/blog/content/posts/03-set-up-rust.md @@ -1,6 +1,5 @@ +++ title = "Set Up Rust" -description = "" url = "set-up-rust" date = "2015-09-02" updated = "2017-04-12" diff --git a/blog/content/posts/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen.md index ce23bd02..927dd388 100644 --- a/blog/content/posts/04-printing-to-screen.md +++ b/blog/content/posts/04-printing-to-screen.md @@ -1,6 +1,5 @@ +++ title = "Printing to Screen" -description = "" slug = "printing-to-screen" date = "2015-10-23" updated = "2016-10-31" diff --git a/blog/content/posts/05-allocating-frames.md b/blog/content/posts/05-allocating-frames.md index 5ca709bf..ca5443af 100644 --- a/blog/content/posts/05-allocating-frames.md +++ b/blog/content/posts/05-allocating-frames.md @@ -1,6 +1,5 @@ +++ title = "Allocating Frames" -description = "" slug = "allocating-frames" date = "2015-11-15" +++ diff --git a/blog/content/posts/06-page-tables.md b/blog/content/posts/06-page-tables.md index dbc2d87a..ea083fc2 100644 --- a/blog/content/posts/06-page-tables.md +++ b/blog/content/posts/06-page-tables.md @@ -1,6 +1,5 @@ +++ title = "Page Tables" -description = "" slug = "page-tables" date = "2015-12-09" +++ diff --git a/blog/content/posts/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel.md index 7e08aa23..739c57db 100644 --- a/blog/content/posts/07-remap-the-kernel.md +++ b/blog/content/posts/07-remap-the-kernel.md @@ -1,6 +1,5 @@ +++ title = "Remap the Kernel" -description = "" slug = "remap-the-kernel" date = "2016-01-01" updated = "2016-03-06" diff --git a/blog/content/posts/08-kernel-heap.md b/blog/content/posts/08-kernel-heap.md index 559ce78a..56f47814 100644 --- a/blog/content/posts/08-kernel-heap.md +++ b/blog/content/posts/08-kernel-heap.md @@ -1,6 +1,5 @@ +++ title = "Kernel Heap" -description = "" slug = "kernel-heap" date = "2016-04-11" +++ diff --git a/blog/content/posts/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions.md index 41dba4bc..607d1dc7 100644 --- a/blog/content/posts/09-handling-exceptions.md +++ b/blog/content/posts/09-handling-exceptions.md @@ -1,6 +1,5 @@ +++ title = "Handling Exceptions" -description = "" slug = "handling-exceptions" date = "2017-03-26" +++ diff --git a/blog/content/posts/10-double-faults.md b/blog/content/posts/10-double-faults.md index 77b725df..bc513665 100644 --- a/blog/content/posts/10-double-faults.md +++ b/blog/content/posts/10-double-faults.md @@ -1,6 +1,5 @@ +++ title = "Double Faults" -description = "" slug = "double-faults" date = "2017-01-02" +++ From d10991279884840f873840c8c4ce9ee2fc80c9a6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:49:18 +0200 Subject: [PATCH 06/42] Remove hugo layout files --- blog/layouts/404.html | 11 ---- blog/layouts/_default/link.html | 1 - blog/layouts/_default/section.html | 11 ---- blog/layouts/additional-resource/single.html | 11 ---- blog/layouts/index.html | 56 -------------------- blog/layouts/old-posts/single.html | 28 ---------- blog/layouts/old-posts/teaser.html | 10 ---- blog/layouts/page/single.html | 10 ---- blog/layouts/partials/analytics.html | 10 ---- blog/layouts/partials/anchorjs.html | 6 --- blog/layouts/partials/disqus.html | 17 ------ blog/layouts/partials/footer.html | 13 ----- blog/layouts/partials/head.html | 40 -------------- blog/layouts/partials/header.html | 18 ------- blog/layouts/partials/recent-updates.html | 0 blog/layouts/post/single.html | 28 ---------- blog/layouts/post/teaser.html | 10 ---- blog/layouts/rss.xml | 24 --------- 18 files changed, 304 deletions(-) delete mode 100644 blog/layouts/404.html delete mode 100644 blog/layouts/_default/link.html delete mode 100644 blog/layouts/_default/section.html delete mode 100644 blog/layouts/additional-resource/single.html delete mode 100644 blog/layouts/index.html delete mode 100644 blog/layouts/old-posts/single.html delete mode 100644 blog/layouts/old-posts/teaser.html delete mode 100644 blog/layouts/page/single.html delete mode 100644 blog/layouts/partials/analytics.html delete mode 100644 blog/layouts/partials/anchorjs.html delete mode 100644 blog/layouts/partials/disqus.html delete mode 100644 blog/layouts/partials/footer.html delete mode 100644 blog/layouts/partials/head.html delete mode 100644 blog/layouts/partials/header.html delete mode 100644 blog/layouts/partials/recent-updates.html delete mode 100644 blog/layouts/post/single.html delete mode 100644 blog/layouts/post/teaser.html delete mode 100644 blog/layouts/rss.xml diff --git a/blog/layouts/404.html b/blog/layouts/404.html deleted file mode 100644 index 518eb4f0..00000000 --- a/blog/layouts/404.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ partial "header.html" . }} - -

Page not found

-

- Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. - Head back home to try finding it again. -

- -

If you followed a link on this site, please report it! - -{{ partial "footer.html" . }} diff --git a/blog/layouts/_default/link.html b/blog/layouts/_default/link.html deleted file mode 100644 index 82ced2f4..00000000 --- a/blog/layouts/_default/link.html +++ /dev/null @@ -1 +0,0 @@ -{{ .Title }} diff --git a/blog/layouts/_default/section.html b/blog/layouts/_default/section.html deleted file mode 100644 index 518eb4f0..00000000 --- a/blog/layouts/_default/section.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ partial "header.html" . }} - -

Page not found

-

- Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. - Head back home to try finding it again. -

- -

If you followed a link on this site, please report it! - -{{ partial "footer.html" . }} diff --git a/blog/layouts/additional-resource/single.html b/blog/layouts/additional-resource/single.html deleted file mode 100644 index 83278b21..00000000 --- a/blog/layouts/additional-resource/single.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ partial "header.html" . }} - -

-

{{ .Title }}

- - {{ .Content }} -
- -{{ partial "disqus.html" . }} -{{ partial "anchorjs.html" . }} -{{ partial "footer.html" . }} diff --git a/blog/layouts/index.html b/blog/layouts/index.html deleted file mode 100644 index 9d86a39b..00000000 --- a/blog/layouts/index.html +++ /dev/null @@ -1,56 +0,0 @@ -{{ partial "header.html" . }} - -

- This blog series creates a small operating system in the - Rust programming language. Each post - is a small tutorial and includes all needed code, so you can follow along if - you like. The source code is also available in the corresponding - Github repository. -

-

Latest post: {{ range first 1 (where .Site.Pages "Section" "post") }} - {{ .Title }} - {{ end }} -

- - -
- {{ range first 4 (where .Site.Pages.ByDate "Section" "post") }} - {{ .Render "teaser" }} - {{ end }} -
- - -
- {{ range first 4 (after 4 (where .Site.Pages.ByDate "Section" "post")) }} - {{ .Render "teaser" }} - {{ end }} -
- - -
- {{ range first 1 (after 9 (where .Site.Pages.ByDate "Section" "post")) }} - {{ .Render "teaser" }} - {{ end }} - {{ range first 1 (after 8 (where .Site.Pages.ByDate "Section" "post")) }} - {{ .Render "teaser" }} - {{ end }} -
- -
-

Additional Resources

- -
    - {{ range (where .Site.Pages.ByDate "Section" "additional-resource") }} -
  • {{ .Render "link" }} - {{ end }} -
- -
- - -
- -{{ partial "footer.html" . }} diff --git a/blog/layouts/old-posts/single.html b/blog/layouts/old-posts/single.html deleted file mode 100644 index d8e2c7a8..00000000 --- a/blog/layouts/old-posts/single.html +++ /dev/null @@ -1,28 +0,0 @@ -{{ partial "header.html" . }} - -
-

{{ .Title }}

- - - {{ .Content }} -
- -
- -
- -{{ partial "disqus.html" . }} -{{ partial "anchorjs.html" . }} -{{ partial "footer.html" . }} diff --git a/blog/layouts/old-posts/teaser.html b/blog/layouts/old-posts/teaser.html deleted file mode 100644 index 795e27ad..00000000 --- a/blog/layouts/old-posts/teaser.html +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/blog/layouts/page/single.html b/blog/layouts/page/single.html deleted file mode 100644 index a091108c..00000000 --- a/blog/layouts/page/single.html +++ /dev/null @@ -1,10 +0,0 @@ -{{ partial "header.html" . }} - -
-

{{ .Title }}

- - {{ .Content }} -
- -{{ partial "anchorjs.html" . }} -{{ partial "footer.html" . }} diff --git a/blog/layouts/partials/analytics.html b/blog/layouts/partials/analytics.html deleted file mode 100644 index c226e17a..00000000 --- a/blog/layouts/partials/analytics.html +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/blog/layouts/partials/anchorjs.html b/blog/layouts/partials/anchorjs.html deleted file mode 100644 index fb6093e3..00000000 --- a/blog/layouts/partials/anchorjs.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/blog/layouts/partials/disqus.html b/blog/layouts/partials/disqus.html deleted file mode 100644 index 6973517f..00000000 --- a/blog/layouts/partials/disqus.html +++ /dev/null @@ -1,17 +0,0 @@ -
- - diff --git a/blog/layouts/partials/footer.html b/blog/layouts/partials/footer.html deleted file mode 100644 index 35a5819f..00000000 --- a/blog/layouts/partials/footer.html +++ /dev/null @@ -1,13 +0,0 @@ - - -
- {{ $year := .Site.LastChange.Format "2006"}} - © - . All rights reserved. - Contact - -
- - - - diff --git a/blog/layouts/partials/head.html b/blog/layouts/partials/head.html deleted file mode 100644 index 6ea2cc9a..00000000 --- a/blog/layouts/partials/head.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - {{ with .Site.Params.author }}{{ end }} - {{ with .Site.Params.description }}{{ end }} - - - {{ .Title }}{{ if not .IsHome }} · {{ .Site.Title }}{{end}} - - - - - - - - - - - - - - - - - - - - - {{ partial "analytics.html" . }} - - - - diff --git a/blog/layouts/partials/header.html b/blog/layouts/partials/header.html deleted file mode 100644 index 6c024b65..00000000 --- a/blog/layouts/partials/header.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -{{ partial "head.html" . }} - -
- -
-

- {{ .Site.Title }} - - RSS - - {{ replace .Site.Params.subtitle " " " " | safeHTML }} -

-
- -
diff --git a/blog/layouts/partials/recent-updates.html b/blog/layouts/partials/recent-updates.html deleted file mode 100644 index e69de29b..00000000 diff --git a/blog/layouts/post/single.html b/blog/layouts/post/single.html deleted file mode 100644 index d8e2c7a8..00000000 --- a/blog/layouts/post/single.html +++ /dev/null @@ -1,28 +0,0 @@ -{{ partial "header.html" . }} - -
-

{{ .Title }}

- - - {{ .Content }} -
- -
- -
- -{{ partial "disqus.html" . }} -{{ partial "anchorjs.html" . }} -{{ partial "footer.html" . }} diff --git a/blog/layouts/post/teaser.html b/blog/layouts/post/teaser.html deleted file mode 100644 index 795e27ad..00000000 --- a/blog/layouts/post/teaser.html +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/blog/layouts/rss.xml b/blog/layouts/rss.xml deleted file mode 100644 index 06575193..00000000 --- a/blog/layouts/rss.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - {{ .Site.Title }} - {{ .Permalink }} - Recent content on {{ .Site.Title }} - Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} - {{.}}{{end}}{{ if not .Date.IsZero }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - - {{ range first 15 (where .Data.Pages "Section" "post") }} - - {{ .Title }} - {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .Permalink }} - {{ .Content | html }} - - {{ end }} - - From 168b59890147f0a991d63b33b9c99f1f9a273525 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:49:50 +0200 Subject: [PATCH 07/42] Create gutenberg templates --- blog/templates/base.html | 41 ++++++++++++++ .../handling-exceptions-with-naked-fns.html | 11 ++++ blog/templates/index.html | 54 +++++++++++++++++++ blog/templates/macros.html | 10 ++++ blog/templates/page.html | 23 ++++++++ blog/templates/section.html | 19 +++++++ 6 files changed, 158 insertions(+) create mode 100644 blog/templates/base.html create mode 100644 blog/templates/handling-exceptions-with-naked-fns.html create mode 100644 blog/templates/index.html create mode 100644 blog/templates/macros.html create mode 100644 blog/templates/page.html create mode 100644 blog/templates/section.html diff --git a/blog/templates/base.html b/blog/templates/base.html new file mode 100644 index 00000000..acb7fdb9 --- /dev/null +++ b/blog/templates/base.html @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + {% block title %}{% endblock title %} + + + +
+
+

+ {{ config.title }} + {{ config.extra.subtitle }} +

+
+ +
{% block main %}{% endblock main %}
+ +
{% block after_main %}{% endblock after_main %}
+ +
+
+ + © . All rights reserved. + Contact + +
+
+ + + diff --git a/blog/templates/handling-exceptions-with-naked-fns.html b/blog/templates/handling-exceptions-with-naked-fns.html new file mode 100644 index 00000000..55cc88fd --- /dev/null +++ b/blog/templates/handling-exceptions-with-naked-fns.html @@ -0,0 +1,11 @@ +{% extends "section.html" %} + +{% block title %}{{ super() }}{% endblock title %} + +{% block main %}{{ super() }}{% endblock main %} + +{% block introduction %} + +

These posts explain how to handle CPU exceptions using naked functions. Historically, these posts were the main exception handling posts before the x86-interrupt calling convention and the x86_64 crate existed. Our new way of handling exceptions can be found in the “Handling Exceptions” post.

+ +{% endblock introduction %} diff --git a/blog/templates/index.html b/blog/templates/index.html new file mode 100644 index 00000000..c09910f0 --- /dev/null +++ b/blog/templates/index.html @@ -0,0 +1,54 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block title %}{{ config.title }}{% endblock title %} + +{% block main %} +
+

+ This blog series creates a small operating system in the + Rust programming language. Each post is a small tutorial and includes all + needed code, so you can follow along if you like. The source code is also available in the corresponding + Github repository. +

+

Latest post: + {{ macros::latest_post_link(page=pages|reverse|last) }} +

+
+ + +
+ {{ macros::post_link(page=pages.9) }} + {{ macros::post_link(page=pages.8) }} + {{ macros::post_link(page=pages.7) }} + {{ macros::post_link(page=pages.6) }} +
+ + +
+ {{ macros::post_link(page=pages.5) }} + {{ macros::post_link(page=pages.4) }} + {{ macros::post_link(page=pages.3) }} + {{ macros::post_link(page=pages.2) }} +
+ + +
+ {{ macros::post_link(page=pages.1) }} + {{ macros::post_link(page=pages.0) }} +
+ +
+

Additional Resources

+ +
    +
+ +
+ + +{% endblock main %} diff --git a/blog/templates/macros.html b/blog/templates/macros.html new file mode 100644 index 00000000..cc953a62 --- /dev/null +++ b/blog/templates/macros.html @@ -0,0 +1,10 @@ +{% macro post_link(page) %} + +{% endmacro post_link %} + +{% macro latest_post_link(page) %} + {{ page.title }} +{% endmacro latest_post_link %} diff --git a/blog/templates/page.html b/blog/templates/page.html new file mode 100644 index 00000000..1ae18660 --- /dev/null +++ b/blog/templates/page.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} + +{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} + +{% block main %} +

{{ page.title }}

+ {{ page.content | safe }} +{% endblock main %} + +{% block after_main %} +
+ +{% endblock after_main %} + + diff --git a/blog/templates/section.html b/blog/templates/section.html new file mode 100644 index 00000000..3b879148 --- /dev/null +++ b/blog/templates/section.html @@ -0,0 +1,19 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %} + +{% block main %} + +

{{ section.title }}

+ +{% block introduction %}{% endblock introduction %} + +
+ {% for page in section.pages %} + {{ macros::post_link(page=page) }} + {% endfor %} +
+ +{% endblock main %} From 68453f7374a3ac216fbf3e9974407fe1df722ec7 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:51:47 +0200 Subject: [PATCH 08/42] Use manual ordering for posts --- blog/content/_index.md | 3 +++ blog/content/posts/01-multiboot-kernel.md | 1 + blog/content/posts/02-entering-longmode.md | 1 + blog/content/posts/03-set-up-rust.md | 1 + blog/content/posts/04-printing-to-screen.md | 1 + blog/content/posts/05-allocating-frames.md | 1 + blog/content/posts/06-page-tables.md | 1 + blog/content/posts/07-remap-the-kernel.md | 1 + blog/content/posts/08-kernel-heap.md | 1 + blog/content/posts/09-handling-exceptions.md | 1 + blog/content/posts/10-double-faults.md | 1 + 11 files changed, 13 insertions(+) create mode 100644 blog/content/_index.md diff --git a/blog/content/_index.md b/blog/content/_index.md new file mode 100644 index 00000000..5ec844a4 --- /dev/null +++ b/blog/content/_index.md @@ -0,0 +1,3 @@ ++++ +sort_by = "order" ++++ diff --git a/blog/content/posts/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel.md index f4017d4a..7b697251 100644 --- a/blog/content/posts/01-multiboot-kernel.md +++ b/blog/content/posts/01-multiboot-kernel.md @@ -1,5 +1,6 @@ +++ title = "A minimal x86 kernel" +order = 1 url = "multiboot-kernel" date = "2015-08-18" aliases = [ diff --git a/blog/content/posts/02-entering-longmode.md b/blog/content/posts/02-entering-longmode.md index ff4dfacf..42195d61 100644 --- a/blog/content/posts/02-entering-longmode.md +++ b/blog/content/posts/02-entering-longmode.md @@ -1,5 +1,6 @@ +++ title = "Entering Long Mode" +order = 2 url = "entering-longmode" date = "2015-08-25" updated = "2015-10-29" diff --git a/blog/content/posts/03-set-up-rust.md b/blog/content/posts/03-set-up-rust.md index 8f268657..320c2f1f 100644 --- a/blog/content/posts/03-set-up-rust.md +++ b/blog/content/posts/03-set-up-rust.md @@ -1,5 +1,6 @@ +++ title = "Set Up Rust" +order = 3 url = "set-up-rust" date = "2015-09-02" updated = "2017-04-12" diff --git a/blog/content/posts/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen.md index 927dd388..2742b98a 100644 --- a/blog/content/posts/04-printing-to-screen.md +++ b/blog/content/posts/04-printing-to-screen.md @@ -1,5 +1,6 @@ +++ title = "Printing to Screen" +order = 4 slug = "printing-to-screen" date = "2015-10-23" updated = "2016-10-31" diff --git a/blog/content/posts/05-allocating-frames.md b/blog/content/posts/05-allocating-frames.md index ca5443af..610780ee 100644 --- a/blog/content/posts/05-allocating-frames.md +++ b/blog/content/posts/05-allocating-frames.md @@ -1,5 +1,6 @@ +++ title = "Allocating Frames" +order = 5 slug = "allocating-frames" date = "2015-11-15" +++ diff --git a/blog/content/posts/06-page-tables.md b/blog/content/posts/06-page-tables.md index ea083fc2..fa61d203 100644 --- a/blog/content/posts/06-page-tables.md +++ b/blog/content/posts/06-page-tables.md @@ -1,5 +1,6 @@ +++ title = "Page Tables" +order = 6 slug = "page-tables" date = "2015-12-09" +++ diff --git a/blog/content/posts/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel.md index 739c57db..0be2ae1c 100644 --- a/blog/content/posts/07-remap-the-kernel.md +++ b/blog/content/posts/07-remap-the-kernel.md @@ -1,5 +1,6 @@ +++ title = "Remap the Kernel" +order = 7 slug = "remap-the-kernel" date = "2016-01-01" updated = "2016-03-06" diff --git a/blog/content/posts/08-kernel-heap.md b/blog/content/posts/08-kernel-heap.md index 56f47814..275bda81 100644 --- a/blog/content/posts/08-kernel-heap.md +++ b/blog/content/posts/08-kernel-heap.md @@ -1,5 +1,6 @@ +++ title = "Kernel Heap" +order = 8 slug = "kernel-heap" date = "2016-04-11" +++ diff --git a/blog/content/posts/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions.md index 607d1dc7..a442cec6 100644 --- a/blog/content/posts/09-handling-exceptions.md +++ b/blog/content/posts/09-handling-exceptions.md @@ -1,5 +1,6 @@ +++ title = "Handling Exceptions" +order = 9 slug = "handling-exceptions" date = "2017-03-26" +++ diff --git a/blog/content/posts/10-double-faults.md b/blog/content/posts/10-double-faults.md index bc513665..531d449e 100644 --- a/blog/content/posts/10-double-faults.md +++ b/blog/content/posts/10-double-faults.md @@ -1,5 +1,6 @@ +++ title = "Double Faults" +order = 10 slug = "double-faults" date = "2017-01-02" +++ From 186ce23e110a1248b0ad92116a6bf9e0ab7d8cae Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:53:46 +0200 Subject: [PATCH 09/42] Move additional-resources/old-posts to a section named `extra` --- .../handling-exceptions-with-naked-fns.html | 48 ------------------- .../cross-compile-binutils.md | 2 + .../cross-compile-libcore.md | 2 + .../_index.md | 5 ++ .../better-exception-messages.md | 4 +- .../catching-exceptions.md | 4 +- .../returning-from-exceptions.md | 4 +- .../set-up-gdb.md | 2 + 8 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 blog/content/additional-resources/handling-exceptions-with-naked-fns.html rename blog/content/{additional-resources => extra}/cross-compile-binutils.md (97%) rename blog/content/{additional-resources => extra}/cross-compile-libcore.md (97%) create mode 100644 blog/content/extra/handling-exceptions-with-naked-fns/_index.md rename blog/content/{old-posts => extra/handling-exceptions-with-naked-fns}/better-exception-messages.md (99%) rename blog/content/{old-posts => extra/handling-exceptions-with-naked-fns}/catching-exceptions.md (99%) rename blog/content/{old-posts => extra/handling-exceptions-with-naked-fns}/returning-from-exceptions.md (99%) rename blog/content/{additional-resources => extra}/set-up-gdb.md (99%) diff --git a/blog/content/additional-resources/handling-exceptions-with-naked-fns.html b/blog/content/additional-resources/handling-exceptions-with-naked-fns.html deleted file mode 100644 index 757a067f..00000000 --- a/blog/content/additional-resources/handling-exceptions-with-naked-fns.html +++ /dev/null @@ -1,48 +0,0 @@ -+++ -title = "Handling Exceptions using Naked Functions" -+++ - -

These posts explain how to handle CPU exceptions using naked functions. - Historically, these posts were the main exception handling posts before the - x86-interrupt calling convention and the x86_64 crate existed. - Our new way of handling exceptions can be found in the - “Handling Exceptions” post. -

- -
- -
-

- - Catching Exceptions - -

- -

In this post, we start exploring exceptions. We set up an interrupt descriptor table and add handler functions. At the end of this post, our kernel will be able to catch divide-by-zero faults.

- -
- - -
-

- - Better Exception Messages - -

- -

In this post, we explore exceptions in more detail. Our goal is to print additional information when an exception occurs, for example the values of the instruction and stack pointer. In the course of this, we will explore inline assembly and naked functions. We will also add a handler function for page faults and read the associated error code.

- -
- - -
-

- - Returning from Exceptions - -

- -

In this post, we learn how to return from exceptions correctly. In the course of this, we will explore the iretq instruction, the C calling convention, multimedia registers, and the red zone.

- -
-
diff --git a/blog/content/additional-resources/cross-compile-binutils.md b/blog/content/extra/cross-compile-binutils.md similarity index 97% rename from blog/content/additional-resources/cross-compile-binutils.md rename to blog/content/extra/cross-compile-binutils.md index 3f8d99a4..53ae157f 100644 --- a/blog/content/additional-resources/cross-compile-binutils.md +++ b/blog/content/extra/cross-compile-binutils.md @@ -1,5 +1,7 @@ +++ title = "Cross Compile Binutils" +description = "" +slug = "cross-compile-binutils" +++ The [GNU Binutils] are a collection of various binary tools such as `ld`, `as`, `objdump`, or `readelf`. These tools are platform-specific, so you need to compile them again if your host system and target system are different. In our case, we need `ld` and `objdump` for the x86_64 architecture. diff --git a/blog/content/additional-resources/cross-compile-libcore.md b/blog/content/extra/cross-compile-libcore.md similarity index 97% rename from blog/content/additional-resources/cross-compile-libcore.md rename to blog/content/extra/cross-compile-libcore.md index 3e3084ee..5bea13eb 100644 --- a/blog/content/additional-resources/cross-compile-libcore.md +++ b/blog/content/extra/cross-compile-libcore.md @@ -1,5 +1,7 @@ +++ title = "Cross Compiling: libcore" +description = "" +slug = "cross-compile-libcore" +++ If you get an `error: can't find crate for 'core'`, you're probably compiling for a different target (e.g. you're passing the `target` option to `cargo build`). Now the compiler complains that it can't find the `core` library. This document gives a quick overview how to fix this problem. For more details, see the [rust-cross] project. diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/_index.md b/blog/content/extra/handling-exceptions-with-naked-fns/_index.md new file mode 100644 index 00000000..c5f74fb2 --- /dev/null +++ b/blog/content/extra/handling-exceptions-with-naked-fns/_index.md @@ -0,0 +1,5 @@ ++++ +title = "Handling Exceptions using naked Functions" +description = "" +template = "handling-exceptions-with-naked-fns.html" ++++ diff --git a/blog/content/old-posts/better-exception-messages.md b/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md similarity index 99% rename from blog/content/old-posts/better-exception-messages.md rename to blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md index d2451765..1efbbc8e 100644 --- a/blog/content/old-posts/better-exception-messages.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md @@ -1,12 +1,14 @@ +++ title = "Better Exception Messages" +description = "" +slug = "better-exception-messages" date = "2016-08-03" updated = "2016-11-01" +++ In this post, we explore exceptions in more detail. Our goal is to print additional information when an exception occurs, for example the values of the instruction and stack pointer. In the course of this, we will explore inline assembly and naked functions. We will also add a handler function for page faults and read the associated error code. - + As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. diff --git a/blog/content/old-posts/catching-exceptions.md b/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md similarity index 99% rename from blog/content/old-posts/catching-exceptions.md rename to blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md index 475fa03a..9d7e7b60 100644 --- a/blog/content/old-posts/catching-exceptions.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md @@ -1,12 +1,14 @@ +++ title = "Catching Exceptions" +description = "" +slug = "catching-exceptions" date = "2016-05-28" updated = "2016-06-25" +++ In this post, we start exploring exceptions. We set up an interrupt descriptor table and add handler functions. At the end of this post, our kernel will be able to catch divide-by-zero faults. - + As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a comment section at the end of this page. diff --git a/blog/content/old-posts/returning-from-exceptions.md b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md similarity index 99% rename from blog/content/old-posts/returning-from-exceptions.md rename to blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md index bf0b568f..f1db1d2e 100644 --- a/blog/content/old-posts/returning-from-exceptions.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md @@ -1,12 +1,14 @@ +++ title = "Returning from Exceptions" +description = "" +slug = "returning-from-exceptions" date = "2016-09-21" updated = "2016-11-01" +++ In this post, we learn how to return from exceptions correctly. In the course of this, we will explore the `iretq` instruction, the C calling convention, multimedia registers, and the red zone. - + As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. diff --git a/blog/content/additional-resources/set-up-gdb.md b/blog/content/extra/set-up-gdb.md similarity index 99% rename from blog/content/additional-resources/set-up-gdb.md rename to blog/content/extra/set-up-gdb.md index 177a46cd..2f8f6197 100644 --- a/blog/content/additional-resources/set-up-gdb.md +++ b/blog/content/extra/set-up-gdb.md @@ -1,5 +1,7 @@ +++ title = "Set Up GDB" +description = "" +slug = "set-up-gdb" +++ There are a lot of things that can go wrong when developing an OS. So it's a good idea to add a debugger to our toolset, which allows us to set breakpoints and examine variables. We will use [GDB](https://www.gnu.org/software/gdb/) as QEMU supports it out of the box. From 76c0c4f1da96f6f2232e0635dca6a635e7374e88 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:54:11 +0200 Subject: [PATCH 10/42] Add slug for contact page --- blog/content/pages/contact.md | 1 + 1 file changed, 1 insertion(+) diff --git a/blog/content/pages/contact.md b/blog/content/pages/contact.md index 4049f483..545b173b 100644 --- a/blog/content/pages/contact.md +++ b/blog/content/pages/contact.md @@ -1,5 +1,6 @@ +++ title = "Contact" +slug = "contact" +++ Philipp Oppermann From c5622c864eabc9c168f72f9b9264d398c8cac608 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 2 May 2017 08:54:45 +0200 Subject: [PATCH 11/42] =?UTF-8?q?Add=20a=20=E2=80=9Cneutral=E2=80=9D=20bor?= =?UTF-8?q?der=20style=20for=20post=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog/static/css/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blog/static/css/main.css b/blog/static/css/main.css index 61e72d64..d25c1f15 100644 --- a/blog/static/css/main.css +++ b/blog/static/css/main.css @@ -41,6 +41,10 @@ main img { margin-right: -0.5rem; } +.posts.neutral { + border: 2px solid #999; +} + .posts.bare-bones { border: 2px solid #66f; } From c4f9b28b41663ba50292549c40abd628651294a1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 3 May 2017 18:33:40 +0200 Subject: [PATCH 12/42] Add styling to heading anchors --- blog/static/css/main.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/blog/static/css/main.css b/blog/static/css/main.css index d25c1f15..bd39bdef 100644 --- a/blog/static/css/main.css +++ b/blog/static/css/main.css @@ -200,3 +200,17 @@ aside#recent-updates time { a code { color: #268bd2; } + +a.anchor { + opacity: 0; + position: absolute; + margin-left: -1.5em; + padding-right: 1em; + font-size: 0.6em; + vertical-align: baseline; + line-height: 2em; +} + +:hover>a.anchor { + opacity: 1; +} From 2ebc323cdbb7d503e5efcb3f9311a5599c429046 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 3 May 2017 18:50:01 +0200 Subject: [PATCH 13/42] Don't underline the anchor link symbol --- blog/static/css/main.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blog/static/css/main.css b/blog/static/css/main.css index bd39bdef..a9132887 100644 --- a/blog/static/css/main.css +++ b/blog/static/css/main.css @@ -213,4 +213,9 @@ a.anchor { :hover>a.anchor { opacity: 1; + text-decoration: none; +} + +a.anchor:hover { + text-decoration: none; } From 7e63bf08fff74dfb557d8d09d001a0e5458962d1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 3 May 2017 18:59:56 +0200 Subject: [PATCH 14/42] Move posts to their own subfolder This allows us to move the images right next to the posts --- .../{01-multiboot-kernel.md => 01-multiboot-kernel/index.md} | 0 .../{02-entering-longmode.md => 02-entering-longmode/index.md} | 0 blog/content/posts/{03-set-up-rust.md => 03-set-up-rust/index.md} | 0 .../{04-printing-to-screen.md => 04-printing-to-screen/index.md} | 0 .../{05-allocating-frames.md => 05-allocating-frames/index.md} | 0 blog/content/posts/{06-page-tables.md => 06-page-tables/index.md} | 0 .../{07-remap-the-kernel.md => 07-remap-the-kernel/index.md} | 0 blog/content/posts/{08-kernel-heap.md => 08-kernel-heap/index.md} | 0 .../index.md} | 0 .../posts/{10-double-faults.md => 10-double-faults/index.md} | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename blog/content/posts/{01-multiboot-kernel.md => 01-multiboot-kernel/index.md} (100%) rename blog/content/posts/{02-entering-longmode.md => 02-entering-longmode/index.md} (100%) rename blog/content/posts/{03-set-up-rust.md => 03-set-up-rust/index.md} (100%) rename blog/content/posts/{04-printing-to-screen.md => 04-printing-to-screen/index.md} (100%) rename blog/content/posts/{05-allocating-frames.md => 05-allocating-frames/index.md} (100%) rename blog/content/posts/{06-page-tables.md => 06-page-tables/index.md} (100%) rename blog/content/posts/{07-remap-the-kernel.md => 07-remap-the-kernel/index.md} (100%) rename blog/content/posts/{08-kernel-heap.md => 08-kernel-heap/index.md} (100%) rename blog/content/posts/{09-handling-exceptions.md => 09-handling-exceptions/index.md} (100%) rename blog/content/posts/{10-double-faults.md => 10-double-faults/index.md} (100%) diff --git a/blog/content/posts/01-multiboot-kernel.md b/blog/content/posts/01-multiboot-kernel/index.md similarity index 100% rename from blog/content/posts/01-multiboot-kernel.md rename to blog/content/posts/01-multiboot-kernel/index.md diff --git a/blog/content/posts/02-entering-longmode.md b/blog/content/posts/02-entering-longmode/index.md similarity index 100% rename from blog/content/posts/02-entering-longmode.md rename to blog/content/posts/02-entering-longmode/index.md diff --git a/blog/content/posts/03-set-up-rust.md b/blog/content/posts/03-set-up-rust/index.md similarity index 100% rename from blog/content/posts/03-set-up-rust.md rename to blog/content/posts/03-set-up-rust/index.md diff --git a/blog/content/posts/04-printing-to-screen.md b/blog/content/posts/04-printing-to-screen/index.md similarity index 100% rename from blog/content/posts/04-printing-to-screen.md rename to blog/content/posts/04-printing-to-screen/index.md diff --git a/blog/content/posts/05-allocating-frames.md b/blog/content/posts/05-allocating-frames/index.md similarity index 100% rename from blog/content/posts/05-allocating-frames.md rename to blog/content/posts/05-allocating-frames/index.md diff --git a/blog/content/posts/06-page-tables.md b/blog/content/posts/06-page-tables/index.md similarity index 100% rename from blog/content/posts/06-page-tables.md rename to blog/content/posts/06-page-tables/index.md diff --git a/blog/content/posts/07-remap-the-kernel.md b/blog/content/posts/07-remap-the-kernel/index.md similarity index 100% rename from blog/content/posts/07-remap-the-kernel.md rename to blog/content/posts/07-remap-the-kernel/index.md diff --git a/blog/content/posts/08-kernel-heap.md b/blog/content/posts/08-kernel-heap/index.md similarity index 100% rename from blog/content/posts/08-kernel-heap.md rename to blog/content/posts/08-kernel-heap/index.md diff --git a/blog/content/posts/09-handling-exceptions.md b/blog/content/posts/09-handling-exceptions/index.md similarity index 100% rename from blog/content/posts/09-handling-exceptions.md rename to blog/content/posts/09-handling-exceptions/index.md diff --git a/blog/content/posts/10-double-faults.md b/blog/content/posts/10-double-faults/index.md similarity index 100% rename from blog/content/posts/10-double-faults.md rename to blog/content/posts/10-double-faults/index.md From 7744a08212adb8d43ba5a20667048fbffc23ad86 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 3 May 2017 19:02:47 +0200 Subject: [PATCH 15/42] Move footnotes to the bottom --- blog/content/posts/01-multiboot-kernel/index.md | 9 +++++---- blog/content/posts/02-entering-longmode/index.md | 13 +++++++------ blog/content/posts/04-printing-to-screen/index.md | 4 +++- blog/content/posts/06-page-tables/index.md | 5 +++-- blog/content/posts/07-remap-the-kernel/index.md | 8 ++++---- blog/content/posts/08-kernel-heap/index.md | 4 +--- blog/content/posts/09-handling-exceptions/index.md | 5 +++-- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/blog/content/posts/01-multiboot-kernel/index.md b/blog/content/posts/01-multiboot-kernel/index.md index 7b697251..5e87c03f 100644 --- a/blog/content/posts/01-multiboot-kernel/index.md +++ b/blog/content/posts/01-multiboot-kernel/index.md @@ -81,8 +81,6 @@ If you don't know x86 assembly, here is some quick guide: - `dd` stands for `define double` (32bit) and `dw` stands for `define word` (16bit). They just output the specified 32bit/16bit constant. - the additional `0x100000000` in the checksum calculation is a small hack[^fn-checksum_hack] to avoid a compiler warning -[^fn-checksum_hack]: The formula from the table, `-(magic + architecture + header_length)`, creates a negative value that doesn't fit into 32bit. By subtracting from `0x100000000` (= 2^(32)) instead, we keep the value positive without changing its truncated value. Without the additional sign bit(s) the result fits into 32bit and the compiler is happy :). - We can already _assemble_ this file (which I called `multiboot_header.asm`) using `nasm`. It produces a flat binary by default, so the resulting file just contains our 24 bytes (in little endian if you work on a x86 machine): ``` @@ -167,8 +165,6 @@ Let's translate it: - the `.text` output section contains all input sections named `.text` - Sections named `.multiboot_header` are added to the first output section (`.boot`) to ensure they are at the beginning of the executable. This is necessary because GRUB expects to find the Multiboot header very early in the file. -[^Linker 1M]: We don't want to load the kernel to e.g. `0x0` because there are many special memory areas below the 1MB mark (for example the so-called VGA buffer at `0xb8000`, that we use to print `OK` to the screen). - So let's create the ELF object files and link them using our new linker script: ``` @@ -324,3 +320,8 @@ In the [next post] we will create a page table and do some CPU configuration to [next post]: {{% relref "02-entering-longmode.md" %}} [long mode]: https://en.wikipedia.org/wiki/Long_mode + +## Footnotes +[^fn-checksum_hack]: The formula from the table, `-(magic + architecture + header_length)`, creates a negative value that doesn't fit into 32bit. By subtracting from `0x100000000` (= 2^(32)) instead, we keep the value positive without changing its truncated value. Without the additional sign bit(s) the result fits into 32bit and the compiler is happy :). + +[^Linker 1M]: We don't want to load the kernel to e.g. `0x0` because there are many special memory areas below the 1MB mark (for example the so-called VGA buffer at `0xb8000`, that we use to print `OK` to the screen). diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index 42195d61..13650a64 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -215,10 +215,6 @@ As I don't like these names, I will call them P4, P3, P2, and P1 from now on. Each page table contains 512 entries and one entry is 8 bytes, so they fit exactly in one page (`512*8 = 4096`). To translate a virtual address to a physical address the CPU[^hardware_lookup] will do the following[^virtual_physical_translation_source]: -[^hardware_lookup]: In the x86 architecture, the page tables are _hardware walked_, so the CPU will look at the table on its own when it needs a translation. Other architectures, for example MIPS, just throw an exception and let the OS translate the virtual address. - -[^virtual_physical_translation_source]: Image source: [Wikipedia](https://commons.wikimedia.org/wiki/File:X86_Paging_64bit.svg), with modified font size, page table naming, and removed sign extended bits. The modified file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. - ![translation of virtual to physical addresses in 64 bit mode](/images/X86_Paging_64bit.svg) 1. Get the address of the P4 table from the CR3 register @@ -259,8 +255,6 @@ To identity map the first gigabyte of our kernel with 512 2MiB pages, we need on We can add these two tables at the beginning[^page_table_alignment] of the `.bss` section: -[^page_table_alignment]: Page tables need to be page-aligned as the bits 0-11 are used for flags. By putting these tables at the beginning of `.bss`, the linker can just page align the whole section and we don't have unused padding bytes in between. - ```nasm ... @@ -524,3 +518,10 @@ It's time to finally leave assembly behind and switch to [Rust]. Rust is a syste [Rust]: https://www.rust-lang.org/ [next post]: {{% relref "03-set-up-rust.md" %}} + +## Footnotes +[^hardware_lookup]: In the x86 architecture, the page tables are _hardware walked_, so the CPU will look at the table on its own when it needs a translation. Other architectures, for example MIPS, just throw an exception and let the OS translate the virtual address. + +[^virtual_physical_translation_source]: Image source: [Wikipedia](https://commons.wikimedia.org/wiki/File:X86_Paging_64bit.svg), with modified font size, page table naming, and removed sign extended bits. The modified file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. + +[^page_table_alignment]: Page tables need to be page-aligned as the bits 0-11 are used for flags. By putting these tables at the beginning of `.bss`, the linker can just page align the whole section and we don't have unused padding bytes in between. diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index 2742b98a..7947e8b0 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -652,7 +652,6 @@ _Note_: You need to [cross compile binutils] to build it (or you create some sym [Rust Bare-Bones Kernel]: https://github.com/thepowersgang/rust-barebones-kernel [higher half]: http://wiki.osdev.org/Higher_Half_Kernel [cross compile binutils]: {{% relref "cross-compile-binutils.md" %}} -[^fn-symlink]: You will need to symlink `x86_64-none_elf-XXX` to `/usr/bin/XXX` where `XXX` is in {`as`, `ld`, `objcopy`, `objdump`, `strip`}. The `x86_64-none_elf-XXX` files must be in some folder that is in your `$PATH`. But then you can only build for your x86_64 host architecture, so use this hack only for testing. - [RustOS]: More advanced kernel that supports allocation, keyboard inputs, and threads. It also has a scheduler and a basic network driver. [RustOS]: https://github.com/RustOS-Fork-Holding-Ground/RustOS @@ -663,3 +662,6 @@ _Note_: You need to [cross compile binutils] to build it (or you create some sym - [Redox]: Probably the most complete Rust OS today. It has an active community and over 1000 Github stars. File systems, network, an audio player, a picture viewer, and much more. Just take a look at the [screenshots][redox screenshots]. [Redox]: https://github.com/redox-os/redox [redox screenshots]: https://github.com/redox-os/redox#what-it-looks-like + +## Footnotes +[^fn-symlink]: You will need to symlink `x86_64-none_elf-XXX` to `/usr/bin/XXX` where `XXX` is in {`as`, `ld`, `objcopy`, `objdump`, `strip`}. The `x86_64-none_elf-XXX` files must be in some folder that is in your `$PATH`. But then you can only build for your x86_64 host architecture, so use this hack only for testing. diff --git a/blog/content/posts/06-page-tables/index.md b/blog/content/posts/06-page-tables/index.md index fa61d203..dac10bc5 100644 --- a/blog/content/posts/06-page-tables/index.md +++ b/blog/content/posts/06-page-tables/index.md @@ -346,8 +346,6 @@ _What happens if we call them on a P1 table?_ Well, they would calculate the address of the next table (which does not exist) and treat it as a page table. Either they construct an invalid address (if `XXX < 400`)[^fn-invalid-address] or access the mapped page itself. That way, we could easily corrupt memory or cause CPU exceptions by accident. So these two functions are not _safe_ in Rust terms. Thus we need to make them `unsafe` functions unless we find some clever solution. -[^fn-invalid-address]: If the `XXX` part of the address is smaller than `0o400`, it's binary representation doesn't start with `1`. But the sign extension bits, which should be a copy of that bit, are `1` instead of `0`. Thus the address is not valid. - ## Some Clever Solution We can use Rust's type system to statically guarantee that the `next_table` methods can only be called on P4, P3, and P2 tables, but not on a P1 table. The idea is to add a `Level` parameter to the `Table` type and implement the `next_table` methods only for level 4, 3, and 2. @@ -887,4 +885,7 @@ Afterwards, we will use this paging module to build a heap allocator. This will Image sources: [^virtual_physical_translation_source] +## Footnotes +[^fn-invalid-address]: If the `XXX` part of the address is smaller than `0o400`, it's binary representation doesn't start with `1`. But the sign extension bits, which should be a copy of that bit, are `1` instead of `0`. Thus the address is not valid. + [^virtual_physical_translation_source]: Image sources: Modified versions of an image from [Wikipedia](https://commons.wikimedia.org/wiki/File:X86_Paging_64bit.svg). The modified files are licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. diff --git a/blog/content/posts/07-remap-the-kernel/index.md b/blog/content/posts/07-remap-the-kernel/index.md index 0be2ae1c..73baeefd 100644 --- a/blog/content/posts/07-remap-the-kernel/index.md +++ b/blog/content/posts/07-remap-the-kernel/index.md @@ -27,7 +27,6 @@ Also, we will use the [information about kernel sections] to map the various sec ## Preparation There are many things that can go wrong when we switch to a new table. Therefore it's a good idea to [set up a debugger][set up gdb]. You should not need it when you follow this post, but it's good to know how to debug a problem when it occurs[^fn-debug-notes]. [set up gdb]: {{% relref "set-up-gdb.md" %}} -[^fn-debug-notes]: For this post the most useful GDB command is probably `p/x *((long int*)0xfffffffffffff000)@512`. It prints all entries of the recursively mapped P4 table by interpreting it as an array of 512 long ints (the `@512` is GDB's array syntax). Of course you can also print other tables by adjusting the address. We also update the `Page` and `Frame` types to make our lives easier. The `Page` struct gets some derived traits: @@ -64,9 +63,7 @@ We can't do that for a `Frame`. If we wanted to be sure that a given frame is un ## Recap: The Paging Module This post builds upon the post about [page tables][previous post], so let's start by quickly recapitulating what we've done there. -We created a `memory::paging` module, which reads and modifies the hierarchical page table through recursive mapping. The owner of the active P4 table and thus all subtables is an `ActivePageTable`[^fn-apt-renamed] struct, which must be instantiated only once. - -[^fn-apt-renamed]: It was renamed in [#88](https://github.com/phil-opp/blog_os/pull/88). The previous name was `RecursivePageTable`. +We created a `memory::paging` module, which reads and modifies the hierarchical page table through recursive mapping. The owner of the active P4 table and thus all subtables is an `ActivePageTable` struct, which must be instantiated only once. The `ActivePageTable` struct provides the following interface: @@ -1077,3 +1074,6 @@ Now that we have a (mostly) safe kernel stack and a working page table module, w [Box]: https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html [Vec]: https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html [BTreeMap]: https://doc.rust-lang.org/nightly/collections/btree_map/struct.BTreeMap.html + +## Footnotes +[^fn-debug-notes]: For this post the most useful GDB command is probably `p/x *((long int*)0xfffffffffffff000)@512`. It prints all entries of the recursively mapped P4 table by interpreting it as an array of 512 long ints (the `@512` is GDB's array syntax). Of course you can also print other tables by adjusting the address. diff --git a/blog/content/posts/08-kernel-heap/index.md b/blog/content/posts/08-kernel-heap/index.md index 275bda81..d51fa017 100644 --- a/blog/content/posts/08-kernel-heap/index.md +++ b/blog/content/posts/08-kernel-heap/index.md @@ -680,9 +680,7 @@ I created the [linked_list_allocator] crate to handle all of these cases. It con [Heap struct]: http://phil-opp.github.io/linked-list-allocator/linked_list_allocator/struct.Heap.html [linked_list_allocator source]: https://github.com/phil-opp/linked-list-allocator -So we just need to implement Rust's allocation modules and integrate it into our kernel. We start by creating a new `hole_list_allocator`[^1] crate inside the `libs` directory: - -[^1]: The name `linked_list_allocator` is already taken, sorry :P. +So we just need to implement Rust's allocation modules and integrate it into our kernel. We start by creating a new `hole_list_allocator` crate inside the `libs` directory: ```shell > cd libs diff --git a/blog/content/posts/09-handling-exceptions/index.md b/blog/content/posts/09-handling-exceptions/index.md index a442cec6..3e3b2eca 100644 --- a/blog/content/posts/09-handling-exceptions/index.md +++ b/blog/content/posts/09-handling-exceptions/index.md @@ -444,8 +444,6 @@ The answer is that the stored instruction pointer only points to the causing ins The reason for the diffent instruction pointer values is that the stored value is also the return address. So for faults, the instruction that caused the exception is restarted and might cause the same exception again if it's not resolved. This would not make much sense for traps, since invoking the breakpoint exception again would just cause another breakpoint exception[^fn-breakpoint-restart-use-cases]. Thus the instruction pointer points to the _next_ instruction for these exceptions. -[^fn-breakpoint-restart-use-cases]: There are valid use cases for restarting an instruction that caused a breakpoint. The most common use case is a debugger: When setting a breakpoint on some code line, the debugger overwrites the corresponding instruction with an `int3` instruction, so that the CPU traps when that line is executed. When the user continues execution, the debugger swaps in the original instruction and continues the program from the replaced instruction. - In some cases, the distinction between faults and traps is vague. For example, the [debug exception] behaves like a fault in some cases, but like a trap in others. So to find out the meaning of the saved instruction pointer, it is a good idea to read the official documentation for the exception, which can be found in the [AMD64 manual] in Section 8.2. For example, for the breakpoint exception it says: [debug exception]: http://wiki.osdev.org/Exceptions#Debug @@ -468,3 +466,6 @@ We've successfully caught our first exception and returned from it! The next ste [triple fault]: http://wiki.osdev.org/Triple_Fault [double faults]: http://wiki.osdev.org/Double_Fault#Double_Fault + +## Footnotes +[^fn-breakpoint-restart-use-cases]: There are valid use cases for restarting an instruction that caused a breakpoint. The most common use case is a debugger: When setting a breakpoint on some code line, the debugger overwrites the corresponding instruction with an `int3` instruction, so that the CPU traps when that line is executed. When the user continues execution, the debugger swaps in the original instruction and continues the program from the replaced instruction. From 3f51f3c61d78c7fd45c208f82c2e26d16e04bf88 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 3 May 2017 19:34:56 +0200 Subject: [PATCH 16/42] Use gutenberg's syntax for internal links --- .../returning-from-exceptions.md | 8 +++---- .../posts/01-multiboot-kernel/index.md | 4 ++-- .../posts/02-entering-longmode/index.md | 10 ++++----- blog/content/posts/03-set-up-rust/index.md | 10 ++++----- .../posts/04-printing-to-screen/index.md | 6 ++--- .../posts/05-allocating-frames/index.md | 4 ++-- blog/content/posts/06-page-tables/index.md | 6 ++--- .../posts/07-remap-the-kernel/index.md | 22 ++++++++++--------- blog/content/posts/08-kernel-heap/index.md | 10 ++++----- .../posts/09-handling-exceptions/index.md | 6 ++--- blog/content/posts/10-double-faults/index.md | 16 +++++++------- 11 files changed, 52 insertions(+), 50 deletions(-) diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md index f1db1d2e..093f812d 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md @@ -37,7 +37,7 @@ The breakpoint exception is commonly used in debuggers: When the user sets a bre For our use case, we don't need to overwrite any instructions (it wouldn't even be possible since we [set the page table flags] to read-only). Instead, we just want to print a message when the breakpoint instruction is executed and then continue the program. -[set the page table flags]: {{% relref "07-remap-the-kernel.md#using-the-correct-flags" %}} +[set the page table flags]: ./posts/07-remap-the-kernel/index.md#using-the-correct-flags ### Catching Breakpoints Let's start by defining a handler function for the breakpoint exception: @@ -211,7 +211,7 @@ Instead of the expected _“It did not crash”_ message after the breakpoint ex ### Debugging Let's debug it using GDB. For that we execute `make debug` in one terminal (which starts QEMU with the `-s -S` flags) and then `make gdb` (which starts and connects GDB) in a second terminal. For more information about GDB debugging, check out our [Set Up GDB] guide. -[Set Up GDB]: {{% relref "set-up-gdb.md" %}} +[Set Up GDB]: ./extra/set-up-gdb.md First we want to check if our `iretq` was successful. Therefore we set a breakpoint on the `println!("It did not crash line!")` statement in `src/lib.rs`. Let's assume that it's on line 61: @@ -299,7 +299,7 @@ Unfortunately, Rust does not support such a calling convention. It was [proposed [interrupt calling conventions]: https://github.com/rust-lang/rfcs/pull/1275 [Naked functions]: https://github.com/rust-lang/rfcs/blob/master/text/1201-naked-fns.md -[naked fn post]: {{% relref "better-exception-messages.md#naked-functions" %}} +[naked fn post]: ./extra/handling-exceptions-with-naked-fns/better-exception-messages.md#naked-functions ### A naked wrapper function @@ -567,7 +567,7 @@ It doesn't compile anymore. The error tells us that the Rust compiler no longer The [core library] is implicitly linked to all `no_std` crates and contains things such as `Result`, `Option`, and iterators. We've used that library without problems since [the very beginning], so why is it no longer available? [core library]: https://doc.rust-lang.org/nightly/core/index.html -[the very beginning]: {{% relref "03-set-up-rust.md" %}} +[the very beginning]: ./posts/03-set-up-rust/index.md The problem is that the core library is distributed together with the Rust compiler as a _precompiled_ library. So it is only valid for the host triple, which is `x86_64-unknown-linux-gnu` in our case. If we want to compile code for other targets, we need to recompile `core` for these targets first. diff --git a/blog/content/posts/01-multiboot-kernel/index.md b/blog/content/posts/01-multiboot-kernel/index.md index 5e87c03f..7dab5adb 100644 --- a/blog/content/posts/01-multiboot-kernel/index.md +++ b/blog/content/posts/01-multiboot-kernel/index.md @@ -188,7 +188,7 @@ Idx Name Size VMA LMA File off Algn CONTENTS, ALLOC, LOAD, READONLY, CODE ``` _Note_: The `ld` and `objdump` commands are platform specific. If you're _not_ working on x86_64 architecture, you will need to [cross compile binutils]. Then use `x86_64‑elf‑ld` and `x86_64‑elf‑objdump` instead of `ld` and `objdump`. -[cross compile binutils]: {{% relref "cross-compile-binutils.md" %}} +[cross compile binutils]: ./extra/cross-compile-binutils.md ## Creating the ISO The last step is to create a bootable ISO image with GRUB. We need to create the following directory structure and copy the `kernel.bin` to the right place: @@ -318,7 +318,7 @@ Now we can invoke `make` and all updated assembly files are compiled and linked. In the [next post] we will create a page table and do some CPU configuration to switch to the 64-bit [long mode]. -[next post]: {{% relref "02-entering-longmode.md" %}} +[next post]: ./posts/02-entering-longmode/index.md [long mode]: https://en.wikipedia.org/wiki/Long_mode ## Footnotes diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index 13650a64..a7c4b970 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -12,7 +12,7 @@ aliases = [ In the [previous post] we created a minimal multiboot kernel. It just prints `OK` and hangs. The goal is to extend it and call 64-bit [Rust] code. But the CPU is currently in [protected mode] and allows only 32-bit instructions and up to 4GiB memory. So we need to set up _Paging_ and switch to the 64-bit [long mode] first. -[previous post]: {{% relref "01-multiboot-kernel.md" %}} +[previous post]: ./posts/01-multiboot-kernel/index.md [Rust]: http://www.rust-lang.org/ [protected mode]: https://en.wikipedia.org/wiki/Protected_mode [long mode]: https://en.wikipedia.org/wiki/Long_mode @@ -40,7 +40,7 @@ error: At address `0xb8000` begins the so-called [VGA text buffer]. It's an array of screen characters that are displayed by the graphics card. A [future post] will cover the VGA buffer in detail and create a Rust interface to it. But for now, manual bit-fiddling is the easiest option. [VGA text buffer]: https://en.wikipedia.org/wiki/VGA-compatible_text_mode -[future post]: {{% relref "04-printing-to-screen.md" %}} +[future post]: ./posts/04-printing-to-screen/index.md A screen character consists of a 8 bit color code and a 8 bit [ASCII] character. We used the color code `4f` for all characters, which means white text on red background. `0x52` is an ASCII `R`, `0x45` is an `E`, `0x3a` is a `:`, and `0x20` is a space. The second space is overwritten by the given ASCII byte. Finally the CPU is stopped with the `hlt` instruction. @@ -494,8 +494,8 @@ _Congratulations_! You have successfully wrestled through this CPU configuration #### One Last Thing Above, we reloaded the code segment register `cs` with the new GDT offset. However, the data segment registers `ss`, `ds`, `es`, `fs`, and `gs` still contain the data segment offsets of the old GDT. This isn't necessarily bad, since they're ignored by almost all instructions in 64-bit mode. However, there are a few instructions that expect a valid data segment descriptor _or the null descriptor_ in those registers. An example is the the [iretq] instruction that we'll need in the [_Returning from Exceptions_] post. -[iretq]: {{% relref "returning-from-exceptions.md#the-iretq-instruction" %}} -[_Returning from Exceptions_]: {{% relref "returning-from-exceptions.md" %}} +[iretq]: ./extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md#the-iretq-instruct/indexion +[_Returning from Exceptions_]: ./extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md To avoid future problems, we reload all data segment registers with null: @@ -517,7 +517,7 @@ long_mode_start: It's time to finally leave assembly behind and switch to [Rust]. Rust is a systems language without garbage collections that guarantees memory safety. Through a real type system and many abstractions it feels like a high-level language but can still be low-level enough for OS development. The [next post] describes the Rust setup. [Rust]: https://www.rust-lang.org/ -[next post]: {{% relref "03-set-up-rust.md" %}} +[next post]: ./posts/03-set-up-rust/index.md ## Footnotes [^hardware_lookup]: In the x86 architecture, the page tables are _hardware walked_, so the CPU will look at the table on its own when it needs a translation. Other architectures, for example MIPS, just throw an exception and let the OS translate the virtual address. diff --git a/blog/content/posts/03-set-up-rust/index.md b/blog/content/posts/03-set-up-rust/index.md index 320c2f1f..96ee4560 100644 --- a/blog/content/posts/03-set-up-rust/index.md +++ b/blog/content/posts/03-set-up-rust/index.md @@ -13,8 +13,8 @@ aliases = [ In the previous posts we created a [minimal Multiboot kernel][multiboot post] and [switched to Long Mode][long mode post]. Now we can finally switch to [Rust] code. Rust is a high-level language without runtime. It allows us to not link the standard library and write bare metal code. Unfortunately the setup is not quite hassle-free yet. -[multiboot post]: {{% relref "01-multiboot-kernel.md" %}} -[long mode post]: {{% relref "02-entering-longmode.md" %}} +[multiboot post]: ./posts/01-multiboot-kernel/index.md +[long mode post]: ./posts/02-entering-longmode/index.md [Rust]: https://www.rust-lang.org/ @@ -90,7 +90,7 @@ Let's define some properties of our target system: - **No SSE**: Our target might not have [SSE] support. Even if it does, we probably don't want to use SSE instructions in our kernel, because it makes interrupt handling much slower. We will explain this in detail in the [“Handling Exceptions”] post. - **No hardware floats**: The `x86_64` architecture uses SSE instructions for floating point operations, which we don't want to use (see the previous point). So we also need to avoid hardware floating point operations in our kernel. Instead, we will use _soft floats_, which are basically software functions that emulate floating point operations using normal integers. -[“Handling Exceptions”]: {{% relref "09-handling-exceptions.md" %}} +[“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ### Target Specifications Rust allows us to define [custom targets] through a JSON configuration file. A minimal target specification equal to `x86_64-unknown-linux-gnu` (the default 64-bit Linux target) looks like this: @@ -480,10 +480,10 @@ Some notes: ### Stack Overflows Since we still use the small 64 byte [stack from the last post], we must be careful not to [overflow] it. Normally, Rust tries to avoid stack overflows through _guard pages_: The page below the stack isn't mapped and such a stack overflow triggers a page fault (instead of silently overwriting random memory). But we can't unmap the page below our stack right now since we currently use only a single big page. Fortunately the stack is located just above the page tables. So some important page table entry would probably get overwritten on stack overflow and then a page fault occurs, too. -[stack from the last post]: {{% relref "02-entering-longmode.md#creating-a-stack" %}} +[stack from the last post]: ./posts/02-entering-longmode/index.md#creating-a-stack [overflow]: https://en.wikipedia.org/wiki/Stack_overflow ## What's next? Until now we write magic bits to some memory location when we want to print something to screen. In the [next post] we create a abstraction for the VGA text buffer that allows us to print strings in different colors and provides a simple interface. -[next post]: {{% relref "04-printing-to-screen.md" %}} +[next post]: ./posts/04-printing-to-screen/index.md diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index 7947e8b0..e52d1c17 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -12,7 +12,7 @@ aliases = [ In the [previous post] we switched from assembly to [Rust], a systems programming language that provides great safety. But so far we are using unsafe features like [raw pointers] whenever we want to print to screen. In this post we will create a Rust module that provides a safe and easy-to-use interface for the VGA text buffer. It will support Rust's [formatting macros], too. -[previous post]: {{% relref "03-set-up-rust.md" %}} +[previous post]: ./posts/03-set-up-rust/index.md [Rust]: https://www.rust-lang.org/ [raw pointers]: https://doc.rust-lang.org/book/raw-pointers.html [formatting macros]: https://doc.rust-lang.org/std/fmt/#related-macros @@ -642,7 +642,7 @@ In the next posts we will map the kernel pages correctly so that accessing `0x0` The [next post] describes the Multiboot information structure and creates a frame allocator using the information about memory areas. -[next post]: {{% relref "05-allocating-frames.md" %}} +[next post]: ./posts/05-allocating-frames/index.md ## Other Rust OS Projects Now that you know the very basics of OS development in Rust, you should also check out the following projects: @@ -651,7 +651,7 @@ Now that you know the very basics of OS development in Rust, you should also che _Note_: You need to [cross compile binutils] to build it (or you create some symbolic links[^fn-symlink] if you're on x86_64). [Rust Bare-Bones Kernel]: https://github.com/thepowersgang/rust-barebones-kernel [higher half]: http://wiki.osdev.org/Higher_Half_Kernel -[cross compile binutils]: {{% relref "cross-compile-binutils.md" %}} +[cross compile binutils]: ./posts/cross-compile-binutils/index.md - [RustOS]: More advanced kernel that supports allocation, keyboard inputs, and threads. It also has a scheduler and a basic network driver. [RustOS]: https://github.com/RustOS-Fork-Holding-Ground/RustOS diff --git a/blog/content/posts/05-allocating-frames/index.md b/blog/content/posts/05-allocating-frames/index.md index 610780ee..3a7a67bd 100644 --- a/blog/content/posts/05-allocating-frames/index.md +++ b/blog/content/posts/05-allocating-frames/index.md @@ -427,10 +427,10 @@ Now we have a working frame allocator. It is a bit rudimentary and cannot free f ## What's next? The [next post] will be about paging again. We will use the frame allocator to create a safe module that allows us to switch page tables and map pages. Then we will use this module and the information from the Elf-sections tag to remap the kernel correctly. -[next post]: {{% relref "06-page-tables.md" %}} +[next post]: ./posts/06-page-tables/index.md ## Recommended Posts Eric Kidd started the [Bare Metal Rust] series last week. Like this post, it builds upon the code from [Printing to Screen], but tries to support keyboard input instead of wrestling through memory management details. [Bare Metal Rust]: http://www.randomhacks.net/bare-metal-rust/ -[Printing to Screen]: {{% relref "04-printing-to-screen.md" %}} +[Printing to Screen]: ./posts/04-printing-to-screen/index.md diff --git a/blog/content/posts/06-page-tables/index.md b/blog/content/posts/06-page-tables/index.md index dac10bc5..64aaa587 100644 --- a/blog/content/posts/06-page-tables/index.md +++ b/blog/content/posts/06-page-tables/index.md @@ -50,7 +50,7 @@ pub struct Page { ``` We import the `PAGE_SIZE` and define a constant for the number of entries per table. To make future function signatures more expressive, we can use the type aliases `PhysicalAddress` and `VirtualAddress`. The `Page` struct is similar to the `Frame` struct in the [previous post], but represents a virtual page instead of a physical frame. -[previous post]: {{% relref "05-allocating-frames.md#a-memory-module" %}} +[previous post]: ./posts/05-allocating-frames/index.md#a-memory-module ### Page Table Entries To model page table entries, we create a new `entry` submodule: @@ -650,7 +650,7 @@ pub struct ActivePageTable { ``` We can't store the `Table` directly because it needs to be at a special memory location (like the [VGA text buffer]). We could use a raw pointer or `&mut` instead of [Unique], but Unique indicates ownership better. -[VGA text buffer]: {{% relref "04-printing-to-screen.md#the-text-buffer" %}} +[VGA text buffer]: ./posts/04-printing-to-screen/index.md#the-text-buffer [Unique]: https://doc.rust-lang.org/nightly/core/ptr/struct.Unique.html Because the `ActivePageTable` owns the unique recursive mapped P4 table, there must be only one `ActivePageTable` instance. Thus we make the constructor function unsafe: @@ -879,7 +879,7 @@ This post has become pretty long. So let's summarize what we've done: ## What's next? In the [next post] we will extend this module and add a function to modify inactive page tables. Through that function, we will create a new page table hierarchy that maps the kernel correctly using 4KiB pages. Then we will switch to the new table to get a safer kernel environment. -[next post]: {{% relref "07-remap-the-kernel.md" %}} +[next post]: ./posts/07-remap-the-kernel/index.md Afterwards, we will use this paging module to build a heap allocator. This will allow us to use allocation and collection types such as `Box` and `Vec`. diff --git a/blog/content/posts/07-remap-the-kernel/index.md b/blog/content/posts/07-remap-the-kernel/index.md index 73baeefd..2939003e 100644 --- a/blog/content/posts/07-remap-the-kernel/index.md +++ b/blog/content/posts/07-remap-the-kernel/index.md @@ -17,16 +17,18 @@ As always, you can find the source code on [Github]. Don't hesitate to file issu ## Motivation In the [previous post], we had a strange bug in the `unmap` function. Its reason was a silent stack overflow, which corrupted the page tables. Fortunately, our kernel stack is right above the page tables so that we noticed the overflow relatively quickly. This won't be the case when we add threads with new stacks in the future. Then a silent stack overflow could overwrite some data without us noticing. But eventually some completely unrelated function fails because a variable changed its value. -[previous post]: {{% relref "06-page-tables.md" %}} + +[previous post]: ./posts/06-page-tables/index.md As you can imagine, these kinds of bugs are horrendous to debug. For that reason we will create a new hierarchical page table in this post, which has _guard page_ below the stack. A guard page is basically an unmapped page that causes a page fault when accessed. Thus we can catch stack overflows right when they happen. Also, we will use the [information about kernel sections] to map the various sections individually instead of blindly mapping the first gigabyte. To improve safety even further, we will set the correct page table flags for the various sections. Thus it won't be possible to modify the contents of `.text` or to execute code from `.data` anymore. -[information about kernel sections]: {{% relref "05-allocating-frames.md#kernel-elf-sections" %}} + +[information about kernel sections]: ./posts/05-allocating-frames/index.md#kernel-elf-sections ## Preparation There are many things that can go wrong when we switch to a new table. Therefore it's a good idea to [set up a debugger][set up gdb]. You should not need it when you follow this post, but it's good to know how to debug a problem when it occurs[^fn-debug-notes]. -[set up gdb]: {{% relref "set-up-gdb.md" %}} +[set up gdb]: ./extra/set-up-gdb.md We also update the `Page` and `Frame` types to make our lives easier. The `Page` struct gets some derived traits: @@ -272,7 +274,7 @@ pub fn map_table_frame(&mut self, } ``` This function interprets the given frame as a page table frame and returns a `Table` reference. We return a table of level 1 because it [forbids calling the `next_table` methods][some clever solution]. Calling `next_table` must not be possible since it's not a page of the recursive mapping. To be able to return a `Table`, we need to make the `Level1` enum in `memory/paging/table.rs` public. -[some clever solution]: {{% relref "06-page-tables.md#some-clever-solution" %}} +[some clever solution]: ./posts/06-page-tables/index.md#some-clever-solution The `unsafe` block is safe since the `VirtualAddress` returned by the `map` function is always valid and the type cast just reinterprets the frame's content. @@ -541,7 +543,7 @@ pub fn remap_the_kernel(allocator: &mut A, boot_info: &BootInformation) First, we create a temporary page at page number `0xcafebabe`. We could use `0xdeadbeaf` or `0x123456789` as well, as long as the page is unused. The `active_table` and the `new_table` are created using their constructor functions. Then we use the `with` function to temporary change the recursive mapping and execute the closure as if the `new_table` were active. This allows us to map the sections in the new table without changing the active mapping. To get the kernel sections, we use the [Multiboot information structure]. -[Multiboot information structure]: {{% relref "05-allocating-frames.md#the-multiboot-information-structure" %}} +[Multiboot information structure]: ./posts/05-allocating-frames/index.md#the-multiboot-information-structure Let's resolve the above `TODO` by identity mapping the sections: @@ -790,7 +792,7 @@ Let's cross our fingers and run it… ### Debugging A QEMU boot loop indicates that some CPU exception occured. We can see all thrown CPU exception by starting QEMU with `-d int` (as described [here][qemu debugging]): -[qemu debugging]: {{% relref "03-set-up-rust.md#debugging" %}} +[qemu debugging]: ./posts/03-set-up-rust/index.md#debugging ```bash > qemu-system-x86_64 -d int -no-reboot -cdrom build/os-x86_64.iso @@ -810,12 +812,12 @@ These lines are the important ones. We can read many useful information from the [page fault error code]: http://wiki.osdev.org/Exceptions#Error_code - `IP=0008:000000000010ab97` or `pc=000000000010ab97`: The program counter register tells us that the exception occurred when the CPU tried to execute the instruction at `0x10ab97`. We can disassemble this address to see the corresponding function. The `0008:` prefix in `IP` indicates the code [GDT segment]. -[GDT segment]: {{% relref "02-entering-longmode.md#loading-the-gdt" %}} +[GDT segment]: ./posts/02-entering-longmode/index.md#loading-the-gdt - `SP=0010:00000000001182d0`: The stack pointer was `0x1182d0` (the `0010:` prefix indicates the data [GDT segment]). This tells us if it the stack overflowed. - `CR2=00000000000b8f00`: Finally the most useful register. It tells us which virtual address caused the page fault. In our case it's `0xb8f00`, which is part of the [VGA text buffer]. -[VGA text buffer]: {{% relref "04-printing-to-screen.md#the-vga-text-buffer" %}} +[VGA text buffer]: ./posts/04-printing-to-screen/index.md#the-vga-text-buffer So let's find out which function caused the exception: @@ -1010,7 +1012,7 @@ If we haven't forgotten to set the `WRITABLE` flag somewhere, it should still wo The final step is to create a guard page for our kernel stack. The decision to place the kernel stack right above the page tables was already useful to detect a silent stack overflow in the [previous post][silent stack overflow]. Now we profit from it again. Let's look at our assembly `.bss` section again to understand why: -[silent stack overflow]: {{% relref "06-page-tables.md#translate" %}} +[silent stack overflow]: ./posts/06-page-tables/index.md#translate ```nasm ; in src/arch/x86_64/boot.asm @@ -1070,7 +1072,7 @@ Unfortunately stack probes require compiler support. They already work on Window ## What's next? Now that we have a (mostly) safe kernel stack and a working page table module, we can add a virtual memory allocator. The [next post] will explore Rust's allocator API and create a very basic allocator. At the end of that post, we will be able to use Rust's allocation and collections types such as [Box], [Vec], or even [BTreeMap]. -[next post]: {{% relref "08-kernel-heap.md" %}} +[next post]: ./posts/08-kernel-heap/index.md [Box]: https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html [Vec]: https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html [BTreeMap]: https://doc.rust-lang.org/nightly/collections/btree_map/struct.BTreeMap.html diff --git a/blog/content/posts/08-kernel-heap/index.md b/blog/content/posts/08-kernel-heap/index.md index d51fa017..5b16f8ae 100644 --- a/blog/content/posts/08-kernel-heap/index.md +++ b/blog/content/posts/08-kernel-heap/index.md @@ -7,8 +7,8 @@ date = "2016-04-11" In the previous posts we have created a [frame allocator] and a [page table module]. Now we are ready to create a kernel heap and a memory allocator. Thus, we will unlock `Box`, `Vec`, `BTreeMap`, and the rest of the [alloc] and [collections] crates. -[frame allocator]: {{% relref "05-allocating-frames.md" %}} -[page table module]: {{% relref "06-page-tables.md" %}} +[frame allocator]: ./posts/05-allocating-frames/index.md +[page table module]: ./posts/06-page-tables/index.md [alloc]: https://doc.rust-lang.org/nightly/alloc/index.html [collections]: https://doc.rust-lang.org/nightly/collections/index.html @@ -470,8 +470,8 @@ That's it. Now our `memory::init` function can only be called once. The macro wo ### Mapping the Heap Now we're ready to map the heap pages. In order to do it, we need access to the `ActivePageTable` or `Mapper` instance (see the [page table] and [kernel remapping] posts). Therefore we return it from the `paging::remap_the_kernel` function: -[page table]: {{% relref "06-page-tables.md" %}} -[kernel remapping]: {{% relref "07-remap-the-kernel.md" %}} +[page table]: ./posts/06-page-tables/index.md +[kernel remapping]: ./posts/07-remap-the-kernel/index.md ```rust // in src/memory/paging/mod.rs @@ -860,4 +860,4 @@ Now we're able to use heap storage in our kernel without leaking memory. This al ## What's next? This post concludes the section about memory management for now. We will revisit this topic eventually, but now it's time to explore other topics. The upcoming posts will be about CPU exceptions and interrupts. We will catch all page, double, and triple faults and create a driver to read keyboard input. The [next post] starts by setting up a so-called _Interrupt Descriptor Table_. -[next post]: {{% relref "09-handling-exceptions.md" %}} +[next post]: ./posts/09-handling-exceptions/index.md diff --git a/blog/content/posts/09-handling-exceptions/index.md b/blog/content/posts/09-handling-exceptions/index.md index 3e3b2eca..4b9eb95c 100644 --- a/blog/content/posts/09-handling-exceptions/index.md +++ b/blog/content/posts/09-handling-exceptions/index.md @@ -193,7 +193,7 @@ The `x86-interrupt` calling convention is a powerful abstraction that hides almo If you are interested in more details: We also have a series of posts that explains exception handling using [naked functions] linked [at the end of this post][too-much-magic]. [naked functions]: https://github.com/rust-lang/rfcs/blob/master/text/1201-naked-fns.md -[too-much-magic]: {{% relref "#too-much-magic" %}} +[too-much-magic]: #too-much-magic ## Implementation Now that we've understood the theory, it's time to handle CPU exceptions in our kernel. We start by creating a new `interrupts` module: @@ -227,7 +227,7 @@ The breakpoint exception is commonly used in debuggers: When the user sets a bre For our use case, we don't need to overwrite any instructions (it wouldn't even be possible since we [set the page table flags] to read-only). Instead, we just want to print a message when the breakpoint instruction is executed and then continue the program. -[set the page table flags]: {{% relref "07-remap-the-kernel.md#using-the-correct-flags" %}} +[set the page table flags]: ./posts/07-remap-the-kernel/index.md#using-the-correct-flags So let's create a simple `breakpoint_handler` function and add it to our IDT: @@ -459,7 +459,7 @@ The documentation of the [`Idt`] struct and the [OSDev Wiki][osdev wiki exceptio ## Too much Magic? The `x86-interrupt` calling convention and the [`Idt`] type made the exception handling process relatively straightforward and painless. If this was too much magic for you and you like to learn all the gory details of exception handling, we got you covered: Our [“Handling Exceptions with Naked Functions”] series shows how to handle exceptions without the `x86-interrupt` calling convention and also creates its own `Idt` type. Historically, these posts were the main exception handling posts before the `x86-interrupt` calling convention and the `x86_64` crate existed. -[“Handling Exceptions with Naked Functions”]: {{% relref "handling-exceptions-with-naked-fns.html" %}} +[“Handling Exceptions with Naked Functions”]: /extra/handling-exceptions-with-naked-fns ## What's next? We've successfully caught our first exception and returned from it! The next step is to add handlers for other common exceptions such as page faults. We also need to make sure that we never cause a [triple fault], since it causes a complete system reset. The next post explains how we can avoid this by correctly catching [double faults]. diff --git a/blog/content/posts/10-double-faults/index.md b/blog/content/posts/10-double-faults/index.md index 531d449e..5daea505 100644 --- a/blog/content/posts/10-double-faults/index.md +++ b/blog/content/posts/10-double-faults/index.md @@ -19,7 +19,7 @@ As always, the complete source code is available on [Github]. Please file [issue ## What is a Double Fault? In simplified terms, a double fault is a special exception that occurs when the CPU fails to invoke an exception handler. For example, it occurs when a page fault is triggered but there is no page fault handler registered in the [Interrupt Descriptor Table][IDT] (IDT). So it's kind of similar to catch-all blocks in programming languages with exceptions, e.g. `catch(...)` in C++ or `catch(Exception e)` in Java or C#. -[IDT]: {{% relref "09-handling-exceptions.md#the-interrupt-descriptor-table" %}} +[IDT]: ./posts/09-handling-exceptions/index.md#the-interrupt-descriptor-table A double fault behaves like a normal exception. It has the vector number `8` and we can define a normal handler function for it in the IDT. It is really important to provide a double fault handler, because if a double fault is unhandled a fatal _triple fault_ occurs. Triple faults can't be caught and most hardware reacts with a system reset. @@ -118,7 +118,7 @@ For example, what happens if… : 3. a divide-by-zero handler causes a breakpoint exception, but the breakpoint handler is swapped out? 4. our kernel overflows its stack and the [guard page] is hit? -[guard page]: {{% relref "07-remap-the-kernel.md#creating-a-guard-page" %}} +[guard page]: ./posts/07-remap-the-kernel/index.md#creating-a-guard-page Fortunately, the AMD64 manual ([PDF][AMD64 manual]) has an exact definition (in Section 8.2.9). According to it, a “double fault exception _can_ occur when a second exception occurs during the handling of a prior (first) exception handler”. The _“can”_ is important: Only very specific combinations of exceptions lead to a double fault. These combinations are: @@ -198,7 +198,7 @@ struct InterruptStackTable { For each exception handler, we can choose an stack from the IST through the `options` field in the corresponding [IDT entry]. For example, we could use the first stack in the IST for our double fault handler. Then the CPU would automatically switch to this stack whenever a double fault occurs. This switch would happen before anything is pushed, so it would prevent the triple fault. -[IDT entry]: {{% relref "09-handling-exceptions.md#the-interrupt-descriptor-table" %}} +[IDT entry]: ./posts/09-handling-exceptions/index.md#the-interrupt-descriptor-table ### Allocating a new Stack In order to fill an Interrupt Stack Table later, we need a way to allocate new stacks. Therefore we extend our `memory` module with a new `stack_allocator` submodule: @@ -229,7 +229,7 @@ impl StackAllocator { ``` We create a simple `StackAllocator` that allocates stacks from a given range of pages (`PageIter` is an Iterator over a range of pages; we introduced it [in the kernel heap post].). -[in the kernel heap post]: {{% relref "08-kernel-heap.md#mapping-the-heap" %}} +[in the kernel heap post]: ./posts/08-kernel-heap/index.md#mapping-the-heap We add a `alloc_stack` method that allocates a new stack: @@ -284,8 +284,8 @@ impl StackAllocator { ``` The method takes mutable references to the [ActivePageTable] and a [FrameAllocator], since it needs to map the new virtual stack pages to physical frames. We define that the stack size is a multiple of the page size. -[ActivePageTable]: {{% relref "06-page-tables.md#page-table-ownership" %}} -[FrameAllocator]: {{% relref "05-allocating-frames.md#a-frame-allocator" %}} +[ActivePageTable]: ./posts/06-page-tables/index.md#page-table-ownership +[FrameAllocator]: ./posts/05-allocating-frames/index.md#a-frame-allocator Instead of operating directly on `self.range`, we [clone] it and only write it back on success. This way, subsequent stack allocations can still succeed if there are pages left (e.g., a call with `size_in_pages = 3` can still succeed after a failed call with `size_in_pages = 100`). @@ -296,7 +296,7 @@ In order to be able to clone `PageIter`, we add a `#[derive(Clone)]` to its defi The actual allocation is straightforward: First, we choose the next page as [guard page]. Then we choose the next `size_in_pages` pages as stack pages using [Iterator::nth]. If all three variables are `Some`, the allocation succeeded and we map the stack pages to physical frames using [ActivePageTable::map]. The guard page remains unmapped. [Iterator::nth]: https://doc.rust-lang.org/nightly/core/iter/trait.Iterator.html#method.nth -[ActivePageTable::map]: {{% relref "06-page-tables.md#more-mapping-functions" %}} +[ActivePageTable::map]: ./posts/06-page-tables/index.md#more-mapping-functions Finally, we create and return a new `Stack`, which we define as follows: @@ -504,7 +504,7 @@ The Global Descriptor Table (GDT) is a relict that was used for [memory segmenta We already created a GDT [when switching to long mode]. Back then, we used assembly to create valid code and data segment descriptors, which were required to enter 64-bit mode. We could just edit that assembly file and add an additional TSS descriptor. However, we now have the expressiveness of Rust, so let's do it in Rust instead. -[when switching to long mode]: {{% relref "02-entering-longmode.md#the-global-descriptor-table" %}} +[when switching to long mode]: ./posts/02-entering-longmode/index.md#the-global-descriptor-table We start by creating a new `interrupts::gdt` submodule. For that we need to rename the `src/interrupts.rs` file to `src/interrupts/mod.rs`. Then we can create a new submodule: From c2dcd29d81cadae1318ac6c9679d664acb2ce4a7 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:35:33 +0200 Subject: [PATCH 17/42] Fix and update gutenberg config file --- blog/config.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/blog/config.toml b/blog/config.toml index 0e23b80a..fa14d9ea 100644 --- a/blog/config.toml +++ b/blog/config.toml @@ -1,13 +1,10 @@ title = "Writing an OS in Rust" -description = "test" -base_url = "https://os.phil-opp.com.com" +base_url = "https://os.phil-opp.com" highlight_code = true highlight_theme = "monokai" -insert_anchor_links = true generate_rss = true [extra] -# Put all your custom variables here subtitle = "Philipp Oppermann's blog" author = { name = "Philipp Oppermann" } From a80017cf6c2cbc301d07776a134c61f83934c62b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:35:50 +0200 Subject: [PATCH 18/42] Remove index section --- blog/content/_index.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 blog/content/_index.md diff --git a/blog/content/_index.md b/blog/content/_index.md deleted file mode 100644 index 5ec844a4..00000000 --- a/blog/content/_index.md +++ /dev/null @@ -1,3 +0,0 @@ -+++ -sort_by = "order" -+++ From c6cd132de9bf844bcb00caf4caa94bc8bc08c97d Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:36:31 +0200 Subject: [PATCH 19/42] Sort naked exception handling posts correctly --- .../content/extra/handling-exceptions-with-naked-fns/_index.md | 3 ++- .../better-exception-messages.md | 2 +- .../handling-exceptions-with-naked-fns/catching-exceptions.md | 2 +- .../returning-from-exceptions.md | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/_index.md b/blog/content/extra/handling-exceptions-with-naked-fns/_index.md index c5f74fb2..a88450f6 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/_index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/_index.md @@ -1,5 +1,6 @@ +++ title = "Handling Exceptions using naked Functions" -description = "" +sort_by = "order" template = "handling-exceptions-with-naked-fns.html" +insert_anchor = "left" +++ diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md b/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md index 1efbbc8e..843d1cbb 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/better-exception-messages.md @@ -1,6 +1,6 @@ +++ title = "Better Exception Messages" -description = "" +order = 2 slug = "better-exception-messages" date = "2016-08-03" updated = "2016-11-01" diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md b/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md index 9d7e7b60..3dfbf37c 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/catching-exceptions.md @@ -1,6 +1,6 @@ +++ title = "Catching Exceptions" -description = "" +order = 1 slug = "catching-exceptions" date = "2016-05-28" updated = "2016-06-25" diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md index 093f812d..b4c12d71 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/returning-from-exceptions.md @@ -1,6 +1,6 @@ +++ title = "Returning from Exceptions" -description = "" +order = 3 slug = "returning-from-exceptions" date = "2016-09-21" updated = "2016-11-01" From 8289bc7d5ba497df6b4ec22801c0c820d0f2d87a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:36:53 +0200 Subject: [PATCH 20/42] The css class for anchors was changed --- blog/static/css/main.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blog/static/css/main.css b/blog/static/css/main.css index a9132887..0d0fb767 100644 --- a/blog/static/css/main.css +++ b/blog/static/css/main.css @@ -201,7 +201,7 @@ a code { color: #268bd2; } -a.anchor { +a.gutenberg-anchor { opacity: 0; position: absolute; margin-left: -1.5em; @@ -211,11 +211,11 @@ a.anchor { line-height: 2em; } -:hover>a.anchor { +:hover>a.gutenberg-anchor { opacity: 1; text-decoration: none; } -a.anchor:hover { +a.gutenberg-anchor:hover { text-decoration: none; } From d5a3b48d62356ab3aa35dd003bbf663fd119faea Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:37:47 +0200 Subject: [PATCH 21/42] Make posts, pages, and extra sections --- blog/content/extra/_index.md | 4 ++++ blog/content/pages/_index.md | 3 +++ blog/content/posts/_index.md | 5 +++++ 3 files changed, 12 insertions(+) create mode 100644 blog/content/extra/_index.md create mode 100644 blog/content/pages/_index.md create mode 100644 blog/content/posts/_index.md diff --git a/blog/content/extra/_index.md b/blog/content/extra/_index.md new file mode 100644 index 00000000..e73320ea --- /dev/null +++ b/blog/content/extra/_index.md @@ -0,0 +1,4 @@ ++++ +title = "Extra Content" +insert_anchor = "left" ++++ diff --git a/blog/content/pages/_index.md b/blog/content/pages/_index.md new file mode 100644 index 00000000..4fdb9cac --- /dev/null +++ b/blog/content/pages/_index.md @@ -0,0 +1,3 @@ ++++ +title = "Pages" ++++ diff --git a/blog/content/posts/_index.md b/blog/content/posts/_index.md new file mode 100644 index 00000000..1b1b16e2 --- /dev/null +++ b/blog/content/posts/_index.md @@ -0,0 +1,5 @@ ++++ +title = "Posts" +sort_by = "order" +insert_anchor = "left" ++++ From 11de9b4c07d3f64860a06b8d45cdca718c03808c Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 13:39:39 +0200 Subject: [PATCH 22/42] Update templates for new page sections --- blog/templates/index.html | 35 +++++++++++++++++++++-------------- blog/templates/macros.html | 4 ---- blog/templates/section.html | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/blog/templates/index.html b/blog/templates/index.html index c09910f0..9007f96b 100644 --- a/blog/templates/index.html +++ b/blog/templates/index.html @@ -5,6 +5,7 @@ {% block title %}{{ config.title }}{% endblock title %} {% block main %} +{% set posts = sections.posts %}

This blog series creates a small operating system in the @@ -13,39 +14,45 @@ Github repository.

Latest post: - {{ macros::latest_post_link(page=pages|reverse|last) }} + {% set latest_post = posts.pages|reverse|last %} + {{ latest_post.title }}

- {{ macros::post_link(page=pages.9) }} - {{ macros::post_link(page=pages.8) }} - {{ macros::post_link(page=pages.7) }} - {{ macros::post_link(page=pages.6) }} + {{ macros::post_link(page=posts.pages.9) }} + {{ macros::post_link(page=posts.pages.8) }} + {{ macros::post_link(page=posts.pages.7) }} + {{ macros::post_link(page=posts.pages.6) }}
- {{ macros::post_link(page=pages.5) }} - {{ macros::post_link(page=pages.4) }} - {{ macros::post_link(page=pages.3) }} - {{ macros::post_link(page=pages.2) }} + {{ macros::post_link(page=posts.pages.5) }} + {{ macros::post_link(page=posts.pages.4) }} + {{ macros::post_link(page=posts.pages.3) }} + {{ macros::post_link(page=posts.pages.2) }}
- {{ macros::post_link(page=pages.1) }} - {{ macros::post_link(page=pages.0) }} + {{ macros::post_link(page=posts.pages.1) }} + {{ macros::post_link(page=posts.pages.0) }}

-

Additional Resources

- +{% set extra = sections.extra %} +

{{ extra.title }}

-
diff --git a/blog/templates/handling-exceptions-with-naked-fns.html b/blog/templates/handling-exceptions-with-naked-fns.html index 55cc88fd..eb512446 100644 --- a/blog/templates/handling-exceptions-with-naked-fns.html +++ b/blog/templates/handling-exceptions-with-naked-fns.html @@ -6,6 +6,6 @@ {% block introduction %} -

These posts explain how to handle CPU exceptions using naked functions. Historically, these posts were the main exception handling posts before the x86-interrupt calling convention and the x86_64 crate existed. Our new way of handling exceptions can be found in the “Handling Exceptions” post.

+

These posts explain how to handle CPU exceptions using naked functions. Historically, these posts were the main exception handling posts before the x86-interrupt calling convention and the x86_64 crate existed. Our new way of handling exceptions can be found in the “Handling Exceptions” post.

{% endblock introduction %} From 6f14cc83af7a5c09a9ab4a554def1143f40fd99b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 15:46:16 +0200 Subject: [PATCH 28/42] Adjust recent-updates generation for gutenberg --- blog/before_build.py | 4 ++-- blog/templates/index.html | 2 +- blog/templates/recent-updates.html | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 blog/templates/recent-updates.html diff --git a/blog/before_build.py b/blog/before_build.py index 52b7a5b9..7af7d1d4 100644 --- a/blog/before_build.py +++ b/blog/before_build.py @@ -4,9 +4,9 @@ import io from github import Github -g = Github("e62e298b2a46ca5cf474cb9a4c0c1bc950b09d46") +g = Github() -with io.open("layouts/partials/recent-updates.html", 'w', encoding='utf8') as recent_updates: +with io.open("templates/recent-updates.html", 'w', encoding='utf8') as recent_updates: recent_updates.truncate() recent_updates.write(u"
    \n") diff --git a/blog/templates/index.html b/blog/templates/index.html index 9007f96b..ad0774ed 100644 --- a/blog/templates/index.html +++ b/blog/templates/index.html @@ -55,7 +55,7 @@ {% endblock main %} diff --git a/blog/templates/recent-updates.html b/blog/templates/recent-updates.html new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/blog/templates/recent-updates.html @@ -0,0 +1 @@ + From 4c09e9792b2ee706e9a9b8106143a6355153c1f2 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 15:47:18 +0200 Subject: [PATCH 29/42] Remove python requirements we no longer need --- requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 67c329ff..945b116a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ -pygments -pygments-github-lexers PyGithub From 8140eb0e7c019c0081cf913593d393b875f5d6d3 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 17:43:58 +0200 Subject: [PATCH 30/42] Don't render section pages for posts,pages,extra --- blog/content/extra/_index.md | 1 + blog/content/pages/_index.md | 1 + blog/content/posts/_index.md | 1 + 3 files changed, 3 insertions(+) diff --git a/blog/content/extra/_index.md b/blog/content/extra/_index.md index e73320ea..6cb496d7 100644 --- a/blog/content/extra/_index.md +++ b/blog/content/extra/_index.md @@ -1,4 +1,5 @@ +++ title = "Extra Content" insert_anchor = "left" +render = false +++ diff --git a/blog/content/pages/_index.md b/blog/content/pages/_index.md index 4fdb9cac..51045f13 100644 --- a/blog/content/pages/_index.md +++ b/blog/content/pages/_index.md @@ -1,3 +1,4 @@ +++ title = "Pages" +render = false +++ diff --git a/blog/content/posts/_index.md b/blog/content/posts/_index.md index 1b1b16e2..67040f85 100644 --- a/blog/content/posts/_index.md +++ b/blog/content/posts/_index.md @@ -2,4 +2,5 @@ title = "Posts" sort_by = "order" insert_anchor = "left" +render = false +++ From e11d8381890c986a2c40f5f04f1fb40083d40aa6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 17:51:55 +0200 Subject: [PATCH 31/42] Add a 404 page --- blog/content/pages/404.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 blog/content/pages/404.md diff --git a/blog/content/pages/404.md b/blog/content/pages/404.md new file mode 100644 index 00000000..df0f46ce --- /dev/null +++ b/blog/content/pages/404.md @@ -0,0 +1,12 @@ ++++ +title = "Page not found" +url = "404.html" ++++ + +Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. + +[Head back home](/) to try finding it again. + +If you followed a link on this site, please [report it]! + +[report it]: https://github.com/phil-opp/blog_os/issues From c1044458802718e610e72afca5fdee5a82d5095f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 18:08:10 +0200 Subject: [PATCH 32/42] Remove sections from URLs --- blog/content/extra/cross-compile-binutils.md | 2 +- blog/content/extra/cross-compile-libcore.md | 2 +- .../01-catching-exceptions/index.md | 2 +- .../02-better-exception-messages/index.md | 2 +- .../03-returning-from-exceptions/index.md | 2 +- blog/content/extra/set-up-gdb/index.md | 2 +- blog/content/pages/contact.md | 2 +- blog/content/posts/04-printing-to-screen/index.md | 2 +- blog/content/posts/05-allocating-frames/index.md | 2 +- blog/content/posts/06-page-tables/index.md | 2 +- blog/content/posts/07-remap-the-kernel/index.md | 2 +- blog/content/posts/08-kernel-heap/index.md | 2 +- blog/content/posts/09-handling-exceptions/index.md | 2 +- blog/content/posts/10-double-faults/index.md | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/blog/content/extra/cross-compile-binutils.md b/blog/content/extra/cross-compile-binutils.md index 53ae157f..483b04a9 100644 --- a/blog/content/extra/cross-compile-binutils.md +++ b/blog/content/extra/cross-compile-binutils.md @@ -1,7 +1,7 @@ +++ title = "Cross Compile Binutils" description = "" -slug = "cross-compile-binutils" +url = "cross-compile-binutils" +++ The [GNU Binutils] are a collection of various binary tools such as `ld`, `as`, `objdump`, or `readelf`. These tools are platform-specific, so you need to compile them again if your host system and target system are different. In our case, we need `ld` and `objdump` for the x86_64 architecture. diff --git a/blog/content/extra/cross-compile-libcore.md b/blog/content/extra/cross-compile-libcore.md index 5bea13eb..77e82e07 100644 --- a/blog/content/extra/cross-compile-libcore.md +++ b/blog/content/extra/cross-compile-libcore.md @@ -1,7 +1,7 @@ +++ title = "Cross Compiling: libcore" description = "" -slug = "cross-compile-libcore" +url = "cross-compile-libcore" +++ If you get an `error: can't find crate for 'core'`, you're probably compiling for a different target (e.g. you're passing the `target` option to `cargo build`). Now the compiler complains that it can't find the `core` library. This document gives a quick overview how to fix this problem. For more details, see the [rust-cross] project. diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md index 854fbc1c..02f0f3bf 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md @@ -1,7 +1,7 @@ +++ title = "Catching Exceptions" order = 1 -slug = "catching-exceptions" +url = "catching-exceptions" date = "2016-05-28" updated = "2016-06-25" +++ diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md index ab9bda0c..3635b228 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md @@ -1,7 +1,7 @@ +++ title = "Better Exception Messages" order = 2 -slug = "better-exception-messages" +url = "better-exception-messages" date = "2016-08-03" updated = "2016-11-01" +++ diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md index 37720ebb..7bb4f4a9 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md @@ -1,7 +1,7 @@ +++ title = "Returning from Exceptions" order = 3 -slug = "returning-from-exceptions" +url = "returning-from-exceptions" date = "2016-09-21" updated = "2016-11-01" +++ diff --git a/blog/content/extra/set-up-gdb/index.md b/blog/content/extra/set-up-gdb/index.md index f8b08e3f..873458c6 100644 --- a/blog/content/extra/set-up-gdb/index.md +++ b/blog/content/extra/set-up-gdb/index.md @@ -1,7 +1,7 @@ +++ title = "Set Up GDB" description = "" -slug = "set-up-gdb" +url = "set-up-gdb" +++ There are a lot of things that can go wrong when developing an OS. So it's a good idea to add a debugger to our toolset, which allows us to set breakpoints and examine variables. We will use [GDB](https://www.gnu.org/software/gdb/) as QEMU supports it out of the box. diff --git a/blog/content/pages/contact.md b/blog/content/pages/contact.md index 545b173b..abe609ac 100644 --- a/blog/content/pages/contact.md +++ b/blog/content/pages/contact.md @@ -1,6 +1,6 @@ +++ title = "Contact" -slug = "contact" +url = "contact" +++ Philipp Oppermann diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index 2cd90e61..d3d8cc65 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -1,7 +1,7 @@ +++ title = "Printing to Screen" order = 4 -slug = "printing-to-screen" +url = "printing-to-screen" date = "2015-10-23" updated = "2016-10-31" aliases = [ diff --git a/blog/content/posts/05-allocating-frames/index.md b/blog/content/posts/05-allocating-frames/index.md index f2122e19..51fc265a 100644 --- a/blog/content/posts/05-allocating-frames/index.md +++ b/blog/content/posts/05-allocating-frames/index.md @@ -1,7 +1,7 @@ +++ title = "Allocating Frames" order = 5 -slug = "allocating-frames" +url = "allocating-frames" date = "2015-11-15" +++ diff --git a/blog/content/posts/06-page-tables/index.md b/blog/content/posts/06-page-tables/index.md index 87be5fa3..7cba5095 100644 --- a/blog/content/posts/06-page-tables/index.md +++ b/blog/content/posts/06-page-tables/index.md @@ -1,7 +1,7 @@ +++ title = "Page Tables" order = 6 -slug = "page-tables" +url = "page-tables" date = "2015-12-09" +++ diff --git a/blog/content/posts/07-remap-the-kernel/index.md b/blog/content/posts/07-remap-the-kernel/index.md index a3a92278..c552e442 100644 --- a/blog/content/posts/07-remap-the-kernel/index.md +++ b/blog/content/posts/07-remap-the-kernel/index.md @@ -1,7 +1,7 @@ +++ title = "Remap the Kernel" order = 7 -slug = "remap-the-kernel" +url = "remap-the-kernel" date = "2016-01-01" updated = "2016-03-06" +++ diff --git a/blog/content/posts/08-kernel-heap/index.md b/blog/content/posts/08-kernel-heap/index.md index ed2fcf5d..c9e0855e 100644 --- a/blog/content/posts/08-kernel-heap/index.md +++ b/blog/content/posts/08-kernel-heap/index.md @@ -1,7 +1,7 @@ +++ title = "Kernel Heap" order = 8 -slug = "kernel-heap" +url = "kernel-heap" date = "2016-04-11" +++ diff --git a/blog/content/posts/09-handling-exceptions/index.md b/blog/content/posts/09-handling-exceptions/index.md index 75cbb001..154d1e19 100644 --- a/blog/content/posts/09-handling-exceptions/index.md +++ b/blog/content/posts/09-handling-exceptions/index.md @@ -1,7 +1,7 @@ +++ title = "Handling Exceptions" order = 9 -slug = "handling-exceptions" +url = "handling-exceptions" date = "2017-03-26" +++ diff --git a/blog/content/posts/10-double-faults/index.md b/blog/content/posts/10-double-faults/index.md index 1226c18a..148ae397 100644 --- a/blog/content/posts/10-double-faults/index.md +++ b/blog/content/posts/10-double-faults/index.md @@ -1,7 +1,7 @@ +++ title = "Double Faults" order = 10 -slug = "double-faults" +url = "double-faults" date = "2017-01-02" +++ From a1ed273f7fc0dc049e290725bb78b229cb0d2563 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 9 Jun 2017 18:46:59 +0200 Subject: [PATCH 33/42] Add redirects from old URLs --- blog/content/posts/01-multiboot-kernel/index.md | 4 ---- blog/content/posts/02-entering-longmode/index.md | 4 ---- blog/content/posts/03-set-up-rust/index.md | 5 ----- blog/content/posts/04-printing-to-screen/index.md | 4 ---- blog/static/_redirects | 10 ++++++++++ 5 files changed, 10 insertions(+), 17 deletions(-) create mode 100644 blog/static/_redirects diff --git a/blog/content/posts/01-multiboot-kernel/index.md b/blog/content/posts/01-multiboot-kernel/index.md index 26622202..7cc15aea 100644 --- a/blog/content/posts/01-multiboot-kernel/index.md +++ b/blog/content/posts/01-multiboot-kernel/index.md @@ -3,10 +3,6 @@ title = "A minimal x86 kernel" order = 1 url = "multiboot-kernel" date = "2015-08-18" -aliases = [ - "/2015/08/18/multiboot-kernel/", - "/rust-os/multiboot-kernel.html", -] +++ This post explains how to create a minimal x86 operating system kernel. In fact, it will just boot and print `OK` to the screen. The following blog posts we will extend it using the [Rust] programming language. diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index d07462c1..546fdbba 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -4,10 +4,6 @@ order = 2 url = "entering-longmode" date = "2015-08-25" updated = "2015-10-29" -aliases = [ - "/2015/08/25/entering-longmode/", - "/rust-os/entering-longmode.html", -] +++ In the [previous post] we created a minimal multiboot kernel. It just prints `OK` and hangs. The goal is to extend it and call 64-bit [Rust] code. But the CPU is currently in [protected mode] and allows only 32-bit instructions and up to 4GiB memory. So we need to set up _Paging_ and switch to the 64-bit [long mode] first. diff --git a/blog/content/posts/03-set-up-rust/index.md b/blog/content/posts/03-set-up-rust/index.md index 2f7098b2..e0d0439f 100644 --- a/blog/content/posts/03-set-up-rust/index.md +++ b/blog/content/posts/03-set-up-rust/index.md @@ -4,11 +4,6 @@ order = 3 url = "set-up-rust" date = "2015-09-02" updated = "2017-04-12" -aliases = [ - "/2015/09/02/setup-rust/", - "/setup-rust.html", - "/rust-os/setup-rust.html", -] +++ In the previous posts we created a [minimal Multiboot kernel][multiboot post] and [switched to Long Mode][long mode post]. Now we can finally switch to [Rust] code. Rust is a high-level language without runtime. It allows us to not link the standard library and write bare metal code. Unfortunately the setup is not quite hassle-free yet. diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index d3d8cc65..2b900a8f 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -4,10 +4,6 @@ order = 4 url = "printing-to-screen" date = "2015-10-23" updated = "2016-10-31" -aliases = [ - "/2015/10/23/printing-to-screen/", - "/rust-os/printing-to-screen.html", -] +++ In the [previous post] we switched from assembly to [Rust], a systems programming language that provides great safety. But so far we are using unsafe features like [raw pointers] whenever we want to print to screen. In this post we will create a Rust module that provides a safe and easy-to-use interface for the VGA text buffer. It will support Rust's [formatting macros], too. diff --git a/blog/static/_redirects b/blog/static/_redirects new file mode 100644 index 00000000..9fb86302 --- /dev/null +++ b/blog/static/_redirects @@ -0,0 +1,10 @@ +# Redirects from what the browser requests to what we serve +/2015/08/18/multiboot-kernel/ /multiboot-kernel/ +/rust-os/multiboot-kernel.html /multiboot-kernel/ +/2015/08/25/entering-longmode/ /entering-longmode/ +/rust-os/entering-longmode.html /entering-longmode/ +/2015/09/02/setup-rust/ /set-up-rust/ +/setup-rust.html /set-up-rust/ +/rust-os/setup-rust.html /set-up-rust/ +/2015/10/23/printing-to-screen/ /printing-to-screen/ +/rust-os/printing-to-screen.html /printing-to-screen/ From d83dc719cf51d1a476d08788be8387be578cb194 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 12:56:58 +0200 Subject: [PATCH 34/42] Add piwik tracking code --- blog/templates/base.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/blog/templates/base.html b/blog/templates/base.html index f20491d0..c261e62a 100644 --- a/blog/templates/base.html +++ b/blog/templates/base.html @@ -36,6 +36,22 @@ + + + + From 918f9045d36a0665c9d40ac2faa1b7992326a5ce Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 14:27:24 +0200 Subject: [PATCH 35/42] Rename naked exception handling section --- .../01-catching-exceptions/index.md | 2 +- .../normal-vs-interrupt-function-return.svg | 0 .../qemu-divide-error-println.png | Bin .../exception-stack-frame.svg | 0 .../02-better-exception-messages/index.md | 2 +- .../qemu-divide-by-zero-stack-frame.png | Bin .../qemu-page-fault-error-code.png | Bin .../qemu-page-fault-handler.png | Bin .../qemu-print-stack-frame-try.png | Bin .../exception-stack-frame.svg | 0 .../function-stack-frame.svg | 0 .../03-returning-from-exceptions/index.md | 4 ++-- .../qemu-breakpoint-handler.png | Bin .../qemu-breakpoint-return-page-fault.png | Bin .../qemu-breakpoint-return.png | Bin .../qemu-page-fault-return.png | Bin .../red-zone-overwrite.svg | 0 .../03-returning-from-exceptions/red-zone.svg | 0 .../03-returning-from-exceptions/xmm-overwrite.svg | 0 .../_index.md | 0 blog/content/posts/01-multiboot-kernel/index.md | 2 +- blog/content/posts/02-entering-longmode/index.md | 4 ++-- 22 files changed, 7 insertions(+), 7 deletions(-) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/01-catching-exceptions/index.md (99%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/01-catching-exceptions/normal-vs-interrupt-function-return.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/01-catching-exceptions/qemu-divide-error-println.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/exception-stack-frame.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/index.md (99%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/qemu-divide-by-zero-stack-frame.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/qemu-page-fault-error-code.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/qemu-page-fault-handler.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/02-better-exception-messages/qemu-print-stack-frame-try.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/exception-stack-frame.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/function-stack-frame.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/index.md (99%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/qemu-breakpoint-handler.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/qemu-breakpoint-return-page-fault.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/qemu-breakpoint-return.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/qemu-page-fault-return.png (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/red-zone-overwrite.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/red-zone.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/03-returning-from-exceptions/xmm-overwrite.svg (100%) rename blog/content/extra/{handling-exceptions-with-naked-fns => naked-exceptions}/_index.md (100%) diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md b/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md similarity index 99% rename from blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md rename to blog/content/extra/naked-exceptions/01-catching-exceptions/index.md index 02f0f3bf..3ab92597 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md +++ b/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md @@ -17,7 +17,7 @@ As always, the complete source code is on [Github]. Please file [issues] for any > **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. -[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions with Naked Functions”]: ./extra/naked-exceptions/_index.md [“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Exceptions diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/normal-vs-interrupt-function-return.svg b/blog/content/extra/naked-exceptions/01-catching-exceptions/normal-vs-interrupt-function-return.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/normal-vs-interrupt-function-return.svg rename to blog/content/extra/naked-exceptions/01-catching-exceptions/normal-vs-interrupt-function-return.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/qemu-divide-error-println.png b/blog/content/extra/naked-exceptions/01-catching-exceptions/qemu-divide-error-println.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/qemu-divide-error-println.png rename to blog/content/extra/naked-exceptions/01-catching-exceptions/qemu-divide-error-println.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/exception-stack-frame.svg b/blog/content/extra/naked-exceptions/02-better-exception-messages/exception-stack-frame.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/exception-stack-frame.svg rename to blog/content/extra/naked-exceptions/02-better-exception-messages/exception-stack-frame.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md similarity index 99% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md rename to blog/content/extra/naked-exceptions/02-better-exception-messages/index.md index 3635b228..b3727536 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md +++ b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md @@ -18,7 +18,7 @@ As always, the complete source code is on [Github]. Please file [issues] for any > **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. -[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions with Naked Functions”]: ./extra/naked-exceptions/_index.md [“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Exceptions in Detail diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-divide-by-zero-stack-frame.png b/blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-divide-by-zero-stack-frame.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-divide-by-zero-stack-frame.png rename to blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-divide-by-zero-stack-frame.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-page-fault-error-code.png b/blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-page-fault-error-code.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-page-fault-error-code.png rename to blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-page-fault-error-code.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-page-fault-handler.png b/blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-page-fault-handler.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-page-fault-handler.png rename to blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-page-fault-handler.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-print-stack-frame-try.png b/blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-print-stack-frame-try.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/qemu-print-stack-frame-try.png rename to blog/content/extra/naked-exceptions/02-better-exception-messages/qemu-print-stack-frame-try.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/exception-stack-frame.svg b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/exception-stack-frame.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/exception-stack-frame.svg rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/exception-stack-frame.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/function-stack-frame.svg b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/function-stack-frame.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/function-stack-frame.svg rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/function-stack-frame.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md similarity index 99% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md index 7bb4f4a9..f6840d36 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md +++ b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md @@ -18,7 +18,7 @@ As always, the complete source code is on [Github]. Please file [issues] for any > **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. -[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions with Naked Functions”]: ./extra/naked-exceptions/_index.md [“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Introduction @@ -301,7 +301,7 @@ Unfortunately, Rust does not support such a calling convention. It was [proposed [interrupt calling conventions]: https://github.com/rust-lang/rfcs/pull/1275 [Naked functions]: https://github.com/rust-lang/rfcs/blob/master/text/1201-naked-fns.md -[naked fn post]: ./extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md#naked-functions +[naked fn post]: ./extra/naked-exceptions/02-better-exception-messages/index.md#naked-functions ### A naked wrapper function diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-handler.png b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-handler.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-handler.png rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-handler.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-return-page-fault.png b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-return-page-fault.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-return-page-fault.png rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-return-page-fault.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-return.png b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-return.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-breakpoint-return.png rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-breakpoint-return.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-page-fault-return.png b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-page-fault-return.png similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/qemu-page-fault-return.png rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/qemu-page-fault-return.png diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/red-zone-overwrite.svg b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/red-zone-overwrite.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/red-zone-overwrite.svg rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/red-zone-overwrite.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/red-zone.svg b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/red-zone.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/red-zone.svg rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/red-zone.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/xmm-overwrite.svg b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/xmm-overwrite.svg similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/xmm-overwrite.svg rename to blog/content/extra/naked-exceptions/03-returning-from-exceptions/xmm-overwrite.svg diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/_index.md b/blog/content/extra/naked-exceptions/_index.md similarity index 100% rename from blog/content/extra/handling-exceptions-with-naked-fns/_index.md rename to blog/content/extra/naked-exceptions/_index.md diff --git a/blog/content/posts/01-multiboot-kernel/index.md b/blog/content/posts/01-multiboot-kernel/index.md index 7cc15aea..64e29232 100644 --- a/blog/content/posts/01-multiboot-kernel/index.md +++ b/blog/content/posts/01-multiboot-kernel/index.md @@ -1,7 +1,7 @@ +++ title = "A minimal x86 kernel" order = 1 -url = "multiboot-kernel" +url = "multiboot-kernel/" date = "2015-08-18" +++ diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index 546fdbba..47a16f2e 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -490,8 +490,8 @@ _Congratulations_! You have successfully wrestled through this CPU configuration #### One Last Thing Above, we reloaded the code segment register `cs` with the new GDT offset. However, the data segment registers `ss`, `ds`, `es`, `fs`, and `gs` still contain the data segment offsets of the old GDT. This isn't necessarily bad, since they're ignored by almost all instructions in 64-bit mode. However, there are a few instructions that expect a valid data segment descriptor _or the null descriptor_ in those registers. An example is the the [iretq] instruction that we'll need in the [_Returning from Exceptions_] post. -[iretq]: ./extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md#the -[_Returning from Exceptions_]: ./extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md +[iretq]: ./extra/naked-exceptions/03-returning-from-exceptions/index.md#the +[_Returning from Exceptions_]: ./extra/naked-exceptions/03-returning-from-exceptions/index.md To avoid future problems, we reload all data segment registers with null: From 1530cfe55fb85bda6707314cfe1abe8cbef28144 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 17:07:36 +0200 Subject: [PATCH 36/42] Include javascript table of content --- blog/static/js/main.js | 4 +++- blog/templates/base.html | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/blog/static/js/main.js b/blog/static/js/main.js index a1c32e85..d2272870 100644 --- a/blog/static/js/main.js +++ b/blog/static/js/main.js @@ -4,11 +4,13 @@ window.onload = function() { if (container != null) { var toc = initTOC({ selector: 'h2, h3', - scope: '.post', + scope: 'main', overwrite: false, prefix: 'toc' }); + toc.innerHTML = toc.innerHTML.split("🔗\n").join(""); + var heading = document.createElement("H2"); var heading_text = document.createTextNode("Table of Contents"); heading.appendChild(heading_text); diff --git a/blog/templates/base.html b/blog/templates/base.html index c261e62a..174ef6c3 100644 --- a/blog/templates/base.html +++ b/blog/templates/base.html @@ -12,6 +12,9 @@ + + + {% block title %}{% endblock title %} From ca96cae9ccceeb943ad26c9962dad7201efba4e8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 17:30:06 +0200 Subject: [PATCH 37/42] Use a plain template for pages --- blog/content/extra/cross-compile-binutils.md | 2 +- blog/content/extra/cross-compile-libcore.md | 2 +- blog/content/extra/set-up-gdb/index.md | 2 +- blog/content/extra/talks.md | 1 + blog/content/pages/404.md | 1 + blog/content/pages/contact.md | 1 + blog/templates/plain.html | 8 ++++++++ 7 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 blog/templates/plain.html diff --git a/blog/content/extra/cross-compile-binutils.md b/blog/content/extra/cross-compile-binutils.md index 483b04a9..6a11c367 100644 --- a/blog/content/extra/cross-compile-binutils.md +++ b/blog/content/extra/cross-compile-binutils.md @@ -1,6 +1,6 @@ +++ title = "Cross Compile Binutils" -description = "" +template = "plain.html" url = "cross-compile-binutils" +++ diff --git a/blog/content/extra/cross-compile-libcore.md b/blog/content/extra/cross-compile-libcore.md index 77e82e07..90de2c76 100644 --- a/blog/content/extra/cross-compile-libcore.md +++ b/blog/content/extra/cross-compile-libcore.md @@ -1,6 +1,6 @@ +++ title = "Cross Compiling: libcore" -description = "" +template = "plain.html" url = "cross-compile-libcore" +++ diff --git a/blog/content/extra/set-up-gdb/index.md b/blog/content/extra/set-up-gdb/index.md index 873458c6..556e0233 100644 --- a/blog/content/extra/set-up-gdb/index.md +++ b/blog/content/extra/set-up-gdb/index.md @@ -1,6 +1,6 @@ +++ title = "Set Up GDB" -description = "" +template = "plain.html" url = "set-up-gdb" +++ diff --git a/blog/content/extra/talks.md b/blog/content/extra/talks.md index b93aa101..2bbd5f19 100644 --- a/blog/content/extra/talks.md +++ b/blog/content/extra/talks.md @@ -1,6 +1,7 @@ +++ title = "Talks" url = "talks" +template = "plain.html" +++ - “Open Source OS Development in Rust” at HTWG Konstanz, May 22, 2017: [slides](https://phil-opp.github.io/talk-konstanz-may-2017/) diff --git a/blog/content/pages/404.md b/blog/content/pages/404.md index df0f46ce..f19f4880 100644 --- a/blog/content/pages/404.md +++ b/blog/content/pages/404.md @@ -1,6 +1,7 @@ +++ title = "Page not found" url = "404.html" +template = "plain.html" +++ Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. diff --git a/blog/content/pages/contact.md b/blog/content/pages/contact.md index abe609ac..f5731d94 100644 --- a/blog/content/pages/contact.md +++ b/blog/content/pages/contact.md @@ -1,6 +1,7 @@ +++ title = "Contact" url = "contact" +template = "plain.html" +++ Philipp Oppermann diff --git a/blog/templates/plain.html b/blog/templates/plain.html new file mode 100644 index 00000000..4ee0df74 --- /dev/null +++ b/blog/templates/plain.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %} + +{% block main %} +

    {{ page.title }}

    + {{ page.content | safe }} +{% endblock main %} From 6f8999ada541441e7e03e44c9c037f0492848e32 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 17:30:36 +0200 Subject: [PATCH 38/42] Display date for posts --- blog/templates/page.html | 1 + 1 file changed, 1 insertion(+) diff --git a/blog/templates/page.html b/blog/templates/page.html index 1ae18660..1ec3edf6 100644 --- a/blog/templates/page.html +++ b/blog/templates/page.html @@ -4,6 +4,7 @@ {% block main %}

    {{ page.title }}

    + {{ page.content | safe }} {% endblock main %} From e84c8ac638b2b7f6477599361fcb0280b60577af Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 17:35:08 +0200 Subject: [PATCH 39/42] Display date of last update for posts --- .../extra/naked-exceptions/01-catching-exceptions/index.md | 1 + .../naked-exceptions/02-better-exception-messages/index.md | 1 + .../naked-exceptions/03-returning-from-exceptions/index.md | 1 + blog/content/posts/02-entering-longmode/index.md | 1 + blog/content/posts/03-set-up-rust/index.md | 1 + blog/content/posts/04-printing-to-screen/index.md | 1 + blog/content/posts/07-remap-the-kernel/index.md | 1 + blog/templates/page.html | 5 ++++- 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md b/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md index 3ab92597..8d58a617 100644 --- a/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md +++ b/blog/content/extra/naked-exceptions/01-catching-exceptions/index.md @@ -3,6 +3,7 @@ title = "Catching Exceptions" order = 1 url = "catching-exceptions" date = "2016-05-28" +[extra] updated = "2016-06-25" +++ diff --git a/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md index b3727536..8df26af4 100644 --- a/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md +++ b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md @@ -3,6 +3,7 @@ title = "Better Exception Messages" order = 2 url = "better-exception-messages" date = "2016-08-03" +[extra] updated = "2016-11-01" +++ diff --git a/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md index f6840d36..e9223f1b 100644 --- a/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md +++ b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md @@ -3,6 +3,7 @@ title = "Returning from Exceptions" order = 3 url = "returning-from-exceptions" date = "2016-09-21" +[extra] updated = "2016-11-01" +++ diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index 47a16f2e..e48b42d6 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -3,6 +3,7 @@ title = "Entering Long Mode" order = 2 url = "entering-longmode" date = "2015-08-25" +[extra] updated = "2015-10-29" +++ diff --git a/blog/content/posts/03-set-up-rust/index.md b/blog/content/posts/03-set-up-rust/index.md index e0d0439f..05ca2ae3 100644 --- a/blog/content/posts/03-set-up-rust/index.md +++ b/blog/content/posts/03-set-up-rust/index.md @@ -3,6 +3,7 @@ title = "Set Up Rust" order = 3 url = "set-up-rust" date = "2015-09-02" +[extra] updated = "2017-04-12" +++ diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index 2b900a8f..1bea9039 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -3,6 +3,7 @@ title = "Printing to Screen" order = 4 url = "printing-to-screen" date = "2015-10-23" +[extra] updated = "2016-10-31" +++ diff --git a/blog/content/posts/07-remap-the-kernel/index.md b/blog/content/posts/07-remap-the-kernel/index.md index c552e442..0413d8f5 100644 --- a/blog/content/posts/07-remap-the-kernel/index.md +++ b/blog/content/posts/07-remap-the-kernel/index.md @@ -3,6 +3,7 @@ title = "Remap the Kernel" order = 7 url = "remap-the-kernel" date = "2016-01-01" +[extra] updated = "2016-03-06" +++ diff --git a/blog/templates/page.html b/blog/templates/page.html index 1ec3edf6..b7d3e7af 100644 --- a/blog/templates/page.html +++ b/blog/templates/page.html @@ -4,7 +4,10 @@ {% block main %}

    {{ page.title }}

    - + {{ page.content | safe }} {% endblock main %} From 1794a94fa9a1543929611cf6bbe76beefbd30253 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 17:47:07 +0200 Subject: [PATCH 40/42] Introduce an (arbitrary) ordering for extra pages --- blog/content/extra/_index.md | 1 + blog/content/extra/cross-compile-binutils.md | 1 + blog/content/extra/cross-compile-libcore.md | 1 + blog/content/extra/set-up-gdb/index.md | 1 + blog/content/extra/talks.md | 1 + 5 files changed, 5 insertions(+) diff --git a/blog/content/extra/_index.md b/blog/content/extra/_index.md index 6cb496d7..3257b416 100644 --- a/blog/content/extra/_index.md +++ b/blog/content/extra/_index.md @@ -2,4 +2,5 @@ title = "Extra Content" insert_anchor = "left" render = false +sort_by = "order" +++ diff --git a/blog/content/extra/cross-compile-binutils.md b/blog/content/extra/cross-compile-binutils.md index 6a11c367..245c767a 100644 --- a/blog/content/extra/cross-compile-binutils.md +++ b/blog/content/extra/cross-compile-binutils.md @@ -2,6 +2,7 @@ title = "Cross Compile Binutils" template = "plain.html" url = "cross-compile-binutils" +order = 2 +++ The [GNU Binutils] are a collection of various binary tools such as `ld`, `as`, `objdump`, or `readelf`. These tools are platform-specific, so you need to compile them again if your host system and target system are different. In our case, we need `ld` and `objdump` for the x86_64 architecture. diff --git a/blog/content/extra/cross-compile-libcore.md b/blog/content/extra/cross-compile-libcore.md index 90de2c76..a67b78c4 100644 --- a/blog/content/extra/cross-compile-libcore.md +++ b/blog/content/extra/cross-compile-libcore.md @@ -2,6 +2,7 @@ title = "Cross Compiling: libcore" template = "plain.html" url = "cross-compile-libcore" +order = 3 +++ If you get an `error: can't find crate for 'core'`, you're probably compiling for a different target (e.g. you're passing the `target` option to `cargo build`). Now the compiler complains that it can't find the `core` library. This document gives a quick overview how to fix this problem. For more details, see the [rust-cross] project. diff --git a/blog/content/extra/set-up-gdb/index.md b/blog/content/extra/set-up-gdb/index.md index 556e0233..aa37f2c2 100644 --- a/blog/content/extra/set-up-gdb/index.md +++ b/blog/content/extra/set-up-gdb/index.md @@ -2,6 +2,7 @@ title = "Set Up GDB" template = "plain.html" url = "set-up-gdb" +order = 4 +++ There are a lot of things that can go wrong when developing an OS. So it's a good idea to add a debugger to our toolset, which allows us to set breakpoints and examine variables. We will use [GDB](https://www.gnu.org/software/gdb/) as QEMU supports it out of the box. diff --git a/blog/content/extra/talks.md b/blog/content/extra/talks.md index 2bbd5f19..6828d001 100644 --- a/blog/content/extra/talks.md +++ b/blog/content/extra/talks.md @@ -2,6 +2,7 @@ title = "Talks" url = "talks" template = "plain.html" +order = 1 +++ - “Open Source OS Development in Rust” at HTWG Konstanz, May 22, 2017: [slides](https://phil-opp.github.io/talk-konstanz-may-2017/) From 487e4c18fc90d3c28965f774a2b261e4c3892c50 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 20:34:15 +0200 Subject: [PATCH 41/42] Add isso comments --- blog/templates/page.html | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/blog/templates/page.html b/blog/templates/page.html index b7d3e7af..a2b94da4 100644 --- a/blog/templates/page.html +++ b/blog/templates/page.html @@ -14,14 +14,22 @@ {% block after_main %}
    + +
    + +
    +

    Comments

    +
    +
    - {% if page.previous %} - - {% endif %} - {% if page.next %} - - {% endif %} - {% endblock after_main %} From ab0d27e3985d0962d997eb1945aa3d75a079611c Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 13 Jun 2017 20:35:03 +0200 Subject: [PATCH 42/42] Redirect from /atom.xml to /rss.xml --- blog/static/_redirects | 1 + 1 file changed, 1 insertion(+) diff --git a/blog/static/_redirects b/blog/static/_redirects index 9fb86302..3f5fe8a4 100644 --- a/blog/static/_redirects +++ b/blog/static/_redirects @@ -8,3 +8,4 @@ /rust-os/setup-rust.html /set-up-rust/ /2015/10/23/printing-to-screen/ /printing-to-screen/ /rust-os/printing-to-screen.html /printing-to-screen/ +/atom.xml /rss.xml