| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef _MOTOROLA_PGALLOC_H |
| 3 |
#define _MOTOROLA_PGALLOC_H |
| 4 |
|
| 5 |
#include <asm/tlb.h> |
| 6 |
#include <asm/tlbflush.h> |
| 7 |
|
| 8 |
extern void mmu_page_ctor(void *page); |
| 9 |
extern void mmu_page_dtor(void *page); |
| 10 |
|
| 11 |
enum m68k_table_types { |
| 12 |
TABLE_PGD, |
| 13 |
TABLE_PMD, |
| 14 |
TABLE_PTE, |
| 15 |
}; |
| 16 |
|
| 17 |
extern void init_pointer_table(void *table, int type); |
| 18 |
extern void *get_pointer_table(struct mm_struct *mm, int type); |
| 19 |
extern int free_pointer_table(void *table, int type); |
| 20 |
|
| 21 |
/* |
| 22 |
* Allocate and free page tables. The xxx_kernel() versions are |
| 23 |
* used to allocate a kernel page table - this turns on ASN bits |
| 24 |
* if any. |
| 25 |
*/ |
| 26 |
|
| 27 |
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) |
| 28 |
{ |
| 29 |
return get_pointer_table(mm, TABLE_PTE); |
| 30 |
} |
| 31 |
|
| 32 |
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
| 33 |
{ |
| 34 |
free_pointer_table(pte, TABLE_PTE); |
| 35 |
} |
| 36 |
|
| 37 |
static inline pgtable_t pte_alloc_one(struct mm_struct *mm) |
| 38 |
{ |
| 39 |
return get_pointer_table(mm, TABLE_PTE); |
| 40 |
} |
| 41 |
|
| 42 |
static inline void pte_free(struct mm_struct *mm, pgtable_t pgtable) |
| 43 |
{ |
| 44 |
free_pointer_table(pgtable, TABLE_PTE); |
| 45 |
} |
| 46 |
|
| 47 |
static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable, |
| 48 |
unsigned long address) |
| 49 |
{ |
| 50 |
free_pointer_table(pgtable, TABLE_PTE); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) |
| 55 |
{ |
| 56 |
return get_pointer_table(mm, TABLE_PMD); |
| 57 |
} |
| 58 |
|
| 59 |
static inline int pmd_free(struct mm_struct *mm, pmd_t *pmd) |
| 60 |
{ |
| 61 |
return free_pointer_table(pmd, TABLE_PMD); |
| 62 |
} |
| 63 |
|
| 64 |
static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, |
| 65 |
unsigned long address) |
| 66 |
{ |
| 67 |
return free_pointer_table(pmd, TABLE_PMD); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
| 72 |
{ |
| 73 |
free_pointer_table(pgd, TABLE_PGD); |
| 74 |
} |
| 75 |
|
| 76 |
static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 77 |
{ |
| 78 |
return get_pointer_table(mm, TABLE_PGD); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) |
| 83 |
{ |
| 84 |
pmd_set(pmd, pte); |
| 85 |
} |
| 86 |
|
| 87 |
static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) |
| 88 |
{ |
| 89 |
pmd_set(pmd, page); |
| 90 |
} |
| 91 |
|
| 92 |
static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) |
| 93 |
{ |
| 94 |
pud_set(pud, pmd); |
| 95 |
} |
| 96 |
|
| 97 |
#endif /* _MOTOROLA_PGALLOC_H */ |