diff --git a/kernel/include/types.hpp b/kernel/include/types.hpp index 0ab69f02..7beda1e2 100644 --- a/kernel/include/types.hpp +++ b/kernel/include/types.hpp @@ -7,8 +7,11 @@ typedef unsigned int uint8_t __attribute__((__mode__(__QI__))); typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__))); typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__))); -static_assert(sizeof(uint8_t) == 1, "The size must match"); -static_assert(sizeof(uint16_t) == 2, "The size must match"); -static_assert(sizeof(uint32_t) == 4, "The size must match"); +typedef std::size_t uintptr_t; + +static_assert(sizeof(uint8_t) == 1, "uint32_t must be 1 byte long"); +static_assert(sizeof(uint16_t) == 2, "uint32_t must be 2 bytes long"); +static_assert(sizeof(uint32_t) == 4, "uint32_t must be 4 bytes long"); +static_assert(sizeof(uintptr_t) == sizeof(std::size_t*), "uintptr_t must have the same size as a pointer"); #endif diff --git a/kernel/src/memory.cpp b/kernel/src/memory.cpp index 618574c4..5e77da26 100644 --- a/kernel/src/memory.cpp +++ b/kernel/src/memory.cpp @@ -81,11 +81,9 @@ std::size_t* allocate_block(std::size_t blocks){ } pml4t_t pml4t = (pml4t_t) 0x70000; - auto pdpt = (page_directory_pointer_table)(pml4t[pml4t_index] - 0x3); - auto pdt = (page_directory_table)(pdpt[pdpt_index] - 0x3); - auto pt = (page_table)(pdt[pdt_index] - 0x3); - - pt = (page_table) 0x73000; + auto pdpt = (page_directory_pointer_table)(reinterpret_cast(pml4t[pml4t_index]) & ~0xFFF); + auto pdt = (page_directory_table)(reinterpret_cast(pdpt[pdpt_index]) & ~0xFFF); + auto pt = (page_table)(reinterpret_cast(pdt[pdt_index]) & ~0xFFF); if(pt_index + blocks >= 512){ //TODO Go to a new page table