diff options
Diffstat (limited to 'include/asm-m68k/motorola_pgalloc.h')
-rw-r--r-- | include/asm-m68k/motorola_pgalloc.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/include/asm-m68k/motorola_pgalloc.h b/include/asm-m68k/motorola_pgalloc.h new file mode 100644 index 000000000000..5158412cd54d --- /dev/null +++ b/include/asm-m68k/motorola_pgalloc.h | |||
@@ -0,0 +1,107 @@ | |||
1 | #ifndef _MOTOROLA_PGALLOC_H | ||
2 | #define _MOTOROLA_PGALLOC_H | ||
3 | |||
4 | #include <asm/tlb.h> | ||
5 | #include <asm/tlbflush.h> | ||
6 | |||
7 | extern pmd_t *get_pointer_table(void); | ||
8 | extern int free_pointer_table(pmd_t *); | ||
9 | |||
10 | |||
11 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | ||
12 | { | ||
13 | pte_t *pte; | ||
14 | |||
15 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); | ||
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 | |||
25 | static inline void pte_free_kernel(pte_t *pte) | ||
26 | { | ||
27 | cache_page(pte); | ||
28 | free_page((unsigned long) pte); | ||
29 | } | ||
30 | |||
31 | static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | ||
32 | { | ||
33 | struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); | ||
34 | pte_t *pte; | ||
35 | |||
36 | if(!page) | ||
37 | return NULL; | ||
38 | |||
39 | pte = kmap(page); | ||
40 | if (pte) { | ||
41 | __flush_page_to_ram(pte); | ||
42 | flush_tlb_kernel_page(pte); | ||
43 | nocache_page(pte); | ||
44 | } | ||
45 | kunmap(pte); | ||
46 | |||
47 | return page; | ||
48 | } | ||
49 | |||
50 | static inline void pte_free(struct page *page) | ||
51 | { | ||
52 | cache_page(kmap(page)); | ||
53 | kunmap(page); | ||
54 | __free_page(page); | ||
55 | } | ||
56 | |||
57 | static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *page) | ||
58 | { | ||
59 | cache_page(kmap(page)); | ||
60 | kunmap(page); | ||
61 | __free_page(page); | ||
62 | } | ||
63 | |||
64 | |||
65 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) | ||
66 | { | ||
67 | return get_pointer_table(); | ||
68 | } | ||
69 | |||
70 | static inline int pmd_free(pmd_t *pmd) | ||
71 | { | ||
72 | return free_pointer_table(pmd); | ||
73 | } | ||
74 | |||
75 | static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) | ||
76 | { | ||
77 | return free_pointer_table(pmd); | ||
78 | } | ||
79 | |||
80 | |||
81 | static inline void pgd_free(pgd_t *pgd) | ||
82 | { | ||
83 | pmd_free((pmd_t *)pgd); | ||
84 | } | ||
85 | |||
86 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | ||
87 | { | ||
88 | return (pgd_t *)get_pointer_table(); | ||
89 | } | ||
90 | |||
91 | |||
92 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) | ||
93 | { | ||
94 | pmd_set(pmd, pte); | ||
95 | } | ||
96 | |||
97 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) | ||
98 | { | ||
99 | pmd_set(pmd, page_address(page)); | ||
100 | } | ||
101 | |||
102 | static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd) | ||
103 | { | ||
104 | pgd_set(pgd, pmd); | ||
105 | } | ||
106 | |||
107 | #endif /* _MOTOROLA_PGALLOC_H */ | ||