30 lines
862 B
C++
30 lines
862 B
C++
#pragma once
|
|
#include "memory/Paging.h"
|
|
|
|
enum Flags
|
|
{
|
|
ReadWrite = 1 << 0,
|
|
User = 1 << 1,
|
|
Execute = 1 << 2
|
|
};
|
|
namespace VMM
|
|
{
|
|
void init(); // Fetch page table from cr3
|
|
|
|
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);
|
|
|
|
PageDirectoryEntry* find_pde(PageTable* root, uint64_t vaddr);
|
|
PageDirectoryEntry* create_pde_if_not_exists(PageTable* root, uint64_t vaddr);
|
|
|
|
void propagate_read_write(PageTable* root, uint64_t vaddr);
|
|
void propagate_user(PageTable* root, uint64_t vaddr);
|
|
|
|
void flush_tlb(uint64_t addr);
|
|
|
|
void decompose_vaddr(uint64_t vaddr, uint64_t& page_index, uint64_t& pt_index, uint64_t& pd_index,
|
|
uint64_t& pdp_index);
|
|
}; |