LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
paging.h
Go to the documentation of this file.
1
9
10#ifndef KERNEL_ARCH_X86_64_PAGING_H
11#define KERNEL_ARCH_X86_64_PAGING_H
12
13#include <stdint.h>
14
15#define PTE_PRESENT (1ULL << 0)
16#define PTE_WRITABLE (1ULL << 1)
17#define PTE_USER (1ULL << 2)
18#define PTE_PWT (1ULL << 3)
19#define PTE_PCD (1ULL << 4)
20#define PTE_ACCESSED (1ULL << 5)
21#define PTE_DIRTY (1ULL << 6)
22#define PTE_HUGE (1ULL << 7) // the PS bit in levels 3 and 2
23#define PTE_GLOBAL (1ULL << 8)
24#define PTE_NX (1ULL << 63)
25
26#define PTE_ADDR_MASK 0x000FFFFFFFFFF000ULL // bits 12 to 51: 4 KiB table or frame
27#define PTE_ADDR_2M 0x000FFFFFFFE00000ULL // bits 21 to 51: 2 MiB page
28#define PTE_ADDR_1G 0x000FFFFFC0000000ULL // bits 30 to 51: 1 GiB page
29
35uint64_t translate(uint64_t virtual_address);
36
37#endif
uint64_t translate(uint64_t virtual_address)
Converts/Translates a virtual address to its corresponding physical address.
Definition paging.c:15