12089Ssos/* SPDX-License-Identifier: GPL-2.0 */ 216565Ssos#ifndef _MOTOROLA_PGALLOC_H 32089Ssos#define _MOTOROLA_PGALLOC_H 42089Ssos 52089Ssos#include <asm/tlb.h> 62089Ssos#include <asm/tlbflush.h> 72089Ssos 82089Ssosextern void mmu_page_ctor(void *page); 95994Ssosextern void mmu_page_dtor(void *page); 105994Ssos 112089Ssosenum m68k_table_types { 122089Ssos TABLE_PGD = 0, 132089Ssos TABLE_PMD = 0, /* same size as PGD */ 142089Ssos TABLE_PTE = 1, 152089Ssos}; 162089Ssos 172089Ssosextern void init_pointer_table(void *table, int type); 182089Ssosextern void *get_pointer_table(int type); 192089Ssosextern int free_pointer_table(void *table, int type); 202089Ssos 212089Ssos/* 222089Ssos * Allocate and free page tables. The xxx_kernel() versions are 232089Ssos * used to allocate a kernel page table - this turns on ASN bits 242089Ssos * if any. 252089Ssos */ 262089Ssos 272089Ssosstatic inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) 282089Ssos{ 2930764Scharnier return get_pointer_table(TABLE_PTE); 3030764Scharnier} 3150479Speter 3230764Scharnierstatic inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 3330764Scharnier{ 342089Ssos free_pointer_table(pte, TABLE_PTE); 3530764Scharnier} 3655849Syokota 372089Ssosstatic inline pgtable_t pte_alloc_one(struct mm_struct *mm) 3823457Sbrian{ 3930764Scharnier return get_pointer_table(TABLE_PTE); 4023702Speter} 412089Ssos 422089Ssosstatic inline void pte_free(struct mm_struct *mm, pgtable_t pgtable) 432089Ssos{ 4423457Sbrian free_pointer_table(pgtable, TABLE_PTE); 452089Ssos} 462089Ssos 472089Ssosstatic inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable, 482089Ssos unsigned long address) 492089Ssos{ 502089Ssos free_pointer_table(pgtable, TABLE_PTE); 516628Ssos} 522089Ssos 536047Ssos 542089Ssosstatic inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) 552089Ssos{ 562089Ssos return get_pointer_table(TABLE_PMD); 572089Ssos} 5830764Scharnier 596628Ssosstatic inline int pmd_free(struct mm_struct *mm, pmd_t *pmd) 606628Ssos{ 6155849Syokota return free_pointer_table(pmd, TABLE_PMD); 6230764Scharnier} 6355849Syokota 6455849Syokotastatic inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, 6555849Syokota unsigned long address) 6630764Scharnier{ 676628Ssos return free_pointer_table(pmd, TABLE_PMD); 686628Ssos} 692089Ssos 702089Ssos 712089Ssosstatic inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 722089Ssos{ 732089Ssos free_pointer_table(pgd, TABLE_PGD); 7430764Scharnier} 752089Ssos 762089Ssosstatic inline pgd_t *pgd_alloc(struct mm_struct *mm) 772089Ssos{ 782089Ssos return get_pointer_table(TABLE_PGD); 792089Ssos} 802089Ssos 816628Ssos 826628Ssosstatic inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) 836628Ssos{ 842089Ssos pmd_set(pmd, pte); 852089Ssos} 8652262Sbillf 872089Ssosstatic inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) 882089Ssos{ 892089Ssos pmd_set(pmd, page); 902089Ssos} 9152262Sbillf 922089Ssosstatic inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) 932089Ssos{ 942089Ssos pud_set(pud, pmd); 952089Ssos} 962089Ssos 972089Ssos#endif /* _MOTOROLA_PGALLOC_H */ 982089Ssos