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