feat: add page table
This commit is contained in:
parent
61dfda6a70
commit
ada1859910
8 changed files with 435 additions and 13 deletions
36
kernel/include/memory/pagetable.h
Normal file
36
kernel/include/memory/pagetable.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "memory/pointer.h"
|
||||
#include "util/optional.h"
|
||||
|
||||
struct PageTable {
|
||||
struct flags_t {
|
||||
enum class granularity_t : uint8_t {
|
||||
page_4KiB,
|
||||
page_2MiB,
|
||||
page_1GiB,
|
||||
};
|
||||
|
||||
bool writeable : 1; // allow writes
|
||||
bool user_accessible : 1; // allow ring-3 access
|
||||
bool write_through : 1; // write-through instead of write-back
|
||||
bool cache_disabled : 1; // uncached (MMIO)
|
||||
bool execute_disabled : 1; // forbid instruction fetch
|
||||
bool global : 1; // keep in TLB across CR3 switches
|
||||
granularity_t granularity : 2; // mapping size
|
||||
};
|
||||
struct info_t {
|
||||
flags_t flags;
|
||||
paddr_t address;
|
||||
};
|
||||
|
||||
static PageTable fromCurrent();
|
||||
|
||||
void activate();
|
||||
bool map(void* vaddress, paddr_t paddress, flags_t flags);
|
||||
void unmap(void* vaddress);
|
||||
optional<info_t> get(void* vaddress);
|
||||
|
||||
private:
|
||||
paddr_t l4;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue