aboutsummaryrefslogtreecommitdiff
path: root/src/core/paging.hpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-04-24 10:09:43 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-04-24 10:09:43 +0200
commit657372f1be95393b76a54f258ba3f937b4073abe (patch)
tree18aa2cb9b7f3e4d38a5208d9db2811f6af46fa61 /src/core/paging.hpp
parent99019721a9e147c49becc466c5427609b937aca8 (diff)
New paging manager and multiboot2 tools
Diffstat (limited to 'src/core/paging.hpp')
-rw-r--r--src/core/paging.hpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/core/paging.hpp b/src/core/paging.hpp
new file mode 100644
index 0000000..1457d10
--- /dev/null
+++ b/src/core/paging.hpp
@@ -0,0 +1,66 @@
+#pragma once
+
+#include "core/types.hpp"
+
+#define PAGING_MAX_PAGE (20*512)
+/**
+ * Current number of page (from the beginning of the ram) used by the kernel that
+ * should not be used by the paging allocation mechanism and should not be granted
+ * for allocation
+ */
+#define PAGING_KERNEL_USED_PAGE (2*512)
+/// @brief New number of page reachable at the end of the paging_enable() call
+#define PAGING_KERNEL_SPACE_MAX_PAGE (20*512)
+#define PAGING_ALLOCATE() paging_allocate_contiguous(1)
+#define PAGING_OPT_P 1
+#define PAGING_OPT_RW (1<<1)
+
+/// @brief Get page address that contain addr
+#define PAGE(addr) (addr&(~(0xFFF)))
+
+/**
+ * Setup and enable PAE paging
+ */
+void paging_enable();
+
+/**
+ * Allocate the next available page
+ * and return its physical address
+ */
+u64* paging_allocate_contiguous(int npages);
+
+/**
+ * Deallocate a page located at addr
+ */
+void paging_deallocate(u64 addr);
+
+/**
+ * Dump a specific range of bytes in the paging_status
+ */
+void paging_dump(int min, int max);
+
+/**
+ * Deallocate all the pages linked to a pml4
+ */
+void paging_deallocate_pml4(u64* pml4);
+
+/**
+ * Deallocate all the pages related to a pml4 structure
+ */
+void paging_deallocate_table(u64* table);
+
+/**
+ * Allocate table structure (pml4, pdp etc..)
+ */
+u64* paging_allocate_table();
+
+/**
+ * Map virtual page associated to virt
+ * to the physical page associated with phy
+ */
+void paging_allocate_addr(u64* pml4_table,u64 virt, u64 phy, u16 options);
+
+/**
+ * Get associated physical address
+ */
+u64 paging_as_phy(u64* pml4_table, u64 virt); \ No newline at end of file