summaryrefslogtreecommitdiff
path: root/kc/core/memory.h
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2022-02-24 01:58:07 +0000
committerAda Christine <adachristine18@gmail.com>2022-02-24 01:58:07 +0000
commit1923e47fd296399180eaf19b990d5e951d71ccd2 (patch)
tree2c61fa3d29321c3cf8e31a6ca1b1edcc053cb8f1 /kc/core/memory.h
parent4fa48a2a7814c2f7d3992533313df283c3aa2652 (diff)
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.
Diffstat (limited to 'kc/core/memory.h')
-rw-r--r--kc/core/memory.h45
1 files changed, 41 insertions, 4 deletions
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 <lib.h>
-
#include <kernel/entry.h>
#include <kernel/memory/paging.h>
#include <kernel/memory/range.h>
+#include <lib.h>
+
+#include <core/memory.h>
+
+#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 *);
+