Luna/kernel/src/arch/x86_64/MMU.h
2023-01-02 13:07:29 +01:00

44 lines
992 B
C

#pragma once
#include <luna/Types.h>
const usize ARCH_PAGE_SIZE = 4096;
const u64 rindex = 0776; // recursive index
const u64 sign = 0177777UL << 48; // sign extension
struct [[gnu::packed]] PageTableEntry
{
union {
struct [[gnu::packed]]
{
bool present : 1;
bool read_write : 1;
bool user : 1;
bool write_through : 1;
bool cache_disabled : 1;
bool accessed : 1;
bool ignore0 : 1;
bool larger_pages : 1;
bool ignore1 : 1;
u8 available : 3;
u64 address : 48;
u8 available2 : 3;
bool no_execute : 1;
};
u64 raw;
};
void set_address(u64 addr);
u64 get_address() const;
void clear();
};
struct alignas(ARCH_PAGE_SIZE) PageDirectory
{
PageTableEntry entries[512];
};
static_assert(sizeof(PageTableEntry) == 8UL);
static_assert(sizeof(PageDirectory) == ARCH_PAGE_SIZE);