summaryrefslogtreecommitdiffstats
path: root/lib/libjove/arch
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2025-08-24 16:05:30 -0400
committerJon Santmyer <jon@jonsantmyer.com>2025-08-24 16:05:30 -0400
commitf0248ad1724f9fbdd372db4da8ee8f956ae6aacd (patch)
tree4d661f264a64c562b56a801d3b6a5373415e42d4 /lib/libjove/arch
parent18c389411a0f6283c1b6dffc78bbcfcb237e367b (diff)
downloadjove-os-f0248ad1724f9fbdd372db4da8ee8f956ae6aacd.tar.gz
jove-os-f0248ad1724f9fbdd372db4da8ee8f956ae6aacd.tar.bz2
jove-os-f0248ad1724f9fbdd372db4da8ee8f956ae6aacd.zip
libc heap impl
Diffstat (limited to 'lib/libjove/arch')
-rw-r--r--lib/libjove/arch/x86_64/pager/ensure.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/libjove/arch/x86_64/pager/ensure.c b/lib/libjove/arch/x86_64/pager/ensure.c
index bfe68ff..874db35 100644
--- a/lib/libjove/arch/x86_64/pager/ensure.c
+++ b/lib/libjove/arch/x86_64/pager/ensure.c
@@ -18,7 +18,7 @@ pager_write_path(uintptr_t vptr, uint8_t depth)
if(depth >= 4) return -1;
uint16_t *path = (uint16_t*)&r;
- for(uint8_t i = 0; i < depth; i++) path[i] = PMLI_DL(vptr, i);
+ for(uint8_t i = 0; i < depth + 1; i++) path[i] = PMLI_DL(vptr, i);
return r;
}
@@ -70,10 +70,10 @@ pager_ensure_at_depth(KernelObjectPageMap *map, uint8_t depth, uint16_t *path)
JoveError
jove_pager_ensure_for(KernelObjectPageMap *map, uintptr_t vptr)
{
+ vptr &= ~0xFFFULL;
+
uint64_t path = pager_write_path(vptr, 3);
if(path == -1) return EJOVE_BADARG;
-
- vptr &= ~0xFFFULL;
uint16_t *path_seg = (uint16_t*)&path;
jove_kprintf("%p Alloc %p : %x:%x:%x:%x\n", map, vptr, path_seg[0], path_seg[1], path_seg[2], path_seg[3]);
@@ -86,3 +86,25 @@ jove_pager_ensure_for(KernelObjectPageMap *map, uintptr_t vptr)
}
return EJOVE_OK;
}
+
+#define PAGER_CACHE_EXISTS_DEPTH(map, path_seg, d) \
+ if(path_seg[d] != d_cache[d]) { \
+ if(!jove_pagemap_exists(map, d, path_seg)) return 0; \
+ d_cache[d] = path_seg[d]; \
+ }
+
+
+int
+jove_pager_exists_for(KernelObjectPageMap *map, uintptr_t vptr)
+{
+ vptr &= ~0xFFFULL;
+
+ uint64_t path = pager_write_path(vptr, 3);
+ if(path == -1) return EJOVE_BADARG;
+ uint16_t *path_seg = (uint16_t*)&path;
+
+ PAGER_CACHE_EXISTS_DEPTH(map, path_seg, 0);
+ PAGER_CACHE_EXISTS_DEPTH(map, path_seg, 1);
+ PAGER_CACHE_EXISTS_DEPTH(map, path_seg, 2);
+ return jove_pagemap_exists(map, 3, path_seg);
+}