summaryrefslogtreecommitdiff
path: root/src/kernel/mem/virt.h
diff options
context:
space:
mode:
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);