summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/page-mapping.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/page-mapping.c')
-rw-r--r--arch/x86_64/page-mapping.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86_64/page-mapping.c b/arch/x86_64/page-mapping.c
new file mode 100644
index 0000000..0de5bfa
--- /dev/null
+++ b/arch/x86_64/page-mapping.c
@@ -0,0 +1,15 @@
+#include "arch/x86_64/page-mapping.h"
+#include "arch/x86_64/page.h"
+#include <stddef.h>
+
+pmle_t*
+page_mapping_traverse(pmle_t *pml4, uint8_t depth, uint16_t *path)
+{
+ uint16_t pathi = path[0];
+
+ pmle_t *pmle = &pml4[pathi];
+ pmle_t *pmle_table = vmem_phys_tovirt(pmle->paddr << 12);
+ if(depth == 0) return pmle;
+ if(!pmle->p) return NULL;
+ return page_mapping_traverse(pmle_table, depth - 1, path + 1);
+}