2022-09-05 14:13:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include "memory/Paging.h"
|
|
|
|
|
2022-10-12 18:02:25 +00:00
|
|
|
enum Flags
|
2022-09-05 14:13:51 +00:00
|
|
|
{
|
2022-10-12 18:02:25 +00:00
|
|
|
ReadWrite = 1 << 0,
|
|
|
|
User = 1 << 1,
|
|
|
|
Execute = 1 << 2
|
|
|
|
};
|
|
|
|
namespace VMM
|
|
|
|
{
|
2022-10-13 16:42:53 +00:00
|
|
|
void init(); // Fetch page table from cr3
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-10-13 16:42:53 +00:00
|
|
|
void map(uint64_t vaddr, uint64_t paddr, int flags);
|
|
|
|
void remap(uint64_t vaddr, int flags);
|
|
|
|
void unmap(uint64_t vaddr);
|
|
|
|
uint64_t get_physical(uint64_t vaddr);
|
|
|
|
uint64_t get_flags(uint64_t vaddr);
|
2022-09-06 11:49:17 +00:00
|
|
|
|
2022-10-13 16:42:53 +00:00
|
|
|
PageDirectoryEntry* find_pde(PageTable* root, uint64_t vaddr);
|
|
|
|
PageDirectoryEntry* create_pde_if_not_exists(PageTable* root, uint64_t vaddr);
|
2022-10-13 15:58:13 +00:00
|
|
|
|
2022-10-13 16:42:53 +00:00
|
|
|
void propagate_read_write(PageTable* root, uint64_t vaddr);
|
|
|
|
void propagate_user(PageTable* root, uint64_t vaddr);
|
2022-10-13 15:58:13 +00:00
|
|
|
|
|
|
|
void flush_tlb(uint64_t addr);
|
2022-10-13 16:15:52 +00:00
|
|
|
|
|
|
|
void decompose_vaddr(uint64_t vaddr, uint64_t& page_index, uint64_t& pt_index, uint64_t& pd_index,
|
|
|
|
uint64_t& pdp_index);
|
2022-10-12 18:02:25 +00:00
|
|
|
};
|