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/include/kernel/alloc.h | 13 ------------- arch/i386/include/kernel/paging.h | 33 +++++++++++++++------------------ 2 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 arch/i386/include/kernel/alloc.h (limited to 'arch/i386/include') diff --git a/arch/i386/include/kernel/alloc.h b/arch/i386/include/kernel/alloc.h deleted file mode 100644 index 986bcc5..0000000 --- a/arch/i386/include/kernel/alloc.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef I386_ALLOC_H -#define I386_ALLOC_H - -#include -#include -#include - -int alloc_init(struct mboot_info *info); -void mark_bitmap(uint32_t paddr, int present); -uint32_t pfa_alloc_frame(void); -void pfa_free(uint32_t paddr, int num_frames); - -#endif diff --git a/arch/i386/include/kernel/paging.h b/arch/i386/include/kernel/paging.h index c65718f..bb79d09 100644 --- a/arch/i386/include/kernel/paging.h +++ b/arch/i386/include/kernel/paging.h @@ -2,6 +2,8 @@ #define I386_PAGING_H #include +#include +#include #include #define PD_PRES 0x0001 @@ -21,32 +23,27 @@ #define ERR_RESERVED 0x8 #define ERR_INST 0x10 -#define BLOCK_SIZE 4096 -#define BLOCKS_PER_BUCKET 8 -#define BLOCK_ALIGN(addr) (((addr) & 0xFFFFF000) + 0x1000) +#define PAGE_SIZE 4096 -#define SETBIT(x,i) x[i/BLOCKS_PER_BUCKET] = x[i/BLOCKS_PER_BUCKET] | (1 << (i % BLOCKS_PER_BUCKET)) -#define CLEARBIT(x,i) x[i/BLOCKS_PER_BUCKET] = x[i/BLOCKS_PER_BUCKET] & (~(1 << (i % BLOCKS_PER_BUCKET))) -#define ISSET(x,i) ((x[i/BLOCKS_PER_BUCKET] >> (i % BLOCKS_PER_BUCKET)) & 0x1) -#define GETBUCKET(x,i) (*((uint32_t*)&x[i/32])) +#define DMA_BITMAP_SZ 128 +#define BDY_BITMAP_SZ 32640 -#define PAGE_SIZE 4096 - -struct page_frame { - int used; - uint32_t addr; +struct pfa_buddy { + uintptr_t start; + uintptr_t *bitmap; + uint8_t size; + struct list_head list; }; -void load_page_dir(uint32_t pd_addr); +void load_page_dir(uintptr_t pd_addr); void enable_paging(void); -void paging_init(); +void paging_init(void); void page_fault_handler(struct isr_frame *frame); -uint32_t get_paddr(uint32_t vaddr); -uint32_t get_vaddr(uint32_t paddr); +uint32_t get_vaddr(uintptr_t paddr); -void map_page(uint32_t paddr, uint32_t vaddr, uint32_t flags); -void unmap_page(uint32_t vaddr); +void map_page(uint32_t *pd, uintptr_t paddr, uintptr_t vaddr, uint32_t flags); +void unmap_page(uint32_t *pd, uintptr_t vaddr); #endif -- cgit v1.2.3