aboutsummaryrefslogtreecommitdiff
path: root/src/vmm.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-03-11 22:48:10 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-03-11 22:48:10 +0200
commit79e11fedd97325ba3dc7546373817b021edd89c7 (patch)
treeb291adc6891b8f51feb28db79c7c94acbee3d35a /src/vmm.h
parentMap kernel to 0xc000 rather than 0xc010 (diff)
downloadkernel.cpp-79e11fedd97325ba3dc7546373817b021edd89c7.tar.xz
vmm: map multiboot structs
Diffstat (limited to 'src/vmm.h')
-rw-r--r--src/vmm.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/vmm.h b/src/vmm.h
index 45aa1e8..9de487b 100644
--- a/src/vmm.h
+++ b/src/vmm.h
@@ -1,3 +1,31 @@
+#include <stdlib.h>
+
#pragma once
extern "C" void dump_address();
+
+struct page_table {
+ uint32_t* addr;
+};
+
+class vmm {
+public:
+ vmm(uint32_t* addr = nullptr);
+
+ constexpr static size_t table_id(uint32_t offset) {
+ offset &= 0xfff00000;
+ offset /= (4 * 1024 * 1024);
+ return static_cast<size_t>(offset);
+ }
+ constexpr static size_t page_id(uint32_t offset) { return static_cast<size_t>(offset / 4096); }
+
+ uint32_t map(uint32_t phys_addr, uint32_t offset);
+
+private:
+ uint32_t* directory;
+};
+
+static_assert(vmm::table_id(0x00001234) == 0);
+static_assert(vmm::table_id(0x00400000) == 1);
+static_assert(vmm::table_id(0xc0000000) == 768);
+static_assert(vmm::table_id(0xc03ff000) == 768);