# 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) 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
