mem: implement buddy allocator

This commit is contained in:
Michael Shaw 2023-04-12 13:58:22 -04:00
commit 4f4af0946d
6 changed files with 245 additions and 14 deletions

View file

@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <kernel/bitwise.h>

View file

@ -49,6 +49,29 @@ struct cr3 {
};
};
struct mem_region {
paddr_t base;
size_t len;
};
struct mem_region_header {
paddr_t usable_base;
size_t usable_len;
struct buddy_free_list *flist;
size_t bitmap_len;
char bitmap[];
};
struct buddy_free_list {
size_t len;
size_t depth;
struct buddy_free_list *next;
struct buddy_free_list *prev;
};
extern uintptr_t __data_end;
extern uintptr_t __bss_start;
extern uintptr_t __bss_end;