#ifndef NOX_PAGE_MAP_H #define NOX_PAGE_MAP_H #include "utils/stdtypes.h" #define VIRTUAL_ADDRESS_MAX 0x1000000000000 // 256 TB (the limit of PML4s) typedef enum { PM_FLAG_PRESENT = 0b0000000000000001, // 1 << 0 PM_FLAG_READ_WRITE = 0b0000000000000010, // 1 << 1 PM_FLAG_USER_SUPER = 0b0000000000000100, // 1 << 2 PM_FLAG_WRITE_THROUGH = 0b0000000000001000, // 1 << 3 PM_FLAG_CACHE_DISABLED = 0b0000000000010000, // 1 << 4 PM_FLAG_ACCESSED = 0b0000000000100000, // 1 << 5 PM_FLAG_DIRTY = 0b0000000001000000, // 1 << 6 PM_FLAG_LARGER_PAGES = 0b0000000010000000, // 1 << 7 PM_FLAG_CUSTOM_0 = 0b0000001000000000, // 1 << 9 PM_FLAG_CUSTOM_1 = 0b0000010000000000, // 1 << 10 PM_FLAG_CUSTOM_2 = 0b0000100000000000, // 1 << 11 PM_FLAG_NO_EXECUTE = 0x8000000000000000 // 1 << 63 } page_map_flag_E; typedef struct { uint64_t entries[512]; }__attribute__((aligned(0x1000))) page_map_T; page_map_T* page_map_create (); extern page_map_T* page_map_fetch_current (); extern void page_map_load (page_map_T* page_map); void page_map_map_memory (page_map_T* page_map, void* virtual_address, void* physical_address, uint64_t flags); void page_map_unmap_memory (page_map_T* page_map, void* virtual_address); bool page_map_check_memory (page_map_T* page_map, void* virtual_address); void* page_map_get_physical_address (page_map_T* page_map, void* virtual_address); void page_map_destruct (page_map_T* page_map); void page_map_dump_info (page_map_T* page_map); void page_map_entry_set_flags (uint64_t* entry, uint64_t flags); bool page_map_entry_get_flag (uint64_t* entry, page_map_flag_E flag); void page_map_entry_set_address (uint64_t* entry, void* address); void* page_map_entry_get_address (uint64_t* entry); void paging_init (); extern page_map_T* g_kernel_page_map; #endif //NOX_PAGE_MAP_H