#pragma once #include "utils/Result.h" #include #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif #define MAP_READ_WRITE 1 << 0 #define MAP_USER 1 << 1 #define MAP_EXEC 1 << 2 #define MAP_AS_OWNED_BY_TASK 1 << 3 namespace MemoryManager { void init(); void protect_kernel_sections(); Result get_mapping(void* physicalAddress, int flags = MAP_READ_WRITE); void release_mapping(void* mapping); Result get_unaligned_mapping(void* physicalAddress, int flags = MAP_READ_WRITE); Result get_unaligned_mappings(void* physicalAddress, uint64_t count, int flags = MAP_READ_WRITE); void release_unaligned_mapping(void* mapping); void release_unaligned_mappings(void* mapping, uint64_t count); Result get_page(int flags = MAP_READ_WRITE); Result get_pages(uint64_t count, int flags = MAP_READ_WRITE); Result get_page_at(uint64_t addr, int flags = MAP_READ_WRITE); Result get_pages_at(uint64_t addr, uint64_t count, int flags = MAP_READ_WRITE); void release_page(void* page); void release_pages(void* pages, uint64_t count); void protect(void* page, uint64_t count, int flags); void map_several_pages(uint64_t physicalAddress, uint64_t virtualAddress, uint64_t count, int flags = MAP_READ_WRITE); }