blob: 0c8fe0f37afd52a7a347c718203c9257fac40300 [file] [log] [blame]
swissChilie00e88a2021-05-30 17:54:26 -07001Architecture
2============
3
4This document seeks to provide a brief overview of Bluejay architecture. This
5should be a good starting point for understanding the code.
6
7Bluejay is exclusively a multiboot kernel, it neither provides nor supports
8alternative bootloaders.
9
10The bootloader (probably GRUB) will initially run the code in ``boot.s``. This
11is where it all begins. This code sets up segmentation and paging and maps the
12higher-half of virtual memory (everything above ``0xC0000000``) to the kernel.
13At first it only maps 8 megabytes, more memory can be mapped on request.
14
15After moving to high memory the kernel jumps to C code and enters ``kmain`` in
16``main.c``. This is the highest level procedure in the kernel, which sets up
17kernel services and drivers one at a time.
18
19This includes VGA, keyboard, and PCI drivers, as well as paging and preemptive
20multi tasking.
21
22Multi tasking
23-------------
24
25Multi tasking is handled by code in ``task.c``. It is first initialized in
26``init_tasks``, which sets up the initial task. Once this is called kernel
27threads can be spawned at will.
28
29Every clock tick an interrupt is triggered (see ``clock.c`` for timing) which
30causes a task switch to occur. Bluejay uses a simple round-robin scheduler, and
31there is no way for tasks to voluntarily give up their processing time (even in
32the case of blocking IO operations). ``task.c`` contains the implementation of
33the scheduler.
34
35Drivers
36-------
37
38So far I have only written very low level drivers (stuff like ATA PIO, PCI, VGA
39text mode, etc). These drivers have all been "bare-metal", ie: interfacing with
40hardware through ``in`` and ``out`` instructions. Higher level drivers will be
41built on top of existing ones. An interface will be created for defining, for
42example, PCI device drivers, or USB device drivers.