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