]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _MOTOROLA_PGALLOC_H |
3 | #define _MOTOROLA_PGALLOC_H | |
4 | ||
5 | #include <asm/tlb.h> | |
6 | #include <asm/tlbflush.h> | |
7 | ||
8 | extern pmd_t *get_pointer_table(void); | |
9 | extern int free_pointer_table(pmd_t *); | |
10 | ||
4cf58924 | 11 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) |
1da177e4 LT |
12 | { |
13 | pte_t *pte; | |
14 | ||
32d6bd90 | 15 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); |
1da177e4 LT |
16 | if (pte) { |
17 | __flush_page_to_ram(pte); | |
18 | flush_tlb_kernel_page(pte); | |
19 | nocache_page(pte); | |
20 | } | |
21 | ||
22 | return pte; | |
23 | } | |
24 | ||
5e541973 | 25 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
1da177e4 LT |
26 | { |
27 | cache_page(pte); | |
28 | free_page((unsigned long) pte); | |
29 | } | |
30 | ||
4cf58924 | 31 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm) |
1da177e4 | 32 | { |
f84c914b | 33 | struct page *page; |
1da177e4 LT |
34 | pte_t *pte; |
35 | ||
32d6bd90 | 36 | page = alloc_pages(GFP_KERNEL|__GFP_ZERO, 0); |
1da177e4 LT |
37 | if(!page) |
38 | return NULL; | |
f84c914b KS |
39 | if (!pgtable_page_ctor(page)) { |
40 | __free_page(page); | |
41 | return NULL; | |
42 | } | |
1da177e4 LT |
43 | |
44 | pte = kmap(page); | |
dc71c7d5 AM |
45 | __flush_page_to_ram(pte); |
46 | flush_tlb_kernel_page(pte); | |
47 | nocache_page(pte); | |
48 | kunmap(page); | |
1da177e4 LT |
49 | return page; |
50 | } | |
51 | ||
2f569afd | 52 | static inline void pte_free(struct mm_struct *mm, pgtable_t page) |
1da177e4 | 53 | { |
2f569afd | 54 | pgtable_page_dtor(page); |
1da177e4 LT |
55 | cache_page(kmap(page)); |
56 | kunmap(page); | |
57 | __free_page(page); | |
58 | } | |
59 | ||
9e1b32ca BH |
60 | static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page, |
61 | unsigned long address) | |
1da177e4 | 62 | { |
2f569afd | 63 | pgtable_page_dtor(page); |
1da177e4 LT |
64 | cache_page(kmap(page)); |
65 | kunmap(page); | |
66 | __free_page(page); | |
67 | } | |
68 | ||
69 | ||
70 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) | |
71 | { | |
72 | return get_pointer_table(); | |
73 | } | |
74 | ||
5e541973 | 75 | static inline int pmd_free(struct mm_struct *mm, pmd_t *pmd) |
1da177e4 LT |
76 | { |
77 | return free_pointer_table(pmd); | |
78 | } | |
79 | ||
9e1b32ca BH |
80 | static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, |
81 | unsigned long address) | |
1da177e4 LT |
82 | { |
83 | return free_pointer_table(pmd); | |
84 | } | |
85 | ||
86 | ||
5e541973 | 87 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
1da177e4 | 88 | { |
5e541973 | 89 | pmd_free(mm, (pmd_t *)pgd); |
1da177e4 LT |
90 | } |
91 | ||
92 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | |
93 | { | |
94 | return (pgd_t *)get_pointer_table(); | |
95 | } | |
96 | ||
97 | ||
98 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) | |
99 | { | |
100 | pmd_set(pmd, pte); | |
101 | } | |
102 | ||
2f569afd | 103 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) |
1da177e4 LT |
104 | { |
105 | pmd_set(pmd, page_address(page)); | |
106 | } | |
2f569afd | 107 | #define pmd_pgtable(pmd) pmd_page(pmd) |
1da177e4 LT |
108 | |
109 | static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd) | |
110 | { | |
111 | pgd_set(pgd, pmd); | |
112 | } | |
113 | ||
114 | #endif /* _MOTOROLA_PGALLOC_H */ |