From 6dfbb3850ac99945de12251f99867c1edff9036c Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Mon, 10 Jan 2022 00:59:00 +0000 Subject: new header vm_object.h --- kc/core/memory.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'kc/core/memory.c') diff --git a/kc/core/memory.c b/kc/core/memory.c index 7421b04..8feab88 100644 --- a/kc/core/memory.c +++ b/kc/core/memory.c @@ -2,6 +2,7 @@ #include "kprint.h" #include "panic.h" #include "vm_tree.h" +#include "vm_object.h" #include @@ -21,48 +22,15 @@ #define align_next(v, a) (((uint64_t)v + a - 1) & ~(a - 1)) -typedef int (*page_fault_handler_func)(uint32_t code, void *address); - static int core_image_handler(uint32_t code, void *address); static int core_vmobject_handler(uint32_t code, void *address); -enum memory_space_flags -{ - VOID_MEMORY_SPACE = 0x00, // memory that cannot do anything, i.e. a guard page - TRANSLATION_MEMORY_SPACE = 0x01, // a mapping to a fixed location in memory - ANONYMOUS_MEMORY_SPACE = 0x02, // a mapping to an arbitrary location in memory - OBJECT_MEMORY_SPACE = 0x03, // a mapping managed by an underlying object - - MEMORY_SPACE_TYPE_MASK = 0x0f, // - - NOFAULT_MEMORY_FLAG = 0x10, // a mapping that cannot be resolved during a page fault - NOSWAP_MEMORY_FLAG = 0x20, // a mapping that cannot be swapped out - COW_MEMORY_FLAG = 0x40, // a mapping that is copy-on-write - - MEMORY_SPACE_FLAGS_MASK = 0xf0, - - INVALID_MEMORY_SPACE = 0xff -}; - struct page { uint32_t next: 31; uint32_t used: 1; }; -enum vm_object_type -{ - NULL_VM_OBJECT, // a non-object. shouldn't even exist. an abomination unto man and god - TRANSLATION_VM_OBJECT, // a direct mapping between a physical and virtual address range - ANONYMOUS_VM_OBJECT, // a mapping that has no definite physical location -}; - -struct vm_object -{ - enum vm_object_type type; - page_fault_handler_func handler; -}; - static struct page *const page_array = (struct page *)0xffffffd800000000; static int first_free_page_index = -1; static size_t page_array_entries = 0; -- cgit v1.3.1-1-g115d