diff options
author | Danny Holman <dholman@gymli.org> | 2024-02-16 13:06:43 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-02-16 13:06:43 -0600 |
commit | 33fdc9b20c12e6c776ed76fc59d848a3ad7f6bca (patch) | |
tree | e305d66a4be29a2446506ee17897957846518125 /arch/i386/include | |
parent | 95606a6be7c64065d295bdabb1a94fb42108e72f (diff) |
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 <dholman@gymli.org>
Diffstat (limited to 'arch/i386/include')
-rw-r--r-- | arch/i386/include/kernel/alloc.h | 13 | ||||
-rw-r--r-- | arch/i386/include/kernel/paging.h | 33 |
2 files changed, 15 insertions, 31 deletions
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 <kernel/multiboot.h> -#include <stdint.h> -#include <stddef.h> - -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 <kernel/isr.h> +#include <kernel/multiboot.h> +#include <kernel/data/list.h> #include <stdint.h> #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 |