summaryrefslogtreecommitdiff
path: root/sys/include/vm
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-16 20:10:07 -0400
committerIan Moffett <ian@osmora.org>2024-04-16 20:10:07 -0400
commit0d8da6f5436874c1dd987b53d11a3d3aea468f67 (patch)
tree02bcff6e0a18633d8318269cb23780f775d99727 /sys/include/vm
parent9a26f4d453b1742c6249d66a077a175120e23338 (diff)
kernel: vm_map: Add mmap() and munmap()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include/vm')
-rw-r--r--sys/include/vm/map.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/include/vm/map.h b/sys/include/vm/map.h
index 078a5e8..f482788 100644
--- a/sys/include/vm/map.h
+++ b/sys/include/vm/map.h
@@ -32,11 +32,49 @@
#include <sys/types.h>
#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/syscall.h>
+#include <sys/spinlock.h>
#include <vm/pmap.h>
+#include <vm/vm.h>
+
+#define MAP_SHARED 0x0001
+#define MAP_PRIVATE 0x0002
+#define MAP_ANONYMOUS 0x0010
+#define MAP_FAILED ((void *)-1)
+
+/* Memory map table entry count */
+#define MTAB_ENTRIES 32
+
+struct vm_mapping {
+ TAILQ_ENTRY(vm_mapping) link;
+ struct vm_range range;
+ paddr_t physmem_base;
+
+ /* Private */
+ size_t vhash; /* Virtual address hash */
+};
+
+typedef TAILQ_HEAD(, vm_mapping) vm_mapq_t;
+
+struct vm_mapspace {
+ vm_mapq_t mtab[MTAB_ENTRIES]; /* Map table */
+ size_t map_count;
+};
+
int vm_map_create(struct vas vas, vaddr_t va, paddr_t pa, vm_prot_t prot,
size_t bytes);
int vm_map_destroy(struct vas vas, vaddr_t va, size_t bytes);
+uint64_t sys_mmap(struct syscall_args *args);
+uint64_t sys_munmap(struct syscall_args *args);
+
+/* Mapespace operations */
+void vm_mapspace_insert(struct vm_mapspace *ms, struct vm_mapping *mapping);
+void vm_mapspace_remove(struct vm_mapspace *ms, struct vm_mapping *mapping);
+struct vm_mapping *vm_mapping_fetch(struct vm_mapspace *ms, vaddr_t va);
+void vm_free_mapq(vm_mapq_t *mapq);
+
#endif /* !_VM_MMAP_H_ */