Wrote physical memory manager

This commit is contained in:
2026-03-20 18:18:15 +01:00
parent 0214b4da31
commit 93ef197e58
7 changed files with 358 additions and 99 deletions
+12 -7
View File
@@ -2,13 +2,16 @@
#include <kernel.h>
#include <limine.h>
/*
* This defines our expected Limine version
*/
static volatile LIMINE_BASE_REVISION(4);
struct bootloader bootloader = { 0 };
static struct limine_paging_mode_request lim_paging_req = {
.id = LIMINE_PAGING_MODE_REQUEST,
.revision = 4,
.mode = LIMINE_PAGING_MODE_X86_64_4LVL,
};
static struct limine_paging_mode_request lim_paging_req =
{ .id = LIMINE_PAGING_MODE_REQUEST, .revision = 4,
.mode = LIMINE_PAGING_MODE_X86_64_4LVL, };
static struct limine_kernel_address_request lim_kaddr_req =
{ .id = LIMINE_KERNEL_ADDRESS_REQUEST, .revision = 4 };
@@ -23,6 +26,8 @@ static struct limine_framebuffer_request lim_fbuf_req =
{ .id = LIMINE_FRAMEBUFFER_REQUEST, .revision = 0 };
int boot_init(void) {
if (LIMINE_BASE_REVISION_SUPPORTED == false) panic("Unsupported Limine base revision.");
struct limine_paging_mode_response* lim_paging_res = lim_paging_req.response;
struct limine_kernel_address_response* lim_kaddr_res = lim_kaddr_req.response;
struct limine_hhdm_response* lim_hhdm_res = lim_hhdm_req.response;
@@ -36,10 +41,10 @@ int boot_init(void) {
bootloader.mm_entries = lim_memmap_res->entries;
bootloader.mm_entry_count = lim_memmap_res->entry_count;
bootloader.mm_total = 0;
bootloader.mm_total_memory = 0;
for (size_t i = 0; i < bootloader.mm_entry_count; i++) {
struct limine_memmap_entry* entry = bootloader.mm_entries[i];
if (entry->type != LIMINE_MEMMAP_USABLE) bootloader.mm_total += entry->length;
if (entry->type == LIMINE_MEMMAP_USABLE) bootloader.mm_total_memory += entry->length;
}
bootloader.fb_entries = lim_fbuf_res->framebuffers;