1
2
3
4
5
6
7
8#ifndef _SPARC_VIKING_H
9#define _SPARC_VIKING_H
10
11#include <asm/asi.h>
12#include <asm/mxcc.h>
13#include <asm/pgtsrmmu.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86#define VIKING_MMUENABLE 0x00000001
87#define VIKING_NOFAULT 0x00000002
88#define VIKING_PSO 0x00000080
89#define VIKING_DCENABLE 0x00000100
90#define VIKING_ICENABLE 0x00000200
91#define VIKING_SBENABLE 0x00000400
92#define VIKING_MMODE 0x00000800
93#define VIKING_PCENABLE 0x00001000
94#define VIKING_BMODE 0x00002000
95#define VIKING_SPENABLE 0x00004000
96#define VIKING_ACENABLE 0x00008000
97#define VIKING_TCENABLE 0x00010000
98#define VIKING_DPENABLE 0x00040000
99
100
101
102
103#define VIKING_ACTION_MIX 0x00001000
104
105
106
107
108#define VIKING_PTAG_VALID 0x01000000
109#define VIKING_PTAG_DIRTY 0x00010000
110#define VIKING_PTAG_SHARED 0x00000100
111
112#ifndef __ASSEMBLY__
113
114static inline void viking_flush_icache(void)
115{
116 __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"
117 :
118 : "i" (ASI_M_IC_FLCLEAR)
119 : "memory");
120}
121
122static inline void viking_flush_dcache(void)
123{
124 __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"
125 :
126 : "i" (ASI_M_DC_FLCLEAR)
127 : "memory");
128}
129
130static inline void viking_unlock_icache(void)
131{
132 __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
133 :
134 : "r" (0x80000000), "i" (ASI_M_IC_FLCLEAR)
135 : "memory");
136}
137
138static inline void viking_unlock_dcache(void)
139{
140 __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
141 :
142 : "r" (0x80000000), "i" (ASI_M_DC_FLCLEAR)
143 : "memory");
144}
145
146static inline void viking_set_bpreg(unsigned long regval)
147{
148 __asm__ __volatile__("sta %0, [%%g0] %1\n\t"
149 :
150 : "r" (regval), "i" (ASI_M_ACTION)
151 : "memory");
152}
153
154static inline unsigned long viking_get_bpreg(void)
155{
156 unsigned long regval;
157
158 __asm__ __volatile__("lda [%%g0] %1, %0\n\t"
159 : "=r" (regval)
160 : "i" (ASI_M_ACTION));
161 return regval;
162}
163
164static inline void viking_get_dcache_ptag(int set, int block,
165 unsigned long *data)
166{
167 unsigned long ptag = ((set & 0x7f) << 5) | ((block & 0x3) << 26) |
168 0x80000000;
169 unsigned long info, page;
170
171 __asm__ __volatile__ ("ldda [%2] %3, %%g2\n\t"
172 "or %%g0, %%g2, %0\n\t"
173 "or %%g0, %%g3, %1\n\t"
174 : "=r" (info), "=r" (page)
175 : "r" (ptag), "i" (ASI_M_DATAC_TAG)
176 : "g2", "g3");
177 data[0] = info;
178 data[1] = page;
179}
180
181static inline void viking_mxcc_turn_off_parity(unsigned long *mregp,
182 unsigned long *mxcc_cregp)
183{
184 unsigned long mreg = *mregp;
185 unsigned long mxcc_creg = *mxcc_cregp;
186
187 mreg &= ~(VIKING_PCENABLE);
188 mxcc_creg &= ~(MXCC_CTL_PARE);
189
190 __asm__ __volatile__ ("set 1f, %%g2\n\t"
191 "andcc %%g2, 4, %%g0\n\t"
192 "bne 2f\n\t"
193 " nop\n"
194 "1:\n\t"
195 "sta %0, [%%g0] %3\n\t"
196 "sta %1, [%2] %4\n\t"
197 "b 1f\n\t"
198 " nop\n\t"
199 "nop\n"
200 "2:\n\t"
201 "sta %0, [%%g0] %3\n\t"
202 "sta %1, [%2] %4\n"
203 "1:\n\t"
204 :
205 : "r" (mreg), "r" (mxcc_creg),
206 "r" (MXCC_CREG), "i" (ASI_M_MMUREGS),
207 "i" (ASI_M_MXCC)
208 : "g2", "memory", "cc");
209 *mregp = mreg;
210 *mxcc_cregp = mxcc_creg;
211}
212
213static inline unsigned long viking_hwprobe(unsigned long vaddr)
214{
215 unsigned long val;
216
217 vaddr &= PAGE_MASK;
218
219 __asm__ __volatile__("lda [%1] %2, %0\n\t"
220 : "=r" (val)
221 : "r" (vaddr | 0x400), "i" (ASI_M_FLUSH_PROBE));
222 if (!val)
223 return 0;
224
225
226 __asm__ __volatile__("lda [%1] %2, %0\n\t"
227 : "=r" (val)
228 : "r" (vaddr | 0x200), "i" (ASI_M_FLUSH_PROBE));
229 if ((val & SRMMU_ET_MASK) == SRMMU_ET_PTE) {
230 vaddr &= ~SRMMU_PGDIR_MASK;
231 vaddr >>= PAGE_SHIFT;
232 return val | (vaddr << 8);
233 }
234
235
236 __asm__ __volatile__("lda [%1] %2, %0\n\t"
237 : "=r" (val)
238 : "r" (vaddr | 0x100), "i" (ASI_M_FLUSH_PROBE));
239 if ((val & SRMMU_ET_MASK) == SRMMU_ET_PTE) {
240 vaddr &= ~SRMMU_REAL_PMD_MASK;
241 vaddr >>= PAGE_SHIFT;
242 return val | (vaddr << 8);
243 }
244
245
246 __asm__ __volatile__("lda [%1] %2, %0\n\t"
247 : "=r" (val)
248 : "r" (vaddr), "i" (ASI_M_FLUSH_PROBE));
249 return val;
250}
251
252#endif
253
254#endif
255