64 lines
1.0 KiB
C
64 lines
1.0 KiB
C
#ifndef ARCH_PAGING_H_
|
|
#define ARCH_PAGING_H_
|
|
|
|
#include <socks/types.h>
|
|
#include <socks/compiler.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define PTE_PRESENT 0x01ULL
|
|
#define PTE_RW 0x02ULL
|
|
#define PTE_USR 0x04ULL
|
|
#define PTE_WRITETHROUGH 0x08ULL
|
|
#define PTE_NOCACHE 0x10ULL
|
|
#define PTE_PAGESIZE 0x80ULL
|
|
#define PTE_NX 0x8000000000000000ULL
|
|
|
|
typedef phys_addr_t pml4t_ptr_t;
|
|
typedef uint64_t pte_t;
|
|
|
|
struct pml4t {
|
|
phys_addr_t p_entries[512];
|
|
} __packed;
|
|
|
|
struct pdpt {
|
|
union {
|
|
/* 4KiB and 2MiB pages */
|
|
phys_addr_t p_entries[512];
|
|
/* 1GiB pages */
|
|
pte_t p_pages[512];
|
|
};
|
|
} __packed;
|
|
|
|
struct pdir {
|
|
union {
|
|
/* 4KiB pages */
|
|
phys_addr_t p_entries[512];
|
|
/* 2MiB pages */
|
|
pte_t p_pages[512];
|
|
};
|
|
} __packed;
|
|
|
|
struct ptab {
|
|
pte_t p_pages[512];
|
|
} __packed;
|
|
|
|
enum page_size {
|
|
PS_4K,
|
|
PS_2M,
|
|
PS_1G,
|
|
};
|
|
|
|
/* returns 1 if gigabyte pages are supported by the CPU, 0 otherwise.
|
|
defined in pmap_ctrl.S */
|
|
extern int gigabyte_pages(void);
|
|
extern int enable_nx(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|