xref: /openbmc/linux/arch/sh/include/asm/pgalloc.h (revision 50df3be7)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_PGALLOC_H
3 #define __ASM_SH_PGALLOC_H
4 
5 #include <asm/page.h>
6 #include <asm-generic/pgalloc.h>
7 
8 extern pgd_t *pgd_alloc(struct mm_struct *);
9 extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
10 
11 #if PAGETABLE_LEVELS > 2
12 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
13 extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
14 extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
15 #endif
16 
17 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
18 				       pte_t *pte)
19 {
20 	set_pmd(pmd, __pmd((unsigned long)pte));
21 }
22 
23 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
24 				pgtable_t pte)
25 {
26 	set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
27 }
28 #define pmd_pgtable(pmd) pmd_page(pmd)
29 
30 #define __pte_free_tlb(tlb,pte,addr)			\
31 do {							\
32 	pgtable_pte_page_dtor(pte);			\
33 	tlb_remove_page((tlb), (pte));			\
34 } while (0)
35 
36 #if CONFIG_PGTABLE_LEVELS > 2
37 #define __pmd_free_tlb(tlb, pmdp, addr)			\
38 do {							\
39 	struct page *page = virt_to_page(pmdp);		\
40 	pgtable_pmd_page_dtor(page);			\
41 	tlb_remove_page((tlb), page);			\
42 } while (0);
43 #endif
44 
45 #endif /* __ASM_SH_PGALLOC_H */
46