1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SH_PGALLOC_H 3 #define __ASM_SH_PGALLOC_H 4 5 #include <linux/mm.h> 6 #include <asm/page.h> 7 8 #define __HAVE_ARCH_PMD_ALLOC_ONE 9 #define __HAVE_ARCH_PMD_FREE 10 #define __HAVE_ARCH_PGD_FREE 11 #include <asm-generic/pgalloc.h> 12 13 extern pgd_t *pgd_alloc(struct mm_struct *); 14 extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 15 16 #if PAGETABLE_LEVELS > 2 17 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd); 18 extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address); 19 extern void pmd_free(struct mm_struct *mm, pmd_t *pmd); 20 extern void __tlb_remove_table(void *table); 21 22 /* PMDs are slab-allocated, tag so they are freed correctly. */ 23 #define __pmd_free_tlb(tlb, pmdp, addr) \ 24 tlb_remove_table((tlb), (void *)((unsigned long)(pmdp) | 1)) 25 #endif 26 27 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 28 pte_t *pte) 29 { 30 set_pmd(pmd, __pmd((unsigned long)pte)); 31 } 32 33 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, 34 pgtable_t pte) 35 { 36 set_pmd(pmd, __pmd((unsigned long)page_address(pte))); 37 } 38 39 #define __pte_free_tlb(tlb, pte, addr) \ 40 tlb_remove_ptdesc((tlb), page_ptdesc(pte)) 41 42 #endif /* __ASM_SH_PGALLOC_H */ 43