2023-03-10 10:32:50 +00:00
|
|
|
|
2023-02-09 17:41:21 +00:00
|
|
|
|
|
|
|
#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
|
2023-02-10 18:29:05 +00:00
|
|
|
PM_FLAG_DIRTY = 0b0000000001000000, // 1 << 6
|
2023-02-09 17:41:21 +00:00
|
|
|
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);
|
2023-04-20 16:29:21 +00:00
|
|
|
bool page_map_check_memory (page_map_T* page_map, void* virtual_address);
|
2023-02-10 19:13:33 +00:00
|
|
|
void* page_map_get_physical_address (page_map_T* page_map, void* virtual_address);
|
2023-02-09 17:41:21 +00:00
|
|
|
void page_map_destruct (page_map_T* page_map);
|
2023-03-04 21:36:52 +00:00
|
|
|
void page_map_dump_info (page_map_T* page_map);
|
2023-02-09 17:41:21 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-02-10 18:29:05 +00:00
|
|
|
void paging_init ();
|
2023-02-09 17:41:21 +00:00
|
|
|
|
|
|
|
extern page_map_T* g_kernel_page_map;
|
|
|
|
|
|
|
|
#endif //NOX_PAGE_MAP_H
|