-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation on the initializtion process of DreamOs
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Kernel Initialization | ||
|
||
## Loading the kernel | ||
|
||
The kernel is loaded by grub2, using the multibtoo2 specifications. | ||
|
||
The tags that are enabled at boot are: | ||
|
||
* Framebuffer | ||
|
||
Although it is optional, in the mid term, support for legacy VGA driver will be dropped. | ||
|
||
The header is defined in the `src/asm/multiboot_header.s` | ||
|
||
Additional tags maybe added in the future (although the long term plan is to replace grub with limine) | ||
|
||
We let the bootloader decide for the framebuffer configuration (that is: Width, Height, Depth) | ||
|
||
## Booting process (Early boot) | ||
|
||
As soon as multiboot pass the control to the kernel loader, the early boot stages are done mostly in the `src/asm/boot.s` file. That will do the following steps: | ||
|
||
* Set up paging and map the kernel in the higher half | ||
* Pre parse the multiboot data passed by grub, preparing the data that will be needed by the kernel. | ||
* Enable PAE | ||
* Map the first 4 megabyte of the Framebuffer | ||
* Jump to the kernel in the higher half | ||
|
||
## Booting Process (Late Boot) | ||
|
||
Once the setup in the early boot process is done, the kernel is fully loaded in the higher half, and we can proceed with the rest of the Initialization | ||
|
||
The sequence of component that are intialized (refer to `src/main.c`): | ||
|
||
* Qemu debug (the main output for now) | ||
* IDT | ||
* Basic System: | ||
- Parse the multiboot information received from the bootloader. | ||
- Parse the mmap and initialize the physical memory manager, marking the pmm areas as busy. | ||
- Initialize the physical mermoy manager, marking the area in the mmap as already taken. | ||
- Validate and parse the SDT tables | ||
- This section needs to be reviewed and check if all the steps are required | ||
* Load the PSF font from memory | ||
* Finish mapping the Framebuffer (there is a potential bug here, need to chek what i do while mapping it) | ||
* Set the Higher Half direct map | ||
* Initialize the kernel VMM | ||
* Initialize the kernel heap | ||
* Initialize the apic | ||
* Initialize the keyboard | ||
* Initialize and load the TSS | ||
* Calibrate the apic timer | ||
* Initialize the VFS layer (although not really used) | ||
* Initialize the scheduler | ||
* Finally start the timer, that it will make the scheulder start working and picking tasks when present in the queue, or run the idle tasks when the queue is empty. | ||
|
||
At this point the startup is completed and the kernel starts its infinite loop. |