avr32: Store virtual addresses in the PGD
[linux-2.6] / include / asm-avr32 / pgalloc.h
1 /*
2  * Copyright (C) 2004-2006 Atmel Corporation
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8 #ifndef __ASM_AVR32_PGALLOC_H
9 #define __ASM_AVR32_PGALLOC_H
10
11 #include <linux/mm.h>
12 #include <linux/sched.h>
13 #include <linux/slab.h>
14
15 static inline void pmd_populate_kernel(struct mm_struct *mm,
16                                        pmd_t *pmd, pte_t *pte)
17 {
18         set_pmd(pmd, __pmd((unsigned long)pte));
19 }
20
21 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
22                                     pgtable_t pte)
23 {
24         set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
25 }
26 #define pmd_pgtable(pmd) pmd_page(pmd)
27
28 /*
29  * Allocate and free page tables
30  */
31 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
32 {
33         return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
34 }
35
36 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
37 {
38         kfree(pgd);
39 }
40
41 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42                                           unsigned long address)
43 {
44         pte_t *pte;
45
46         pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
47
48         return pte;
49 }
50
51 static inline struct page *pte_alloc_one(struct mm_struct *mm,
52                                          unsigned long address)
53 {
54         struct page *pte;
55
56         pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
57         if (!pte)
58                 return NULL;
59         pgtable_page_ctor(pte);
60         return pte;
61 }
62
63 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
64 {
65         free_page((unsigned long)pte);
66 }
67
68 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
69 {
70         pgtable_page_dtor(pte);
71         __free_page(pte);
72 }
73
74 #define __pte_free_tlb(tlb,pte)                         \
75 do {                                                    \
76         pgtable_page_dtor(pte);                         \
77         tlb_remove_page((tlb), pte);                    \
78 } while (0)
79
80 #define check_pgt_cache() do { } while(0)
81
82 #endif /* __ASM_AVR32_PGALLOC_H */