summaryrefslogtreecommitdiff
path: root/src/kernel/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/mem')
-rw-r--r--src/kernel/mem/virt.c3
-rw-r--r--src/kernel/mem/virt.h11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/kernel/mem/virt.c b/src/kernel/mem/virt.c
index e0d8e44..7a38a88 100644
--- a/src/kernel/mem/virt.c
+++ b/src/kernel/mem/virt.c
@@ -41,7 +41,8 @@ bool virt_iter_next(struct virt_iter *iter) {
}
} else {
// "iterate" over physical memory
- iter->frag = (void*) iter->_virt;
+ // the double cast supresses the warning about changing address spaces
+ iter->frag = (void*)(uintptr_t)iter->_virt;
}
iter->frag_len = partial;
diff --git a/src/kernel/mem/virt.h b/src/kernel/mem/virt.h
index 7dac887..78d0cb3 100644
--- a/src/kernel/mem/virt.h
+++ b/src/kernel/mem/virt.h
@@ -27,3 +27,14 @@ bool virt_iter_next(struct virt_iter *);
bool virt_cpy(
struct pagedir *dest_pages, void __user *dest,
struct pagedir *src_pages, const void __user *src, size_t length);
+
+
+inline bool virt_cpy_to(struct pagedir *dest_pages, // physical -> virtual
+ void __user *dest, const void *src, size_t length) {
+ return virt_cpy(dest_pages, dest, NULL, (userptr_t)src, length);
+}
+
+inline bool virt_cpy_from(struct pagedir *src_pages, // virtual -> physical
+ void *dest, const void __user *src, size_t length) {
+ return virt_cpy(NULL, (userptr_t)dest, src_pages, src, length);
+}