• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_M32R_PGALLOC_H
3 #define _ASM_M32R_PGALLOC_H
4 
5 #include <linux/mm.h>
6 
7 #include <asm/io.h>
8 
9 #define pmd_populate_kernel(mm, pmd, pte)	\
10 	set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
11 
pmd_populate(struct mm_struct * mm,pmd_t * pmd,pgtable_t pte)12 static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
13 	pgtable_t pte)
14 {
15 	set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
16 }
17 #define pmd_pgtable(pmd) pmd_page(pmd)
18 
19 /*
20  * Allocate and free page tables.
21  */
pgd_alloc(struct mm_struct * mm)22 static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
23 {
24 	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
25 
26 	return pgd;
27 }
28 
pgd_free(struct mm_struct * mm,pgd_t * pgd)29 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
30 {
31 	free_page((unsigned long)pgd);
32 }
33 
pte_alloc_one_kernel(struct mm_struct * mm,unsigned long address)34 static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
35 	unsigned long address)
36 {
37 	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
38 
39 	return pte;
40 }
41 
pte_alloc_one(struct mm_struct * mm,unsigned long address)42 static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm,
43 	unsigned long address)
44 {
45 	struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO);
46 
47 	if (!pte)
48 		return NULL;
49 	if (!pgtable_page_ctor(pte)) {
50 		__free_page(pte);
51 		return NULL;
52 	}
53 	return pte;
54 }
55 
pte_free_kernel(struct mm_struct * mm,pte_t * pte)56 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
57 {
58 	free_page((unsigned long)pte);
59 }
60 
pte_free(struct mm_struct * mm,pgtable_t pte)61 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
62 {
63 	pgtable_page_dtor(pte);
64 	__free_page(pte);
65 }
66 
67 #define __pte_free_tlb(tlb, pte, addr)	pte_free((tlb)->mm, (pte))
68 
69 /*
70  * allocating and freeing a pmd is trivial: the 1-entry pmd is
71  * inside the pgd, so has no extra memory associated with it.
72  * (In the PAE case we free the pmds as part of the pgd.)
73  */
74 
75 #define pmd_alloc_one(mm, addr)		({ BUG(); ((pmd_t *)2); })
76 #define pmd_free(mm, x)			do { } while (0)
77 #define __pmd_free_tlb(tlb, x, addr)	do { } while (0)
78 #define pgd_populate(mm, pmd, pte)	BUG()
79 
80 #define check_pgt_cache()	do { } while (0)
81 
82 #endif /* _ASM_M32R_PGALLOC_H */
83