From 33fdc9b20c12e6c776ed76fc59d848a3ad7f6bca Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Fri, 16 Feb 2024 13:06:43 -0600 Subject: arch: i386: roll physical memory control into VMM The VMM should control the physical memory as well as paging. This allows the VMM to grab frames as it sees fit. Signed-off-by: Danny Holman --- arch/i386/kernel/alloc.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 arch/i386/kernel/alloc.c (limited to 'arch/i386/kernel/alloc.c') diff --git a/arch/i386/kernel/alloc.c b/arch/i386/kernel/alloc.c deleted file mode 100644 index 890c2f1..0000000 --- a/arch/i386/kernel/alloc.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include - -extern uint32_t _bitmap_start; -static uint32_t *bm_start = &_bitmap_start; - -static struct mboot_info *info; - -int alloc_init(struct mboot_info *info) { - struct mboot_mmap_entry *mme; - for (uint32_t i = 0; i < info->mmap_length; i += sizeof(struct mboot_mmap_entry)) { - mme = (struct mboot_mmap_entry*)(info->mmap_addr + i); - if (mme->type != MBOOT_MEM_AVAILABLE) - mark_bitmap(mme->addr_low, 1); - } - return 0; -} - -void mark_bitmap(uint32_t paddr, int present) { - uint32_t index = (paddr & 0xFFFFF000) / 4096 / 32; - uint32_t bit = (paddr & 0xFFFFF000) / 4096 % 32; - bm_start[index] |= (present << bit); -} - -uint32_t pfa_alloc_frame(void) { - for (uint32_t i = 0; i < 4096; i++) { - uint32_t index = i / 32; - uint32_t bit = i % 32; - if ((bm_start[index] & (1 << bit)) == 0) { - mark_bitmap(i*4096, 1); - return i * 4096; - } - } - return 0xFFFFFFFF; -} - -void pfa_free(uint32_t paddr, int num_frames) { - for (int i = 0; i < num_frames; i++) - mark_bitmap(paddr + (i*4096), 0); -} -- cgit v1.2.3