#pragma once #include "memory/pointer.h" #include "util/optional.h" struct PageTable { struct flags_t { enum class granularity_t : uint8_t { page_4KiB, page_2MiB, page_1GiB, }; bool writeable : 1; // allow writes bool user_accessible : 1; // allow ring-3 access bool write_through : 1; // write-through instead of write-back bool cache_disabled : 1; // uncached (MMIO) bool execute_disabled : 1; // forbid instruction fetch bool global : 1; // keep in TLB across CR3 switches granularity_t granularity : 2; // mapping size }; struct info_t { flags_t flags; paddr_t address; }; static PageTable fromCurrent(); void activate(); bool map(void* vaddress, paddr_t paddress, flags_t flags); void unmap(void* vaddress); optional get(void* vaddress); private: paddr_t l4; };