Foundations of memory management
— This post is a work in progress —
In the last post, we discussed how to set up serial output for our operating system. We setup a dbg! as a debug mechanism.
In this post, we lay down the foundations of memory management.
We’ll tackle this early since a lot of the functionalities we’ll implement later down the line require access to specific physical memory regions. For example, when we want to access memory mapped IO devices, or read specific structures from physical memory that the bootloader has placed for us in memory.
For that, we need to be able to read and write to specific locations in physical memory but since as discussed in the Integrating a concrete, battle tested bootloader post, x86 long mode simply does not work without paging.
This means, in order to get to those physical memory locations, we need to be able to access the page tables, update entries to map virtual pages to physical ones, and then access the memory via the page table.