ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-alpha / pgalloc.h
1 #ifndef _ALPHA_PGALLOC_H
2 #define _ALPHA_PGALLOC_H
3
4 #include <linux/config.h>
5 #include <linux/mm.h>
6 #include <linux/mmzone.h>
7
8 /*      
9  * Allocate and free page tables. The xxx_kernel() versions are
10  * used to allocate a kernel page table - this turns on ASN bits
11  * if any.
12  */
13
14 static inline void
15 pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
16 {
17         pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET));
18 }
19
20 static inline void
21 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
22 {
23         pmd_set(pmd, pte);
24 }
25
26 static inline void
27 pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
28 {
29         pgd_set(pgd, pmd);
30 }
31
32 extern pgd_t *pgd_alloc(struct mm_struct *mm);
33
34 static inline void
35 pgd_free(pgd_t *pgd)
36 {
37         free_page((unsigned long)pgd);
38 }
39
40 static inline pmd_t *
41 pmd_alloc_one(struct mm_struct *mm, unsigned long address)
42 {
43         pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
44         if (ret)
45                 clear_page(ret);
46         return ret;
47 }
48
49 static inline void
50 pmd_free(pmd_t *pmd)
51 {
52         free_page((unsigned long)pmd);
53 }
54
55 extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr);
56
57 static inline void
58 pte_free_kernel(pte_t *pte)
59 {
60         free_page((unsigned long)pte);
61 }
62
63 static inline struct page *
64 pte_alloc_one(struct mm_struct *mm, unsigned long addr)
65 {
66         pte_t *pte = pte_alloc_one_kernel(mm, addr);
67         if (pte)
68                 return virt_to_page(pte);
69         return 0;
70 }
71
72 static inline void
73 pte_free(struct page *page)
74 {
75         __free_page(page);
76 }
77
78 #define check_pgt_cache()       do { } while (0)
79
80 #endif /* _ALPHA_PGALLOC_H */