summaryrefslogtreecommitdiff
path: root/mem/vmap.h
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-07-26 14:06:40 +0200
committerAlejandro Sior <aho@sior.be>2022-07-26 14:06:40 +0200
commite0fbf5ca9599cb7599731fe48573e97d05fa38da (patch)
tree2c3b3925c49fd2da68086c6cb4b06a891e823bd5 /mem/vmap.h
parentc4e9a8ba15391ae5f1c820744ff1b03544d63467 (diff)
mem/vmap: add basic virtual memory management abstraction
Diffstat (limited to 'mem/vmap.h')
-rw-r--r--mem/vmap.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/mem/vmap.h b/mem/vmap.h
new file mode 100644
index 0000000..4e1816c
--- /dev/null
+++ b/mem/vmap.h
@@ -0,0 +1,31 @@
+#ifndef MEM_VMAP_H
+#define MEM_VMAP_H
+
+#include <rt.h>
+
+typedef struct mem_vmap MemVmap;
+
+typedef usize (*MemVmapTranslate)(MemVmap *, usize);
+typedef int (*MemVmapMap)(MemVmap *, usize, usize, usize, int);
+typedef int (*MemVmapUnmap)(MemVmap *, usize, usize);
+typedef void (*MemVmapSwitchTo)(MemVmap *);
+
+/* Structure abstracting the memory mapping facilities of
+ the machine */
+struct mem_vmap {
+ MemVmapTranslate translate;
+ MemVmapMap map;
+ MemVmapUnmap unmap;
+ MemVmapSwitchTo switch_to;
+
+ /* Flag indicating whether the previous translation
+ lead to a miss */
+ int miss;
+};
+
+usize mem_vmap_translate(MemVmap *inner, usize virt);
+int mem_vmap_map(MemVmap *inner, usize phys, usize virt, usize len, int flags);
+void mem_vmap_unmap(MemVmap *inner, usize virt, usize len);
+void mem_vmap_switch_to(MemVmap *inner);
+
+#endif \ No newline at end of file