This source file includes following definitions.
- mk_pte
- pte_modify
- pmd_set
- pgd_set
- pte_page
- pmd_page
- pgd_page
- pte_none
- pte_present
- pte_inuse
- pte_clear
- pmd_none
- pmd_bad
- pmd_present
- pmd_inuse
- pmd_clear
- pgd_none
- pgd_bad
- pgd_present
- pgd_inuse
- 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
- SET_PAGE_DIR
- pgd_offset
- pmd_offset
- pte_offset
- pte_free_kernel
- pte_alloc_kernel
- pmd_free_kernel
- pmd_alloc_kernel
- pte_free
- pte_alloc
- pmd_free
- pmd_alloc
- pgd_free
- pgd_alloc
1 #ifndef _ALPHA_PGTABLE_H
2 #define _ALPHA_PGTABLE_H
3
4
5
6
7
8
9
10
11
12
13 #define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3))
14 #define PMD_SIZE (1UL << PMD_SHIFT)
15 #define PMD_MASK (~(PMD_SIZE-1))
16
17
18 #define PGDIR_SHIFT (PAGE_SHIFT + 2*(PAGE_SHIFT-3))
19 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
20 #define PGDIR_MASK (~(PGDIR_SIZE-1))
21
22
23
24
25
26 #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3))
27 #define PTRS_PER_PMD (1UL << (PAGE_SHIFT-3))
28 #define PTRS_PER_PGD (1UL << (PAGE_SHIFT-3))
29
30
31 #define PTRS_PER_PAGE (1UL << (PAGE_SHIFT-3))
32
33 #define VMALLOC_START 0xFFFFFE0000000000
34 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
35
36
37
38
39 #define _PAGE_VALID 0x0001
40 #define _PAGE_FOR 0x0002
41 #define _PAGE_FOW 0x0004
42 #define _PAGE_FOE 0x0008
43 #define _PAGE_ASM 0x0010
44 #define _PAGE_KRE 0x0100
45 #define _PAGE_URE 0x0200
46 #define _PAGE_KWE 0x1000
47 #define _PAGE_UWE 0x2000
48
49
50 #define _PAGE_COW 0x10000
51 #define _PAGE_DIRTY 0x20000
52 #define _PAGE_ACCESSED 0x40000
53
54
55
56
57
58
59
60
61
62
63
64
65 #define __DIRTY_BITS (_PAGE_DIRTY | _PAGE_KWE | _PAGE_UWE)
66 #define __ACCESS_BITS (_PAGE_ACCESSED | _PAGE_KRE | _PAGE_URE)
67
68 #define _PFN_MASK 0xFFFFFFFF00000000
69
70 #define _PAGE_TABLE (_PAGE_VALID | __DIRTY_BITS | __ACCESS_BITS)
71 #define _PAGE_CHG_MASK (_PFN_MASK | __DIRTY_BITS | __ACCESS_BITS)
72
73
74
75
76
77 #define PAGE_NONE __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
78 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
79 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_COW)
80 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
81 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
82
83 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
84
85 #define __P000 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
86 #define __P001 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOW | _PAGE_FOE)
87 #define __P010 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOE)
88 #define __P011 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOE)
89 #define __P100 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOW)
90 #define __P101 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOW)
91 #define __P110 _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR)
92 #define __P111 _PAGE_NORMAL(_PAGE_COW)
93
94 #define __S000 _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
95 #define __S001 _PAGE_NORMAL(_PAGE_FOW | _PAGE_FOE)
96 #define __S010 _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOE)
97 #define __S011 _PAGE_NORMAL(_PAGE_FOE)
98 #define __S100 _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOW)
99 #define __S101 _PAGE_NORMAL(_PAGE_FOW)
100 #define __S110 _PAGE_NORMAL(_PAGE_FOR)
101 #define __S111 _PAGE_NORMAL(0)
102
103
104
105
106
107
108
109
110 extern pte_t __bad_page(void);
111 extern pmd_t * __bad_pagetable(void);
112
113 extern unsigned long __zero_page(void);
114
115 #define BAD_PAGETABLE __bad_pagetable()
116 #define BAD_PAGE __bad_page()
117 #define ZERO_PAGE __zero_page()
118
119
120 #define BITS_PER_PTR (8*sizeof(unsigned long))
121
122
123 #define PTR_MASK (~(sizeof(void*)-1))
124
125
126 #define SIZEOF_PTR_LOG2 3
127
128
129 #define PAGE_PTR(address) \
130 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
131
132 extern unsigned long high_memory;
133
134
135
136
137
138 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
139 { pte_t pte; pte_val(pte) = ((page-PAGE_OFFSET) << (32-PAGE_SHIFT)) | pgprot_val(pgprot); return pte; }
140
141 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
142 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
143
144 extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
145 { pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
146
147 extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
148 { pgd_val(*pgdp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
149
150 extern inline unsigned long pte_page(pte_t pte)
151 { return PAGE_OFFSET + ((pte_val(pte) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
152
153 extern inline unsigned long pmd_page(pmd_t pmd)
154 { return PAGE_OFFSET + ((pmd_val(pmd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
155
156 extern inline unsigned long pgd_page(pgd_t pgd)
157 { return PAGE_OFFSET + ((pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
158
159 extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
160 extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; }
161 extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] > 1; }
162 extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; }
163
164 extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); }
165 extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~_PFN_MASK) != _PAGE_TABLE || pmd_page(pmd) > high_memory; }
166 extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; }
167 extern inline int pmd_inuse(pmd_t *pmdp) { return mem_map[MAP_NR(pmdp)] > 1; }
168 extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; }
169
170 extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); }
171 extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE || pgd_page(pgd) > high_memory; }
172 extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; }
173 extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)] > 1; }
174 extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; }
175
176
177
178
179
180 extern inline int pte_read(pte_t pte) { return !(pte_val(pte) & _PAGE_FOR); }
181 extern inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_FOW); }
182 extern inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_FOE); }
183 extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
184 extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
185 extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; }
186
187 extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOW; return pte; }
188 extern inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOR; return pte; }
189 extern inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOE; return pte; }
190 extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(__DIRTY_BITS); return pte; }
191 extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~(__ACCESS_BITS); return pte; }
192 extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; }
193 extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= _PAGE_FOW; return pte; }
194 extern inline pte_t pte_mkread(pte_t pte) { pte_val(pte) &= _PAGE_FOR; return pte; }
195 extern inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) &= _PAGE_FOE; return pte; }
196 extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= __DIRTY_BITS; return pte; }
197 extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; return pte; }
198 extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte; }
199
200
201 extern inline void SET_PAGE_DIR(struct task_struct * tsk, pgd_t * pgdir)
202 {
203 tsk->tss.ptbr = ((unsigned long) pgdir - PAGE_OFFSET) >> PAGE_SHIFT;
204 if (tsk == current)
205 invalidate();
206 }
207
208 #define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
209
210
211 extern inline pgd_t * pgd_offset(struct task_struct * tsk, unsigned long address)
212 {
213 return (pgd_t *) ((tsk->tss.ptbr << PAGE_SHIFT) + PAGE_OFFSET) +
214 ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1));
215 }
216
217
218 extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
219 {
220 return (pmd_t *) pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1));
221 }
222
223
224 extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address)
225 {
226 return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
227 }
228
229
230
231
232
233
234 extern inline void pte_free_kernel(pte_t * pte)
235 {
236 mem_map[MAP_NR(pte)] = 1;
237 free_page((unsigned long) pte);
238 }
239
240 extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address)
241 {
242 address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
243 if (pmd_none(*pmd)) {
244 pte_t *page = (pte_t *) get_free_page(GFP_KERNEL);
245 if (pmd_none(*pmd)) {
246 if (page) {
247 pmd_set(pmd, page);
248 mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
249 return page + address;
250 }
251 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
252 return NULL;
253 }
254 free_page((unsigned long) page);
255 }
256 if (pmd_bad(*pmd)) {
257 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
258 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
259 return NULL;
260 }
261 return (pte_t *) pmd_page(*pmd) + address;
262 }
263
264 extern inline void pmd_free_kernel(pmd_t * pmd)
265 {
266 mem_map[MAP_NR(pmd)] = 1;
267 free_page((unsigned long) pmd);
268 }
269
270 extern inline pmd_t * pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
271 {
272 address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
273 if (pgd_none(*pgd)) {
274 pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL);
275 if (pgd_none(*pgd)) {
276 if (page) {
277 pgd_set(pgd, page);
278 mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
279 return page + address;
280 }
281 pgd_set(pgd, BAD_PAGETABLE);
282 return NULL;
283 }
284 free_page((unsigned long) page);
285 }
286 if (pgd_bad(*pgd)) {
287 printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd));
288 pgd_set(pgd, BAD_PAGETABLE);
289 return NULL;
290 }
291 return (pmd_t *) pgd_page(*pgd) + address;
292 }
293
294 extern inline void pte_free(pte_t * pte)
295 {
296 free_page((unsigned long) pte);
297 }
298
299 extern inline pte_t * pte_alloc(pmd_t *pmd, unsigned long address)
300 {
301 address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
302 if (pmd_none(*pmd)) {
303 pte_t *page = (pte_t *) get_free_page(GFP_KERNEL);
304 if (pmd_none(*pmd)) {
305 if (page) {
306 pmd_set(pmd, page);
307 return page + address;
308 }
309 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
310 return NULL;
311 }
312 free_page((unsigned long) page);
313 }
314 if (pmd_bad(*pmd)) {
315 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
316 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
317 return NULL;
318 }
319 return (pte_t *) pmd_page(*pmd) + address;
320 }
321
322 extern inline void pmd_free(pmd_t * pmd)
323 {
324 free_page((unsigned long) pmd);
325 }
326
327 extern inline pmd_t * pmd_alloc(pgd_t *pgd, unsigned long address)
328 {
329 address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
330 if (pgd_none(*pgd)) {
331 pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL);
332 if (pgd_none(*pgd)) {
333 if (page) {
334 pgd_set(pgd, page);
335 return page + address;
336 }
337 pgd_set(pgd, BAD_PAGETABLE);
338 return NULL;
339 }
340 free_page((unsigned long) page);
341 }
342 if (pgd_bad(*pgd)) {
343 printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd));
344 pgd_set(pgd, BAD_PAGETABLE);
345 return NULL;
346 }
347 return (pmd_t *) pgd_page(*pgd) + address;
348 }
349
350 extern inline void pgd_free(pgd_t * pgd)
351 {
352 free_page((unsigned long) pgd);
353 }
354
355 extern inline pgd_t * pgd_alloc(void)
356 {
357 return (pgd_t *) get_free_page(GFP_KERNEL);
358 }
359
360 extern pgd_t swapper_pg_dir[1024];
361
362 #endif