This is a continuation of Writing OS in Rust walkthrough. This time I'm learning about the boot process.

When you boot your PC, something called POST is happening. It's not about POST HTTP method, but rather Power-On Self-Test. It's piece of code on the motherboard in ROM which does basic initialization, of memory, CPU and hardware and then loads OS kernel.

There are two most common standards: BIOS and UEFI. BIOS stands for Basic Input/Output System. It's and old and well-supported implementation. UEFI means Unified Extensible Firmware Interface. It's modern and more complicated implementation.

With BIOS, this is what is happening when you start your PC:

  1. BIOS is loaded from certain memory of the motherboard.
  2. It performs self-test and hardware initialization.
  3. It passes the execution to the bootloader.

Now, the bootloader has three main tasks:

  1. Locate and load the kernel image.
  2. Switch from 16-bit real mode to 32-bit protected mode and then to 64-bit long mode.
  3. Get various information from the BIOS and pass it to the kernel.

What's about this XX-bit modes? Because BIOS is old and well-supported it also means that is supports very old bootloaders which are working in the 16-bit mode. That's why it starts in 16-bit. Then the bootloader is responsible for switching the modes. Next, 32-bit mode is more powerful and allows doing more, then the 64-bit mode allows running 64 bit instructions and access even more memory.