vserver 1.9.5.x5
[linux-2.6.git] / include / asm-sh / pgalloc.h
1 #ifndef __ASM_SH_PGALLOC_H
2 #define __ASM_SH_PGALLOC_H
3
4 #include <asm/processor.h>
5 #include <linux/threads.h>
6 #include <linux/slab.h>
7 #include <linux/mm.h>
8
9 #define pgd_quicklist ((unsigned long *)0)
10 #define pmd_quicklist ((unsigned long *)0)
11 #define pte_quicklist ((unsigned long *)0)
12 #define pgtable_cache_size 0L
13
14 #define pmd_populate_kernel(mm, pmd, pte) \
15                 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
16
17 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
18                                 struct page *pte)
19 {
20         set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
21 }
22
23 /*
24  * Allocate and free page tables.
25  */
26 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
27 {
28         unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
29         pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
30
31         if (pgd)
32                 memset(pgd, 0, pgd_size);
33
34         return pgd;
35 }
36
37 static inline void pgd_free(pgd_t *pgd)
38 {
39         kfree(pgd);
40 }
41
42 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
43                                           unsigned long address)
44 {
45         pte_t *pte;
46
47         pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
48
49         return pte;
50 }
51
52 static inline struct page *pte_alloc_one(struct mm_struct *mm,
53                                          unsigned long address)
54 {
55         struct page *pte;
56
57         pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
58
59         return pte;
60 }
61
62 static inline void pte_free_kernel(pte_t *pte)
63 {
64         free_page((unsigned long)pte);
65 }
66
67 static inline void pte_free(struct page *pte)
68 {
69         __free_page(pte);
70 }
71
72 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
73
74 /*
75  * allocating and freeing a pmd is trivial: the 1-entry pmd is
76  * inside the pgd, so has no extra memory associated with it.
77  */
78
79 #define pmd_alloc_one(mm, addr)         ({ BUG(); ((pmd_t *)2); })
80 #define pmd_free(x)                     do { } while (0)
81 #define __pmd_free_tlb(tlb,x)           do { } while (0)
82 #define pgd_populate(mm, pmd, pte)      BUG()
83 #define check_pgt_cache()               do { } while (0)
84
85 #ifdef CONFIG_CPU_SH4
86 #define PG_mapped                       PG_arch_1
87 #endif
88
89 #endif /* __ASM_SH_PGALLOC_H */