mittos65/documentation/2 - booting.md
2022-01-17 14:38:07 +01:00

1.7 KiB

Boot into C

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

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

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