2022-09-05 14:13:51 +00:00
|
|
|
#pragma once
|
|
|
|
#include "memory/Paging.h"
|
|
|
|
|
|
|
|
namespace Paging
|
|
|
|
{
|
2022-09-22 05:57:30 +00:00
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
ReadWrite = 1 << 0,
|
|
|
|
User = 1 << 1,
|
2022-09-23 14:41:43 +00:00
|
|
|
Execute = 1 << 2
|
2022-09-22 05:57:30 +00:00
|
|
|
};
|
2022-09-05 14:13:51 +00:00
|
|
|
class VirtualMemoryManager
|
|
|
|
{
|
2022-09-06 11:49:17 +00:00
|
|
|
public:
|
|
|
|
void init(); // fetch page table from cr3
|
2022-10-05 15:34:22 +00:00
|
|
|
void init(PageTable* cr3);
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-22 05:57:30 +00:00
|
|
|
void map(uint64_t virtualAddress, uint64_t physicalAddress, int flags);
|
|
|
|
void remap(uint64_t virtualAddress, int flags);
|
2022-09-06 11:49:17 +00:00
|
|
|
void unmap(uint64_t virtualAddress);
|
2022-09-06 16:08:15 +00:00
|
|
|
uint64_t getPhysical(uint64_t virtualAddress);
|
2022-09-22 06:14:04 +00:00
|
|
|
uint64_t getFlags(uint64_t virtualAddress);
|
2022-09-05 14:13:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
PageTable* PML4;
|
|
|
|
};
|
2022-09-06 11:49:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern Paging::VirtualMemoryManager kernelVMM;
|