Linux 2.6.12-rc6
[cris-mirror.git] / include / asm-m68k / motorola_pgalloc.h
blob5158412cd54dd4f8a8ca827c57b6441897850101
1 #ifndef _MOTOROLA_PGALLOC_H
2 #define _MOTOROLA_PGALLOC_H
4 #include <asm/tlb.h>
5 #include <asm/tlbflush.h>
7 extern pmd_t *get_pointer_table(void);
8 extern int free_pointer_table(pmd_t *);
11 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
13 pte_t *pte;
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);
22 return pte;
25 static inline void pte_free_kernel(pte_t *pte)
27 cache_page(pte);
28 free_page((unsigned long) pte);
31 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
33 struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
34 pte_t *pte;
36 if(!page)
37 return NULL;
39 pte = kmap(page);
40 if (pte) {
41 __flush_page_to_ram(pte);
42 flush_tlb_kernel_page(pte);
43 nocache_page(pte);
45 kunmap(pte);
47 return page;
50 static inline void pte_free(struct page *page)
52 cache_page(kmap(page));
53 kunmap(page);
54 __free_page(page);
57 static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *page)
59 cache_page(kmap(page));
60 kunmap(page);
61 __free_page(page);
65 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
67 return get_pointer_table();
70 static inline int pmd_free(pmd_t *pmd)
72 return free_pointer_table(pmd);
75 static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
77 return free_pointer_table(pmd);
81 static inline void pgd_free(pgd_t *pgd)
83 pmd_free((pmd_t *)pgd);
86 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
88 return (pgd_t *)get_pointer_table();
92 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
94 pmd_set(pmd, pte);
97 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page)
99 pmd_set(pmd, page_address(page));
102 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
104 pgd_set(pgd, pmd);
107 #endif /* _MOTOROLA_PGALLOC_H */