diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-11 22:48:10 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-11 22:48:10 +0200 |
commit | 79e11fedd97325ba3dc7546373817b021edd89c7 (patch) | |
tree | b291adc6891b8f51feb28db79c7c94acbee3d35a /src/vmm.h | |
parent | Map kernel to 0xc000 rather than 0xc010 (diff) | |
download | kernel.cpp-79e11fedd97325ba3dc7546373817b021edd89c7.tar.xz |
vmm: map multiboot structs
Diffstat (limited to 'src/vmm.h')
-rw-r--r-- | src/vmm.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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); |