diff --git a/documentation/2 - booting.md b/documentation/2 - booting.md new file mode 100644 index 0000000..4040fa5 --- /dev/null +++ b/documentation/2 - booting.md @@ -0,0 +1,36 @@ +# Boot into C + +> - [Mittos64 documentation chapter 2](https://github.com/thomasloven/mittos64/blob/master/doc/2_A_Bootable_Kernel.md). +> - [Mittos64 documentation chapter 3](https://github.com/thomasloven/mittos64/blob/master/doc/3_Activate_Long_Mode.md) +> - [Mittos64 documentation chapter 4](https://github.com/thomasloven/mittos64/blob/master/doc/4_Higher_Half_Kernel.md) + +`src/kernel/boot/boot.S` will set up the bootstrap processoc (BSP) for running higher-half c code in 64 bit mode as soon as possible. + +Data structures such as the Page Directory, GDT and Multiboot2 Headers are hardcoded as far as possible. The GDT is hardcoded in c, the rest in ASM. + +Mittos requires a MultiBoot2 compliant bootloader such as Grub 2.0 and assumes an x86_64 processor. Therefore several sanity checks are currently not performed. + +## Parsing multiboot data + +> - [Mittos64 documentation chapter 7](https://github.com/thomasloven/mittos64/blob/master/doc/7_Multiboot_Data.md) +> - [The MultiBoot 2 specification](https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html) + +`parse_multiboot2(struct taglist *tags)` in `src/kernel/boot/multiboot.c` goes through the taglist passed to the kernel from the bootloader and saves some relevant information into a global data structure. + +What's currently saved is: +- Bootloader name (unused) +- Kernel command line (unused) +- Memory map +- Framebuffer information +- RSDP information + +## Exceptions and interrupts +> - [Mittos64 documentation chapter 8](https://github.com/thomasloven/mittos64/blob/master/doc/8_Exceptions.md) + +## Relevant files: +- `src/kernel/boot/boot.S` +- `src/kernel/boot/boot_PT.S` +- `src/kernel/boot/multiboot_header.S` +- `src/kernel/cpu/gdt.c` +- `src/kernel/boot/kmain.c` +- `src/kernel/boot/multiboot.c` \ No newline at end of file