ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-generic / pgtable.h
1 #ifndef _ASM_GENERIC_PGTABLE_H
2 #define _ASM_GENERIC_PGTABLE_H
3
4 #ifndef __HAVE_ARCH_PTEP_ESTABLISH
5 /*
6  * Establish a new mapping:
7  *  - flush the old one
8  *  - update the page tables
9  *  - inform the TLB about the new one
10  *
11  * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
12  */
13 #define ptep_establish(__vma, __address, __ptep, __entry)               \
14 do {                                                                    \
15         set_pte(__ptep, __entry);                                       \
16         flush_tlb_page(__vma, __address);                               \
17 } while (0)
18 #endif
19
20 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
21 static inline int ptep_test_and_clear_young(pte_t *ptep)
22 {
23         pte_t pte = *ptep;
24         if (!pte_young(pte))
25                 return 0;
26         set_pte(ptep, pte_mkold(pte));
27         return 1;
28 }
29 #endif
30
31 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
32 #define ptep_clear_flush_young(__vma, __address, __ptep)                \
33 ({                                                                      \
34         int __young = ptep_test_and_clear_young(__ptep);                \
35         if (__young)                                                    \
36                 flush_tlb_page(__vma, __address);                       \
37         __young;                                                        \
38 })
39 #endif
40
41 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
42 static inline int ptep_test_and_clear_dirty(pte_t *ptep)
43 {
44         pte_t pte = *ptep;
45         if (!pte_dirty(pte))
46                 return 0;
47         set_pte(ptep, pte_mkclean(pte));
48         return 1;
49 }
50 #endif
51
52 #ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
53 #define ptep_clear_flush_dirty(__vma, __address, __ptep)                \
54 ({                                                                      \
55         int __dirty = ptep_test_and_clear_dirty(__ptep);                \
56         if (__dirty)                                                    \
57                 flush_tlb_page(__vma, __address);                       \
58         __dirty;                                                        \
59 })
60 #endif
61
62 #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
63 static inline pte_t ptep_get_and_clear(pte_t *ptep)
64 {
65         pte_t pte = *ptep;
66         pte_clear(ptep);
67         return pte;
68 }
69 #endif
70
71 #ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
72 #define ptep_clear_flush(__vma, __address, __ptep)                      \
73 ({                                                                      \
74         pte_t __pte = ptep_get_and_clear(__ptep);                       \
75         flush_tlb_page(__vma, __address);                               \
76         __pte;                                                          \
77 })
78 #endif
79
80 #ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
81 static inline void ptep_set_wrprotect(pte_t *ptep)
82 {
83         pte_t old_pte = *ptep;
84         set_pte(ptep, pte_wrprotect(old_pte));
85 }
86 #endif
87
88 #ifndef __HAVE_ARCH_PTEP_MKDIRTY
89 static inline void ptep_mkdirty(pte_t *ptep)
90 {
91         pte_t old_pte = *ptep;
92         set_pte(ptep, pte_mkdirty(old_pte));
93 }
94 #endif
95
96 #ifndef __HAVE_ARCH_PTE_SAME
97 #define pte_same(A,B)   (pte_val(A) == pte_val(B))
98 #endif
99
100 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
101 #define page_test_and_clear_dirty(page) (0)
102 #endif
103
104 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
105 #define page_test_and_clear_young(page) (0)
106 #endif
107
108 #endif /* _ASM_GENERIC_PGTABLE_H */