xref: /openbmc/linux/arch/sh/include/asm/pgalloc.h (revision c7bcbc8ab9cb20536b8f50c62a48cebda965fdba)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_PGALLOC_H
3f15cbe6fSPaul Mundt #define __ASM_SH_PGALLOC_H
4f15cbe6fSPaul Mundt 
5f15cbe6fSPaul Mundt #include <asm/page.h>
66fb12766SMike Rapoport #include <asm-generic/pgalloc.h>
7f15cbe6fSPaul Mundt 
82a5eaccaSMatt Fleming extern pgd_t *pgd_alloc(struct mm_struct *);
92a5eaccaSMatt Fleming extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
102a5eaccaSMatt Fleming 
11782bb5a5SPaul Mundt #if PAGETABLE_LEVELS > 2
122a5eaccaSMatt Fleming extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
132a5eaccaSMatt Fleming extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
142a5eaccaSMatt Fleming extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
15*c7bcbc8aSPeter Zijlstra #define __pmd_free_tlb(tlb, pmdp, addr)		pmd_free((tlb)->mm, (pmdp))
165d9b4b19SMatt Fleming #endif
17b73c8063SMatt Fleming 
18f15cbe6fSPaul Mundt static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
19f15cbe6fSPaul Mundt 				       pte_t *pte)
20f15cbe6fSPaul Mundt {
21f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)pte));
22f15cbe6fSPaul Mundt }
23f15cbe6fSPaul Mundt 
24f15cbe6fSPaul Mundt static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
25f15cbe6fSPaul Mundt 				pgtable_t pte)
26f15cbe6fSPaul Mundt {
27f15cbe6fSPaul Mundt 	set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
28f15cbe6fSPaul Mundt }
29f15cbe6fSPaul Mundt #define pmd_pgtable(pmd) pmd_page(pmd)
30f15cbe6fSPaul Mundt 
319e1b32caSBenjamin Herrenschmidt #define __pte_free_tlb(tlb,pte,addr)			\
32f15cbe6fSPaul Mundt do {							\
33b4ed71f5SMark Rutland 	pgtable_pte_page_dtor(pte);			\
34f15cbe6fSPaul Mundt 	tlb_remove_page((tlb), (pte));			\
35f15cbe6fSPaul Mundt } while (0)
36f15cbe6fSPaul Mundt 
37f15cbe6fSPaul Mundt #endif /* __ASM_SH_PGALLOC_H */
38