vbos/amd64/include/arch/page.h

40 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _AMD64_PAGE_H_
#define _AMD64_PAGE_H_
#include <kernel/page.h>
#define PAGE_SIZE 0x1000ull
#define PAGE_MASK (~(PAGE_SIZE - 1))
#define PAGE_ALIGN (PAGE_SIZE - 1)
#define PAGE_LARGE_SIZE 0x200000ull /* 2 MiB */
#define PAGE_LARGE_MASK (~(PAGE_LARGE_SIZE - 1))
#define PAGE_LARGE_ALIGN (PAGE_LARGE_SIZE - 1)
#define PAGE_HUGE_SIZE 0x40000000ull /* 1 GiB */
#define PAGE_HUGE_MASK (~(PAGE_HUGE_SIZE - 1))
#define PAGE_HUGE_ALIGN (PAGE_HUGE_SIZE - 1)
#define PAGE_PRESENT 0x001
#define PAGE_RW 0x002
#define PAGE_USER 0x004
#define PAGE_WRITE_THRU 0x008
#define PAGE_CACHE_DISABLE 0x010
#define PAGE_ACCESSED 0x020
#define PAGE_DIRTY 0x040
#define PAGE_PS 0x080
#define PAGE_XD (1ull << 63)
#define pgd_index(address) (((address) >> 39) & 0x1FF)
#define pud_index(address) (((address) >> 30) & 0x1FF)
#define pmd_index(address) (((address) >> 21) & 0x1FF)
#define pte_index(address) (((address) >> 12) & 0x1FF)
u64 *_pt_read(u64 *dir, size_t index, u64 *flags);
void _pt_write(u64 *dir, size_t index, u64 *val, u64 flags);
void pgd_load(pgd_t *pgd);
pgd_t *pgd_get();
#endif /* _AMD64_PAGE_H_ */