MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-m68k / motorola_pgalloc.h
blobdda9618adc070d2e7718e96a3c7b2c6b9e330fda
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);
16 if (pte) {
17 clear_page(pte);
18 __flush_page_to_ram(pte);
19 flush_tlb_kernel_page(pte);
20 nocache_page(pte);
23 return pte;
26 static inline void pte_free_kernel(pte_t *pte)
28 cache_page(pte);
29 free_page((unsigned long) pte);
32 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
34 struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
35 pte_t *pte;
37 if(!page)
38 return NULL;
40 pte = kmap(page);
41 if (pte) {
42 clear_page(pte);
43 __flush_page_to_ram(pte);
44 flush_tlb_kernel_page(pte);
45 nocache_page(pte);
47 kunmap(pte);
49 return page;
52 static inline void pte_free(struct page *page)
54 cache_page(kmap(page));
55 kunmap(page);
56 __free_page(page);
59 static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *page)
61 cache_page(kmap(page));
62 kunmap(page);
63 __free_page(page);
67 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
69 return get_pointer_table();
72 static inline int pmd_free(pmd_t *pmd)
74 return free_pointer_table(pmd);
77 static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
79 return free_pointer_table(pmd);
83 static inline void pgd_free(pgd_t *pgd)
85 pmd_free((pmd_t *)pgd);
88 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
90 return (pgd_t *)get_pointer_table();
94 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
96 pmd_set(pmd, pte);
99 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page)
101 pmd_set(pmd, page_address(page));
104 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
106 pgd_set(pgd, pmd);
109 #endif /* _MOTOROLA_PGALLOC_H */