microblaze: Remove VMALLOC_VMADDR
[safe/jmp/linux-2.6] / arch / microblaze / include / asm / pgtable.h
1 /*
2  * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3  * Copyright (C) 2008-2009 PetaLogix
4  * Copyright (C) 2006 Atmark Techno, Inc.
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License. See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10
11 #ifndef _ASM_MICROBLAZE_PGTABLE_H
12 #define _ASM_MICROBLAZE_PGTABLE_H
13
14 #include <asm/setup.h>
15
16 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)         \
17                 remap_pfn_range(vma, vaddr, pfn, size, prot)
18
19 #ifndef CONFIG_MMU
20
21 #define pgd_present(pgd)        (1) /* pages are always present on non MMU */
22 #define pgd_none(pgd)           (0)
23 #define pgd_bad(pgd)            (0)
24 #define pgd_clear(pgdp)
25 #define kern_addr_valid(addr)   (1)
26 #define pmd_offset(a, b)        ((void *) 0)
27
28 #define PAGE_NONE               __pgprot(0) /* these mean nothing to non MMU */
29 #define PAGE_SHARED             __pgprot(0) /* these mean nothing to non MMU */
30 #define PAGE_COPY               __pgprot(0) /* these mean nothing to non MMU */
31 #define PAGE_READONLY           __pgprot(0) /* these mean nothing to non MMU */
32 #define PAGE_KERNEL             __pgprot(0) /* these mean nothing to non MMU */
33
34 #define pgprot_noncached(x)     (x)
35
36 #define __swp_type(x)           (0)
37 #define __swp_offset(x)         (0)
38 #define __swp_entry(typ, off)   ((swp_entry_t) { ((typ) | ((off) << 7)) })
39 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
40 #define __swp_entry_to_pte(x)   ((pte_t) { (x).val })
41
42 #ifndef __ASSEMBLY__
43 static inline int pte_file(pte_t pte) { return 0; }
44 #endif /* __ASSEMBLY__ */
45
46 #define ZERO_PAGE(vaddr)        ({ BUG(); NULL; })
47
48 #define swapper_pg_dir ((pgd_t *) NULL)
49
50 #define pgtable_cache_init()    do {} while (0)
51
52 #define arch_enter_lazy_cpu_mode()      do {} while (0)
53
54 #else /* CONFIG_MMU */
55
56 #include <asm-generic/4level-fixup.h>
57
58 #ifdef __KERNEL__
59 #ifndef __ASSEMBLY__
60
61 #include <linux/sched.h>
62 #include <linux/threads.h>
63 #include <asm/processor.h>              /* For TASK_SIZE */
64 #include <asm/mmu.h>
65 #include <asm/page.h>
66
67 #define FIRST_USER_ADDRESS      0
68
69 extern unsigned long va_to_phys(unsigned long address);
70 extern pte_t *va_to_pte(unsigned long address);
71 extern unsigned long ioremap_bot, ioremap_base;
72
73 /*
74  * The following only work if pte_present() is true.
75  * Undefined behaviour if not..
76  */
77
78 static inline int pte_special(pte_t pte)        { return 0; }
79
80 static inline pte_t pte_mkspecial(pte_t pte)    { return pte; }
81
82 /* Start and end of the vmalloc area. */
83 /* Make sure to map the vmalloc area above the pinned kernel memory area
84    of 32Mb.  */
85 #define VMALLOC_START   (CONFIG_KERNEL_START + \
86                                 max(32 * 1024 * 1024UL, memory_size))
87 #define VMALLOC_END     ioremap_bot
88
89 #endif /* __ASSEMBLY__ */
90
91 /*
92  * Macro to mark a page protection value as "uncacheable".
93  */
94
95 #define _PAGE_CACHE_CTL (_PAGE_GUARDED | _PAGE_NO_CACHE | \
96                                                         _PAGE_WRITETHRU)
97
98 #define pgprot_noncached(prot) \
99                         (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \
100                                         _PAGE_NO_CACHE | _PAGE_GUARDED))
101
102 #define pgprot_noncached_wc(prot) \
103                          (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \
104                                                         _PAGE_NO_CACHE))
105
106 /*
107  * The MicroBlaze MMU is identical to the PPC-40x MMU, and uses a hash
108  * table containing PTEs, together with a set of 16 segment registers, to
109  * define the virtual to physical address mapping.
110  *
111  * We use the hash table as an extended TLB, i.e. a cache of currently
112  * active mappings.  We maintain a two-level page table tree, much
113  * like that used by the i386, for the sake of the Linux memory
114  * management code.  Low-level assembler code in hashtable.S
115  * (procedure hash_page) is responsible for extracting ptes from the
116  * tree and putting them into the hash table when necessary, and
117  * updating the accessed and modified bits in the page table tree.
118  */
119
120 /*
121  * The MicroBlaze processor has a TLB architecture identical to PPC-40x. The
122  * instruction and data sides share a unified, 64-entry, semi-associative
123  * TLB which is maintained totally under software control. In addition, the
124  * instruction side has a hardware-managed, 2,4, or 8-entry, fully-associative
125  * TLB which serves as a first level to the shared TLB. These two TLBs are
126  * known as the UTLB and ITLB, respectively (see "mmu.h" for definitions).
127  */
128
129 /*
130  * The normal case is that PTEs are 32-bits and we have a 1-page
131  * 1024-entry pgdir pointing to 1-page 1024-entry PTE pages.  -- paulus
132  *
133  */
134
135 /* PMD_SHIFT determines the size of the area mapped by the PTE pages */
136 #define PMD_SHIFT       (PAGE_SHIFT + PTE_SHIFT)
137 #define PMD_SIZE        (1UL << PMD_SHIFT)
138 #define PMD_MASK        (~(PMD_SIZE-1))
139
140 /* PGDIR_SHIFT determines what a top-level page table entry can map */
141 #define PGDIR_SHIFT     PMD_SHIFT
142 #define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
143 #define PGDIR_MASK      (~(PGDIR_SIZE-1))
144
145 /*
146  * entries per page directory level: our page-table tree is two-level, so
147  * we don't really have any PMD directory.
148  */
149 #define PTRS_PER_PTE    (1 << PTE_SHIFT)
150 #define PTRS_PER_PMD    1
151 #define PTRS_PER_PGD    (1 << (32 - PGDIR_SHIFT))
152
153 #define USER_PTRS_PER_PGD       (TASK_SIZE / PGDIR_SIZE)
154 #define FIRST_USER_PGD_NR       0
155
156 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
157 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
158
159 #define pte_ERROR(e) \
160         printk(KERN_ERR "%s:%d: bad pte "PTE_FMT".\n", \
161                 __FILE__, __LINE__, pte_val(e))
162 #define pmd_ERROR(e) \
163         printk(KERN_ERR "%s:%d: bad pmd %08lx.\n", \
164                 __FILE__, __LINE__, pmd_val(e))
165 #define pgd_ERROR(e) \
166         printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \
167                 __FILE__, __LINE__, pgd_val(e))
168
169 /*
170  * Bits in a linux-style PTE.  These match the bits in the
171  * (hardware-defined) PTE as closely as possible.
172  */
173
174 /* There are several potential gotchas here.  The hardware TLBLO
175  * field looks like this:
176  *
177  * 0  1  2  3  4  ... 18 19 20 21 22 23 24 25 26 27 28 29 30 31
178  * RPN.....................  0  0 EX WR ZSEL.......  W  I  M  G
179  *
180  * Where possible we make the Linux PTE bits match up with this
181  *
182  * - bits 20 and 21 must be cleared, because we use 4k pages (4xx can
183  * support down to 1k pages), this is done in the TLBMiss exception
184  * handler.
185  * - We use only zones 0 (for kernel pages) and 1 (for user pages)
186  * of the 16 available.  Bit 24-26 of the TLB are cleared in the TLB
187  * miss handler.  Bit 27 is PAGE_USER, thus selecting the correct
188  * zone.
189  * - PRESENT *must* be in the bottom two bits because swap cache
190  * entries use the top 30 bits.  Because 4xx doesn't support SMP
191  * anyway, M is irrelevant so we borrow it for PAGE_PRESENT.  Bit 30
192  * is cleared in the TLB miss handler before the TLB entry is loaded.
193  * - All other bits of the PTE are loaded into TLBLO without
194  *  * modification, leaving us only the bits 20, 21, 24, 25, 26, 30 for
195  * software PTE bits.  We actually use use bits 21, 24, 25, and
196  * 30 respectively for the software bits: ACCESSED, DIRTY, RW, and
197  * PRESENT.
198  */
199
200 /* Definitions for MicroBlaze. */
201 #define _PAGE_GUARDED   0x001   /* G: page is guarded from prefetch */
202 #define _PAGE_FILE      0x001   /* when !present: nonlinear file mapping */
203 #define _PAGE_PRESENT   0x002   /* software: PTE contains a translation */
204 #define _PAGE_NO_CACHE  0x004   /* I: caching is inhibited */
205 #define _PAGE_WRITETHRU 0x008   /* W: caching is write-through */
206 #define _PAGE_USER      0x010   /* matches one of the zone permission bits */
207 #define _PAGE_RW        0x040   /* software: Writes permitted */
208 #define _PAGE_DIRTY     0x080   /* software: dirty page */
209 #define _PAGE_HWWRITE   0x100   /* hardware: Dirty & RW, set in exception */
210 #define _PAGE_HWEXEC    0x200   /* hardware: EX permission */
211 #define _PAGE_ACCESSED  0x400   /* software: R: page referenced */
212 #define _PMD_PRESENT    PAGE_MASK
213
214 /*
215  * Some bits are unused...
216  */
217 #ifndef _PAGE_HASHPTE
218 #define _PAGE_HASHPTE   0
219 #endif
220 #ifndef _PTE_NONE_MASK
221 #define _PTE_NONE_MASK  0
222 #endif
223 #ifndef _PAGE_SHARED
224 #define _PAGE_SHARED    0
225 #endif
226 #ifndef _PAGE_HWWRITE
227 #define _PAGE_HWWRITE   0
228 #endif
229 #ifndef _PAGE_HWEXEC
230 #define _PAGE_HWEXEC    0
231 #endif
232 #ifndef _PAGE_EXEC
233 #define _PAGE_EXEC      0
234 #endif
235
236 #define _PAGE_CHG_MASK  (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
237
238 /*
239  * Note: the _PAGE_COHERENT bit automatically gets set in the hardware
240  * PTE if CONFIG_SMP is defined (hash_page does this); there is no need
241  * to have it in the Linux PTE, and in fact the bit could be reused for
242  * another purpose.  -- paulus.
243  */
244 #define _PAGE_BASE      (_PAGE_PRESENT | _PAGE_ACCESSED)
245 #define _PAGE_WRENABLE  (_PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE)
246
247 #define _PAGE_KERNEL \
248         (_PAGE_BASE | _PAGE_WRENABLE | _PAGE_SHARED | _PAGE_HWEXEC)
249
250 #define _PAGE_IO        (_PAGE_KERNEL | _PAGE_NO_CACHE | _PAGE_GUARDED)
251
252 #define PAGE_NONE       __pgprot(_PAGE_BASE)
253 #define PAGE_READONLY   __pgprot(_PAGE_BASE | _PAGE_USER)
254 #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
255 #define PAGE_SHARED     __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
256 #define PAGE_SHARED_X \
257                 __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
258 #define PAGE_COPY       __pgprot(_PAGE_BASE | _PAGE_USER)
259 #define PAGE_COPY_X     __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
260
261 #define PAGE_KERNEL     __pgprot(_PAGE_KERNEL)
262 #define PAGE_KERNEL_RO  __pgprot(_PAGE_BASE | _PAGE_SHARED)
263 #define PAGE_KERNEL_CI  __pgprot(_PAGE_IO)
264
265 /*
266  * We consider execute permission the same as read.
267  * Also, write permissions imply read permissions.
268  */
269 #define __P000  PAGE_NONE
270 #define __P001  PAGE_READONLY_X
271 #define __P010  PAGE_COPY
272 #define __P011  PAGE_COPY_X
273 #define __P100  PAGE_READONLY
274 #define __P101  PAGE_READONLY_X
275 #define __P110  PAGE_COPY
276 #define __P111  PAGE_COPY_X
277
278 #define __S000  PAGE_NONE
279 #define __S001  PAGE_READONLY_X
280 #define __S010  PAGE_SHARED
281 #define __S011  PAGE_SHARED_X
282 #define __S100  PAGE_READONLY
283 #define __S101  PAGE_READONLY_X
284 #define __S110  PAGE_SHARED
285 #define __S111  PAGE_SHARED_X
286
287 #ifndef __ASSEMBLY__
288 /*
289  * ZERO_PAGE is a global shared page that is always zero: used
290  * for zero-mapped memory areas etc..
291  */
292 extern unsigned long empty_zero_page[1024];
293 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
294
295 #endif /* __ASSEMBLY__ */
296
297 #define pte_none(pte)           ((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
298 #define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
299 #define pte_clear(mm, addr, ptep) \
300         do { set_pte_at((mm), (addr), (ptep), __pte(0)); } while (0)
301
302 #define pmd_none(pmd)           (!pmd_val(pmd))
303 #define pmd_bad(pmd)            ((pmd_val(pmd) & _PMD_PRESENT) == 0)
304 #define pmd_present(pmd)        ((pmd_val(pmd) & _PMD_PRESENT) != 0)
305 #define pmd_clear(pmdp)         do { pmd_val(*(pmdp)) = 0; } while (0)
306
307 #define pte_page(x)             (mem_map + (unsigned long) \
308                                 ((pte_val(x) - memory_start) >> PAGE_SHIFT))
309 #define PFN_SHIFT_OFFSET        (PAGE_SHIFT)
310
311 #define pte_pfn(x)              (pte_val(x) >> PFN_SHIFT_OFFSET)
312
313 #define pfn_pte(pfn, prot) \
314         __pte(((pte_basic_t)(pfn) << PFN_SHIFT_OFFSET) | pgprot_val(prot))
315
316 #ifndef __ASSEMBLY__
317 /*
318  * The "pgd_xxx()" functions here are trivial for a folded two-level
319  * setup: the pgd is never bad, and a pmd always exists (as it's folded
320  * into the pgd entry)
321  */
322 static inline int pgd_none(pgd_t pgd)           { return 0; }
323 static inline int pgd_bad(pgd_t pgd)            { return 0; }
324 static inline int pgd_present(pgd_t pgd)        { return 1; }
325 #define pgd_clear(xp)                           do { } while (0)
326 #define pgd_page(pgd) \
327         ((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
328
329 /*
330  * The following only work if pte_present() is true.
331  * Undefined behaviour if not..
332  */
333 static inline int pte_read(pte_t pte)  { return pte_val(pte) & _PAGE_USER; }
334 static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
335 static inline int pte_exec(pte_t pte)  { return pte_val(pte) & _PAGE_EXEC; }
336 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
337 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
338 static inline int pte_file(pte_t pte)  { return pte_val(pte) & _PAGE_FILE; }
339
340 static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
341 static inline void pte_cache(pte_t pte)   { pte_val(pte) &= ~_PAGE_NO_CACHE; }
342
343 static inline pte_t pte_rdprotect(pte_t pte) \
344                 { pte_val(pte) &= ~_PAGE_USER; return pte; }
345 static inline pte_t pte_wrprotect(pte_t pte) \
346         { pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE); return pte; }
347 static inline pte_t pte_exprotect(pte_t pte) \
348         { pte_val(pte) &= ~_PAGE_EXEC; return pte; }
349 static inline pte_t pte_mkclean(pte_t pte) \
350         { pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; }
351 static inline pte_t pte_mkold(pte_t pte) \
352         { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
353
354 static inline pte_t pte_mkread(pte_t pte) \
355         { pte_val(pte) |= _PAGE_USER; return pte; }
356 static inline pte_t pte_mkexec(pte_t pte) \
357         { pte_val(pte) |= _PAGE_USER | _PAGE_EXEC; return pte; }
358 static inline pte_t pte_mkwrite(pte_t pte) \
359         { pte_val(pte) |= _PAGE_RW; return pte; }
360 static inline pte_t pte_mkdirty(pte_t pte) \
361         { pte_val(pte) |= _PAGE_DIRTY; return pte; }
362 static inline pte_t pte_mkyoung(pte_t pte) \
363         { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
364
365 /*
366  * Conversion functions: convert a page and protection to a page entry,
367  * and a page entry and page directory to the page they refer to.
368  */
369
370 static inline pte_t mk_pte_phys(phys_addr_t physpage, pgprot_t pgprot)
371 {
372         pte_t pte;
373         pte_val(pte) = physpage | pgprot_val(pgprot);
374         return pte;
375 }
376
377 #define mk_pte(page, pgprot) \
378 ({                                                                         \
379         pte_t pte;                                                         \
380         pte_val(pte) = (((page - mem_map) << PAGE_SHIFT) + memory_start) |  \
381                         pgprot_val(pgprot);                                \
382         pte;                                                               \
383 })
384
385 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
386 {
387         pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
388         return pte;
389 }
390
391 /*
392  * Atomic PTE updates.
393  *
394  * pte_update clears and sets bit atomically, and returns
395  * the old pte value.
396  * The ((unsigned long)(p+1) - 4) hack is to get to the least-significant
397  * 32 bits of the PTE regardless of whether PTEs are 32 or 64 bits.
398  */
399 static inline unsigned long pte_update(pte_t *p, unsigned long clr,
400                                 unsigned long set)
401 {
402         unsigned long old, tmp, msr;
403
404         __asm__ __volatile__("\
405         msrclr  %2, 0x2\n\
406         nop\n\
407         lw      %0, %4, r0\n\
408         andn    %1, %0, %5\n\
409         or      %1, %1, %6\n\
410         sw      %1, %4, r0\n\
411         mts     rmsr, %2\n\
412         nop"
413         : "=&r" (old), "=&r" (tmp), "=&r" (msr), "=m" (*p)
414         : "r" ((unsigned long)(p+1) - 4), "r" (clr), "r" (set), "m" (*p)
415         : "cc");
416
417         return old;
418 }
419
420 /*
421  * set_pte stores a linux PTE into the linux page table.
422  */
423 static inline void set_pte(struct mm_struct *mm, unsigned long addr,
424                 pte_t *ptep, pte_t pte)
425 {
426         *ptep = pte;
427 }
428
429 static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
430                 pte_t *ptep, pte_t pte)
431 {
432         *ptep = pte;
433 }
434
435 static inline int ptep_test_and_clear_young(struct mm_struct *mm,
436                 unsigned long addr, pte_t *ptep)
437 {
438         return (pte_update(ptep, _PAGE_ACCESSED, 0) & _PAGE_ACCESSED) != 0;
439 }
440
441 static inline int ptep_test_and_clear_dirty(struct mm_struct *mm,
442                 unsigned long addr, pte_t *ptep)
443 {
444         return (pte_update(ptep, \
445                 (_PAGE_DIRTY | _PAGE_HWWRITE), 0) & _PAGE_DIRTY) != 0;
446 }
447
448 static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
449                 unsigned long addr, pte_t *ptep)
450 {
451         return __pte(pte_update(ptep, ~_PAGE_HASHPTE, 0));
452 }
453
454 /*static inline void ptep_set_wrprotect(struct mm_struct *mm,
455                 unsigned long addr, pte_t *ptep)
456 {
457         pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), 0);
458 }*/
459
460 static inline void ptep_mkdirty(struct mm_struct *mm,
461                 unsigned long addr, pte_t *ptep)
462 {
463         pte_update(ptep, 0, _PAGE_DIRTY);
464 }
465
466 /*#define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HASHPTE) == 0)*/
467
468 /* Convert pmd entry to page */
469 /* our pmd entry is an effective address of pte table*/
470 /* returns effective address of the pmd entry*/
471 #define pmd_page_kernel(pmd)    ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
472
473 /* returns struct *page of the pmd entry*/
474 #define pmd_page(pmd)   (pfn_to_page(__pa(pmd_val(pmd)) >> PAGE_SHIFT))
475
476 /* to find an entry in a kernel page-table-directory */
477 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
478
479 /* to find an entry in a page-table-directory */
480 #define pgd_index(address)       ((address) >> PGDIR_SHIFT)
481 #define pgd_offset(mm, address)  ((mm)->pgd + pgd_index(address))
482
483 /* Find an entry in the second-level page table.. */
484 static inline pmd_t *pmd_offset(pgd_t *dir, unsigned long address)
485 {
486         return (pmd_t *) dir;
487 }
488
489 /* Find an entry in the third-level page table.. */
490 #define pte_index(address)              \
491         (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
492 #define pte_offset_kernel(dir, addr)    \
493         ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr))
494 #define pte_offset_map(dir, addr)               \
495         ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr))
496 #define pte_offset_map_nested(dir, addr)        \
497         ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
498
499 #define pte_unmap(pte)          kunmap_atomic(pte, KM_PTE0)
500 #define pte_unmap_nested(pte)   kunmap_atomic(pte, KM_PTE1)
501
502 /* Encode and decode a nonlinear file mapping entry */
503 #define PTE_FILE_MAX_BITS       29
504 #define pte_to_pgoff(pte)       (pte_val(pte) >> 3)
505 #define pgoff_to_pte(off)       ((pte_t) { ((off) << 3) | _PAGE_FILE })
506
507 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
508
509 /*
510  * When flushing the tlb entry for a page, we also need to flush the hash
511  * table entry.  flush_hash_page is assembler (for speed) in hashtable.S.
512  */
513 extern int flush_hash_page(unsigned context, unsigned long va, pte_t *ptep);
514
515 /* Add an HPTE to the hash table */
516 extern void add_hash_page(unsigned context, unsigned long va, pte_t *ptep);
517
518 /*
519  * Encode and decode a swap entry.
520  * Note that the bits we use in a PTE for representing a swap entry
521  * must not include the _PAGE_PRESENT bit, or the _PAGE_HASHPTE bit
522  * (if used).  -- paulus
523  */
524 #define __swp_type(entry)               ((entry).val & 0x3f)
525 #define __swp_offset(entry)     ((entry).val >> 6)
526 #define __swp_entry(type, offset) \
527                 ((swp_entry_t) { (type) | ((offset) << 6) })
528 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 2 })
529 #define __swp_entry_to_pte(x)   ((pte_t) { (x).val << 2 })
530
531
532 /* CONFIG_APUS */
533 /* For virtual address to physical address conversion */
534 extern void cache_clear(__u32 addr, int length);
535 extern void cache_push(__u32 addr, int length);
536 extern int mm_end_of_chunk(unsigned long addr, int len);
537 extern unsigned long iopa(unsigned long addr);
538 /* extern unsigned long mm_ptov(unsigned long addr) \
539         __attribute__ ((const)); TBD */
540
541 /* Values for nocacheflag and cmode */
542 /* These are not used by the APUS kernel_map, but prevents
543  * compilation errors.
544  */
545 #define IOMAP_FULL_CACHING      0
546 #define IOMAP_NOCACHE_SER       1
547 #define IOMAP_NOCACHE_NONSER    2
548 #define IOMAP_NO_COPYBACK       3
549
550 /*
551  * Map some physical address range into the kernel address space.
552  */
553 extern unsigned long kernel_map(unsigned long paddr, unsigned long size,
554                                 int nocacheflag, unsigned long *memavailp);
555
556 /*
557  * Set cache mode of (kernel space) address range.
558  */
559 extern void kernel_set_cachemode(unsigned long address, unsigned long size,
560                                 unsigned int cmode);
561
562 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
563 #define kern_addr_valid(addr)   (1)
564
565 #define io_remap_page_range remap_page_range
566
567 /*
568  * No page table caches to initialise
569  */
570 #define pgtable_cache_init()    do { } while (0)
571
572 void do_page_fault(struct pt_regs *regs, unsigned long address,
573                    unsigned long error_code);
574
575 void __init io_block_mapping(unsigned long virt, phys_addr_t phys,
576                              unsigned int size, int flags);
577
578 void __init adjust_total_lowmem(void);
579 void mapin_ram(void);
580 int map_page(unsigned long va, phys_addr_t pa, int flags);
581
582 extern int mem_init_done;
583 extern unsigned long ioremap_base;
584 extern unsigned long ioremap_bot;
585
586 asmlinkage void __init mmu_init(void);
587
588 void __init *early_get_page(void);
589
590 void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle);
591 void consistent_free(void *vaddr);
592 void consistent_sync(void *vaddr, size_t size, int direction);
593 void consistent_sync_page(struct page *page, unsigned long offset,
594         size_t size, int direction);
595 #endif /* __ASSEMBLY__ */
596 #endif /* __KERNEL__ */
597
598 #endif /* CONFIG_MMU */
599
600 #ifndef __ASSEMBLY__
601 #include <asm-generic/pgtable.h>
602
603 void setup_memory(void);
604 #endif /* __ASSEMBLY__ */
605
606 #endif /* _ASM_MICROBLAZE_PGTABLE_H */