1 #ifndef __LUNAIX_ARCH_GENERIC_INIT_PAGETABLE_H
2 #define __LUNAIX_ARCH_GENERIC_INIT_PAGETABLE_H
4 #include <lunaix/types.h>
5 #include <lunaix/mm/pagetable.h>
16 struct pt_alloc* alloc;
24 * Allocate a page table from the page-table pool
27 kpt_alloc_table(struct pt_alloc* alloc);
30 * Set contiguous number of ptes starting from `addr`
31 * Using flattened apporach (i.e., unfold recursive)
34 kpt_set_ptes_flatten(struct ptw_state* state, ptr_t addr,
35 pte_t pte, unsigned long lsize, unsigned int nr);
38 * Remap the kernel to high-memory
41 kpt_migrate_highmem(struct ptw_state* state);
43 static inline void must_inline
44 init_pt_alloc(struct pt_alloc* alloc, ptr_t pool, unsigned int size)
46 *alloc = (struct pt_alloc) {
49 .total = size / PAGE_SIZE
53 static inline void must_inline
54 init_ptw_state(struct ptw_state* state, struct pt_alloc* alloc, ptr_t root)
56 *state = (struct ptw_state) {
58 .root = (pte_t*) root,
64 * set_ptes that is ensured to success
66 static inline void must_inline
67 kpt_set_ptes(struct ptw_state* state, ptr_t addr,
68 pte_t pte, unsigned long lsize, unsigned int nr)
70 if (kpt_set_ptes_flatten(state, addr, pte, lsize, nr) != nr) {
76 * prepare a editable page table covering va range [addr, addr + lsize)
78 static inline void must_inline
79 kpt_mktable_at(struct ptw_state* state, ptr_t addr, unsigned long lsize)
81 kpt_set_ptes(state, addr, null_pte, lsize >> _PAGE_BASE_SHIFT, 1);
84 #endif /* __LUNAIX_ARCH_GENERIC_INIT_PAGETABLE_H */