Files
vystem-b/docs/shelter/bootprocess.md
2026-05-27 19:34:54 +02:00

178 lines
4.1 KiB
Markdown

# Shelter Boot Process
## Introduction
Shelter has a very precise boot process to ensure everything goes to plan. In this file, we detail everything that is done for the kernel boot but it doesn't include how to use the kernel API, algorithms, etc. For that, please dig through the documentation.
## 1) Basic kernel initialization
1.1) Print kernel version
1.2) Detect and parse boot config
1.3) Load basic settings
1.3.1) Load logging ring size
1.3.2) Load serial port settings
1.3.3) Load PTP virtual address
1.3.4) Load kernel log level
---
Starting here, all logs go through the standard log API.
---
## 2) Memory subsystem initialization
### 2.1) Page subsystem initialization
2.1.1) Copying memory map to a secured buffer
2.1.2) Initializing current PTP using boot configuration information
2.1.3) Using the framebuffer informations, initializing the framebuffer subsystem
2.1.4) Parsing and validating memory map, initializing physical pages bitmap
### 2.2) Pez dependencies subsystems initialization
2.2.1) Initializing physical region slab allocator
2.2.1.a) Initializing slab allocator structure
2.2.1.b) Adding first slab and verifying slab metadata
2.2.2) Initializing virtual region slab allocator
2.2.2.a) Initializing slab allocator structure
2.2.2.b) Adding first slab and verifying slab metadata
2.2.3) Initializing radix tree node slab allocator
2.2.3.a) Initializing page block allocator structure for slab allocator
2.2.3.b) Initializing slab allocator structure
2.2.3.c) Adding first slab and verifying slab metadata
2.2.4) Benchmarking and testing all slabs allocator
2.2.5) Benchmarking and testing radix tree subsystem
### 2.3) Pez physical subsystem initialization
2.3.1) Creating Pez physical allocation plane
2.3.2) Benchmarking and testing Pez physical allocation plane
### 2.4) Pez virtual subsystem initialization
2.4.1) Creating Pez virtual allocation plane for kernel heap
(Pez virtual plane for kernel heap isn't benchmarked and tested because it's exactly the same algorithm and metadatas under the hood)
### 2.5) Kernel heap initialization
2.5.1) Initializing kernel heap structure
2.5.2) For each slab allocator inside kernel heap:
2.5.2.a) Initializing corresponding page block allocator structure
2.5.2.b) Initializing corresponding slab allocator structure
2.5.2.c) Adding first slab and verifying slab metadata
2.5.3) Benchmarking and testing kernel heap
## 3) Basic CPU features configuration
### 3.1) TSS structure initialization
3.1.1) Initializing TSS structure
### 3.2) GDT structure initialization
3.2.1) Generating GDT structure
3.2.2) Loading GDT register
3.2.3) Loading TSS register
### 3.3) IDT structure initialization
3.3.1) Generating IDT structure
3.3.2) Loading IDT register
## 4) ACPI parsing
### 4.1) Parsing RSDP
### 4.2) Parsing XSDT
### 4.3) Parsing all availables tables
### 4.4) Parsing MADT table
4.4.1) Counting all LAPICs, IOAPICs and ISOs
4.4.2) Initializing devices system for LAPICs and IOAPICs
4.4.3) Registering all informations inside MADT table
4.4.3.a) Registering, initializing and binding all LAPICs
4.4.3.b) Registering, initializing and binding all IOAPICs
4.4.3.c) Registering all ISOs
## 5) Devices bootstrap
### 5.1) Applications= processors (AP) bootstrap
5.1.1) Disabing all GSI lines
5.1.2) Checking somes CPU ID flags for logging
5.1.2.a) Checking hypervisor flag
5.1.2.b) Checking TSC constant flag
5.1.3) Trying to obtain CPU frequency
5.1.3.a) Trying to obtain CPU frequency from CPU ID
5.1.3.b) Trying to obtain CPU frequency from TSC and PIT
5.1.4) Initializing LAPIC for bootstrap CPU
5.1.5) Estimating LAPIC frequency
5.1.6) Loading 32 bits mode GDT for AP bootstrap
5.1.7) Preparing for AP launch by filling various structures
5.1.8) Launching all APs in an infinite loop
---
Starting here, all logs go through the standard library print functions.
---
5.1.9) Switching legacy IRQ management from PIT to IOAPIC subsystem
### 5.2) Keyboard bootstrap
5.2.1) Initializing keyboard subsystem
5.2.2) Initializing PS2 keyboard driver
5.2.3) Disabing PS2 keyboard scanning for the rest of kernel boot process