1 /* $Id: pgtsun4.h,v 1.5 2000/06/05 06:08:46 anton Exp $
2 * pgtsun4.h: Sun4 specific pgtable.h defines and code.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 #ifndef _SPARC_PGTSUN4C_H
8 #define _SPARC_PGTSUN4C_H
10 #include <asm/contregs.h>
12 /* PMD_SHIFT determines the size of the area a second-level page table can map */
13 #define SUN4C_PMD_SHIFT 23
15 /* PGDIR_SHIFT determines what a third-level page table entry can map */
16 #define SUN4C_PGDIR_SHIFT 23
17 #define SUN4C_PGDIR_SIZE (1UL << SUN4C_PGDIR_SHIFT)
18 #define SUN4C_PGDIR_MASK (~(SUN4C_PGDIR_SIZE-1))
19 #define SUN4C_PGDIR_ALIGN(addr) (((addr)+SUN4C_PGDIR_SIZE-1)&SUN4C_PGDIR_MASK)
21 /* To represent how the sun4c mmu really lays things out. */
22 #define SUN4C_REAL_PGDIR_SHIFT 18
23 #define SUN4C_REAL_PGDIR_SIZE (1UL << SUN4C_REAL_PGDIR_SHIFT)
24 #define SUN4C_REAL_PGDIR_MASK (~(SUN4C_REAL_PGDIR_SIZE-1))
25 #define SUN4C_REAL_PGDIR_ALIGN(addr) (((addr)+SUN4C_REAL_PGDIR_SIZE-1)&SUN4C_REAL_PGDIR_MASK)
27 /* 19 bit PFN on sun4 */
28 #define SUN4C_PFN_MASK 0x7ffff
30 /* Don't increase these unless the structures in sun4c.c are fixed */
31 #define SUN4C_MAX_SEGMAPS 256
32 #define SUN4C_MAX_CONTEXTS 16
35 * To be efficient, and not have to worry about allocating such
36 * a huge pgd, we make the kernel sun4c tables each hold 1024
37 * entries and the pgd similarly just like the i386 tables.
39 #define SUN4C_PTRS_PER_PTE 1024
40 #define SUN4C_PTRS_PER_PMD 1
41 #define SUN4C_PTRS_PER_PGD 1024
44 * Sparc SUN4C pte fields.
46 #define _SUN4C_PAGE_VALID 0x80000000
47 #define _SUN4C_PAGE_SILENT_READ 0x80000000 /* synonym */
48 #define _SUN4C_PAGE_DIRTY 0x40000000
49 #define _SUN4C_PAGE_SILENT_WRITE 0x40000000 /* synonym */
50 #define _SUN4C_PAGE_PRIV 0x20000000 /* privileged page */
51 #define _SUN4C_PAGE_NOCACHE 0x10000000 /* non-cacheable page */
52 #define _SUN4C_PAGE_PRESENT 0x08000000 /* implemented in software */
53 #define _SUN4C_PAGE_IO 0x04000000 /* I/O page */
54 #define _SUN4C_PAGE_READ 0x00800000 /* implemented in software */
55 #define _SUN4C_PAGE_WRITE 0x00400000 /* implemented in software */
56 #define _SUN4C_PAGE_ACCESSED 0x00200000 /* implemented in software */
57 #define _SUN4C_PAGE_MODIFIED 0x00100000 /* implemented in software */
59 #define _SUN4C_READABLE (_SUN4C_PAGE_READ|_SUN4C_PAGE_SILENT_READ|\
61 #define _SUN4C_WRITEABLE (_SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE|\
64 #define _SUN4C_PAGE_CHG_MASK (0xffff|_SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_MODIFIED)
66 #define SUN4C_PAGE_NONE __pgprot(_SUN4C_PAGE_PRESENT)
67 #define SUN4C_PAGE_SHARED __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE|\
69 #define SUN4C_PAGE_COPY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
70 #define SUN4C_PAGE_READONLY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
71 #define SUN4C_PAGE_KERNEL __pgprot(_SUN4C_READABLE|_SUN4C_WRITEABLE|\
72 _SUN4C_PAGE_DIRTY|_SUN4C_PAGE_PRIV)
76 static inline unsigned long sun4c_get_synchronous_error(void)
78 unsigned long sync_err;
80 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
82 "r" (AC_SYNC_ERR), "i" (ASI_CONTROL));
86 static inline unsigned long sun4c_get_synchronous_address(void)
88 unsigned long sync_addr;
90 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
92 "r" (AC_SYNC_VA), "i" (ASI_CONTROL));
96 /* SUN4 pte, segmap, and context manipulation */
97 static inline unsigned long sun4c_get_segmap(unsigned long addr)
99 register unsigned long entry;
101 __asm__ __volatile__("\n\tlduha [%1] %2, %0\n\t" :
103 "r" (addr), "i" (ASI_SEGMAP));
107 static inline void sun4c_put_segmap(unsigned long addr, unsigned long entry)
109 __asm__ __volatile__("\n\tstha %1, [%0] %2; nop; nop; nop;\n\t" : :
110 "r" (addr), "r" (entry),
115 static inline unsigned long sun4c_get_pte(unsigned long addr)
117 register unsigned long entry;
119 __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
121 "r" (addr), "i" (ASI_PTE));
125 static inline void sun4c_put_pte(unsigned long addr, unsigned long entry)
127 __asm__ __volatile__("\n\tsta %1, [%0] %2; nop; nop; nop;\n\t" : :
129 "r" ((entry & ~(_SUN4C_PAGE_PRESENT))), "i" (ASI_PTE)
133 static inline int sun4c_get_context(void)
137 __asm__ __volatile__("\n\tlduba [%1] %2, %0\n\t" :
139 "r" (AC_CONTEXT), "i" (ASI_CONTROL));
144 static inline int sun4c_set_context(int ctx)
146 __asm__ __volatile__("\n\tstba %0, [%1] %2; nop; nop; nop;\n\t" : :
147 "r" (ctx), "r" (AC_CONTEXT), "i" (ASI_CONTROL)
153 #endif /* !(__ASSEMBLY__) */
155 #endif /* !(_SPARC_PGTSUN4_H) */