This source file includes following definitions.
- pte_none
- pte_present
- pte_clear
- pgd_none
- pgd_bad
- pgd_present
- pgd_clear
- pte_read
- pte_write
- pte_exec
- pte_dirty
- pte_young
- pte_cow
- pte_wrprotect
- pte_rdprotect
- pte_exprotect
- pte_mkclean
- pte_mkold
- pte_uncow
- pte_mkwrite
- pte_mkread
- pte_mkexec
- pte_mkdirty
- pte_mkyoung
- pte_mkcow
- mk_pte
- pte_modify
- pte_page
- pgd_page
- pgd_set
1 #ifndef __ASM_MIPS_PAGE_H
2 #define __ASM_MIPS_PAGE_H
3
4 #define CONFIG_STRICT_MM_TYPECHECKS
5
6 #ifndef __ASSEMBLY__
7
8 #include <linux/linkage.h>
9
10 #define invalidate() tlbflush();
11 extern asmlinkage void tlbflush(void);
12
13 typedef unsigned short mem_map_t;
14
15 #ifdef CONFIG_STRICT_MM_TYPECHECKS
16
17
18
19 typedef struct { unsigned long pte; } pte_t;
20 typedef struct { unsigned long pgd; } pgd_t;
21 typedef struct { unsigned long pgprot; } pgprot_t;
22
23 #define pte_val(x) ((x).pte)
24 #define pgd_val(x) ((x).pgd)
25 #define pgprot_val(x) ((x).pgprot)
26
27 #define __pte(x) ((pte_t) { (x) } )
28 #define __pgd(x) ((pgd_t) { (x) } )
29 #define __pgprot(x) ((pgprot_t) { (x) } )
30
31 #else
32
33
34
35 typedef unsigned long pte_t;
36 typedef unsigned long pgd_t;
37 typedef unsigned long pgprot_t;
38
39 #define pte_val(x) (x)
40 #define pgd_val(x) (x)
41 #define pgprot_val(x) (x)
42
43 #define __pte(x) (x)
44 #define __pgd(x) (x)
45 #define __pgprot(x) (x)
46
47 #endif
48 #endif
49
50
51
52
53
54
55
56
57 #define _PAGE_PRESENT (1<<0)
58 #define _PAGE_COW (1<<1)
59 #define _PAGE_DIRTY (1<<2)
60 #define _PAGE_USER (1<<3)
61 #define _PAGE_UNUSED1 (1<<4)
62 #define _PAGE_UNUSED2 (1<<5)
63 #define _PAGE_GLOBAL (1<<6)
64 #define _PAGE_ACCESSED (1<<7)
65 #define _PAGE_RW (1<<8)
66 #define _CACHE_CACHABLE_NO_WA (0<<9)
67 #define _CACHE_CACHABLE_WA (1<<9)
68 #define _CACHE_UNCACHED (2<<9)
69 #define _CACHE_CACHABLE_NONCOHERENT (3<<9)
70 #define _CACHE_CACHABLE_CE (4<<9)
71 #define _CACHE_CACHABLE_COW (5<<9)
72 #define _CACHE_CACHABLE_CUW (6<<9)
73 #define _CACHE_MASK (7<<9)
74
75 #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY | \
76 _CACHE_CACHABLE_NO_WA)
77
78 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _CACHE_MASK)
79
80 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
81 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _CACHE_CACHABLE_NO_WA)
82 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_COW | _CACHE_CACHABLE_NO_WA)
83 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _CACHE_CACHABLE_NO_WA)
84 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
85
86
87
88
89
90
91 #define __P000 PAGE_NONE
92 #define __P001 PAGE_READONLY
93 #define __P010 PAGE_COPY
94 #define __P011 PAGE_COPY
95 #define __P100 PAGE_READONLY
96 #define __P101 PAGE_READONLY
97 #define __P110 PAGE_COPY
98 #define __P111 PAGE_COPY
99
100 #define __S000 PAGE_NONE
101 #define __S001 PAGE_READONLY
102 #define __S010 PAGE_SHARED
103 #define __S011 PAGE_SHARED
104 #define __S100 PAGE_READONLY
105 #define __S101 PAGE_READONLY
106 #define __S110 PAGE_SHARED
107 #define __S111 PAGE_SHARED
108
109
110 #define PAGE_SHIFT 12
111 #define PGDIR_SHIFT 22
112 #define PAGE_SIZE (1UL << PAGE_SHIFT)
113 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
114
115 #ifdef __KERNEL__
116
117 #define PAGE_OFFSET KERNELBASE
118 #define MAP_NR(addr) (((addr) - PAGE_OFFSET) >> PAGE_SHIFT)
119 #define MAP_PAGE_RESERVED (1<<15)
120
121 #if !defined (__ASSEMBLY__)
122
123
124 extern unsigned long pg0[1024];
125
126
127
128
129
130
131
132
133 extern pte_t __bad_page(void);
134 extern pte_t * __bad_pagetable(void);
135
136 extern unsigned long __zero_page(void);
137
138 #define BAD_PAGETABLE __bad_pagetable()
139 #define BAD_PAGE __bad_page()
140 #define ZERO_PAGE __zero_page()
141
142
143 #define BITS_PER_PTR (8*sizeof(unsigned long))
144
145
146 #define PAGE_MASK (~(PAGE_SIZE-1))
147
148
149 #define PGDIR_MASK (~(PGDIR_SIZE-1))
150
151
152 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
153
154
155 #define PTR_MASK (~(sizeof(void*)-1))
156
157
158
159 #define SIZEOF_PTR_LOG2 2
160
161
162 #define PAGE_DIR_OFFSET(tsk,address) \
163 ((((unsigned long)(address)) >> PGDIR_SHIFT) + (pgd_t *) (tsk)->tss.pg_dir)
164
165
166 #define PAGE_PTR(address) \
167 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
168
169
170 #define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*))
171
172
173 #define SET_PAGE_DIR(tsk,pgdir) \
174 do { \
175 (tsk)->tss.pg_dir = (unsigned long) (pgdir); \
176 if ((tsk) == current) \
177 invalidate(); \
178 } while (0)
179
180 extern unsigned long high_memory;
181
182 extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
183 extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; }
184 extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; }
185
186 extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); }
187 extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~PAGE_MASK) != _PAGE_TABLE || pgd_val(pgd) > high_memory; }
188 extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_PRESENT; }
189 extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; }
190
191
192
193
194
195 extern inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; }
196 extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
197 extern inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_USER; }
198 extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
199 extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
200 extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; }
201
202 extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_RW; return pte; }
203 extern inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_USER; return pte; }
204 extern inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_USER; return pte; }
205 extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
206 extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
207 extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; }
208 extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) |= _PAGE_RW; return pte; }
209 extern inline pte_t pte_mkread(pte_t pte) { pte_val(pte) |= _PAGE_USER; return pte; }
210 extern inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) |= _PAGE_USER; return pte; }
211 extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= _PAGE_DIRTY; return pte; }
212 extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
213 extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte; }
214
215
216
217
218
219 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
220 { pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; }
221
222 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
223 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
224
225 extern inline unsigned long pte_page(pte_t pte) { return pte_val(pte) & PAGE_MASK; }
226 extern inline unsigned long pgd_page(pgd_t pgd) { return pgd_val(pgd) & PAGE_MASK; }
227
228 extern inline void pgd_set(pgd_t * pgdp, pte_t * ptep)
229 { pgd_val(*pgdp) = _PAGE_TABLE | (unsigned long) ptep; }
230
231 #endif
232 #endif
233
234 #endif