summaryrefslogtreecommitdiff
path: root/src/kernel/mem/virt.h
diff options
context:
space:
mode:
authordzwdz2021-09-05 18:32:08 +0200
committerdzwdz2021-09-05 18:32:08 +0200
commit838b142b7374150df63ec02b02377c114a14b314 (patch)
treeb5b22e5517da7a4ac96a47f0cfe6a4755d00da44 /src/kernel/mem/virt.h
parentd6c1dceba2511fa2edf839942b237d3a27bb9535 (diff)
move most of the memory stuff to kernel/mem/
Diffstat (limited to 'src/kernel/mem/virt.h')
-rw-r--r--src/kernel/mem/virt.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/kernel/mem/virt.h b/src/kernel/mem/virt.h
new file mode 100644
index 0000000..98a7a16
--- /dev/null
+++ b/src/kernel/mem/virt.h
@@ -0,0 +1,28 @@
+/* contains utilities for interacting with virtual memory */
+#pragma once
+#include <kernel/types.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+struct virt_iter {
+ void *frag;
+ size_t frag_len;
+ size_t prior; // sum of all prior frag_lens
+ bool error;
+
+ user_ptr _virt;
+ size_t _remaining;
+ struct pagedir *_pages;
+ bool _user;
+ bool _writeable;
+};
+
+void virt_iter_new(
+ struct virt_iter *iter, user_ptr virt, size_t length,
+ struct pagedir *pages, bool user, bool writeable);
+
+bool virt_iter_next(struct virt_iter *);
+
+bool virt_user_cpy(
+ struct pagedir *dest_pages, user_ptr dest,
+ struct pagedir *src_pages, const user_ptr src, size_t length);