[PATCH] LSM: remove BSD secure level security module
[usb.git] / include / asm-sparc / pgtsun4.h
blob60bda107f2067877138433b74c84d9eabed541be
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)
6 */
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_FILE 0x02000000 /* implemented in software */
55 #define _SUN4C_PAGE_READ 0x00800000 /* implemented in software */
56 #define _SUN4C_PAGE_WRITE 0x00400000 /* implemented in software */
57 #define _SUN4C_PAGE_ACCESSED 0x00200000 /* implemented in software */
58 #define _SUN4C_PAGE_MODIFIED 0x00100000 /* implemented in software */
60 #define _SUN4C_READABLE (_SUN4C_PAGE_READ|_SUN4C_PAGE_SILENT_READ|\
61 _SUN4C_PAGE_ACCESSED)
62 #define _SUN4C_WRITEABLE (_SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE|\
63 _SUN4C_PAGE_MODIFIED)
65 #define _SUN4C_PAGE_CHG_MASK (0xffff|_SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_MODIFIED)
67 #define SUN4C_PAGE_NONE __pgprot(_SUN4C_PAGE_PRESENT)
68 #define SUN4C_PAGE_SHARED __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE|\
69 _SUN4C_PAGE_WRITE)
70 #define SUN4C_PAGE_COPY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
71 #define SUN4C_PAGE_READONLY __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
72 #define SUN4C_PAGE_KERNEL __pgprot(_SUN4C_READABLE|_SUN4C_WRITEABLE|\
73 _SUN4C_PAGE_DIRTY|_SUN4C_PAGE_PRIV)
75 /* SUN4C swap entry encoding
77 * We use 5 bits for the type and 19 for the offset. This gives us
78 * 32 swapfiles of 4GB each. Encoding looks like:
80 * RRRRRRRRooooooooooooooooooottttt
81 * fedcba9876543210fedcba9876543210
83 * The top 8 bits are reserved for protection and status bits, especially
84 * FILE and PRESENT.
86 #define SUN4C_SWP_TYPE_MASK 0x1f
87 #define SUN4C_SWP_OFF_MASK 0x7ffff
88 #define SUN4C_SWP_OFF_SHIFT 5
90 #ifndef __ASSEMBLY__
92 static inline unsigned long sun4c_get_synchronous_error(void)
94 unsigned long sync_err;
96 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
97 "=r" (sync_err) :
98 "r" (AC_SYNC_ERR), "i" (ASI_CONTROL));
99 return sync_err;
102 static inline unsigned long sun4c_get_synchronous_address(void)
104 unsigned long sync_addr;
106 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
107 "=r" (sync_addr) :
108 "r" (AC_SYNC_VA), "i" (ASI_CONTROL));
109 return sync_addr;
112 /* SUN4 pte, segmap, and context manipulation */
113 static inline unsigned long sun4c_get_segmap(unsigned long addr)
115 register unsigned long entry;
117 __asm__ __volatile__("\n\tlduha [%1] %2, %0\n\t" :
118 "=r" (entry) :
119 "r" (addr), "i" (ASI_SEGMAP));
120 return entry;
123 static inline void sun4c_put_segmap(unsigned long addr, unsigned long entry)
125 __asm__ __volatile__("\n\tstha %1, [%0] %2; nop; nop; nop;\n\t" : :
126 "r" (addr), "r" (entry),
127 "i" (ASI_SEGMAP)
128 : "memory");
131 static inline unsigned long sun4c_get_pte(unsigned long addr)
133 register unsigned long entry;
135 __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
136 "=r" (entry) :
137 "r" (addr), "i" (ASI_PTE));
138 return entry;
141 static inline void sun4c_put_pte(unsigned long addr, unsigned long entry)
143 __asm__ __volatile__("\n\tsta %1, [%0] %2; nop; nop; nop;\n\t" : :
144 "r" (addr),
145 "r" ((entry & ~(_SUN4C_PAGE_PRESENT))), "i" (ASI_PTE)
146 : "memory");
149 static inline int sun4c_get_context(void)
151 register int ctx;
153 __asm__ __volatile__("\n\tlduba [%1] %2, %0\n\t" :
154 "=r" (ctx) :
155 "r" (AC_CONTEXT), "i" (ASI_CONTROL));
157 return ctx;
160 static inline int sun4c_set_context(int ctx)
162 __asm__ __volatile__("\n\tstba %0, [%1] %2; nop; nop; nop;\n\t" : :
163 "r" (ctx), "r" (AC_CONTEXT), "i" (ASI_CONTROL)
164 : "memory");
166 return ctx;
169 #endif /* !(__ASSEMBLY__) */
171 #endif /* !(_SPARC_PGTSUN4_H) */