1
2
3
4
5#ifndef _CRIS_PGTABLE_H
6#define _CRIS_PGTABLE_H
7
8#include <asm/page.h>
9#include <asm-generic/pgtable-nopmd.h>
10
11#ifndef __ASSEMBLY__
12#include <linux/sched.h>
13#include <asm/mmu.h>
14#endif
15#include <arch/pgtable.h>
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef __ASSEMBLY__
29extern void paging_init(void);
30#endif
31
32
33
34
35
36#define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
37#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
38
39
40
41
42
43#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
44#define set_pgu(pudptr, pudval) (*(pudptr) = pudval)
45
46
47
48
49
50
51#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-2))
52#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
53#define PGDIR_MASK (~(PGDIR_SIZE-1))
54
55
56
57
58
59
60
61#define PTRS_PER_PTE (1UL << (PAGE_SHIFT-2))
62#define PTRS_PER_PGD (1UL << (PAGE_SHIFT-2))
63
64
65
66
67
68
69#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
70#define FIRST_USER_ADDRESS 0UL
71
72
73#ifndef __ASSEMBLY__
74extern unsigned long empty_zero_page;
75#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
76#endif
77
78
79#define BITS_PER_PTR (8*sizeof(unsigned long))
80
81
82#define PTR_MASK (~(sizeof(void*)-1))
83
84
85
86#define SIZEOF_PTR_LOG2 2
87
88
89#define PAGE_PTR(address) \
90((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
91
92
93#define SET_PAGE_DIR(tsk,pgdir)
94
95#define pte_none(x) (!pte_val(x))
96#define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
97#define pte_clear(mm,addr,xp) do { pte_val(*(xp)) = 0; } while (0)
98
99#define pmd_none(x) (!pmd_val(x))
100
101
102
103#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_KERNEL)) != _PAGE_TABLE)
104#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
105#define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0)
106
107#ifndef __ASSEMBLY__
108
109
110
111
112
113
114static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
115static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; }
116static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
117static inline int pte_special(pte_t pte) { return 0; }
118
119static inline pte_t pte_wrprotect(pte_t pte)
120{
121 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
122 return pte;
123}
124
125static inline pte_t pte_mkclean(pte_t pte)
126{
127 pte_val(pte) &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE);
128 return pte;
129}
130
131static inline pte_t pte_mkold(pte_t pte)
132{
133 pte_val(pte) &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ);
134 return pte;
135}
136
137static inline pte_t pte_mkwrite(pte_t pte)
138{
139 pte_val(pte) |= _PAGE_WRITE;
140 if (pte_val(pte) & _PAGE_MODIFIED)
141 pte_val(pte) |= _PAGE_SILENT_WRITE;
142 return pte;
143}
144
145static inline pte_t pte_mkdirty(pte_t pte)
146{
147 pte_val(pte) |= _PAGE_MODIFIED;
148 if (pte_val(pte) & _PAGE_WRITE)
149 pte_val(pte) |= _PAGE_SILENT_WRITE;
150 return pte;
151}
152
153static inline pte_t pte_mkyoung(pte_t pte)
154{
155 pte_val(pte) |= _PAGE_ACCESSED;
156 if (pte_val(pte) & _PAGE_READ)
157 {
158 pte_val(pte) |= _PAGE_SILENT_READ;
159 if ((pte_val(pte) & (_PAGE_WRITE | _PAGE_MODIFIED)) ==
160 (_PAGE_WRITE | _PAGE_MODIFIED))
161 pte_val(pte) |= _PAGE_SILENT_WRITE;
162 }
163 return pte;
164}
165static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
166
167
168
169
170
171
172
173
174
175
176
177
178static inline pte_t __mk_pte(void * page, pgprot_t pgprot)
179{
180 pte_t pte;
181
182 pte_val(pte) = __pa(page) | pgprot_val(pgprot);
183 return pte;
184}
185
186#define mk_pte(page, pgprot) __mk_pte(page_address(page), (pgprot))
187
188#define mk_pte_phys(physpage, pgprot) \
189({ \
190 pte_t __pte; \
191 \
192 pte_val(__pte) = (physpage) + pgprot_val(pgprot); \
193 __pte; \
194})
195
196static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
197{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
198
199#define pgprot_noncached(prot) __pgprot((pgprot_val(prot) | _PAGE_NO_CACHE))
200
201
202
203
204
205
206
207static inline unsigned long __pte_page(pte_t pte)
208{
209
210 return (unsigned long)__va(pte_val(pte) & PAGE_MASK);
211}
212
213#define pte_pagenr(pte) ((__pte_page(pte) - PAGE_OFFSET) >> PAGE_SHIFT)
214
215
216
217#define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT))
218#define pte_page(pte) (mem_map+pte_pagenr(pte))
219
220
221
222
223
224
225static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
226{ pmd_val(*pmdp) = _PAGE_TABLE | (unsigned long) ptep; }
227
228#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
229#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
230
231
232#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
233
234
235static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long address)
236{
237 return mm->pgd + pgd_index(address);
238}
239
240
241#define pgd_offset_k(address) pgd_offset(&init_mm, address)
242
243
244#define __pte_offset(address) \
245 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
246#define pte_offset_kernel(dir, address) \
247 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
248#define pte_offset_map(dir, address) \
249 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
250
251#define pte_unmap(pte) do { } while (0)
252#define pte_pfn(x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)
253#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
254
255#define pte_ERROR(e) \
256 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), pte_val(e))
257#define pgd_ERROR(e) \
258 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), pgd_val(e))
259
260
261extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
262
263
264
265
266
267
268
269static inline void update_mmu_cache(struct vm_area_struct * vma,
270 unsigned long address, pte_t *ptep)
271{
272}
273
274
275
276
277#define __swp_type(x) (((x).val >> 5) & 0x7f)
278#define __swp_offset(x) ((x).val >> 12)
279#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 5) | ((offset) << 12) })
280#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
281#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
282
283#define kern_addr_valid(addr) (1)
284
285#include <asm-generic/pgtable.h>
286
287
288
289
290#define pgtable_cache_init() do { } while (0)
291
292typedef pte_t *pte_addr_t;
293
294#endif
295#endif
296