From 1923e47fd296399180eaf19b990d5e951d71ccd2 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Thu, 24 Feb 2022 01:58:07 +0000 Subject: many changes - boot time memory allocation has changed. the fractal page map has been replaced by a single self-mapped page giving 2MiB of ready virtual space to play with without needing a fully-initialized memory manager. this scheme may be repeated for other purposes - the page stack has now been totally overhauled to make use of sparse allocation and all of the ugly init_*() procedures are gone. long live the new interface. also reference counting is a thing now. sort of. - found a bug in vmt_init_node where insertion did not use the root node as the parent in the case of no predecessor node. whoops. --- kc/core/memory.h | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'kc/core/memory.h') diff --git a/kc/core/memory.h b/kc/core/memory.h index 526d8ca..ea86912 100644 --- a/kc/core/memory.h +++ b/kc/core/memory.h @@ -1,11 +1,15 @@ #pragma once -#include - #include #include #include +#include + +#include + +#include "vm_tree.h" + typedef int (*memory_space_handler_func)(uint32_t code, void *vaddr); enum page_map_flags @@ -21,20 +25,53 @@ enum page_map_flags SIZE_MASK = 0xc, }; +enum page_alloc_flags +{ + PAGE_ALLOC_NONE, + PAGE_ALLOC_LOW, + PAGE_ALLOC_CONV, + PAGE_ALLOC_HIGH, + PAGE_ALLOC_ANY +}; + +enum vm_alloc_flags +{ + VM_ALLOC_ANY = 0, + VM_ALLOC_CACHE = 1, + VM_ALLOC_CORE = 2, + VM_ALLOC_TYPE_MASK = 3, + + VM_ALLOC_IMMEDIATE = 4, + VM_ALLOC_ACTION_MASK = 4, + + VM_ALLOC_ANONYMOUS = 8, + VM_ALLOC_DIRECT = 16, + VM_ALLOC_TRANSLATE = 24, + VM_ALLOC_MECHANISM_MASK = 24, +}; + void memory_init(void); +void page_set_present(kc_phys_addr page); +void page_set_allocated(kc_phys_addr page); +void page_set_free(kc_phys_addr page); + void *page_map(phys_addr_t paddr, enum page_map_flags flags); void page_unmap(void *vaddr); -phys_addr_t page_alloc(void); +phys_addr_t page_alloc(enum page_alloc_flags flags); void page_free(phys_addr_t paddr); void *heap_alloc(size_t size); void heap_free(void *block); -void *vm_alloc(size_t size); +void *vm_alloc(size_t size, enum vm_alloc_flags flags); void vm_free(void *block); void *memory_alloc(size_t size); void memory_free(void *block); +struct vm_tree *vm_get_tree(void); + +int anonymous_page_handler(struct vm_tree_node *, uint32_t, void *); + -- cgit v1.3.1-1-g115d