all kernel headers have been moved from include/mango to include/kernel and include definitions that are only relevant to kernel-space. any definitions that are relevant to both kernel- and user-space (i.e. type definitions, syscall IDs) have been moved to include/mango within libmango.
64 lines
1.0 KiB
C
64 lines
1.0 KiB
C
#ifndef ARCH_PAGING_H_
|
|
#define ARCH_PAGING_H_
|
|
|
|
#include <kernel/types.h>
|
|
#include <kernel/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
|