Physical Memory Partitions

Kernel's source is compiled into three binaries:

exceptions.bin (source: exceptions.S)

Contains code which stores registers on current thread's stack, jumps to TLB Refill or General Exception handlers in kernel.bin which have fixed addresses, loads stored registers when returned and ends by eret instruction.

loader.bin (source: loader.S)

A jump on the fixed kernel entry point in the kernel.bin.

kernel.bin (source: sys.S, end.S, ...)

Starts with fixed exception handlers followed by kernel's stack. Handlers consist of C function call. This implementation allows to split kernel image to two separate parts and place some devices between.

End of kernel's image is specified by constant KERNEL_SIZE.

Context switch routines are implemented in sys.S.

The first piece of code called after entering kernel's start function is initialization routine init_os. It calls initialization routines of all subsystems of kernel. The first subsystem being initialized is Memory Management. It allocates structures representing physical memory in memory which immediately follows kernel's image (PMM's internally allocated memory in the figure). After PMM initialization Kernel Memory Manager gets its first block of mallocable memory ending at 0x003fffff (4MB - 1). Remaining memory is free and prepared for frame allocations managed by PMM.


Note: Positions and sizes of almost all memory partitions can be changed in memory_partitions.h. To change kernel base address (now 0x80001000) a file ld_binary_kernel has to be changed accordingly.