summaryrefslogtreecommitdiff
path: root/api/kernel/memory/paging.h
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-03-27 18:29:31 +0000
committerAda Christine <adachristine18@gmail.com>2021-03-27 18:29:31 +0000
commit56ec6c782455f7d8e4560d30ad6d2c3e1cd2738f (patch)
tree7529396e629092ca2b403ac7360ca40bafeba327 /api/kernel/memory/paging.h
parentfda565807ee5b7c99eadcd2e7bfe0d36f68991ab (diff)
paging constants into header
Diffstat (limited to 'api/kernel/memory/paging.h')
-rw-r--r--api/kernel/memory/paging.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/api/kernel/memory/paging.h b/api/kernel/memory/paging.h
new file mode 100644
index 0000000..25e5eea
--- /dev/null
+++ b/api/kernel/memory/paging.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#define PAGE_PR 1
+#define PAGE_WR 2
+
+#define PAGE_MAP_LEVELS 4
+#define PAGE_MAP_BITS 9
+#define PAGE_OFFSET_BITS 12
+
+#define PAGE_TABLE_INDEX_MASK ((1 << PAGE_MAP_BITS) - 1)
+#define PAGE_TABLE_ADDRESS_MASK ~((1 << PAGE_OFFSET_BITS) - 1)
+
+#define page_table_index_bits(l) (PAGE_OFFSET_BITS + PAGE_MAP_BITS * (l - 1))
+#define page_table_index(v, l) ((v >> page_table_index_bits(l)) & PAGE_TABLE_INDEX_MASK)
+