diff --git a/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md b/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md index 93a63632..15befc68 100644 --- a/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md +++ b/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md @@ -50,10 +50,30 @@ Writing a bootloader is a bit cumbersome as it requires assembly language and a If you are interested in building your own bootloader: Stay tuned, a set of posts on this topic is already planned! +#### The Multiboot Standard +To avoid that every operating system implements its own bootloader, which is only compatible with a single OS, the Free Software Foundation created an open bootloader standard called [Multiboot] in 1995. The standard defines an interface between the bootloader and operating system, so that any Multiboot compliant bootloader can load any Multiboot compliant operating system. The reference implementation is [GNU GRUB], which is the most popular bootloader for Linux systems. -### The Multiboot Standard +[Multiboot]: https://wiki.osdev.org/Multiboot +[GNU GRUB]: https://en.wikipedia.org/wiki/GNU_GRUB -TODO +To make a kernel Multiboot compliant, one just need to insert a so-called [Multiboot header] at the beginning of the kernel file. This makes it very easy to boot an OS in GRUB. However, GRUB and the the Multiboot standard have some problems too: + +[Multiboot header]: https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#OS-image-format + +- They support only the 32-bit protected mode. This means that you still have to do the CPU configuration to switch to the 64-bit long mode. +- The newest version of the standard, [Multiboot 2.0], supports kernels in the 64-bit ELF format, but requires a [adjusting the default page size]. +- The development of the standard and GRUB is highly interleaved. For example, I'm not aware of an other bootloader that is Multiboot compliant. As a result, one often has to look into the GRUB source code when the standard is not clear enough. +- The standard is written for the C programming language. That means lots of C-typical structures such as linked lists in the [boot information]. +- Both GRUB and the Multiboot standard are only sparsely documented. +- GRUB needs to be installed on the host system to create a bootable disk image from the kernel file. This makes development on Windows or Mac more difficult. + +[boot information]: https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format +[Multiboot 2.0]: https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html +[adjusting the default page size]: https://wiki.osdev.org/Multiboot#Multiboot_2 + +Because of these drawbacks we decided to not use GRUB or the Multiboot standard. However, we plan to add Multiboot support to our [bootimage] tool, so that it's possible to load your kernel on a GRUB system too. If you're interested in writing a Multiboot compliant kernel, check out the [first edition] of this blog series. + +[first edition]: ./first-edition/_index.md ### UEFI