root / target-sparc / op_helper.c @ bdf9f35d
History | View | Annotate | Download (94.4 kB)
1 | e8af50a3 | bellard | #include "exec.h" |
---|---|---|---|
2 | eed152bb | blueswir1 | #include "host-utils.h" |
3 | 1a2fb1c0 | blueswir1 | #include "helper.h" |
4 | 0828b448 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
5 | 0828b448 | blueswir1 | #include "softmmu_exec.h" |
6 | 0828b448 | blueswir1 | #endif /* !defined(CONFIG_USER_ONLY) */ |
7 | e8af50a3 | bellard | |
8 | e80cfcfc | bellard | //#define DEBUG_MMU
|
9 | 952a328f | blueswir1 | //#define DEBUG_MXCC
|
10 | 94554550 | blueswir1 | //#define DEBUG_UNALIGNED
|
11 | 6c36d3fa | blueswir1 | //#define DEBUG_UNASSIGNED
|
12 | 8543e2cf | blueswir1 | //#define DEBUG_ASI
|
13 | d81fd722 | blueswir1 | //#define DEBUG_PCALL
|
14 | e80cfcfc | bellard | |
15 | 952a328f | blueswir1 | #ifdef DEBUG_MMU
|
16 | 952a328f | blueswir1 | #define DPRINTF_MMU(fmt, args...) \
|
17 | 952a328f | blueswir1 | do { printf("MMU: " fmt , ##args); } while (0) |
18 | 952a328f | blueswir1 | #else
|
19 | 22548760 | blueswir1 | #define DPRINTF_MMU(fmt, args...) do {} while (0) |
20 | 952a328f | blueswir1 | #endif
|
21 | 952a328f | blueswir1 | |
22 | 952a328f | blueswir1 | #ifdef DEBUG_MXCC
|
23 | 952a328f | blueswir1 | #define DPRINTF_MXCC(fmt, args...) \
|
24 | 952a328f | blueswir1 | do { printf("MXCC: " fmt , ##args); } while (0) |
25 | 952a328f | blueswir1 | #else
|
26 | 22548760 | blueswir1 | #define DPRINTF_MXCC(fmt, args...) do {} while (0) |
27 | 952a328f | blueswir1 | #endif
|
28 | 952a328f | blueswir1 | |
29 | 8543e2cf | blueswir1 | #ifdef DEBUG_ASI
|
30 | 8543e2cf | blueswir1 | #define DPRINTF_ASI(fmt, args...) \
|
31 | 8543e2cf | blueswir1 | do { printf("ASI: " fmt , ##args); } while (0) |
32 | 8543e2cf | blueswir1 | #endif
|
33 | 8543e2cf | blueswir1 | |
34 | 2cade6a3 | blueswir1 | #ifdef TARGET_SPARC64
|
35 | 2cade6a3 | blueswir1 | #ifndef TARGET_ABI32
|
36 | 2cade6a3 | blueswir1 | #define AM_CHECK(env1) ((env1)->pstate & PS_AM)
|
37 | c2bc0e38 | blueswir1 | #else
|
38 | 2cade6a3 | blueswir1 | #define AM_CHECK(env1) (1) |
39 | 2cade6a3 | blueswir1 | #endif
|
40 | c2bc0e38 | blueswir1 | #endif
|
41 | c2bc0e38 | blueswir1 | |
42 | 9c22a623 | Blue Swirl | #if defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
|
43 | 697a77e6 | Igor Kovalenko | // Calculates TSB pointer value for fault page size 8k or 64k
|
44 | 697a77e6 | Igor Kovalenko | static uint64_t ultrasparc_tsb_pointer(uint64_t tsb_register,
|
45 | 697a77e6 | Igor Kovalenko | uint64_t tag_access_register, |
46 | 697a77e6 | Igor Kovalenko | int page_size)
|
47 | 697a77e6 | Igor Kovalenko | { |
48 | 697a77e6 | Igor Kovalenko | uint64_t tsb_base = tsb_register & ~0x1fffULL;
|
49 | 697a77e6 | Igor Kovalenko | int tsb_split = (env->dmmuregs[5] & 0x1000ULL) ? 1 : 0; |
50 | 697a77e6 | Igor Kovalenko | int tsb_size = env->dmmuregs[5] & 0xf; |
51 | 697a77e6 | Igor Kovalenko | |
52 | 697a77e6 | Igor Kovalenko | // discard lower 13 bits which hold tag access context
|
53 | 697a77e6 | Igor Kovalenko | uint64_t tag_access_va = tag_access_register & ~0x1fffULL;
|
54 | 697a77e6 | Igor Kovalenko | |
55 | 697a77e6 | Igor Kovalenko | // now reorder bits
|
56 | 697a77e6 | Igor Kovalenko | uint64_t tsb_base_mask = ~0x1fffULL;
|
57 | 697a77e6 | Igor Kovalenko | uint64_t va = tag_access_va; |
58 | 697a77e6 | Igor Kovalenko | |
59 | 697a77e6 | Igor Kovalenko | // move va bits to correct position
|
60 | 697a77e6 | Igor Kovalenko | if (page_size == 8*1024) { |
61 | 697a77e6 | Igor Kovalenko | va >>= 9;
|
62 | 697a77e6 | Igor Kovalenko | } else if (page_size == 64*1024) { |
63 | 697a77e6 | Igor Kovalenko | va >>= 12;
|
64 | 697a77e6 | Igor Kovalenko | } |
65 | 697a77e6 | Igor Kovalenko | |
66 | 697a77e6 | Igor Kovalenko | if (tsb_size) {
|
67 | 697a77e6 | Igor Kovalenko | tsb_base_mask <<= tsb_size; |
68 | 697a77e6 | Igor Kovalenko | } |
69 | 697a77e6 | Igor Kovalenko | |
70 | 697a77e6 | Igor Kovalenko | // calculate tsb_base mask and adjust va if split is in use
|
71 | 697a77e6 | Igor Kovalenko | if (tsb_split) {
|
72 | 697a77e6 | Igor Kovalenko | if (page_size == 8*1024) { |
73 | 697a77e6 | Igor Kovalenko | va &= ~(1ULL << (13 + tsb_size)); |
74 | 697a77e6 | Igor Kovalenko | } else if (page_size == 64*1024) { |
75 | 697a77e6 | Igor Kovalenko | va |= (1ULL << (13 + tsb_size)); |
76 | 697a77e6 | Igor Kovalenko | } |
77 | 697a77e6 | Igor Kovalenko | tsb_base_mask <<= 1;
|
78 | 697a77e6 | Igor Kovalenko | } |
79 | 697a77e6 | Igor Kovalenko | |
80 | 697a77e6 | Igor Kovalenko | return ((tsb_base & tsb_base_mask) | (va & ~tsb_base_mask)) & ~0xfULL; |
81 | 697a77e6 | Igor Kovalenko | } |
82 | 697a77e6 | Igor Kovalenko | |
83 | 697a77e6 | Igor Kovalenko | // Calculates tag target register value by reordering bits
|
84 | 697a77e6 | Igor Kovalenko | // in tag access register
|
85 | 697a77e6 | Igor Kovalenko | static uint64_t ultrasparc_tag_target(uint64_t tag_access_register)
|
86 | 697a77e6 | Igor Kovalenko | { |
87 | 697a77e6 | Igor Kovalenko | return ((tag_access_register & 0x1fff) << 48) | (tag_access_register >> 22); |
88 | 697a77e6 | Igor Kovalenko | } |
89 | 697a77e6 | Igor Kovalenko | |
90 | 697a77e6 | Igor Kovalenko | #endif
|
91 | 697a77e6 | Igor Kovalenko | |
92 | 2cade6a3 | blueswir1 | static inline void address_mask(CPUState *env1, target_ulong *addr) |
93 | 2cade6a3 | blueswir1 | { |
94 | 2cade6a3 | blueswir1 | #ifdef TARGET_SPARC64
|
95 | 2cade6a3 | blueswir1 | if (AM_CHECK(env1))
|
96 | 2cade6a3 | blueswir1 | *addr &= 0xffffffffULL;
|
97 | 2cade6a3 | blueswir1 | #endif
|
98 | 2cade6a3 | blueswir1 | } |
99 | 2cade6a3 | blueswir1 | |
100 | f4a5a5ba | blueswir1 | static void raise_exception(int tt) |
101 | 9d893301 | bellard | { |
102 | 9d893301 | bellard | env->exception_index = tt; |
103 | 9d893301 | bellard | cpu_loop_exit(); |
104 | 3b46e624 | ths | } |
105 | 9d893301 | bellard | |
106 | a7812ae4 | pbrook | void HELPER(raise_exception)(int tt) |
107 | a7812ae4 | pbrook | { |
108 | a7812ae4 | pbrook | raise_exception(tt); |
109 | a7812ae4 | pbrook | } |
110 | a7812ae4 | pbrook | |
111 | 91736d37 | blueswir1 | static inline void set_cwp(int new_cwp) |
112 | 91736d37 | blueswir1 | { |
113 | 91736d37 | blueswir1 | cpu_set_cwp(env, new_cwp); |
114 | 91736d37 | blueswir1 | } |
115 | 91736d37 | blueswir1 | |
116 | 2b29924f | blueswir1 | void helper_check_align(target_ulong addr, uint32_t align)
|
117 | 2b29924f | blueswir1 | { |
118 | c2bc0e38 | blueswir1 | if (addr & align) {
|
119 | c2bc0e38 | blueswir1 | #ifdef DEBUG_UNALIGNED
|
120 | c2bc0e38 | blueswir1 | printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx |
121 | c2bc0e38 | blueswir1 | "\n", addr, env->pc);
|
122 | c2bc0e38 | blueswir1 | #endif
|
123 | 2b29924f | blueswir1 | raise_exception(TT_UNALIGNED); |
124 | c2bc0e38 | blueswir1 | } |
125 | 2b29924f | blueswir1 | } |
126 | 2b29924f | blueswir1 | |
127 | 44e7757c | blueswir1 | #define F_HELPER(name, p) void helper_f##name##p(void) |
128 | 44e7757c | blueswir1 | |
129 | 44e7757c | blueswir1 | #define F_BINOP(name) \
|
130 | 714547bb | blueswir1 | float32 helper_f ## name ## s (float32 src1, float32 src2) \ |
131 | 44e7757c | blueswir1 | { \ |
132 | 714547bb | blueswir1 | return float32_ ## name (src1, src2, &env->fp_status); \ |
133 | 44e7757c | blueswir1 | } \ |
134 | 44e7757c | blueswir1 | F_HELPER(name, d) \ |
135 | 44e7757c | blueswir1 | { \ |
136 | 44e7757c | blueswir1 | DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \ |
137 | 4e14008f | blueswir1 | } \ |
138 | 4e14008f | blueswir1 | F_HELPER(name, q) \ |
139 | 4e14008f | blueswir1 | { \ |
140 | 4e14008f | blueswir1 | QT0 = float128_ ## name (QT0, QT1, &env->fp_status); \ |
141 | 44e7757c | blueswir1 | } |
142 | 44e7757c | blueswir1 | |
143 | 44e7757c | blueswir1 | F_BINOP(add); |
144 | 44e7757c | blueswir1 | F_BINOP(sub); |
145 | 44e7757c | blueswir1 | F_BINOP(mul); |
146 | 44e7757c | blueswir1 | F_BINOP(div); |
147 | 44e7757c | blueswir1 | #undef F_BINOP
|
148 | 44e7757c | blueswir1 | |
149 | d84763bc | blueswir1 | void helper_fsmuld(float32 src1, float32 src2)
|
150 | 1a2fb1c0 | blueswir1 | { |
151 | d84763bc | blueswir1 | DT0 = float64_mul(float32_to_float64(src1, &env->fp_status), |
152 | d84763bc | blueswir1 | float32_to_float64(src2, &env->fp_status), |
153 | 44e7757c | blueswir1 | &env->fp_status); |
154 | 44e7757c | blueswir1 | } |
155 | 1a2fb1c0 | blueswir1 | |
156 | 4e14008f | blueswir1 | void helper_fdmulq(void) |
157 | 4e14008f | blueswir1 | { |
158 | 4e14008f | blueswir1 | QT0 = float128_mul(float64_to_float128(DT0, &env->fp_status), |
159 | 4e14008f | blueswir1 | float64_to_float128(DT1, &env->fp_status), |
160 | 4e14008f | blueswir1 | &env->fp_status); |
161 | 4e14008f | blueswir1 | } |
162 | 4e14008f | blueswir1 | |
163 | 714547bb | blueswir1 | float32 helper_fnegs(float32 src) |
164 | 44e7757c | blueswir1 | { |
165 | 714547bb | blueswir1 | return float32_chs(src);
|
166 | 417454b0 | blueswir1 | } |
167 | 417454b0 | blueswir1 | |
168 | 44e7757c | blueswir1 | #ifdef TARGET_SPARC64
|
169 | 44e7757c | blueswir1 | F_HELPER(neg, d) |
170 | 7e8c2b6c | blueswir1 | { |
171 | 44e7757c | blueswir1 | DT0 = float64_chs(DT1); |
172 | 7e8c2b6c | blueswir1 | } |
173 | 4e14008f | blueswir1 | |
174 | 4e14008f | blueswir1 | F_HELPER(neg, q) |
175 | 4e14008f | blueswir1 | { |
176 | 4e14008f | blueswir1 | QT0 = float128_chs(QT1); |
177 | 4e14008f | blueswir1 | } |
178 | 4e14008f | blueswir1 | #endif
|
179 | 44e7757c | blueswir1 | |
180 | 44e7757c | blueswir1 | /* Integer to float conversion. */
|
181 | 714547bb | blueswir1 | float32 helper_fitos(int32_t src) |
182 | a0c4cb4a | bellard | { |
183 | 714547bb | blueswir1 | return int32_to_float32(src, &env->fp_status);
|
184 | a0c4cb4a | bellard | } |
185 | a0c4cb4a | bellard | |
186 | d84763bc | blueswir1 | void helper_fitod(int32_t src)
|
187 | a0c4cb4a | bellard | { |
188 | d84763bc | blueswir1 | DT0 = int32_to_float64(src, &env->fp_status); |
189 | a0c4cb4a | bellard | } |
190 | 9c2b428e | blueswir1 | |
191 | c5d04e99 | blueswir1 | void helper_fitoq(int32_t src)
|
192 | 4e14008f | blueswir1 | { |
193 | c5d04e99 | blueswir1 | QT0 = int32_to_float128(src, &env->fp_status); |
194 | 4e14008f | blueswir1 | } |
195 | 4e14008f | blueswir1 | |
196 | 1e64e78d | blueswir1 | #ifdef TARGET_SPARC64
|
197 | d84763bc | blueswir1 | float32 helper_fxtos(void)
|
198 | 1e64e78d | blueswir1 | { |
199 | d84763bc | blueswir1 | return int64_to_float32(*((int64_t *)&DT1), &env->fp_status);
|
200 | 1e64e78d | blueswir1 | } |
201 | 1e64e78d | blueswir1 | |
202 | 44e7757c | blueswir1 | F_HELPER(xto, d) |
203 | 1e64e78d | blueswir1 | { |
204 | 1e64e78d | blueswir1 | DT0 = int64_to_float64(*((int64_t *)&DT1), &env->fp_status); |
205 | 1e64e78d | blueswir1 | } |
206 | 64a88d5d | blueswir1 | |
207 | 4e14008f | blueswir1 | F_HELPER(xto, q) |
208 | 4e14008f | blueswir1 | { |
209 | 4e14008f | blueswir1 | QT0 = int64_to_float128(*((int64_t *)&DT1), &env->fp_status); |
210 | 4e14008f | blueswir1 | } |
211 | 4e14008f | blueswir1 | #endif
|
212 | 44e7757c | blueswir1 | #undef F_HELPER
|
213 | 44e7757c | blueswir1 | |
214 | 44e7757c | blueswir1 | /* floating point conversion */
|
215 | d84763bc | blueswir1 | float32 helper_fdtos(void)
|
216 | 44e7757c | blueswir1 | { |
217 | d84763bc | blueswir1 | return float64_to_float32(DT1, &env->fp_status);
|
218 | 44e7757c | blueswir1 | } |
219 | 44e7757c | blueswir1 | |
220 | d84763bc | blueswir1 | void helper_fstod(float32 src)
|
221 | 44e7757c | blueswir1 | { |
222 | d84763bc | blueswir1 | DT0 = float32_to_float64(src, &env->fp_status); |
223 | 44e7757c | blueswir1 | } |
224 | 9c2b428e | blueswir1 | |
225 | c5d04e99 | blueswir1 | float32 helper_fqtos(void)
|
226 | 4e14008f | blueswir1 | { |
227 | c5d04e99 | blueswir1 | return float128_to_float32(QT1, &env->fp_status);
|
228 | 4e14008f | blueswir1 | } |
229 | 4e14008f | blueswir1 | |
230 | c5d04e99 | blueswir1 | void helper_fstoq(float32 src)
|
231 | 4e14008f | blueswir1 | { |
232 | c5d04e99 | blueswir1 | QT0 = float32_to_float128(src, &env->fp_status); |
233 | 4e14008f | blueswir1 | } |
234 | 4e14008f | blueswir1 | |
235 | 4e14008f | blueswir1 | void helper_fqtod(void) |
236 | 4e14008f | blueswir1 | { |
237 | 4e14008f | blueswir1 | DT0 = float128_to_float64(QT1, &env->fp_status); |
238 | 4e14008f | blueswir1 | } |
239 | 4e14008f | blueswir1 | |
240 | 4e14008f | blueswir1 | void helper_fdtoq(void) |
241 | 4e14008f | blueswir1 | { |
242 | 4e14008f | blueswir1 | QT0 = float64_to_float128(DT1, &env->fp_status); |
243 | 4e14008f | blueswir1 | } |
244 | 4e14008f | blueswir1 | |
245 | 44e7757c | blueswir1 | /* Float to integer conversion. */
|
246 | 714547bb | blueswir1 | int32_t helper_fstoi(float32 src) |
247 | 44e7757c | blueswir1 | { |
248 | 714547bb | blueswir1 | return float32_to_int32_round_to_zero(src, &env->fp_status);
|
249 | 44e7757c | blueswir1 | } |
250 | 44e7757c | blueswir1 | |
251 | d84763bc | blueswir1 | int32_t helper_fdtoi(void)
|
252 | 44e7757c | blueswir1 | { |
253 | d84763bc | blueswir1 | return float64_to_int32_round_to_zero(DT1, &env->fp_status);
|
254 | 44e7757c | blueswir1 | } |
255 | 44e7757c | blueswir1 | |
256 | c5d04e99 | blueswir1 | int32_t helper_fqtoi(void)
|
257 | 4e14008f | blueswir1 | { |
258 | c5d04e99 | blueswir1 | return float128_to_int32_round_to_zero(QT1, &env->fp_status);
|
259 | 4e14008f | blueswir1 | } |
260 | 4e14008f | blueswir1 | |
261 | 44e7757c | blueswir1 | #ifdef TARGET_SPARC64
|
262 | d84763bc | blueswir1 | void helper_fstox(float32 src)
|
263 | 44e7757c | blueswir1 | { |
264 | d84763bc | blueswir1 | *((int64_t *)&DT0) = float32_to_int64_round_to_zero(src, &env->fp_status); |
265 | 44e7757c | blueswir1 | } |
266 | 44e7757c | blueswir1 | |
267 | 44e7757c | blueswir1 | void helper_fdtox(void) |
268 | 44e7757c | blueswir1 | { |
269 | 44e7757c | blueswir1 | *((int64_t *)&DT0) = float64_to_int64_round_to_zero(DT1, &env->fp_status); |
270 | 44e7757c | blueswir1 | } |
271 | 44e7757c | blueswir1 | |
272 | 4e14008f | blueswir1 | void helper_fqtox(void) |
273 | 4e14008f | blueswir1 | { |
274 | 4e14008f | blueswir1 | *((int64_t *)&DT0) = float128_to_int64_round_to_zero(QT1, &env->fp_status); |
275 | 4e14008f | blueswir1 | } |
276 | 4e14008f | blueswir1 | |
277 | 44e7757c | blueswir1 | void helper_faligndata(void) |
278 | 44e7757c | blueswir1 | { |
279 | 44e7757c | blueswir1 | uint64_t tmp; |
280 | 44e7757c | blueswir1 | |
281 | 44e7757c | blueswir1 | tmp = (*((uint64_t *)&DT0)) << ((env->gsr & 7) * 8); |
282 | 06057e6f | blueswir1 | /* on many architectures a shift of 64 does nothing */
|
283 | 06057e6f | blueswir1 | if ((env->gsr & 7) != 0) { |
284 | 06057e6f | blueswir1 | tmp |= (*((uint64_t *)&DT1)) >> (64 - (env->gsr & 7) * 8); |
285 | 06057e6f | blueswir1 | } |
286 | 44e7757c | blueswir1 | *((uint64_t *)&DT0) = tmp; |
287 | 44e7757c | blueswir1 | } |
288 | 44e7757c | blueswir1 | |
289 | 44e7757c | blueswir1 | #ifdef WORDS_BIGENDIAN
|
290 | 44e7757c | blueswir1 | #define VIS_B64(n) b[7 - (n)] |
291 | 44e7757c | blueswir1 | #define VIS_W64(n) w[3 - (n)] |
292 | 44e7757c | blueswir1 | #define VIS_SW64(n) sw[3 - (n)] |
293 | 44e7757c | blueswir1 | #define VIS_L64(n) l[1 - (n)] |
294 | 44e7757c | blueswir1 | #define VIS_B32(n) b[3 - (n)] |
295 | 44e7757c | blueswir1 | #define VIS_W32(n) w[1 - (n)] |
296 | 44e7757c | blueswir1 | #else
|
297 | 44e7757c | blueswir1 | #define VIS_B64(n) b[n]
|
298 | 44e7757c | blueswir1 | #define VIS_W64(n) w[n]
|
299 | 44e7757c | blueswir1 | #define VIS_SW64(n) sw[n]
|
300 | 44e7757c | blueswir1 | #define VIS_L64(n) l[n]
|
301 | 44e7757c | blueswir1 | #define VIS_B32(n) b[n]
|
302 | 44e7757c | blueswir1 | #define VIS_W32(n) w[n]
|
303 | 44e7757c | blueswir1 | #endif
|
304 | 44e7757c | blueswir1 | |
305 | 44e7757c | blueswir1 | typedef union { |
306 | 44e7757c | blueswir1 | uint8_t b[8];
|
307 | 44e7757c | blueswir1 | uint16_t w[4];
|
308 | 44e7757c | blueswir1 | int16_t sw[4];
|
309 | 44e7757c | blueswir1 | uint32_t l[2];
|
310 | 44e7757c | blueswir1 | float64 d; |
311 | 44e7757c | blueswir1 | } vis64; |
312 | 44e7757c | blueswir1 | |
313 | 44e7757c | blueswir1 | typedef union { |
314 | 44e7757c | blueswir1 | uint8_t b[4];
|
315 | 44e7757c | blueswir1 | uint16_t w[2];
|
316 | 44e7757c | blueswir1 | uint32_t l; |
317 | 44e7757c | blueswir1 | float32 f; |
318 | 44e7757c | blueswir1 | } vis32; |
319 | 44e7757c | blueswir1 | |
320 | 44e7757c | blueswir1 | void helper_fpmerge(void) |
321 | 44e7757c | blueswir1 | { |
322 | 44e7757c | blueswir1 | vis64 s, d; |
323 | 44e7757c | blueswir1 | |
324 | 44e7757c | blueswir1 | s.d = DT0; |
325 | 44e7757c | blueswir1 | d.d = DT1; |
326 | 44e7757c | blueswir1 | |
327 | 44e7757c | blueswir1 | // Reverse calculation order to handle overlap
|
328 | 44e7757c | blueswir1 | d.VIS_B64(7) = s.VIS_B64(3); |
329 | 44e7757c | blueswir1 | d.VIS_B64(6) = d.VIS_B64(3); |
330 | 44e7757c | blueswir1 | d.VIS_B64(5) = s.VIS_B64(2); |
331 | 44e7757c | blueswir1 | d.VIS_B64(4) = d.VIS_B64(2); |
332 | 44e7757c | blueswir1 | d.VIS_B64(3) = s.VIS_B64(1); |
333 | 44e7757c | blueswir1 | d.VIS_B64(2) = d.VIS_B64(1); |
334 | 44e7757c | blueswir1 | d.VIS_B64(1) = s.VIS_B64(0); |
335 | 44e7757c | blueswir1 | //d.VIS_B64(0) = d.VIS_B64(0);
|
336 | 44e7757c | blueswir1 | |
337 | 44e7757c | blueswir1 | DT0 = d.d; |
338 | 44e7757c | blueswir1 | } |
339 | 44e7757c | blueswir1 | |
340 | 44e7757c | blueswir1 | void helper_fmul8x16(void) |
341 | 44e7757c | blueswir1 | { |
342 | 44e7757c | blueswir1 | vis64 s, d; |
343 | 44e7757c | blueswir1 | uint32_t tmp; |
344 | 44e7757c | blueswir1 | |
345 | 44e7757c | blueswir1 | s.d = DT0; |
346 | 44e7757c | blueswir1 | d.d = DT1; |
347 | 44e7757c | blueswir1 | |
348 | 44e7757c | blueswir1 | #define PMUL(r) \
|
349 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \ |
350 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
351 | 44e7757c | blueswir1 | tmp += 0x100; \
|
352 | 44e7757c | blueswir1 | d.VIS_W64(r) = tmp >> 8;
|
353 | 44e7757c | blueswir1 | |
354 | 44e7757c | blueswir1 | PMUL(0);
|
355 | 44e7757c | blueswir1 | PMUL(1);
|
356 | 44e7757c | blueswir1 | PMUL(2);
|
357 | 44e7757c | blueswir1 | PMUL(3);
|
358 | 44e7757c | blueswir1 | #undef PMUL
|
359 | 44e7757c | blueswir1 | |
360 | 44e7757c | blueswir1 | DT0 = d.d; |
361 | 44e7757c | blueswir1 | } |
362 | 44e7757c | blueswir1 | |
363 | 44e7757c | blueswir1 | void helper_fmul8x16al(void) |
364 | 44e7757c | blueswir1 | { |
365 | 44e7757c | blueswir1 | vis64 s, d; |
366 | 44e7757c | blueswir1 | uint32_t tmp; |
367 | 44e7757c | blueswir1 | |
368 | 44e7757c | blueswir1 | s.d = DT0; |
369 | 44e7757c | blueswir1 | d.d = DT1; |
370 | 44e7757c | blueswir1 | |
371 | 44e7757c | blueswir1 | #define PMUL(r) \
|
372 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
|
373 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
374 | 44e7757c | blueswir1 | tmp += 0x100; \
|
375 | 44e7757c | blueswir1 | d.VIS_W64(r) = tmp >> 8;
|
376 | 44e7757c | blueswir1 | |
377 | 44e7757c | blueswir1 | PMUL(0);
|
378 | 44e7757c | blueswir1 | PMUL(1);
|
379 | 44e7757c | blueswir1 | PMUL(2);
|
380 | 44e7757c | blueswir1 | PMUL(3);
|
381 | 44e7757c | blueswir1 | #undef PMUL
|
382 | 44e7757c | blueswir1 | |
383 | 44e7757c | blueswir1 | DT0 = d.d; |
384 | 44e7757c | blueswir1 | } |
385 | 44e7757c | blueswir1 | |
386 | 44e7757c | blueswir1 | void helper_fmul8x16au(void) |
387 | 44e7757c | blueswir1 | { |
388 | 44e7757c | blueswir1 | vis64 s, d; |
389 | 44e7757c | blueswir1 | uint32_t tmp; |
390 | 44e7757c | blueswir1 | |
391 | 44e7757c | blueswir1 | s.d = DT0; |
392 | 44e7757c | blueswir1 | d.d = DT1; |
393 | 44e7757c | blueswir1 | |
394 | 44e7757c | blueswir1 | #define PMUL(r) \
|
395 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
|
396 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
397 | 44e7757c | blueswir1 | tmp += 0x100; \
|
398 | 44e7757c | blueswir1 | d.VIS_W64(r) = tmp >> 8;
|
399 | 44e7757c | blueswir1 | |
400 | 44e7757c | blueswir1 | PMUL(0);
|
401 | 44e7757c | blueswir1 | PMUL(1);
|
402 | 44e7757c | blueswir1 | PMUL(2);
|
403 | 44e7757c | blueswir1 | PMUL(3);
|
404 | 44e7757c | blueswir1 | #undef PMUL
|
405 | 44e7757c | blueswir1 | |
406 | 44e7757c | blueswir1 | DT0 = d.d; |
407 | 44e7757c | blueswir1 | } |
408 | 44e7757c | blueswir1 | |
409 | 44e7757c | blueswir1 | void helper_fmul8sux16(void) |
410 | 44e7757c | blueswir1 | { |
411 | 44e7757c | blueswir1 | vis64 s, d; |
412 | 44e7757c | blueswir1 | uint32_t tmp; |
413 | 44e7757c | blueswir1 | |
414 | 44e7757c | blueswir1 | s.d = DT0; |
415 | 44e7757c | blueswir1 | d.d = DT1; |
416 | 44e7757c | blueswir1 | |
417 | 44e7757c | blueswir1 | #define PMUL(r) \
|
418 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
|
419 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
420 | 44e7757c | blueswir1 | tmp += 0x100; \
|
421 | 44e7757c | blueswir1 | d.VIS_W64(r) = tmp >> 8;
|
422 | 44e7757c | blueswir1 | |
423 | 44e7757c | blueswir1 | PMUL(0);
|
424 | 44e7757c | blueswir1 | PMUL(1);
|
425 | 44e7757c | blueswir1 | PMUL(2);
|
426 | 44e7757c | blueswir1 | PMUL(3);
|
427 | 44e7757c | blueswir1 | #undef PMUL
|
428 | 44e7757c | blueswir1 | |
429 | 44e7757c | blueswir1 | DT0 = d.d; |
430 | 44e7757c | blueswir1 | } |
431 | 44e7757c | blueswir1 | |
432 | 44e7757c | blueswir1 | void helper_fmul8ulx16(void) |
433 | 44e7757c | blueswir1 | { |
434 | 44e7757c | blueswir1 | vis64 s, d; |
435 | 44e7757c | blueswir1 | uint32_t tmp; |
436 | 44e7757c | blueswir1 | |
437 | 44e7757c | blueswir1 | s.d = DT0; |
438 | 44e7757c | blueswir1 | d.d = DT1; |
439 | 44e7757c | blueswir1 | |
440 | 44e7757c | blueswir1 | #define PMUL(r) \
|
441 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
|
442 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
443 | 44e7757c | blueswir1 | tmp += 0x100; \
|
444 | 44e7757c | blueswir1 | d.VIS_W64(r) = tmp >> 8;
|
445 | 44e7757c | blueswir1 | |
446 | 44e7757c | blueswir1 | PMUL(0);
|
447 | 44e7757c | blueswir1 | PMUL(1);
|
448 | 44e7757c | blueswir1 | PMUL(2);
|
449 | 44e7757c | blueswir1 | PMUL(3);
|
450 | 44e7757c | blueswir1 | #undef PMUL
|
451 | 44e7757c | blueswir1 | |
452 | 44e7757c | blueswir1 | DT0 = d.d; |
453 | 44e7757c | blueswir1 | } |
454 | 44e7757c | blueswir1 | |
455 | 44e7757c | blueswir1 | void helper_fmuld8sux16(void) |
456 | 44e7757c | blueswir1 | { |
457 | 44e7757c | blueswir1 | vis64 s, d; |
458 | 44e7757c | blueswir1 | uint32_t tmp; |
459 | 44e7757c | blueswir1 | |
460 | 44e7757c | blueswir1 | s.d = DT0; |
461 | 44e7757c | blueswir1 | d.d = DT1; |
462 | 44e7757c | blueswir1 | |
463 | 44e7757c | blueswir1 | #define PMUL(r) \
|
464 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
|
465 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
466 | 44e7757c | blueswir1 | tmp += 0x100; \
|
467 | 44e7757c | blueswir1 | d.VIS_L64(r) = tmp; |
468 | 44e7757c | blueswir1 | |
469 | 44e7757c | blueswir1 | // Reverse calculation order to handle overlap
|
470 | 44e7757c | blueswir1 | PMUL(1);
|
471 | 44e7757c | blueswir1 | PMUL(0);
|
472 | 44e7757c | blueswir1 | #undef PMUL
|
473 | 44e7757c | blueswir1 | |
474 | 44e7757c | blueswir1 | DT0 = d.d; |
475 | 44e7757c | blueswir1 | } |
476 | 44e7757c | blueswir1 | |
477 | 44e7757c | blueswir1 | void helper_fmuld8ulx16(void) |
478 | 44e7757c | blueswir1 | { |
479 | 44e7757c | blueswir1 | vis64 s, d; |
480 | 44e7757c | blueswir1 | uint32_t tmp; |
481 | 44e7757c | blueswir1 | |
482 | 44e7757c | blueswir1 | s.d = DT0; |
483 | 44e7757c | blueswir1 | d.d = DT1; |
484 | 44e7757c | blueswir1 | |
485 | 44e7757c | blueswir1 | #define PMUL(r) \
|
486 | 44e7757c | blueswir1 | tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
|
487 | 44e7757c | blueswir1 | if ((tmp & 0xff) > 0x7f) \ |
488 | 44e7757c | blueswir1 | tmp += 0x100; \
|
489 | 44e7757c | blueswir1 | d.VIS_L64(r) = tmp; |
490 | 44e7757c | blueswir1 | |
491 | 44e7757c | blueswir1 | // Reverse calculation order to handle overlap
|
492 | 44e7757c | blueswir1 | PMUL(1);
|
493 | 44e7757c | blueswir1 | PMUL(0);
|
494 | 44e7757c | blueswir1 | #undef PMUL
|
495 | 44e7757c | blueswir1 | |
496 | 44e7757c | blueswir1 | DT0 = d.d; |
497 | 44e7757c | blueswir1 | } |
498 | 44e7757c | blueswir1 | |
499 | 44e7757c | blueswir1 | void helper_fexpand(void) |
500 | 44e7757c | blueswir1 | { |
501 | 44e7757c | blueswir1 | vis32 s; |
502 | 44e7757c | blueswir1 | vis64 d; |
503 | 44e7757c | blueswir1 | |
504 | 44e7757c | blueswir1 | s.l = (uint32_t)(*(uint64_t *)&DT0 & 0xffffffff);
|
505 | 44e7757c | blueswir1 | d.d = DT1; |
506 | c55bda30 | blueswir1 | d.VIS_W64(0) = s.VIS_B32(0) << 4; |
507 | c55bda30 | blueswir1 | d.VIS_W64(1) = s.VIS_B32(1) << 4; |
508 | c55bda30 | blueswir1 | d.VIS_W64(2) = s.VIS_B32(2) << 4; |
509 | c55bda30 | blueswir1 | d.VIS_W64(3) = s.VIS_B32(3) << 4; |
510 | 44e7757c | blueswir1 | |
511 | 44e7757c | blueswir1 | DT0 = d.d; |
512 | 44e7757c | blueswir1 | } |
513 | 44e7757c | blueswir1 | |
514 | 44e7757c | blueswir1 | #define VIS_HELPER(name, F) \
|
515 | 44e7757c | blueswir1 | void name##16(void) \ |
516 | 44e7757c | blueswir1 | { \ |
517 | 44e7757c | blueswir1 | vis64 s, d; \ |
518 | 44e7757c | blueswir1 | \ |
519 | 44e7757c | blueswir1 | s.d = DT0; \ |
520 | 44e7757c | blueswir1 | d.d = DT1; \ |
521 | 44e7757c | blueswir1 | \ |
522 | 44e7757c | blueswir1 | d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \ |
523 | 44e7757c | blueswir1 | d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \ |
524 | 44e7757c | blueswir1 | d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \ |
525 | 44e7757c | blueswir1 | d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \ |
526 | 44e7757c | blueswir1 | \ |
527 | 44e7757c | blueswir1 | DT0 = d.d; \ |
528 | 44e7757c | blueswir1 | } \ |
529 | 44e7757c | blueswir1 | \ |
530 | 1d01299d | blueswir1 | uint32_t name##16s(uint32_t src1, uint32_t src2) \ |
531 | 44e7757c | blueswir1 | { \ |
532 | 44e7757c | blueswir1 | vis32 s, d; \ |
533 | 44e7757c | blueswir1 | \ |
534 | 1d01299d | blueswir1 | s.l = src1; \ |
535 | 1d01299d | blueswir1 | d.l = src2; \ |
536 | 44e7757c | blueswir1 | \ |
537 | 44e7757c | blueswir1 | d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \ |
538 | 44e7757c | blueswir1 | d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \ |
539 | 44e7757c | blueswir1 | \ |
540 | 1d01299d | blueswir1 | return d.l; \
|
541 | 44e7757c | blueswir1 | } \ |
542 | 44e7757c | blueswir1 | \ |
543 | 44e7757c | blueswir1 | void name##32(void) \ |
544 | 44e7757c | blueswir1 | { \ |
545 | 44e7757c | blueswir1 | vis64 s, d; \ |
546 | 44e7757c | blueswir1 | \ |
547 | 44e7757c | blueswir1 | s.d = DT0; \ |
548 | 44e7757c | blueswir1 | d.d = DT1; \ |
549 | 44e7757c | blueswir1 | \ |
550 | 44e7757c | blueswir1 | d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \ |
551 | 44e7757c | blueswir1 | d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \ |
552 | 44e7757c | blueswir1 | \ |
553 | 44e7757c | blueswir1 | DT0 = d.d; \ |
554 | 44e7757c | blueswir1 | } \ |
555 | 44e7757c | blueswir1 | \ |
556 | 1d01299d | blueswir1 | uint32_t name##32s(uint32_t src1, uint32_t src2) \ |
557 | 44e7757c | blueswir1 | { \ |
558 | 44e7757c | blueswir1 | vis32 s, d; \ |
559 | 44e7757c | blueswir1 | \ |
560 | 1d01299d | blueswir1 | s.l = src1; \ |
561 | 1d01299d | blueswir1 | d.l = src2; \ |
562 | 44e7757c | blueswir1 | \ |
563 | 44e7757c | blueswir1 | d.l = F(d.l, s.l); \ |
564 | 44e7757c | blueswir1 | \ |
565 | 1d01299d | blueswir1 | return d.l; \
|
566 | 44e7757c | blueswir1 | } |
567 | 44e7757c | blueswir1 | |
568 | 44e7757c | blueswir1 | #define FADD(a, b) ((a) + (b))
|
569 | 44e7757c | blueswir1 | #define FSUB(a, b) ((a) - (b))
|
570 | 44e7757c | blueswir1 | VIS_HELPER(helper_fpadd, FADD) |
571 | 44e7757c | blueswir1 | VIS_HELPER(helper_fpsub, FSUB) |
572 | 44e7757c | blueswir1 | |
573 | 44e7757c | blueswir1 | #define VIS_CMPHELPER(name, F) \
|
574 | 44e7757c | blueswir1 | void name##16(void) \ |
575 | 44e7757c | blueswir1 | { \ |
576 | 44e7757c | blueswir1 | vis64 s, d; \ |
577 | 44e7757c | blueswir1 | \ |
578 | 44e7757c | blueswir1 | s.d = DT0; \ |
579 | 44e7757c | blueswir1 | d.d = DT1; \ |
580 | 44e7757c | blueswir1 | \ |
581 | 44e7757c | blueswir1 | d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \ |
582 | 44e7757c | blueswir1 | d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \ |
583 | 44e7757c | blueswir1 | d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \ |
584 | 44e7757c | blueswir1 | d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \ |
585 | 44e7757c | blueswir1 | \ |
586 | 44e7757c | blueswir1 | DT0 = d.d; \ |
587 | 44e7757c | blueswir1 | } \ |
588 | 44e7757c | blueswir1 | \ |
589 | 44e7757c | blueswir1 | void name##32(void) \ |
590 | 44e7757c | blueswir1 | { \ |
591 | 44e7757c | blueswir1 | vis64 s, d; \ |
592 | 44e7757c | blueswir1 | \ |
593 | 44e7757c | blueswir1 | s.d = DT0; \ |
594 | 44e7757c | blueswir1 | d.d = DT1; \ |
595 | 44e7757c | blueswir1 | \ |
596 | 44e7757c | blueswir1 | d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \ |
597 | 44e7757c | blueswir1 | d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \ |
598 | 44e7757c | blueswir1 | \ |
599 | 44e7757c | blueswir1 | DT0 = d.d; \ |
600 | 44e7757c | blueswir1 | } |
601 | 44e7757c | blueswir1 | |
602 | 44e7757c | blueswir1 | #define FCMPGT(a, b) ((a) > (b))
|
603 | 44e7757c | blueswir1 | #define FCMPEQ(a, b) ((a) == (b))
|
604 | 44e7757c | blueswir1 | #define FCMPLE(a, b) ((a) <= (b))
|
605 | 44e7757c | blueswir1 | #define FCMPNE(a, b) ((a) != (b))
|
606 | 44e7757c | blueswir1 | |
607 | 44e7757c | blueswir1 | VIS_CMPHELPER(helper_fcmpgt, FCMPGT) |
608 | 44e7757c | blueswir1 | VIS_CMPHELPER(helper_fcmpeq, FCMPEQ) |
609 | 44e7757c | blueswir1 | VIS_CMPHELPER(helper_fcmple, FCMPLE) |
610 | 44e7757c | blueswir1 | VIS_CMPHELPER(helper_fcmpne, FCMPNE) |
611 | 44e7757c | blueswir1 | #endif
|
612 | 44e7757c | blueswir1 | |
613 | 44e7757c | blueswir1 | void helper_check_ieee_exceptions(void) |
614 | 44e7757c | blueswir1 | { |
615 | 44e7757c | blueswir1 | target_ulong status; |
616 | 44e7757c | blueswir1 | |
617 | 44e7757c | blueswir1 | status = get_float_exception_flags(&env->fp_status); |
618 | 44e7757c | blueswir1 | if (status) {
|
619 | 44e7757c | blueswir1 | /* Copy IEEE 754 flags into FSR */
|
620 | 44e7757c | blueswir1 | if (status & float_flag_invalid)
|
621 | 44e7757c | blueswir1 | env->fsr |= FSR_NVC; |
622 | 44e7757c | blueswir1 | if (status & float_flag_overflow)
|
623 | 44e7757c | blueswir1 | env->fsr |= FSR_OFC; |
624 | 44e7757c | blueswir1 | if (status & float_flag_underflow)
|
625 | 44e7757c | blueswir1 | env->fsr |= FSR_UFC; |
626 | 44e7757c | blueswir1 | if (status & float_flag_divbyzero)
|
627 | 44e7757c | blueswir1 | env->fsr |= FSR_DZC; |
628 | 44e7757c | blueswir1 | if (status & float_flag_inexact)
|
629 | 44e7757c | blueswir1 | env->fsr |= FSR_NXC; |
630 | 44e7757c | blueswir1 | |
631 | 44e7757c | blueswir1 | if ((env->fsr & FSR_CEXC_MASK) & ((env->fsr & FSR_TEM_MASK) >> 23)) { |
632 | 44e7757c | blueswir1 | /* Unmasked exception, generate a trap */
|
633 | 44e7757c | blueswir1 | env->fsr |= FSR_FTT_IEEE_EXCP; |
634 | 44e7757c | blueswir1 | raise_exception(TT_FP_EXCP); |
635 | 44e7757c | blueswir1 | } else {
|
636 | 44e7757c | blueswir1 | /* Accumulate exceptions */
|
637 | 44e7757c | blueswir1 | env->fsr |= (env->fsr & FSR_CEXC_MASK) << 5;
|
638 | 44e7757c | blueswir1 | } |
639 | 44e7757c | blueswir1 | } |
640 | 44e7757c | blueswir1 | } |
641 | 44e7757c | blueswir1 | |
642 | 44e7757c | blueswir1 | void helper_clear_float_exceptions(void) |
643 | 44e7757c | blueswir1 | { |
644 | 44e7757c | blueswir1 | set_float_exception_flags(0, &env->fp_status);
|
645 | 44e7757c | blueswir1 | } |
646 | 44e7757c | blueswir1 | |
647 | 714547bb | blueswir1 | float32 helper_fabss(float32 src) |
648 | e8af50a3 | bellard | { |
649 | 714547bb | blueswir1 | return float32_abs(src);
|
650 | e8af50a3 | bellard | } |
651 | e8af50a3 | bellard | |
652 | 3475187d | bellard | #ifdef TARGET_SPARC64
|
653 | 7e8c2b6c | blueswir1 | void helper_fabsd(void) |
654 | 3475187d | bellard | { |
655 | 3475187d | bellard | DT0 = float64_abs(DT1); |
656 | 3475187d | bellard | } |
657 | 4e14008f | blueswir1 | |
658 | 4e14008f | blueswir1 | void helper_fabsq(void) |
659 | 4e14008f | blueswir1 | { |
660 | 4e14008f | blueswir1 | QT0 = float128_abs(QT1); |
661 | 4e14008f | blueswir1 | } |
662 | 4e14008f | blueswir1 | #endif
|
663 | 3475187d | bellard | |
664 | 714547bb | blueswir1 | float32 helper_fsqrts(float32 src) |
665 | e8af50a3 | bellard | { |
666 | 714547bb | blueswir1 | return float32_sqrt(src, &env->fp_status);
|
667 | e8af50a3 | bellard | } |
668 | e8af50a3 | bellard | |
669 | 7e8c2b6c | blueswir1 | void helper_fsqrtd(void) |
670 | e8af50a3 | bellard | { |
671 | 7a0e1f41 | bellard | DT0 = float64_sqrt(DT1, &env->fp_status); |
672 | e8af50a3 | bellard | } |
673 | e8af50a3 | bellard | |
674 | 4e14008f | blueswir1 | void helper_fsqrtq(void) |
675 | 4e14008f | blueswir1 | { |
676 | 4e14008f | blueswir1 | QT0 = float128_sqrt(QT1, &env->fp_status); |
677 | 4e14008f | blueswir1 | } |
678 | 4e14008f | blueswir1 | |
679 | 417454b0 | blueswir1 | #define GEN_FCMP(name, size, reg1, reg2, FS, TRAP) \
|
680 | 7e8c2b6c | blueswir1 | void glue(helper_, name) (void) \ |
681 | 65ce8c2f | bellard | { \ |
682 | 1a2fb1c0 | blueswir1 | target_ulong new_fsr; \ |
683 | 1a2fb1c0 | blueswir1 | \ |
684 | 65ce8c2f | bellard | env->fsr &= ~((FSR_FCC1 | FSR_FCC0) << FS); \ |
685 | 65ce8c2f | bellard | switch (glue(size, _compare) (reg1, reg2, &env->fp_status)) { \
|
686 | 65ce8c2f | bellard | case float_relation_unordered: \
|
687 | 1a2fb1c0 | blueswir1 | new_fsr = (FSR_FCC1 | FSR_FCC0) << FS; \ |
688 | 417454b0 | blueswir1 | if ((env->fsr & FSR_NVM) || TRAP) { \
|
689 | 1a2fb1c0 | blueswir1 | env->fsr |= new_fsr; \ |
690 | 417454b0 | blueswir1 | env->fsr |= FSR_NVC; \ |
691 | 417454b0 | blueswir1 | env->fsr |= FSR_FTT_IEEE_EXCP; \ |
692 | 65ce8c2f | bellard | raise_exception(TT_FP_EXCP); \ |
693 | 65ce8c2f | bellard | } else { \
|
694 | 65ce8c2f | bellard | env->fsr |= FSR_NVA; \ |
695 | 65ce8c2f | bellard | } \ |
696 | 65ce8c2f | bellard | break; \
|
697 | 65ce8c2f | bellard | case float_relation_less: \
|
698 | 1a2fb1c0 | blueswir1 | new_fsr = FSR_FCC0 << FS; \ |
699 | 65ce8c2f | bellard | break; \
|
700 | 65ce8c2f | bellard | case float_relation_greater: \
|
701 | 1a2fb1c0 | blueswir1 | new_fsr = FSR_FCC1 << FS; \ |
702 | 65ce8c2f | bellard | break; \
|
703 | 65ce8c2f | bellard | default: \
|
704 | 1a2fb1c0 | blueswir1 | new_fsr = 0; \
|
705 | 65ce8c2f | bellard | break; \
|
706 | 65ce8c2f | bellard | } \ |
707 | 1a2fb1c0 | blueswir1 | env->fsr |= new_fsr; \ |
708 | e8af50a3 | bellard | } |
709 | 714547bb | blueswir1 | #define GEN_FCMPS(name, size, FS, TRAP) \
|
710 | 714547bb | blueswir1 | void glue(helper_, name)(float32 src1, float32 src2) \
|
711 | 714547bb | blueswir1 | { \ |
712 | 714547bb | blueswir1 | target_ulong new_fsr; \ |
713 | 714547bb | blueswir1 | \ |
714 | 714547bb | blueswir1 | env->fsr &= ~((FSR_FCC1 | FSR_FCC0) << FS); \ |
715 | 714547bb | blueswir1 | switch (glue(size, _compare) (src1, src2, &env->fp_status)) { \
|
716 | 714547bb | blueswir1 | case float_relation_unordered: \
|
717 | 714547bb | blueswir1 | new_fsr = (FSR_FCC1 | FSR_FCC0) << FS; \ |
718 | 714547bb | blueswir1 | if ((env->fsr & FSR_NVM) || TRAP) { \
|
719 | 714547bb | blueswir1 | env->fsr |= new_fsr; \ |
720 | 714547bb | blueswir1 | env->fsr |= FSR_NVC; \ |
721 | 714547bb | blueswir1 | env->fsr |= FSR_FTT_IEEE_EXCP; \ |
722 | 714547bb | blueswir1 | raise_exception(TT_FP_EXCP); \ |
723 | 714547bb | blueswir1 | } else { \
|
724 | 714547bb | blueswir1 | env->fsr |= FSR_NVA; \ |
725 | 714547bb | blueswir1 | } \ |
726 | 714547bb | blueswir1 | break; \
|
727 | 714547bb | blueswir1 | case float_relation_less: \
|
728 | 714547bb | blueswir1 | new_fsr = FSR_FCC0 << FS; \ |
729 | 714547bb | blueswir1 | break; \
|
730 | 714547bb | blueswir1 | case float_relation_greater: \
|
731 | 714547bb | blueswir1 | new_fsr = FSR_FCC1 << FS; \ |
732 | 714547bb | blueswir1 | break; \
|
733 | 714547bb | blueswir1 | default: \
|
734 | 714547bb | blueswir1 | new_fsr = 0; \
|
735 | 714547bb | blueswir1 | break; \
|
736 | 714547bb | blueswir1 | } \ |
737 | 714547bb | blueswir1 | env->fsr |= new_fsr; \ |
738 | 714547bb | blueswir1 | } |
739 | e8af50a3 | bellard | |
740 | 714547bb | blueswir1 | GEN_FCMPS(fcmps, float32, 0, 0); |
741 | 417454b0 | blueswir1 | GEN_FCMP(fcmpd, float64, DT0, DT1, 0, 0); |
742 | 417454b0 | blueswir1 | |
743 | 714547bb | blueswir1 | GEN_FCMPS(fcmpes, float32, 0, 1); |
744 | 417454b0 | blueswir1 | GEN_FCMP(fcmped, float64, DT0, DT1, 0, 1); |
745 | 3475187d | bellard | |
746 | 4e14008f | blueswir1 | GEN_FCMP(fcmpq, float128, QT0, QT1, 0, 0); |
747 | 4e14008f | blueswir1 | GEN_FCMP(fcmpeq, float128, QT0, QT1, 0, 1); |
748 | 4e14008f | blueswir1 | |
749 | 8393617c | Blue Swirl | static uint32_t compute_all_flags(void) |
750 | 8393617c | Blue Swirl | { |
751 | 8393617c | Blue Swirl | return env->psr & PSR_ICC;
|
752 | 8393617c | Blue Swirl | } |
753 | 8393617c | Blue Swirl | |
754 | 8393617c | Blue Swirl | static uint32_t compute_C_flags(void) |
755 | 8393617c | Blue Swirl | { |
756 | 8393617c | Blue Swirl | return env->psr & PSR_CARRY;
|
757 | 8393617c | Blue Swirl | } |
758 | 8393617c | Blue Swirl | |
759 | bdf9f35d | Blue Swirl | static inline uint32_t get_NZ_icc(target_ulong dst) |
760 | bdf9f35d | Blue Swirl | { |
761 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
762 | bdf9f35d | Blue Swirl | |
763 | bdf9f35d | Blue Swirl | if (!(dst & 0xffffffffULL)) |
764 | bdf9f35d | Blue Swirl | ret |= PSR_ZERO; |
765 | bdf9f35d | Blue Swirl | if ((int32_t) (dst & 0xffffffffULL) < 0) |
766 | bdf9f35d | Blue Swirl | ret |= PSR_NEG; |
767 | bdf9f35d | Blue Swirl | return ret;
|
768 | bdf9f35d | Blue Swirl | } |
769 | bdf9f35d | Blue Swirl | |
770 | 8393617c | Blue Swirl | #ifdef TARGET_SPARC64
|
771 | 8393617c | Blue Swirl | static uint32_t compute_all_flags_xcc(void) |
772 | 8393617c | Blue Swirl | { |
773 | 8393617c | Blue Swirl | return env->xcc & PSR_ICC;
|
774 | 8393617c | Blue Swirl | } |
775 | 8393617c | Blue Swirl | |
776 | 8393617c | Blue Swirl | static uint32_t compute_C_flags_xcc(void) |
777 | 8393617c | Blue Swirl | { |
778 | 8393617c | Blue Swirl | return env->xcc & PSR_CARRY;
|
779 | 8393617c | Blue Swirl | } |
780 | 8393617c | Blue Swirl | |
781 | bdf9f35d | Blue Swirl | static inline uint32_t get_NZ_xcc(target_ulong dst) |
782 | bdf9f35d | Blue Swirl | { |
783 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
784 | bdf9f35d | Blue Swirl | |
785 | bdf9f35d | Blue Swirl | if (!dst)
|
786 | bdf9f35d | Blue Swirl | ret |= PSR_ZERO; |
787 | bdf9f35d | Blue Swirl | if ((int64_t)dst < 0) |
788 | bdf9f35d | Blue Swirl | ret |= PSR_NEG; |
789 | bdf9f35d | Blue Swirl | return ret;
|
790 | bdf9f35d | Blue Swirl | } |
791 | bdf9f35d | Blue Swirl | #endif
|
792 | bdf9f35d | Blue Swirl | |
793 | bdf9f35d | Blue Swirl | static inline uint32_t get_C_add_icc(target_ulong dst, target_ulong src1) |
794 | bdf9f35d | Blue Swirl | { |
795 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
796 | bdf9f35d | Blue Swirl | |
797 | bdf9f35d | Blue Swirl | if ((dst & 0xffffffffULL) < (src1 & 0xffffffffULL)) |
798 | bdf9f35d | Blue Swirl | ret |= PSR_CARRY; |
799 | bdf9f35d | Blue Swirl | return ret;
|
800 | bdf9f35d | Blue Swirl | } |
801 | bdf9f35d | Blue Swirl | |
802 | bdf9f35d | Blue Swirl | static inline uint32_t get_V_add_icc(target_ulong dst, target_ulong src1, |
803 | bdf9f35d | Blue Swirl | target_ulong src2) |
804 | bdf9f35d | Blue Swirl | { |
805 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
806 | bdf9f35d | Blue Swirl | |
807 | bdf9f35d | Blue Swirl | if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1ULL << 31)) |
808 | bdf9f35d | Blue Swirl | ret |= PSR_OVF; |
809 | bdf9f35d | Blue Swirl | return ret;
|
810 | bdf9f35d | Blue Swirl | } |
811 | bdf9f35d | Blue Swirl | |
812 | bdf9f35d | Blue Swirl | static uint32_t compute_all_add(void) |
813 | bdf9f35d | Blue Swirl | { |
814 | bdf9f35d | Blue Swirl | uint32_t ret; |
815 | bdf9f35d | Blue Swirl | |
816 | bdf9f35d | Blue Swirl | ret = get_NZ_icc(CC_DST); |
817 | bdf9f35d | Blue Swirl | ret |= get_C_add_icc(CC_DST, CC_SRC); |
818 | bdf9f35d | Blue Swirl | ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); |
819 | bdf9f35d | Blue Swirl | return ret;
|
820 | bdf9f35d | Blue Swirl | } |
821 | bdf9f35d | Blue Swirl | |
822 | bdf9f35d | Blue Swirl | static uint32_t compute_C_add(void) |
823 | bdf9f35d | Blue Swirl | { |
824 | bdf9f35d | Blue Swirl | return get_C_add_icc(CC_DST, CC_SRC);
|
825 | bdf9f35d | Blue Swirl | } |
826 | bdf9f35d | Blue Swirl | |
827 | bdf9f35d | Blue Swirl | #ifdef TARGET_SPARC64
|
828 | bdf9f35d | Blue Swirl | static inline uint32_t get_C_add_xcc(target_ulong dst, target_ulong src1) |
829 | bdf9f35d | Blue Swirl | { |
830 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
831 | bdf9f35d | Blue Swirl | |
832 | bdf9f35d | Blue Swirl | if (dst < src1)
|
833 | bdf9f35d | Blue Swirl | ret |= PSR_CARRY; |
834 | bdf9f35d | Blue Swirl | return ret;
|
835 | bdf9f35d | Blue Swirl | } |
836 | bdf9f35d | Blue Swirl | |
837 | bdf9f35d | Blue Swirl | static inline uint32_t get_V_add_xcc(target_ulong dst, target_ulong src1, |
838 | bdf9f35d | Blue Swirl | target_ulong src2) |
839 | bdf9f35d | Blue Swirl | { |
840 | bdf9f35d | Blue Swirl | uint32_t ret = 0;
|
841 | bdf9f35d | Blue Swirl | |
842 | bdf9f35d | Blue Swirl | if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1ULL << 63)) |
843 | bdf9f35d | Blue Swirl | ret |= PSR_OVF; |
844 | bdf9f35d | Blue Swirl | return ret;
|
845 | bdf9f35d | Blue Swirl | } |
846 | bdf9f35d | Blue Swirl | |
847 | bdf9f35d | Blue Swirl | static uint32_t compute_all_add_xcc(void) |
848 | bdf9f35d | Blue Swirl | { |
849 | bdf9f35d | Blue Swirl | uint32_t ret; |
850 | bdf9f35d | Blue Swirl | |
851 | bdf9f35d | Blue Swirl | ret = get_NZ_xcc(CC_DST); |
852 | bdf9f35d | Blue Swirl | ret |= get_C_add_xcc(CC_DST, CC_SRC); |
853 | bdf9f35d | Blue Swirl | ret |= get_V_add_xcc(CC_DST, CC_SRC, CC_SRC2); |
854 | bdf9f35d | Blue Swirl | return ret;
|
855 | bdf9f35d | Blue Swirl | } |
856 | bdf9f35d | Blue Swirl | |
857 | bdf9f35d | Blue Swirl | static uint32_t compute_C_add_xcc(void) |
858 | bdf9f35d | Blue Swirl | { |
859 | bdf9f35d | Blue Swirl | return get_C_add_xcc(CC_DST, CC_SRC);
|
860 | bdf9f35d | Blue Swirl | } |
861 | 8393617c | Blue Swirl | #endif
|
862 | 8393617c | Blue Swirl | |
863 | 8393617c | Blue Swirl | typedef struct CCTable { |
864 | 8393617c | Blue Swirl | uint32_t (*compute_all)(void); /* return all the flags */ |
865 | 8393617c | Blue Swirl | uint32_t (*compute_c)(void); /* return the C flag */ |
866 | 8393617c | Blue Swirl | } CCTable; |
867 | 8393617c | Blue Swirl | |
868 | 8393617c | Blue Swirl | static const CCTable icc_table[CC_OP_NB] = { |
869 | 8393617c | Blue Swirl | /* CC_OP_DYNAMIC should never happen */
|
870 | 8393617c | Blue Swirl | [CC_OP_FLAGS] = { compute_all_flags, compute_C_flags }, |
871 | bdf9f35d | Blue Swirl | [CC_OP_ADD] = { compute_all_add, compute_C_add }, |
872 | 8393617c | Blue Swirl | }; |
873 | 8393617c | Blue Swirl | |
874 | 8393617c | Blue Swirl | #ifdef TARGET_SPARC64
|
875 | 8393617c | Blue Swirl | static const CCTable xcc_table[CC_OP_NB] = { |
876 | 8393617c | Blue Swirl | /* CC_OP_DYNAMIC should never happen */
|
877 | 8393617c | Blue Swirl | [CC_OP_FLAGS] = { compute_all_flags_xcc, compute_C_flags_xcc }, |
878 | bdf9f35d | Blue Swirl | [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, |
879 | 8393617c | Blue Swirl | }; |
880 | 8393617c | Blue Swirl | #endif
|
881 | 8393617c | Blue Swirl | |
882 | 8393617c | Blue Swirl | void helper_compute_psr(void) |
883 | 8393617c | Blue Swirl | { |
884 | 8393617c | Blue Swirl | uint32_t new_psr; |
885 | 8393617c | Blue Swirl | |
886 | 8393617c | Blue Swirl | new_psr = icc_table[CC_OP].compute_all(); |
887 | 8393617c | Blue Swirl | env->psr = new_psr; |
888 | 8393617c | Blue Swirl | #ifdef TARGET_SPARC64
|
889 | 8393617c | Blue Swirl | new_psr = xcc_table[CC_OP].compute_all(); |
890 | 8393617c | Blue Swirl | env->xcc = new_psr; |
891 | 8393617c | Blue Swirl | #endif
|
892 | 8393617c | Blue Swirl | CC_OP = CC_OP_FLAGS; |
893 | 8393617c | Blue Swirl | } |
894 | 8393617c | Blue Swirl | |
895 | 8393617c | Blue Swirl | uint32_t helper_compute_C_icc(void)
|
896 | 8393617c | Blue Swirl | { |
897 | 8393617c | Blue Swirl | uint32_t ret; |
898 | 8393617c | Blue Swirl | |
899 | 8393617c | Blue Swirl | ret = icc_table[CC_OP].compute_c() >> PSR_CARRY_SHIFT; |
900 | 8393617c | Blue Swirl | return ret;
|
901 | 8393617c | Blue Swirl | } |
902 | 8393617c | Blue Swirl | |
903 | 3475187d | bellard | #ifdef TARGET_SPARC64
|
904 | 714547bb | blueswir1 | GEN_FCMPS(fcmps_fcc1, float32, 22, 0); |
905 | 417454b0 | blueswir1 | GEN_FCMP(fcmpd_fcc1, float64, DT0, DT1, 22, 0); |
906 | 64a88d5d | blueswir1 | GEN_FCMP(fcmpq_fcc1, float128, QT0, QT1, 22, 0); |
907 | 417454b0 | blueswir1 | |
908 | 714547bb | blueswir1 | GEN_FCMPS(fcmps_fcc2, float32, 24, 0); |
909 | 417454b0 | blueswir1 | GEN_FCMP(fcmpd_fcc2, float64, DT0, DT1, 24, 0); |
910 | 64a88d5d | blueswir1 | GEN_FCMP(fcmpq_fcc2, float128, QT0, QT1, 24, 0); |
911 | 417454b0 | blueswir1 | |
912 | 714547bb | blueswir1 | GEN_FCMPS(fcmps_fcc3, float32, 26, 0); |
913 | 417454b0 | blueswir1 | GEN_FCMP(fcmpd_fcc3, float64, DT0, DT1, 26, 0); |
914 | 64a88d5d | blueswir1 | GEN_FCMP(fcmpq_fcc3, float128, QT0, QT1, 26, 0); |
915 | 417454b0 | blueswir1 | |
916 | 714547bb | blueswir1 | GEN_FCMPS(fcmpes_fcc1, float32, 22, 1); |
917 | 417454b0 | blueswir1 | GEN_FCMP(fcmped_fcc1, float64, DT0, DT1, 22, 1); |
918 | 64a88d5d | blueswir1 | GEN_FCMP(fcmpeq_fcc1, float128, QT0, QT1, 22, 1); |
919 | 3475187d | bellard | |
920 | 714547bb | blueswir1 | GEN_FCMPS(fcmpes_fcc2, float32, 24, 1); |
921 | 417454b0 | blueswir1 | GEN_FCMP(fcmped_fcc2, float64, DT0, DT1, 24, 1); |
922 | 64a88d5d | blueswir1 | GEN_FCMP(fcmpeq_fcc2, float128, QT0, QT1, 24, 1); |
923 | 3475187d | bellard | |
924 | 714547bb | blueswir1 | GEN_FCMPS(fcmpes_fcc3, float32, 26, 1); |
925 | 417454b0 | blueswir1 | GEN_FCMP(fcmped_fcc3, float64, DT0, DT1, 26, 1); |
926 | 4e14008f | blueswir1 | GEN_FCMP(fcmpeq_fcc3, float128, QT0, QT1, 26, 1); |
927 | 4e14008f | blueswir1 | #endif
|
928 | 714547bb | blueswir1 | #undef GEN_FCMPS
|
929 | 3475187d | bellard | |
930 | 77f193da | blueswir1 | #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) && \
|
931 | 77f193da | blueswir1 | defined(DEBUG_MXCC) |
932 | 952a328f | blueswir1 | static void dump_mxcc(CPUState *env) |
933 | 952a328f | blueswir1 | { |
934 | 952a328f | blueswir1 | printf("mxccdata: %016llx %016llx %016llx %016llx\n",
|
935 | 77f193da | blueswir1 | env->mxccdata[0], env->mxccdata[1], |
936 | 77f193da | blueswir1 | env->mxccdata[2], env->mxccdata[3]); |
937 | 952a328f | blueswir1 | printf("mxccregs: %016llx %016llx %016llx %016llx\n"
|
938 | 952a328f | blueswir1 | " %016llx %016llx %016llx %016llx\n",
|
939 | 77f193da | blueswir1 | env->mxccregs[0], env->mxccregs[1], |
940 | 77f193da | blueswir1 | env->mxccregs[2], env->mxccregs[3], |
941 | 77f193da | blueswir1 | env->mxccregs[4], env->mxccregs[5], |
942 | 77f193da | blueswir1 | env->mxccregs[6], env->mxccregs[7]); |
943 | 952a328f | blueswir1 | } |
944 | 952a328f | blueswir1 | #endif
|
945 | 952a328f | blueswir1 | |
946 | 1a2fb1c0 | blueswir1 | #if (defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)) \
|
947 | 1a2fb1c0 | blueswir1 | && defined(DEBUG_ASI) |
948 | 1a2fb1c0 | blueswir1 | static void dump_asi(const char *txt, target_ulong addr, int asi, int size, |
949 | 1a2fb1c0 | blueswir1 | uint64_t r1) |
950 | 8543e2cf | blueswir1 | { |
951 | 8543e2cf | blueswir1 | switch (size)
|
952 | 8543e2cf | blueswir1 | { |
953 | 8543e2cf | blueswir1 | case 1: |
954 | 1a2fb1c0 | blueswir1 | DPRINTF_ASI("%s "TARGET_FMT_lx " asi 0x%02x = %02" PRIx64 "\n", txt, |
955 | 1a2fb1c0 | blueswir1 | addr, asi, r1 & 0xff);
|
956 | 8543e2cf | blueswir1 | break;
|
957 | 8543e2cf | blueswir1 | case 2: |
958 | 1a2fb1c0 | blueswir1 | DPRINTF_ASI("%s "TARGET_FMT_lx " asi 0x%02x = %04" PRIx64 "\n", txt, |
959 | 1a2fb1c0 | blueswir1 | addr, asi, r1 & 0xffff);
|
960 | 8543e2cf | blueswir1 | break;
|
961 | 8543e2cf | blueswir1 | case 4: |
962 | 1a2fb1c0 | blueswir1 | DPRINTF_ASI("%s "TARGET_FMT_lx " asi 0x%02x = %08" PRIx64 "\n", txt, |
963 | 1a2fb1c0 | blueswir1 | addr, asi, r1 & 0xffffffff);
|
964 | 8543e2cf | blueswir1 | break;
|
965 | 8543e2cf | blueswir1 | case 8: |
966 | 1a2fb1c0 | blueswir1 | DPRINTF_ASI("%s "TARGET_FMT_lx " asi 0x%02x = %016" PRIx64 "\n", txt, |
967 | 1a2fb1c0 | blueswir1 | addr, asi, r1); |
968 | 8543e2cf | blueswir1 | break;
|
969 | 8543e2cf | blueswir1 | } |
970 | 8543e2cf | blueswir1 | } |
971 | 8543e2cf | blueswir1 | #endif
|
972 | 8543e2cf | blueswir1 | |
973 | 1a2fb1c0 | blueswir1 | #ifndef TARGET_SPARC64
|
974 | 1a2fb1c0 | blueswir1 | #ifndef CONFIG_USER_ONLY
|
975 | 1a2fb1c0 | blueswir1 | uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) |
976 | e8af50a3 | bellard | { |
977 | 1a2fb1c0 | blueswir1 | uint64_t ret = 0;
|
978 | 8543e2cf | blueswir1 | #if defined(DEBUG_MXCC) || defined(DEBUG_ASI)
|
979 | 1a2fb1c0 | blueswir1 | uint32_t last_addr = addr; |
980 | 952a328f | blueswir1 | #endif
|
981 | e80cfcfc | bellard | |
982 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
983 | e80cfcfc | bellard | switch (asi) {
|
984 | 6c36d3fa | blueswir1 | case 2: /* SuperSparc MXCC registers */ |
985 | 1a2fb1c0 | blueswir1 | switch (addr) {
|
986 | 952a328f | blueswir1 | case 0x01c00a00: /* MXCC control register */ |
987 | 1a2fb1c0 | blueswir1 | if (size == 8) |
988 | 1a2fb1c0 | blueswir1 | ret = env->mxccregs[3];
|
989 | 1a2fb1c0 | blueswir1 | else
|
990 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
991 | 77f193da | blueswir1 | size); |
992 | 952a328f | blueswir1 | break;
|
993 | 952a328f | blueswir1 | case 0x01c00a04: /* MXCC control register */ |
994 | 952a328f | blueswir1 | if (size == 4) |
995 | 952a328f | blueswir1 | ret = env->mxccregs[3];
|
996 | 952a328f | blueswir1 | else
|
997 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
998 | 77f193da | blueswir1 | size); |
999 | 952a328f | blueswir1 | break;
|
1000 | 295db113 | blueswir1 | case 0x01c00c00: /* Module reset register */ |
1001 | 295db113 | blueswir1 | if (size == 8) { |
1002 | 1a2fb1c0 | blueswir1 | ret = env->mxccregs[5];
|
1003 | 295db113 | blueswir1 | // should we do something here?
|
1004 | 295db113 | blueswir1 | } else
|
1005 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1006 | 77f193da | blueswir1 | size); |
1007 | 295db113 | blueswir1 | break;
|
1008 | 952a328f | blueswir1 | case 0x01c00f00: /* MBus port address register */ |
1009 | 1a2fb1c0 | blueswir1 | if (size == 8) |
1010 | 1a2fb1c0 | blueswir1 | ret = env->mxccregs[7];
|
1011 | 1a2fb1c0 | blueswir1 | else
|
1012 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1013 | 77f193da | blueswir1 | size); |
1014 | 952a328f | blueswir1 | break;
|
1015 | 952a328f | blueswir1 | default:
|
1016 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr,
|
1017 | 77f193da | blueswir1 | size); |
1018 | 952a328f | blueswir1 | break;
|
1019 | 952a328f | blueswir1 | } |
1020 | 77f193da | blueswir1 | DPRINTF_MXCC("asi = %d, size = %d, sign = %d, "
|
1021 | 9827e450 | blueswir1 | "addr = %08x -> ret = %" PRIx64 "," |
1022 | 1a2fb1c0 | blueswir1 | "addr = %08x\n", asi, size, sign, last_addr, ret, addr);
|
1023 | 952a328f | blueswir1 | #ifdef DEBUG_MXCC
|
1024 | 952a328f | blueswir1 | dump_mxcc(env); |
1025 | 952a328f | blueswir1 | #endif
|
1026 | 6c36d3fa | blueswir1 | break;
|
1027 | e8af50a3 | bellard | case 3: /* MMU probe */ |
1028 | 0f8a249a | blueswir1 | { |
1029 | 0f8a249a | blueswir1 | int mmulev;
|
1030 | 0f8a249a | blueswir1 | |
1031 | 1a2fb1c0 | blueswir1 | mmulev = (addr >> 8) & 15; |
1032 | 0f8a249a | blueswir1 | if (mmulev > 4) |
1033 | 0f8a249a | blueswir1 | ret = 0;
|
1034 | 1a2fb1c0 | blueswir1 | else
|
1035 | 1a2fb1c0 | blueswir1 | ret = mmu_probe(env, addr, mmulev); |
1036 | 1a2fb1c0 | blueswir1 | DPRINTF_MMU("mmu_probe: 0x%08x (lev %d) -> 0x%08" PRIx64 "\n", |
1037 | 1a2fb1c0 | blueswir1 | addr, mmulev, ret); |
1038 | 0f8a249a | blueswir1 | } |
1039 | 0f8a249a | blueswir1 | break;
|
1040 | e8af50a3 | bellard | case 4: /* read MMU regs */ |
1041 | 0f8a249a | blueswir1 | { |
1042 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 8) & 0x1f; |
1043 | 3b46e624 | ths | |
1044 | 0f8a249a | blueswir1 | ret = env->mmuregs[reg]; |
1045 | 0f8a249a | blueswir1 | if (reg == 3) /* Fault status cleared on read */ |
1046 | 3dd9a152 | blueswir1 | env->mmuregs[3] = 0; |
1047 | 3dd9a152 | blueswir1 | else if (reg == 0x13) /* Fault status read */ |
1048 | 3dd9a152 | blueswir1 | ret = env->mmuregs[3];
|
1049 | 3dd9a152 | blueswir1 | else if (reg == 0x14) /* Fault address read */ |
1050 | 3dd9a152 | blueswir1 | ret = env->mmuregs[4];
|
1051 | 1a2fb1c0 | blueswir1 | DPRINTF_MMU("mmu_read: reg[%d] = 0x%08" PRIx64 "\n", reg, ret); |
1052 | 0f8a249a | blueswir1 | } |
1053 | 0f8a249a | blueswir1 | break;
|
1054 | 045380be | blueswir1 | case 5: // Turbosparc ITLB Diagnostic |
1055 | 045380be | blueswir1 | case 6: // Turbosparc DTLB Diagnostic |
1056 | 045380be | blueswir1 | case 7: // Turbosparc IOTLB Diagnostic |
1057 | 045380be | blueswir1 | break;
|
1058 | 6c36d3fa | blueswir1 | case 9: /* Supervisor code access */ |
1059 | 6c36d3fa | blueswir1 | switch(size) {
|
1060 | 6c36d3fa | blueswir1 | case 1: |
1061 | 1a2fb1c0 | blueswir1 | ret = ldub_code(addr); |
1062 | 6c36d3fa | blueswir1 | break;
|
1063 | 6c36d3fa | blueswir1 | case 2: |
1064 | a4e7dd52 | blueswir1 | ret = lduw_code(addr); |
1065 | 6c36d3fa | blueswir1 | break;
|
1066 | 6c36d3fa | blueswir1 | default:
|
1067 | 6c36d3fa | blueswir1 | case 4: |
1068 | a4e7dd52 | blueswir1 | ret = ldl_code(addr); |
1069 | 6c36d3fa | blueswir1 | break;
|
1070 | 6c36d3fa | blueswir1 | case 8: |
1071 | a4e7dd52 | blueswir1 | ret = ldq_code(addr); |
1072 | 6c36d3fa | blueswir1 | break;
|
1073 | 6c36d3fa | blueswir1 | } |
1074 | 6c36d3fa | blueswir1 | break;
|
1075 | 81ad8ba2 | blueswir1 | case 0xa: /* User data access */ |
1076 | 81ad8ba2 | blueswir1 | switch(size) {
|
1077 | 81ad8ba2 | blueswir1 | case 1: |
1078 | 1a2fb1c0 | blueswir1 | ret = ldub_user(addr); |
1079 | 81ad8ba2 | blueswir1 | break;
|
1080 | 81ad8ba2 | blueswir1 | case 2: |
1081 | a4e7dd52 | blueswir1 | ret = lduw_user(addr); |
1082 | 81ad8ba2 | blueswir1 | break;
|
1083 | 81ad8ba2 | blueswir1 | default:
|
1084 | 81ad8ba2 | blueswir1 | case 4: |
1085 | a4e7dd52 | blueswir1 | ret = ldl_user(addr); |
1086 | 81ad8ba2 | blueswir1 | break;
|
1087 | 81ad8ba2 | blueswir1 | case 8: |
1088 | a4e7dd52 | blueswir1 | ret = ldq_user(addr); |
1089 | 81ad8ba2 | blueswir1 | break;
|
1090 | 81ad8ba2 | blueswir1 | } |
1091 | 81ad8ba2 | blueswir1 | break;
|
1092 | 81ad8ba2 | blueswir1 | case 0xb: /* Supervisor data access */ |
1093 | 81ad8ba2 | blueswir1 | switch(size) {
|
1094 | 81ad8ba2 | blueswir1 | case 1: |
1095 | 1a2fb1c0 | blueswir1 | ret = ldub_kernel(addr); |
1096 | 81ad8ba2 | blueswir1 | break;
|
1097 | 81ad8ba2 | blueswir1 | case 2: |
1098 | a4e7dd52 | blueswir1 | ret = lduw_kernel(addr); |
1099 | 81ad8ba2 | blueswir1 | break;
|
1100 | 81ad8ba2 | blueswir1 | default:
|
1101 | 81ad8ba2 | blueswir1 | case 4: |
1102 | a4e7dd52 | blueswir1 | ret = ldl_kernel(addr); |
1103 | 81ad8ba2 | blueswir1 | break;
|
1104 | 81ad8ba2 | blueswir1 | case 8: |
1105 | a4e7dd52 | blueswir1 | ret = ldq_kernel(addr); |
1106 | 81ad8ba2 | blueswir1 | break;
|
1107 | 81ad8ba2 | blueswir1 | } |
1108 | 81ad8ba2 | blueswir1 | break;
|
1109 | 6c36d3fa | blueswir1 | case 0xc: /* I-cache tag */ |
1110 | 6c36d3fa | blueswir1 | case 0xd: /* I-cache data */ |
1111 | 6c36d3fa | blueswir1 | case 0xe: /* D-cache tag */ |
1112 | 6c36d3fa | blueswir1 | case 0xf: /* D-cache data */ |
1113 | 6c36d3fa | blueswir1 | break;
|
1114 | 6c36d3fa | blueswir1 | case 0x20: /* MMU passthrough */ |
1115 | 02aab46a | bellard | switch(size) {
|
1116 | 02aab46a | bellard | case 1: |
1117 | 1a2fb1c0 | blueswir1 | ret = ldub_phys(addr); |
1118 | 02aab46a | bellard | break;
|
1119 | 02aab46a | bellard | case 2: |
1120 | a4e7dd52 | blueswir1 | ret = lduw_phys(addr); |
1121 | 02aab46a | bellard | break;
|
1122 | 02aab46a | bellard | default:
|
1123 | 02aab46a | bellard | case 4: |
1124 | a4e7dd52 | blueswir1 | ret = ldl_phys(addr); |
1125 | 02aab46a | bellard | break;
|
1126 | 9e61bde5 | bellard | case 8: |
1127 | a4e7dd52 | blueswir1 | ret = ldq_phys(addr); |
1128 | 0f8a249a | blueswir1 | break;
|
1129 | 02aab46a | bellard | } |
1130 | 0f8a249a | blueswir1 | break;
|
1131 | 7d85892b | blueswir1 | case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */ |
1132 | 5dcb6b91 | blueswir1 | switch(size) {
|
1133 | 5dcb6b91 | blueswir1 | case 1: |
1134 | 1a2fb1c0 | blueswir1 | ret = ldub_phys((target_phys_addr_t)addr |
1135 | 5dcb6b91 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32)); |
1136 | 5dcb6b91 | blueswir1 | break;
|
1137 | 5dcb6b91 | blueswir1 | case 2: |
1138 | a4e7dd52 | blueswir1 | ret = lduw_phys((target_phys_addr_t)addr |
1139 | 5dcb6b91 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32)); |
1140 | 5dcb6b91 | blueswir1 | break;
|
1141 | 5dcb6b91 | blueswir1 | default:
|
1142 | 5dcb6b91 | blueswir1 | case 4: |
1143 | a4e7dd52 | blueswir1 | ret = ldl_phys((target_phys_addr_t)addr |
1144 | 5dcb6b91 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32)); |
1145 | 5dcb6b91 | blueswir1 | break;
|
1146 | 5dcb6b91 | blueswir1 | case 8: |
1147 | a4e7dd52 | blueswir1 | ret = ldq_phys((target_phys_addr_t)addr |
1148 | 5dcb6b91 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32)); |
1149 | 0f8a249a | blueswir1 | break;
|
1150 | 5dcb6b91 | blueswir1 | } |
1151 | 0f8a249a | blueswir1 | break;
|
1152 | 045380be | blueswir1 | case 0x30: // Turbosparc secondary cache diagnostic |
1153 | 045380be | blueswir1 | case 0x31: // Turbosparc RAM snoop |
1154 | 045380be | blueswir1 | case 0x32: // Turbosparc page table descriptor diagnostic |
1155 | 666c87aa | blueswir1 | case 0x39: /* data cache diagnostic register */ |
1156 | 666c87aa | blueswir1 | ret = 0;
|
1157 | 666c87aa | blueswir1 | break;
|
1158 | 4017190e | blueswir1 | case 0x38: /* SuperSPARC MMU Breakpoint Control Registers */ |
1159 | 4017190e | blueswir1 | { |
1160 | 4017190e | blueswir1 | int reg = (addr >> 8) & 3; |
1161 | 4017190e | blueswir1 | |
1162 | 4017190e | blueswir1 | switch(reg) {
|
1163 | 4017190e | blueswir1 | case 0: /* Breakpoint Value (Addr) */ |
1164 | 4017190e | blueswir1 | ret = env->mmubpregs[reg]; |
1165 | 4017190e | blueswir1 | break;
|
1166 | 4017190e | blueswir1 | case 1: /* Breakpoint Mask */ |
1167 | 4017190e | blueswir1 | ret = env->mmubpregs[reg]; |
1168 | 4017190e | blueswir1 | break;
|
1169 | 4017190e | blueswir1 | case 2: /* Breakpoint Control */ |
1170 | 4017190e | blueswir1 | ret = env->mmubpregs[reg]; |
1171 | 4017190e | blueswir1 | break;
|
1172 | 4017190e | blueswir1 | case 3: /* Breakpoint Status */ |
1173 | 4017190e | blueswir1 | ret = env->mmubpregs[reg]; |
1174 | 4017190e | blueswir1 | env->mmubpregs[reg] = 0ULL;
|
1175 | 4017190e | blueswir1 | break;
|
1176 | 4017190e | blueswir1 | } |
1177 | 4017190e | blueswir1 | DPRINTF_MMU("read breakpoint reg[%d] 0x%016llx\n", reg, ret);
|
1178 | 4017190e | blueswir1 | } |
1179 | 4017190e | blueswir1 | break;
|
1180 | 045380be | blueswir1 | case 8: /* User code access, XXX */ |
1181 | e8af50a3 | bellard | default:
|
1182 | e18231a3 | blueswir1 | do_unassigned_access(addr, 0, 0, asi, size); |
1183 | 0f8a249a | blueswir1 | ret = 0;
|
1184 | 0f8a249a | blueswir1 | break;
|
1185 | e8af50a3 | bellard | } |
1186 | 81ad8ba2 | blueswir1 | if (sign) {
|
1187 | 81ad8ba2 | blueswir1 | switch(size) {
|
1188 | 81ad8ba2 | blueswir1 | case 1: |
1189 | 1a2fb1c0 | blueswir1 | ret = (int8_t) ret; |
1190 | e32664fb | blueswir1 | break;
|
1191 | 81ad8ba2 | blueswir1 | case 2: |
1192 | 1a2fb1c0 | blueswir1 | ret = (int16_t) ret; |
1193 | 1a2fb1c0 | blueswir1 | break;
|
1194 | 1a2fb1c0 | blueswir1 | case 4: |
1195 | 1a2fb1c0 | blueswir1 | ret = (int32_t) ret; |
1196 | e32664fb | blueswir1 | break;
|
1197 | 81ad8ba2 | blueswir1 | default:
|
1198 | 81ad8ba2 | blueswir1 | break;
|
1199 | 81ad8ba2 | blueswir1 | } |
1200 | 81ad8ba2 | blueswir1 | } |
1201 | 8543e2cf | blueswir1 | #ifdef DEBUG_ASI
|
1202 | 1a2fb1c0 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1203 | 8543e2cf | blueswir1 | #endif
|
1204 | 1a2fb1c0 | blueswir1 | return ret;
|
1205 | e8af50a3 | bellard | } |
1206 | e8af50a3 | bellard | |
1207 | 1a2fb1c0 | blueswir1 | void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size) |
1208 | e8af50a3 | bellard | { |
1209 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
1210 | e8af50a3 | bellard | switch(asi) {
|
1211 | 6c36d3fa | blueswir1 | case 2: /* SuperSparc MXCC registers */ |
1212 | 1a2fb1c0 | blueswir1 | switch (addr) {
|
1213 | 952a328f | blueswir1 | case 0x01c00000: /* MXCC stream data register 0 */ |
1214 | 952a328f | blueswir1 | if (size == 8) |
1215 | 1a2fb1c0 | blueswir1 | env->mxccdata[0] = val;
|
1216 | 952a328f | blueswir1 | else
|
1217 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1218 | 77f193da | blueswir1 | size); |
1219 | 952a328f | blueswir1 | break;
|
1220 | 952a328f | blueswir1 | case 0x01c00008: /* MXCC stream data register 1 */ |
1221 | 952a328f | blueswir1 | if (size == 8) |
1222 | 1a2fb1c0 | blueswir1 | env->mxccdata[1] = val;
|
1223 | 952a328f | blueswir1 | else
|
1224 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1225 | 77f193da | blueswir1 | size); |
1226 | 952a328f | blueswir1 | break;
|
1227 | 952a328f | blueswir1 | case 0x01c00010: /* MXCC stream data register 2 */ |
1228 | 952a328f | blueswir1 | if (size == 8) |
1229 | 1a2fb1c0 | blueswir1 | env->mxccdata[2] = val;
|
1230 | 952a328f | blueswir1 | else
|
1231 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1232 | 77f193da | blueswir1 | size); |
1233 | 952a328f | blueswir1 | break;
|
1234 | 952a328f | blueswir1 | case 0x01c00018: /* MXCC stream data register 3 */ |
1235 | 952a328f | blueswir1 | if (size == 8) |
1236 | 1a2fb1c0 | blueswir1 | env->mxccdata[3] = val;
|
1237 | 952a328f | blueswir1 | else
|
1238 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1239 | 77f193da | blueswir1 | size); |
1240 | 952a328f | blueswir1 | break;
|
1241 | 952a328f | blueswir1 | case 0x01c00100: /* MXCC stream source */ |
1242 | 952a328f | blueswir1 | if (size == 8) |
1243 | 1a2fb1c0 | blueswir1 | env->mxccregs[0] = val;
|
1244 | 952a328f | blueswir1 | else
|
1245 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1246 | 77f193da | blueswir1 | size); |
1247 | 77f193da | blueswir1 | env->mxccdata[0] = ldq_phys((env->mxccregs[0] & 0xffffffffULL) + |
1248 | 77f193da | blueswir1 | 0);
|
1249 | 77f193da | blueswir1 | env->mxccdata[1] = ldq_phys((env->mxccregs[0] & 0xffffffffULL) + |
1250 | 77f193da | blueswir1 | 8);
|
1251 | 77f193da | blueswir1 | env->mxccdata[2] = ldq_phys((env->mxccregs[0] & 0xffffffffULL) + |
1252 | 77f193da | blueswir1 | 16);
|
1253 | 77f193da | blueswir1 | env->mxccdata[3] = ldq_phys((env->mxccregs[0] & 0xffffffffULL) + |
1254 | 77f193da | blueswir1 | 24);
|
1255 | 952a328f | blueswir1 | break;
|
1256 | 952a328f | blueswir1 | case 0x01c00200: /* MXCC stream destination */ |
1257 | 952a328f | blueswir1 | if (size == 8) |
1258 | 1a2fb1c0 | blueswir1 | env->mxccregs[1] = val;
|
1259 | 952a328f | blueswir1 | else
|
1260 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1261 | 77f193da | blueswir1 | size); |
1262 | 77f193da | blueswir1 | stq_phys((env->mxccregs[1] & 0xffffffffULL) + 0, |
1263 | 77f193da | blueswir1 | env->mxccdata[0]);
|
1264 | 77f193da | blueswir1 | stq_phys((env->mxccregs[1] & 0xffffffffULL) + 8, |
1265 | 77f193da | blueswir1 | env->mxccdata[1]);
|
1266 | 77f193da | blueswir1 | stq_phys((env->mxccregs[1] & 0xffffffffULL) + 16, |
1267 | 77f193da | blueswir1 | env->mxccdata[2]);
|
1268 | 77f193da | blueswir1 | stq_phys((env->mxccregs[1] & 0xffffffffULL) + 24, |
1269 | 77f193da | blueswir1 | env->mxccdata[3]);
|
1270 | 952a328f | blueswir1 | break;
|
1271 | 952a328f | blueswir1 | case 0x01c00a00: /* MXCC control register */ |
1272 | 952a328f | blueswir1 | if (size == 8) |
1273 | 1a2fb1c0 | blueswir1 | env->mxccregs[3] = val;
|
1274 | 952a328f | blueswir1 | else
|
1275 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1276 | 77f193da | blueswir1 | size); |
1277 | 952a328f | blueswir1 | break;
|
1278 | 952a328f | blueswir1 | case 0x01c00a04: /* MXCC control register */ |
1279 | 952a328f | blueswir1 | if (size == 4) |
1280 | 9f4576f0 | blueswir1 | env->mxccregs[3] = (env->mxccregs[3] & 0xffffffff00000000ULL) |
1281 | 77f193da | blueswir1 | | val; |
1282 | 952a328f | blueswir1 | else
|
1283 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1284 | 77f193da | blueswir1 | size); |
1285 | 952a328f | blueswir1 | break;
|
1286 | 952a328f | blueswir1 | case 0x01c00e00: /* MXCC error register */ |
1287 | bbf7d96b | blueswir1 | // writing a 1 bit clears the error
|
1288 | 952a328f | blueswir1 | if (size == 8) |
1289 | 1a2fb1c0 | blueswir1 | env->mxccregs[6] &= ~val;
|
1290 | 952a328f | blueswir1 | else
|
1291 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1292 | 77f193da | blueswir1 | size); |
1293 | 952a328f | blueswir1 | break;
|
1294 | 952a328f | blueswir1 | case 0x01c00f00: /* MBus port address register */ |
1295 | 952a328f | blueswir1 | if (size == 8) |
1296 | 1a2fb1c0 | blueswir1 | env->mxccregs[7] = val;
|
1297 | 952a328f | blueswir1 | else
|
1298 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr,
|
1299 | 77f193da | blueswir1 | size); |
1300 | 952a328f | blueswir1 | break;
|
1301 | 952a328f | blueswir1 | default:
|
1302 | 77f193da | blueswir1 | DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr,
|
1303 | 77f193da | blueswir1 | size); |
1304 | 952a328f | blueswir1 | break;
|
1305 | 952a328f | blueswir1 | } |
1306 | 9827e450 | blueswir1 | DPRINTF_MXCC("asi = %d, size = %d, addr = %08x, val = %" PRIx64 "\n", |
1307 | 9827e450 | blueswir1 | asi, size, addr, val); |
1308 | 952a328f | blueswir1 | #ifdef DEBUG_MXCC
|
1309 | 952a328f | blueswir1 | dump_mxcc(env); |
1310 | 952a328f | blueswir1 | #endif
|
1311 | 6c36d3fa | blueswir1 | break;
|
1312 | e8af50a3 | bellard | case 3: /* MMU flush */ |
1313 | 0f8a249a | blueswir1 | { |
1314 | 0f8a249a | blueswir1 | int mmulev;
|
1315 | e80cfcfc | bellard | |
1316 | 1a2fb1c0 | blueswir1 | mmulev = (addr >> 8) & 15; |
1317 | 952a328f | blueswir1 | DPRINTF_MMU("mmu flush level %d\n", mmulev);
|
1318 | 0f8a249a | blueswir1 | switch (mmulev) {
|
1319 | 0f8a249a | blueswir1 | case 0: // flush page |
1320 | 1a2fb1c0 | blueswir1 | tlb_flush_page(env, addr & 0xfffff000);
|
1321 | 0f8a249a | blueswir1 | break;
|
1322 | 0f8a249a | blueswir1 | case 1: // flush segment (256k) |
1323 | 0f8a249a | blueswir1 | case 2: // flush region (16M) |
1324 | 0f8a249a | blueswir1 | case 3: // flush context (4G) |
1325 | 0f8a249a | blueswir1 | case 4: // flush entire |
1326 | 0f8a249a | blueswir1 | tlb_flush(env, 1);
|
1327 | 0f8a249a | blueswir1 | break;
|
1328 | 0f8a249a | blueswir1 | default:
|
1329 | 0f8a249a | blueswir1 | break;
|
1330 | 0f8a249a | blueswir1 | } |
1331 | 55754d9e | bellard | #ifdef DEBUG_MMU
|
1332 | 0f8a249a | blueswir1 | dump_mmu(env); |
1333 | 55754d9e | bellard | #endif
|
1334 | 0f8a249a | blueswir1 | } |
1335 | 8543e2cf | blueswir1 | break;
|
1336 | e8af50a3 | bellard | case 4: /* write MMU regs */ |
1337 | 0f8a249a | blueswir1 | { |
1338 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 8) & 0x1f; |
1339 | 0f8a249a | blueswir1 | uint32_t oldreg; |
1340 | 3b46e624 | ths | |
1341 | 0f8a249a | blueswir1 | oldreg = env->mmuregs[reg]; |
1342 | 55754d9e | bellard | switch(reg) {
|
1343 | 3deaeab7 | blueswir1 | case 0: // Control Register |
1344 | 3dd9a152 | blueswir1 | env->mmuregs[reg] = (env->mmuregs[reg] & 0xff000000) |
|
1345 | 1a2fb1c0 | blueswir1 | (val & 0x00ffffff);
|
1346 | 0f8a249a | blueswir1 | // Mappings generated during no-fault mode or MMU
|
1347 | 0f8a249a | blueswir1 | // disabled mode are invalid in normal mode
|
1348 | 5578ceab | blueswir1 | if ((oldreg & (MMU_E | MMU_NF | env->def->mmu_bm)) !=
|
1349 | 5578ceab | blueswir1 | (env->mmuregs[reg] & (MMU_E | MMU_NF | env->def->mmu_bm))) |
1350 | 55754d9e | bellard | tlb_flush(env, 1);
|
1351 | 55754d9e | bellard | break;
|
1352 | 3deaeab7 | blueswir1 | case 1: // Context Table Pointer Register |
1353 | 5578ceab | blueswir1 | env->mmuregs[reg] = val & env->def->mmu_ctpr_mask; |
1354 | 3deaeab7 | blueswir1 | break;
|
1355 | 3deaeab7 | blueswir1 | case 2: // Context Register |
1356 | 5578ceab | blueswir1 | env->mmuregs[reg] = val & env->def->mmu_cxr_mask; |
1357 | 55754d9e | bellard | if (oldreg != env->mmuregs[reg]) {
|
1358 | 55754d9e | bellard | /* we flush when the MMU context changes because
|
1359 | 55754d9e | bellard | QEMU has no MMU context support */
|
1360 | 55754d9e | bellard | tlb_flush(env, 1);
|
1361 | 55754d9e | bellard | } |
1362 | 55754d9e | bellard | break;
|
1363 | 3deaeab7 | blueswir1 | case 3: // Synchronous Fault Status Register with Clear |
1364 | 3deaeab7 | blueswir1 | case 4: // Synchronous Fault Address Register |
1365 | 3deaeab7 | blueswir1 | break;
|
1366 | 3deaeab7 | blueswir1 | case 0x10: // TLB Replacement Control Register |
1367 | 5578ceab | blueswir1 | env->mmuregs[reg] = val & env->def->mmu_trcr_mask; |
1368 | 55754d9e | bellard | break;
|
1369 | 3deaeab7 | blueswir1 | case 0x13: // Synchronous Fault Status Register with Read and Clear |
1370 | 5578ceab | blueswir1 | env->mmuregs[3] = val & env->def->mmu_sfsr_mask;
|
1371 | 3dd9a152 | blueswir1 | break;
|
1372 | 3deaeab7 | blueswir1 | case 0x14: // Synchronous Fault Address Register |
1373 | 1a2fb1c0 | blueswir1 | env->mmuregs[4] = val;
|
1374 | 3dd9a152 | blueswir1 | break;
|
1375 | 55754d9e | bellard | default:
|
1376 | 1a2fb1c0 | blueswir1 | env->mmuregs[reg] = val; |
1377 | 55754d9e | bellard | break;
|
1378 | 55754d9e | bellard | } |
1379 | 55754d9e | bellard | if (oldreg != env->mmuregs[reg]) {
|
1380 | 77f193da | blueswir1 | DPRINTF_MMU("mmu change reg[%d]: 0x%08x -> 0x%08x\n",
|
1381 | 77f193da | blueswir1 | reg, oldreg, env->mmuregs[reg]); |
1382 | 55754d9e | bellard | } |
1383 | 952a328f | blueswir1 | #ifdef DEBUG_MMU
|
1384 | 0f8a249a | blueswir1 | dump_mmu(env); |
1385 | 55754d9e | bellard | #endif
|
1386 | 0f8a249a | blueswir1 | } |
1387 | 8543e2cf | blueswir1 | break;
|
1388 | 045380be | blueswir1 | case 5: // Turbosparc ITLB Diagnostic |
1389 | 045380be | blueswir1 | case 6: // Turbosparc DTLB Diagnostic |
1390 | 045380be | blueswir1 | case 7: // Turbosparc IOTLB Diagnostic |
1391 | 045380be | blueswir1 | break;
|
1392 | 81ad8ba2 | blueswir1 | case 0xa: /* User data access */ |
1393 | 81ad8ba2 | blueswir1 | switch(size) {
|
1394 | 81ad8ba2 | blueswir1 | case 1: |
1395 | 1a2fb1c0 | blueswir1 | stb_user(addr, val); |
1396 | 81ad8ba2 | blueswir1 | break;
|
1397 | 81ad8ba2 | blueswir1 | case 2: |
1398 | a4e7dd52 | blueswir1 | stw_user(addr, val); |
1399 | 81ad8ba2 | blueswir1 | break;
|
1400 | 81ad8ba2 | blueswir1 | default:
|
1401 | 81ad8ba2 | blueswir1 | case 4: |
1402 | a4e7dd52 | blueswir1 | stl_user(addr, val); |
1403 | 81ad8ba2 | blueswir1 | break;
|
1404 | 81ad8ba2 | blueswir1 | case 8: |
1405 | a4e7dd52 | blueswir1 | stq_user(addr, val); |
1406 | 81ad8ba2 | blueswir1 | break;
|
1407 | 81ad8ba2 | blueswir1 | } |
1408 | 81ad8ba2 | blueswir1 | break;
|
1409 | 81ad8ba2 | blueswir1 | case 0xb: /* Supervisor data access */ |
1410 | 81ad8ba2 | blueswir1 | switch(size) {
|
1411 | 81ad8ba2 | blueswir1 | case 1: |
1412 | 1a2fb1c0 | blueswir1 | stb_kernel(addr, val); |
1413 | 81ad8ba2 | blueswir1 | break;
|
1414 | 81ad8ba2 | blueswir1 | case 2: |
1415 | a4e7dd52 | blueswir1 | stw_kernel(addr, val); |
1416 | 81ad8ba2 | blueswir1 | break;
|
1417 | 81ad8ba2 | blueswir1 | default:
|
1418 | 81ad8ba2 | blueswir1 | case 4: |
1419 | a4e7dd52 | blueswir1 | stl_kernel(addr, val); |
1420 | 81ad8ba2 | blueswir1 | break;
|
1421 | 81ad8ba2 | blueswir1 | case 8: |
1422 | a4e7dd52 | blueswir1 | stq_kernel(addr, val); |
1423 | 81ad8ba2 | blueswir1 | break;
|
1424 | 81ad8ba2 | blueswir1 | } |
1425 | 81ad8ba2 | blueswir1 | break;
|
1426 | 6c36d3fa | blueswir1 | case 0xc: /* I-cache tag */ |
1427 | 6c36d3fa | blueswir1 | case 0xd: /* I-cache data */ |
1428 | 6c36d3fa | blueswir1 | case 0xe: /* D-cache tag */ |
1429 | 6c36d3fa | blueswir1 | case 0xf: /* D-cache data */ |
1430 | 6c36d3fa | blueswir1 | case 0x10: /* I/D-cache flush page */ |
1431 | 6c36d3fa | blueswir1 | case 0x11: /* I/D-cache flush segment */ |
1432 | 6c36d3fa | blueswir1 | case 0x12: /* I/D-cache flush region */ |
1433 | 6c36d3fa | blueswir1 | case 0x13: /* I/D-cache flush context */ |
1434 | 6c36d3fa | blueswir1 | case 0x14: /* I/D-cache flush user */ |
1435 | 6c36d3fa | blueswir1 | break;
|
1436 | e80cfcfc | bellard | case 0x17: /* Block copy, sta access */ |
1437 | 0f8a249a | blueswir1 | { |
1438 | 1a2fb1c0 | blueswir1 | // val = src
|
1439 | 1a2fb1c0 | blueswir1 | // addr = dst
|
1440 | 0f8a249a | blueswir1 | // copy 32 bytes
|
1441 | 6c36d3fa | blueswir1 | unsigned int i; |
1442 | 1a2fb1c0 | blueswir1 | uint32_t src = val & ~3, dst = addr & ~3, temp; |
1443 | 3b46e624 | ths | |
1444 | 6c36d3fa | blueswir1 | for (i = 0; i < 32; i += 4, src += 4, dst += 4) { |
1445 | 6c36d3fa | blueswir1 | temp = ldl_kernel(src); |
1446 | 6c36d3fa | blueswir1 | stl_kernel(dst, temp); |
1447 | 6c36d3fa | blueswir1 | } |
1448 | 0f8a249a | blueswir1 | } |
1449 | 8543e2cf | blueswir1 | break;
|
1450 | e80cfcfc | bellard | case 0x1f: /* Block fill, stda access */ |
1451 | 0f8a249a | blueswir1 | { |
1452 | 1a2fb1c0 | blueswir1 | // addr = dst
|
1453 | 1a2fb1c0 | blueswir1 | // fill 32 bytes with val
|
1454 | 6c36d3fa | blueswir1 | unsigned int i; |
1455 | 1a2fb1c0 | blueswir1 | uint32_t dst = addr & 7;
|
1456 | 6c36d3fa | blueswir1 | |
1457 | 6c36d3fa | blueswir1 | for (i = 0; i < 32; i += 8, dst += 8) |
1458 | 6c36d3fa | blueswir1 | stq_kernel(dst, val); |
1459 | 0f8a249a | blueswir1 | } |
1460 | 8543e2cf | blueswir1 | break;
|
1461 | 6c36d3fa | blueswir1 | case 0x20: /* MMU passthrough */ |
1462 | 0f8a249a | blueswir1 | { |
1463 | 02aab46a | bellard | switch(size) {
|
1464 | 02aab46a | bellard | case 1: |
1465 | 1a2fb1c0 | blueswir1 | stb_phys(addr, val); |
1466 | 02aab46a | bellard | break;
|
1467 | 02aab46a | bellard | case 2: |
1468 | a4e7dd52 | blueswir1 | stw_phys(addr, val); |
1469 | 02aab46a | bellard | break;
|
1470 | 02aab46a | bellard | case 4: |
1471 | 02aab46a | bellard | default:
|
1472 | a4e7dd52 | blueswir1 | stl_phys(addr, val); |
1473 | 02aab46a | bellard | break;
|
1474 | 9e61bde5 | bellard | case 8: |
1475 | a4e7dd52 | blueswir1 | stq_phys(addr, val); |
1476 | 9e61bde5 | bellard | break;
|
1477 | 02aab46a | bellard | } |
1478 | 0f8a249a | blueswir1 | } |
1479 | 8543e2cf | blueswir1 | break;
|
1480 | 045380be | blueswir1 | case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */ |
1481 | 0f8a249a | blueswir1 | { |
1482 | 5dcb6b91 | blueswir1 | switch(size) {
|
1483 | 5dcb6b91 | blueswir1 | case 1: |
1484 | 1a2fb1c0 | blueswir1 | stb_phys((target_phys_addr_t)addr |
1485 | 1a2fb1c0 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32), val); |
1486 | 5dcb6b91 | blueswir1 | break;
|
1487 | 5dcb6b91 | blueswir1 | case 2: |
1488 | a4e7dd52 | blueswir1 | stw_phys((target_phys_addr_t)addr |
1489 | 1a2fb1c0 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32), val); |
1490 | 5dcb6b91 | blueswir1 | break;
|
1491 | 5dcb6b91 | blueswir1 | case 4: |
1492 | 5dcb6b91 | blueswir1 | default:
|
1493 | a4e7dd52 | blueswir1 | stl_phys((target_phys_addr_t)addr |
1494 | 1a2fb1c0 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32), val); |
1495 | 5dcb6b91 | blueswir1 | break;
|
1496 | 5dcb6b91 | blueswir1 | case 8: |
1497 | a4e7dd52 | blueswir1 | stq_phys((target_phys_addr_t)addr |
1498 | 1a2fb1c0 | blueswir1 | | ((target_phys_addr_t)(asi & 0xf) << 32), val); |
1499 | 5dcb6b91 | blueswir1 | break;
|
1500 | 5dcb6b91 | blueswir1 | } |
1501 | 0f8a249a | blueswir1 | } |
1502 | 8543e2cf | blueswir1 | break;
|
1503 | 045380be | blueswir1 | case 0x30: // store buffer tags or Turbosparc secondary cache diagnostic |
1504 | 045380be | blueswir1 | case 0x31: // store buffer data, Ross RT620 I-cache flush or |
1505 | 045380be | blueswir1 | // Turbosparc snoop RAM
|
1506 | 77f193da | blueswir1 | case 0x32: // store buffer control or Turbosparc page table |
1507 | 77f193da | blueswir1 | // descriptor diagnostic
|
1508 | 6c36d3fa | blueswir1 | case 0x36: /* I-cache flash clear */ |
1509 | 6c36d3fa | blueswir1 | case 0x37: /* D-cache flash clear */ |
1510 | 666c87aa | blueswir1 | case 0x4c: /* breakpoint action */ |
1511 | 6c36d3fa | blueswir1 | break;
|
1512 | 4017190e | blueswir1 | case 0x38: /* SuperSPARC MMU Breakpoint Control Registers*/ |
1513 | 4017190e | blueswir1 | { |
1514 | 4017190e | blueswir1 | int reg = (addr >> 8) & 3; |
1515 | 4017190e | blueswir1 | |
1516 | 4017190e | blueswir1 | switch(reg) {
|
1517 | 4017190e | blueswir1 | case 0: /* Breakpoint Value (Addr) */ |
1518 | 4017190e | blueswir1 | env->mmubpregs[reg] = (val & 0xfffffffffULL);
|
1519 | 4017190e | blueswir1 | break;
|
1520 | 4017190e | blueswir1 | case 1: /* Breakpoint Mask */ |
1521 | 4017190e | blueswir1 | env->mmubpregs[reg] = (val & 0xfffffffffULL);
|
1522 | 4017190e | blueswir1 | break;
|
1523 | 4017190e | blueswir1 | case 2: /* Breakpoint Control */ |
1524 | 4017190e | blueswir1 | env->mmubpregs[reg] = (val & 0x7fULL);
|
1525 | 4017190e | blueswir1 | break;
|
1526 | 4017190e | blueswir1 | case 3: /* Breakpoint Status */ |
1527 | 4017190e | blueswir1 | env->mmubpregs[reg] = (val & 0xfULL);
|
1528 | 4017190e | blueswir1 | break;
|
1529 | 4017190e | blueswir1 | } |
1530 | 4017190e | blueswir1 | DPRINTF_MMU("write breakpoint reg[%d] 0x%016llx\n", reg,
|
1531 | 4017190e | blueswir1 | env->mmuregs[reg]); |
1532 | 4017190e | blueswir1 | } |
1533 | 4017190e | blueswir1 | break;
|
1534 | 045380be | blueswir1 | case 8: /* User code access, XXX */ |
1535 | 6c36d3fa | blueswir1 | case 9: /* Supervisor code access, XXX */ |
1536 | e8af50a3 | bellard | default:
|
1537 | e18231a3 | blueswir1 | do_unassigned_access(addr, 1, 0, asi, size); |
1538 | 8543e2cf | blueswir1 | break;
|
1539 | e8af50a3 | bellard | } |
1540 | 8543e2cf | blueswir1 | #ifdef DEBUG_ASI
|
1541 | 1a2fb1c0 | blueswir1 | dump_asi("write", addr, asi, size, val);
|
1542 | 8543e2cf | blueswir1 | #endif
|
1543 | e8af50a3 | bellard | } |
1544 | e8af50a3 | bellard | |
1545 | 81ad8ba2 | blueswir1 | #endif /* CONFIG_USER_ONLY */ |
1546 | 81ad8ba2 | blueswir1 | #else /* TARGET_SPARC64 */ |
1547 | 81ad8ba2 | blueswir1 | |
1548 | 81ad8ba2 | blueswir1 | #ifdef CONFIG_USER_ONLY
|
1549 | 1a2fb1c0 | blueswir1 | uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) |
1550 | 81ad8ba2 | blueswir1 | { |
1551 | 81ad8ba2 | blueswir1 | uint64_t ret = 0;
|
1552 | 1a2fb1c0 | blueswir1 | #if defined(DEBUG_ASI)
|
1553 | 1a2fb1c0 | blueswir1 | target_ulong last_addr = addr; |
1554 | 1a2fb1c0 | blueswir1 | #endif
|
1555 | 81ad8ba2 | blueswir1 | |
1556 | 81ad8ba2 | blueswir1 | if (asi < 0x80) |
1557 | 81ad8ba2 | blueswir1 | raise_exception(TT_PRIV_ACT); |
1558 | 81ad8ba2 | blueswir1 | |
1559 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
1560 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
1561 | c2bc0e38 | blueswir1 | |
1562 | 81ad8ba2 | blueswir1 | switch (asi) {
|
1563 | 81ad8ba2 | blueswir1 | case 0x82: // Primary no-fault |
1564 | 81ad8ba2 | blueswir1 | case 0x8a: // Primary no-fault LE |
1565 | e83ce550 | blueswir1 | if (page_check_range(addr, size, PAGE_READ) == -1) { |
1566 | e83ce550 | blueswir1 | #ifdef DEBUG_ASI
|
1567 | e83ce550 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1568 | e83ce550 | blueswir1 | #endif
|
1569 | e83ce550 | blueswir1 | return 0; |
1570 | e83ce550 | blueswir1 | } |
1571 | e83ce550 | blueswir1 | // Fall through
|
1572 | e83ce550 | blueswir1 | case 0x80: // Primary |
1573 | e83ce550 | blueswir1 | case 0x88: // Primary LE |
1574 | 81ad8ba2 | blueswir1 | { |
1575 | 81ad8ba2 | blueswir1 | switch(size) {
|
1576 | 81ad8ba2 | blueswir1 | case 1: |
1577 | 1a2fb1c0 | blueswir1 | ret = ldub_raw(addr); |
1578 | 81ad8ba2 | blueswir1 | break;
|
1579 | 81ad8ba2 | blueswir1 | case 2: |
1580 | a4e7dd52 | blueswir1 | ret = lduw_raw(addr); |
1581 | 81ad8ba2 | blueswir1 | break;
|
1582 | 81ad8ba2 | blueswir1 | case 4: |
1583 | a4e7dd52 | blueswir1 | ret = ldl_raw(addr); |
1584 | 81ad8ba2 | blueswir1 | break;
|
1585 | 81ad8ba2 | blueswir1 | default:
|
1586 | 81ad8ba2 | blueswir1 | case 8: |
1587 | a4e7dd52 | blueswir1 | ret = ldq_raw(addr); |
1588 | 81ad8ba2 | blueswir1 | break;
|
1589 | 81ad8ba2 | blueswir1 | } |
1590 | 81ad8ba2 | blueswir1 | } |
1591 | 81ad8ba2 | blueswir1 | break;
|
1592 | 81ad8ba2 | blueswir1 | case 0x83: // Secondary no-fault |
1593 | 81ad8ba2 | blueswir1 | case 0x8b: // Secondary no-fault LE |
1594 | e83ce550 | blueswir1 | if (page_check_range(addr, size, PAGE_READ) == -1) { |
1595 | e83ce550 | blueswir1 | #ifdef DEBUG_ASI
|
1596 | e83ce550 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1597 | e83ce550 | blueswir1 | #endif
|
1598 | e83ce550 | blueswir1 | return 0; |
1599 | e83ce550 | blueswir1 | } |
1600 | e83ce550 | blueswir1 | // Fall through
|
1601 | e83ce550 | blueswir1 | case 0x81: // Secondary |
1602 | e83ce550 | blueswir1 | case 0x89: // Secondary LE |
1603 | 81ad8ba2 | blueswir1 | // XXX
|
1604 | 81ad8ba2 | blueswir1 | break;
|
1605 | 81ad8ba2 | blueswir1 | default:
|
1606 | 81ad8ba2 | blueswir1 | break;
|
1607 | 81ad8ba2 | blueswir1 | } |
1608 | 81ad8ba2 | blueswir1 | |
1609 | 81ad8ba2 | blueswir1 | /* Convert from little endian */
|
1610 | 81ad8ba2 | blueswir1 | switch (asi) {
|
1611 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
1612 | 81ad8ba2 | blueswir1 | case 0x89: // Secondary LE |
1613 | 81ad8ba2 | blueswir1 | case 0x8a: // Primary no-fault LE |
1614 | 81ad8ba2 | blueswir1 | case 0x8b: // Secondary no-fault LE |
1615 | 81ad8ba2 | blueswir1 | switch(size) {
|
1616 | 81ad8ba2 | blueswir1 | case 2: |
1617 | 81ad8ba2 | blueswir1 | ret = bswap16(ret); |
1618 | e32664fb | blueswir1 | break;
|
1619 | 81ad8ba2 | blueswir1 | case 4: |
1620 | 81ad8ba2 | blueswir1 | ret = bswap32(ret); |
1621 | e32664fb | blueswir1 | break;
|
1622 | 81ad8ba2 | blueswir1 | case 8: |
1623 | 81ad8ba2 | blueswir1 | ret = bswap64(ret); |
1624 | e32664fb | blueswir1 | break;
|
1625 | 81ad8ba2 | blueswir1 | default:
|
1626 | 81ad8ba2 | blueswir1 | break;
|
1627 | 81ad8ba2 | blueswir1 | } |
1628 | 81ad8ba2 | blueswir1 | default:
|
1629 | 81ad8ba2 | blueswir1 | break;
|
1630 | 81ad8ba2 | blueswir1 | } |
1631 | 81ad8ba2 | blueswir1 | |
1632 | 81ad8ba2 | blueswir1 | /* Convert to signed number */
|
1633 | 81ad8ba2 | blueswir1 | if (sign) {
|
1634 | 81ad8ba2 | blueswir1 | switch(size) {
|
1635 | 81ad8ba2 | blueswir1 | case 1: |
1636 | 81ad8ba2 | blueswir1 | ret = (int8_t) ret; |
1637 | e32664fb | blueswir1 | break;
|
1638 | 81ad8ba2 | blueswir1 | case 2: |
1639 | 81ad8ba2 | blueswir1 | ret = (int16_t) ret; |
1640 | e32664fb | blueswir1 | break;
|
1641 | 81ad8ba2 | blueswir1 | case 4: |
1642 | 81ad8ba2 | blueswir1 | ret = (int32_t) ret; |
1643 | e32664fb | blueswir1 | break;
|
1644 | 81ad8ba2 | blueswir1 | default:
|
1645 | 81ad8ba2 | blueswir1 | break;
|
1646 | 81ad8ba2 | blueswir1 | } |
1647 | 81ad8ba2 | blueswir1 | } |
1648 | 1a2fb1c0 | blueswir1 | #ifdef DEBUG_ASI
|
1649 | 1a2fb1c0 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1650 | 1a2fb1c0 | blueswir1 | #endif
|
1651 | 1a2fb1c0 | blueswir1 | return ret;
|
1652 | 81ad8ba2 | blueswir1 | } |
1653 | 81ad8ba2 | blueswir1 | |
1654 | 1a2fb1c0 | blueswir1 | void helper_st_asi(target_ulong addr, target_ulong val, int asi, int size) |
1655 | 81ad8ba2 | blueswir1 | { |
1656 | 1a2fb1c0 | blueswir1 | #ifdef DEBUG_ASI
|
1657 | 1a2fb1c0 | blueswir1 | dump_asi("write", addr, asi, size, val);
|
1658 | 1a2fb1c0 | blueswir1 | #endif
|
1659 | 81ad8ba2 | blueswir1 | if (asi < 0x80) |
1660 | 81ad8ba2 | blueswir1 | raise_exception(TT_PRIV_ACT); |
1661 | 81ad8ba2 | blueswir1 | |
1662 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
1663 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
1664 | c2bc0e38 | blueswir1 | |
1665 | 81ad8ba2 | blueswir1 | /* Convert to little endian */
|
1666 | 81ad8ba2 | blueswir1 | switch (asi) {
|
1667 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
1668 | 81ad8ba2 | blueswir1 | case 0x89: // Secondary LE |
1669 | 81ad8ba2 | blueswir1 | switch(size) {
|
1670 | 81ad8ba2 | blueswir1 | case 2: |
1671 | 1a2fb1c0 | blueswir1 | addr = bswap16(addr); |
1672 | e32664fb | blueswir1 | break;
|
1673 | 81ad8ba2 | blueswir1 | case 4: |
1674 | 1a2fb1c0 | blueswir1 | addr = bswap32(addr); |
1675 | e32664fb | blueswir1 | break;
|
1676 | 81ad8ba2 | blueswir1 | case 8: |
1677 | 1a2fb1c0 | blueswir1 | addr = bswap64(addr); |
1678 | e32664fb | blueswir1 | break;
|
1679 | 81ad8ba2 | blueswir1 | default:
|
1680 | 81ad8ba2 | blueswir1 | break;
|
1681 | 81ad8ba2 | blueswir1 | } |
1682 | 81ad8ba2 | blueswir1 | default:
|
1683 | 81ad8ba2 | blueswir1 | break;
|
1684 | 81ad8ba2 | blueswir1 | } |
1685 | 81ad8ba2 | blueswir1 | |
1686 | 81ad8ba2 | blueswir1 | switch(asi) {
|
1687 | 81ad8ba2 | blueswir1 | case 0x80: // Primary |
1688 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
1689 | 81ad8ba2 | blueswir1 | { |
1690 | 81ad8ba2 | blueswir1 | switch(size) {
|
1691 | 81ad8ba2 | blueswir1 | case 1: |
1692 | 1a2fb1c0 | blueswir1 | stb_raw(addr, val); |
1693 | 81ad8ba2 | blueswir1 | break;
|
1694 | 81ad8ba2 | blueswir1 | case 2: |
1695 | a4e7dd52 | blueswir1 | stw_raw(addr, val); |
1696 | 81ad8ba2 | blueswir1 | break;
|
1697 | 81ad8ba2 | blueswir1 | case 4: |
1698 | a4e7dd52 | blueswir1 | stl_raw(addr, val); |
1699 | 81ad8ba2 | blueswir1 | break;
|
1700 | 81ad8ba2 | blueswir1 | case 8: |
1701 | 81ad8ba2 | blueswir1 | default:
|
1702 | a4e7dd52 | blueswir1 | stq_raw(addr, val); |
1703 | 81ad8ba2 | blueswir1 | break;
|
1704 | 81ad8ba2 | blueswir1 | } |
1705 | 81ad8ba2 | blueswir1 | } |
1706 | 81ad8ba2 | blueswir1 | break;
|
1707 | 81ad8ba2 | blueswir1 | case 0x81: // Secondary |
1708 | 81ad8ba2 | blueswir1 | case 0x89: // Secondary LE |
1709 | 81ad8ba2 | blueswir1 | // XXX
|
1710 | 81ad8ba2 | blueswir1 | return;
|
1711 | 81ad8ba2 | blueswir1 | |
1712 | 81ad8ba2 | blueswir1 | case 0x82: // Primary no-fault, RO |
1713 | 81ad8ba2 | blueswir1 | case 0x83: // Secondary no-fault, RO |
1714 | 81ad8ba2 | blueswir1 | case 0x8a: // Primary no-fault LE, RO |
1715 | 81ad8ba2 | blueswir1 | case 0x8b: // Secondary no-fault LE, RO |
1716 | 81ad8ba2 | blueswir1 | default:
|
1717 | e18231a3 | blueswir1 | do_unassigned_access(addr, 1, 0, 1, size); |
1718 | 81ad8ba2 | blueswir1 | return;
|
1719 | 81ad8ba2 | blueswir1 | } |
1720 | 81ad8ba2 | blueswir1 | } |
1721 | 81ad8ba2 | blueswir1 | |
1722 | 81ad8ba2 | blueswir1 | #else /* CONFIG_USER_ONLY */ |
1723 | 3475187d | bellard | |
1724 | 1a2fb1c0 | blueswir1 | uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) |
1725 | 3475187d | bellard | { |
1726 | 83469015 | bellard | uint64_t ret = 0;
|
1727 | 1a2fb1c0 | blueswir1 | #if defined(DEBUG_ASI)
|
1728 | 1a2fb1c0 | blueswir1 | target_ulong last_addr = addr; |
1729 | 1a2fb1c0 | blueswir1 | #endif
|
1730 | 3475187d | bellard | |
1731 | 6f27aba6 | blueswir1 | if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) |
1732 | 5578ceab | blueswir1 | || ((env->def->features & CPU_FEATURE_HYPV) |
1733 | 5578ceab | blueswir1 | && asi >= 0x30 && asi < 0x80 |
1734 | fb79ceb9 | blueswir1 | && !(env->hpstate & HS_PRIV))) |
1735 | 0f8a249a | blueswir1 | raise_exception(TT_PRIV_ACT); |
1736 | 3475187d | bellard | |
1737 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
1738 | 3475187d | bellard | switch (asi) {
|
1739 | e83ce550 | blueswir1 | case 0x82: // Primary no-fault |
1740 | e83ce550 | blueswir1 | case 0x8a: // Primary no-fault LE |
1741 | e83ce550 | blueswir1 | if (cpu_get_phys_page_debug(env, addr) == -1ULL) { |
1742 | e83ce550 | blueswir1 | #ifdef DEBUG_ASI
|
1743 | e83ce550 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1744 | e83ce550 | blueswir1 | #endif
|
1745 | e83ce550 | blueswir1 | return 0; |
1746 | e83ce550 | blueswir1 | } |
1747 | e83ce550 | blueswir1 | // Fall through
|
1748 | 81ad8ba2 | blueswir1 | case 0x10: // As if user primary |
1749 | 81ad8ba2 | blueswir1 | case 0x18: // As if user primary LE |
1750 | 81ad8ba2 | blueswir1 | case 0x80: // Primary |
1751 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
1752 | c99657d3 | blueswir1 | case 0xe2: // UA2007 Primary block init |
1753 | c99657d3 | blueswir1 | case 0xe3: // UA2007 Secondary block init |
1754 | 81ad8ba2 | blueswir1 | if ((asi & 0x80) && (env->pstate & PS_PRIV)) { |
1755 | 5578ceab | blueswir1 | if ((env->def->features & CPU_FEATURE_HYPV)
|
1756 | 5578ceab | blueswir1 | && env->hpstate & HS_PRIV) { |
1757 | 6f27aba6 | blueswir1 | switch(size) {
|
1758 | 6f27aba6 | blueswir1 | case 1: |
1759 | 1a2fb1c0 | blueswir1 | ret = ldub_hypv(addr); |
1760 | 6f27aba6 | blueswir1 | break;
|
1761 | 6f27aba6 | blueswir1 | case 2: |
1762 | a4e7dd52 | blueswir1 | ret = lduw_hypv(addr); |
1763 | 6f27aba6 | blueswir1 | break;
|
1764 | 6f27aba6 | blueswir1 | case 4: |
1765 | a4e7dd52 | blueswir1 | ret = ldl_hypv(addr); |
1766 | 6f27aba6 | blueswir1 | break;
|
1767 | 6f27aba6 | blueswir1 | default:
|
1768 | 6f27aba6 | blueswir1 | case 8: |
1769 | a4e7dd52 | blueswir1 | ret = ldq_hypv(addr); |
1770 | 6f27aba6 | blueswir1 | break;
|
1771 | 6f27aba6 | blueswir1 | } |
1772 | 6f27aba6 | blueswir1 | } else {
|
1773 | 6f27aba6 | blueswir1 | switch(size) {
|
1774 | 6f27aba6 | blueswir1 | case 1: |
1775 | 1a2fb1c0 | blueswir1 | ret = ldub_kernel(addr); |
1776 | 6f27aba6 | blueswir1 | break;
|
1777 | 6f27aba6 | blueswir1 | case 2: |
1778 | a4e7dd52 | blueswir1 | ret = lduw_kernel(addr); |
1779 | 6f27aba6 | blueswir1 | break;
|
1780 | 6f27aba6 | blueswir1 | case 4: |
1781 | a4e7dd52 | blueswir1 | ret = ldl_kernel(addr); |
1782 | 6f27aba6 | blueswir1 | break;
|
1783 | 6f27aba6 | blueswir1 | default:
|
1784 | 6f27aba6 | blueswir1 | case 8: |
1785 | a4e7dd52 | blueswir1 | ret = ldq_kernel(addr); |
1786 | 6f27aba6 | blueswir1 | break;
|
1787 | 6f27aba6 | blueswir1 | } |
1788 | 81ad8ba2 | blueswir1 | } |
1789 | 81ad8ba2 | blueswir1 | } else {
|
1790 | 81ad8ba2 | blueswir1 | switch(size) {
|
1791 | 81ad8ba2 | blueswir1 | case 1: |
1792 | 1a2fb1c0 | blueswir1 | ret = ldub_user(addr); |
1793 | 81ad8ba2 | blueswir1 | break;
|
1794 | 81ad8ba2 | blueswir1 | case 2: |
1795 | a4e7dd52 | blueswir1 | ret = lduw_user(addr); |
1796 | 81ad8ba2 | blueswir1 | break;
|
1797 | 81ad8ba2 | blueswir1 | case 4: |
1798 | a4e7dd52 | blueswir1 | ret = ldl_user(addr); |
1799 | 81ad8ba2 | blueswir1 | break;
|
1800 | 81ad8ba2 | blueswir1 | default:
|
1801 | 81ad8ba2 | blueswir1 | case 8: |
1802 | a4e7dd52 | blueswir1 | ret = ldq_user(addr); |
1803 | 81ad8ba2 | blueswir1 | break;
|
1804 | 81ad8ba2 | blueswir1 | } |
1805 | 81ad8ba2 | blueswir1 | } |
1806 | 81ad8ba2 | blueswir1 | break;
|
1807 | 3475187d | bellard | case 0x14: // Bypass |
1808 | 3475187d | bellard | case 0x15: // Bypass, non-cacheable |
1809 | 81ad8ba2 | blueswir1 | case 0x1c: // Bypass LE |
1810 | 81ad8ba2 | blueswir1 | case 0x1d: // Bypass, non-cacheable LE |
1811 | 0f8a249a | blueswir1 | { |
1812 | 02aab46a | bellard | switch(size) {
|
1813 | 02aab46a | bellard | case 1: |
1814 | 1a2fb1c0 | blueswir1 | ret = ldub_phys(addr); |
1815 | 02aab46a | bellard | break;
|
1816 | 02aab46a | bellard | case 2: |
1817 | a4e7dd52 | blueswir1 | ret = lduw_phys(addr); |
1818 | 02aab46a | bellard | break;
|
1819 | 02aab46a | bellard | case 4: |
1820 | a4e7dd52 | blueswir1 | ret = ldl_phys(addr); |
1821 | 02aab46a | bellard | break;
|
1822 | 02aab46a | bellard | default:
|
1823 | 02aab46a | bellard | case 8: |
1824 | a4e7dd52 | blueswir1 | ret = ldq_phys(addr); |
1825 | 02aab46a | bellard | break;
|
1826 | 02aab46a | bellard | } |
1827 | 0f8a249a | blueswir1 | break;
|
1828 | 0f8a249a | blueswir1 | } |
1829 | db166940 | blueswir1 | case 0x24: // Nucleus quad LDD 128 bit atomic |
1830 | db166940 | blueswir1 | case 0x2c: // Nucleus quad LDD 128 bit atomic LE |
1831 | db166940 | blueswir1 | // Only ldda allowed
|
1832 | db166940 | blueswir1 | raise_exception(TT_ILL_INSN); |
1833 | db166940 | blueswir1 | return 0; |
1834 | e83ce550 | blueswir1 | case 0x83: // Secondary no-fault |
1835 | e83ce550 | blueswir1 | case 0x8b: // Secondary no-fault LE |
1836 | e83ce550 | blueswir1 | if (cpu_get_phys_page_debug(env, addr) == -1ULL) { |
1837 | e83ce550 | blueswir1 | #ifdef DEBUG_ASI
|
1838 | e83ce550 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
1839 | e83ce550 | blueswir1 | #endif
|
1840 | e83ce550 | blueswir1 | return 0; |
1841 | e83ce550 | blueswir1 | } |
1842 | e83ce550 | blueswir1 | // Fall through
|
1843 | 83469015 | bellard | case 0x04: // Nucleus |
1844 | 83469015 | bellard | case 0x0c: // Nucleus Little Endian (LE) |
1845 | 83469015 | bellard | case 0x11: // As if user secondary |
1846 | 83469015 | bellard | case 0x19: // As if user secondary LE |
1847 | 83469015 | bellard | case 0x4a: // UPA config |
1848 | 81ad8ba2 | blueswir1 | case 0x81: // Secondary |
1849 | 83469015 | bellard | case 0x89: // Secondary LE |
1850 | 0f8a249a | blueswir1 | // XXX
|
1851 | 0f8a249a | blueswir1 | break;
|
1852 | 3475187d | bellard | case 0x45: // LSU |
1853 | 0f8a249a | blueswir1 | ret = env->lsu; |
1854 | 0f8a249a | blueswir1 | break;
|
1855 | 3475187d | bellard | case 0x50: // I-MMU regs |
1856 | 0f8a249a | blueswir1 | { |
1857 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 3) & 0xf; |
1858 | 3475187d | bellard | |
1859 | 697a77e6 | Igor Kovalenko | if (reg == 0) { |
1860 | 697a77e6 | Igor Kovalenko | // I-TSB Tag Target register
|
1861 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tag_target(env->immuregs[6]);
|
1862 | 697a77e6 | Igor Kovalenko | } else {
|
1863 | 697a77e6 | Igor Kovalenko | ret = env->immuregs[reg]; |
1864 | 697a77e6 | Igor Kovalenko | } |
1865 | 697a77e6 | Igor Kovalenko | |
1866 | 0f8a249a | blueswir1 | break;
|
1867 | 0f8a249a | blueswir1 | } |
1868 | 3475187d | bellard | case 0x51: // I-MMU 8k TSB pointer |
1869 | 697a77e6 | Igor Kovalenko | { |
1870 | 697a77e6 | Igor Kovalenko | // env->immuregs[5] holds I-MMU TSB register value
|
1871 | 697a77e6 | Igor Kovalenko | // env->immuregs[6] holds I-MMU Tag Access register value
|
1872 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tsb_pointer(env->immuregs[5], env->immuregs[6], |
1873 | 697a77e6 | Igor Kovalenko | 8*1024); |
1874 | 697a77e6 | Igor Kovalenko | break;
|
1875 | 697a77e6 | Igor Kovalenko | } |
1876 | 3475187d | bellard | case 0x52: // I-MMU 64k TSB pointer |
1877 | 697a77e6 | Igor Kovalenko | { |
1878 | 697a77e6 | Igor Kovalenko | // env->immuregs[5] holds I-MMU TSB register value
|
1879 | 697a77e6 | Igor Kovalenko | // env->immuregs[6] holds I-MMU Tag Access register value
|
1880 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tsb_pointer(env->immuregs[5], env->immuregs[6], |
1881 | 697a77e6 | Igor Kovalenko | 64*1024); |
1882 | 697a77e6 | Igor Kovalenko | break;
|
1883 | 697a77e6 | Igor Kovalenko | } |
1884 | a5a52cf2 | blueswir1 | case 0x55: // I-MMU data access |
1885 | a5a52cf2 | blueswir1 | { |
1886 | a5a52cf2 | blueswir1 | int reg = (addr >> 3) & 0x3f; |
1887 | a5a52cf2 | blueswir1 | |
1888 | a5a52cf2 | blueswir1 | ret = env->itlb_tte[reg]; |
1889 | a5a52cf2 | blueswir1 | break;
|
1890 | a5a52cf2 | blueswir1 | } |
1891 | 83469015 | bellard | case 0x56: // I-MMU tag read |
1892 | 0f8a249a | blueswir1 | { |
1893 | 43e9e742 | blueswir1 | int reg = (addr >> 3) & 0x3f; |
1894 | 0f8a249a | blueswir1 | |
1895 | 43e9e742 | blueswir1 | ret = env->itlb_tag[reg]; |
1896 | 0f8a249a | blueswir1 | break;
|
1897 | 0f8a249a | blueswir1 | } |
1898 | 3475187d | bellard | case 0x58: // D-MMU regs |
1899 | 0f8a249a | blueswir1 | { |
1900 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 3) & 0xf; |
1901 | 3475187d | bellard | |
1902 | 697a77e6 | Igor Kovalenko | if (reg == 0) { |
1903 | 697a77e6 | Igor Kovalenko | // D-TSB Tag Target register
|
1904 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tag_target(env->dmmuregs[6]);
|
1905 | 697a77e6 | Igor Kovalenko | } else {
|
1906 | 697a77e6 | Igor Kovalenko | ret = env->dmmuregs[reg]; |
1907 | 697a77e6 | Igor Kovalenko | } |
1908 | 697a77e6 | Igor Kovalenko | break;
|
1909 | 697a77e6 | Igor Kovalenko | } |
1910 | 697a77e6 | Igor Kovalenko | case 0x59: // D-MMU 8k TSB pointer |
1911 | 697a77e6 | Igor Kovalenko | { |
1912 | 697a77e6 | Igor Kovalenko | // env->dmmuregs[5] holds D-MMU TSB register value
|
1913 | 697a77e6 | Igor Kovalenko | // env->dmmuregs[6] holds D-MMU Tag Access register value
|
1914 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tsb_pointer(env->dmmuregs[5], env->dmmuregs[6], |
1915 | 697a77e6 | Igor Kovalenko | 8*1024); |
1916 | 697a77e6 | Igor Kovalenko | break;
|
1917 | 697a77e6 | Igor Kovalenko | } |
1918 | 697a77e6 | Igor Kovalenko | case 0x5a: // D-MMU 64k TSB pointer |
1919 | 697a77e6 | Igor Kovalenko | { |
1920 | 697a77e6 | Igor Kovalenko | // env->dmmuregs[5] holds D-MMU TSB register value
|
1921 | 697a77e6 | Igor Kovalenko | // env->dmmuregs[6] holds D-MMU Tag Access register value
|
1922 | 697a77e6 | Igor Kovalenko | ret = ultrasparc_tsb_pointer(env->dmmuregs[5], env->dmmuregs[6], |
1923 | 697a77e6 | Igor Kovalenko | 64*1024); |
1924 | 0f8a249a | blueswir1 | break;
|
1925 | 0f8a249a | blueswir1 | } |
1926 | a5a52cf2 | blueswir1 | case 0x5d: // D-MMU data access |
1927 | a5a52cf2 | blueswir1 | { |
1928 | a5a52cf2 | blueswir1 | int reg = (addr >> 3) & 0x3f; |
1929 | a5a52cf2 | blueswir1 | |
1930 | a5a52cf2 | blueswir1 | ret = env->dtlb_tte[reg]; |
1931 | a5a52cf2 | blueswir1 | break;
|
1932 | a5a52cf2 | blueswir1 | } |
1933 | 83469015 | bellard | case 0x5e: // D-MMU tag read |
1934 | 0f8a249a | blueswir1 | { |
1935 | 43e9e742 | blueswir1 | int reg = (addr >> 3) & 0x3f; |
1936 | 0f8a249a | blueswir1 | |
1937 | 43e9e742 | blueswir1 | ret = env->dtlb_tag[reg]; |
1938 | 0f8a249a | blueswir1 | break;
|
1939 | 0f8a249a | blueswir1 | } |
1940 | f7350b47 | blueswir1 | case 0x46: // D-cache data |
1941 | f7350b47 | blueswir1 | case 0x47: // D-cache tag access |
1942 | a5a52cf2 | blueswir1 | case 0x4b: // E-cache error enable |
1943 | a5a52cf2 | blueswir1 | case 0x4c: // E-cache asynchronous fault status |
1944 | a5a52cf2 | blueswir1 | case 0x4d: // E-cache asynchronous fault address |
1945 | f7350b47 | blueswir1 | case 0x4e: // E-cache tag data |
1946 | f7350b47 | blueswir1 | case 0x66: // I-cache instruction access |
1947 | f7350b47 | blueswir1 | case 0x67: // I-cache tag access |
1948 | f7350b47 | blueswir1 | case 0x6e: // I-cache predecode |
1949 | f7350b47 | blueswir1 | case 0x6f: // I-cache LRU etc. |
1950 | f7350b47 | blueswir1 | case 0x76: // E-cache tag |
1951 | f7350b47 | blueswir1 | case 0x7e: // E-cache tag |
1952 | f7350b47 | blueswir1 | break;
|
1953 | 3475187d | bellard | case 0x5b: // D-MMU data pointer |
1954 | 83469015 | bellard | case 0x48: // Interrupt dispatch, RO |
1955 | 83469015 | bellard | case 0x49: // Interrupt data receive |
1956 | 83469015 | bellard | case 0x7f: // Incoming interrupt vector, RO |
1957 | 0f8a249a | blueswir1 | // XXX
|
1958 | 0f8a249a | blueswir1 | break;
|
1959 | 3475187d | bellard | case 0x54: // I-MMU data in, WO |
1960 | 3475187d | bellard | case 0x57: // I-MMU demap, WO |
1961 | 3475187d | bellard | case 0x5c: // D-MMU data in, WO |
1962 | 3475187d | bellard | case 0x5f: // D-MMU demap, WO |
1963 | 83469015 | bellard | case 0x77: // Interrupt vector, WO |
1964 | 3475187d | bellard | default:
|
1965 | e18231a3 | blueswir1 | do_unassigned_access(addr, 0, 0, 1, size); |
1966 | 0f8a249a | blueswir1 | ret = 0;
|
1967 | 0f8a249a | blueswir1 | break;
|
1968 | 3475187d | bellard | } |
1969 | 81ad8ba2 | blueswir1 | |
1970 | 81ad8ba2 | blueswir1 | /* Convert from little endian */
|
1971 | 81ad8ba2 | blueswir1 | switch (asi) {
|
1972 | 81ad8ba2 | blueswir1 | case 0x0c: // Nucleus Little Endian (LE) |
1973 | 81ad8ba2 | blueswir1 | case 0x18: // As if user primary LE |
1974 | 81ad8ba2 | blueswir1 | case 0x19: // As if user secondary LE |
1975 | 81ad8ba2 | blueswir1 | case 0x1c: // Bypass LE |
1976 | 81ad8ba2 | blueswir1 | case 0x1d: // Bypass, non-cacheable LE |
1977 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
1978 | 81ad8ba2 | blueswir1 | case 0x89: // Secondary LE |
1979 | 81ad8ba2 | blueswir1 | case 0x8a: // Primary no-fault LE |
1980 | 81ad8ba2 | blueswir1 | case 0x8b: // Secondary no-fault LE |
1981 | 81ad8ba2 | blueswir1 | switch(size) {
|
1982 | 81ad8ba2 | blueswir1 | case 2: |
1983 | 81ad8ba2 | blueswir1 | ret = bswap16(ret); |
1984 | e32664fb | blueswir1 | break;
|
1985 | 81ad8ba2 | blueswir1 | case 4: |
1986 | 81ad8ba2 | blueswir1 | ret = bswap32(ret); |
1987 | e32664fb | blueswir1 | break;
|
1988 | 81ad8ba2 | blueswir1 | case 8: |
1989 | 81ad8ba2 | blueswir1 | ret = bswap64(ret); |
1990 | e32664fb | blueswir1 | break;
|
1991 | 81ad8ba2 | blueswir1 | default:
|
1992 | 81ad8ba2 | blueswir1 | break;
|
1993 | 81ad8ba2 | blueswir1 | } |
1994 | 81ad8ba2 | blueswir1 | default:
|
1995 | 81ad8ba2 | blueswir1 | break;
|
1996 | 81ad8ba2 | blueswir1 | } |
1997 | 81ad8ba2 | blueswir1 | |
1998 | 81ad8ba2 | blueswir1 | /* Convert to signed number */
|
1999 | 81ad8ba2 | blueswir1 | if (sign) {
|
2000 | 81ad8ba2 | blueswir1 | switch(size) {
|
2001 | 81ad8ba2 | blueswir1 | case 1: |
2002 | 81ad8ba2 | blueswir1 | ret = (int8_t) ret; |
2003 | e32664fb | blueswir1 | break;
|
2004 | 81ad8ba2 | blueswir1 | case 2: |
2005 | 81ad8ba2 | blueswir1 | ret = (int16_t) ret; |
2006 | e32664fb | blueswir1 | break;
|
2007 | 81ad8ba2 | blueswir1 | case 4: |
2008 | 81ad8ba2 | blueswir1 | ret = (int32_t) ret; |
2009 | e32664fb | blueswir1 | break;
|
2010 | 81ad8ba2 | blueswir1 | default:
|
2011 | 81ad8ba2 | blueswir1 | break;
|
2012 | 81ad8ba2 | blueswir1 | } |
2013 | 81ad8ba2 | blueswir1 | } |
2014 | 1a2fb1c0 | blueswir1 | #ifdef DEBUG_ASI
|
2015 | 1a2fb1c0 | blueswir1 | dump_asi("read ", last_addr, asi, size, ret);
|
2016 | 1a2fb1c0 | blueswir1 | #endif
|
2017 | 1a2fb1c0 | blueswir1 | return ret;
|
2018 | 3475187d | bellard | } |
2019 | 3475187d | bellard | |
2020 | 1a2fb1c0 | blueswir1 | void helper_st_asi(target_ulong addr, target_ulong val, int asi, int size) |
2021 | 3475187d | bellard | { |
2022 | 1a2fb1c0 | blueswir1 | #ifdef DEBUG_ASI
|
2023 | 1a2fb1c0 | blueswir1 | dump_asi("write", addr, asi, size, val);
|
2024 | 1a2fb1c0 | blueswir1 | #endif
|
2025 | 6f27aba6 | blueswir1 | if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) |
2026 | 5578ceab | blueswir1 | || ((env->def->features & CPU_FEATURE_HYPV) |
2027 | 5578ceab | blueswir1 | && asi >= 0x30 && asi < 0x80 |
2028 | fb79ceb9 | blueswir1 | && !(env->hpstate & HS_PRIV))) |
2029 | 0f8a249a | blueswir1 | raise_exception(TT_PRIV_ACT); |
2030 | 3475187d | bellard | |
2031 | c2bc0e38 | blueswir1 | helper_check_align(addr, size - 1);
|
2032 | 81ad8ba2 | blueswir1 | /* Convert to little endian */
|
2033 | 81ad8ba2 | blueswir1 | switch (asi) {
|
2034 | 81ad8ba2 | blueswir1 | case 0x0c: // Nucleus Little Endian (LE) |
2035 | 81ad8ba2 | blueswir1 | case 0x18: // As if user primary LE |
2036 | 81ad8ba2 | blueswir1 | case 0x19: // As if user secondary LE |
2037 | 81ad8ba2 | blueswir1 | case 0x1c: // Bypass LE |
2038 | 81ad8ba2 | blueswir1 | case 0x1d: // Bypass, non-cacheable LE |
2039 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
2040 | 81ad8ba2 | blueswir1 | case 0x89: // Secondary LE |
2041 | 81ad8ba2 | blueswir1 | switch(size) {
|
2042 | 81ad8ba2 | blueswir1 | case 2: |
2043 | 1a2fb1c0 | blueswir1 | addr = bswap16(addr); |
2044 | e32664fb | blueswir1 | break;
|
2045 | 81ad8ba2 | blueswir1 | case 4: |
2046 | 1a2fb1c0 | blueswir1 | addr = bswap32(addr); |
2047 | e32664fb | blueswir1 | break;
|
2048 | 81ad8ba2 | blueswir1 | case 8: |
2049 | 1a2fb1c0 | blueswir1 | addr = bswap64(addr); |
2050 | e32664fb | blueswir1 | break;
|
2051 | 81ad8ba2 | blueswir1 | default:
|
2052 | 81ad8ba2 | blueswir1 | break;
|
2053 | 81ad8ba2 | blueswir1 | } |
2054 | 81ad8ba2 | blueswir1 | default:
|
2055 | 81ad8ba2 | blueswir1 | break;
|
2056 | 81ad8ba2 | blueswir1 | } |
2057 | 81ad8ba2 | blueswir1 | |
2058 | 3475187d | bellard | switch(asi) {
|
2059 | 81ad8ba2 | blueswir1 | case 0x10: // As if user primary |
2060 | 81ad8ba2 | blueswir1 | case 0x18: // As if user primary LE |
2061 | 81ad8ba2 | blueswir1 | case 0x80: // Primary |
2062 | 81ad8ba2 | blueswir1 | case 0x88: // Primary LE |
2063 | c99657d3 | blueswir1 | case 0xe2: // UA2007 Primary block init |
2064 | c99657d3 | blueswir1 | case 0xe3: // UA2007 Secondary block init |
2065 | 81ad8ba2 | blueswir1 | if ((asi & 0x80) && (env->pstate & PS_PRIV)) { |
2066 | 5578ceab | blueswir1 | if ((env->def->features & CPU_FEATURE_HYPV)
|
2067 | 5578ceab | blueswir1 | && env->hpstate & HS_PRIV) { |
2068 | 6f27aba6 | blueswir1 | switch(size) {
|
2069 | 6f27aba6 | blueswir1 | case 1: |
2070 | 1a2fb1c0 | blueswir1 | stb_hypv(addr, val); |
2071 | 6f27aba6 | blueswir1 | break;
|
2072 | 6f27aba6 | blueswir1 | case 2: |
2073 | a4e7dd52 | blueswir1 | stw_hypv(addr, val); |
2074 | 6f27aba6 | blueswir1 | break;
|
2075 | 6f27aba6 | blueswir1 | case 4: |
2076 | a4e7dd52 | blueswir1 | stl_hypv(addr, val); |
2077 | 6f27aba6 | blueswir1 | break;
|
2078 | 6f27aba6 | blueswir1 | case 8: |
2079 | 6f27aba6 | blueswir1 | default:
|
2080 | a4e7dd52 | blueswir1 | stq_hypv(addr, val); |
2081 | 6f27aba6 | blueswir1 | break;
|
2082 | 6f27aba6 | blueswir1 | } |
2083 | 6f27aba6 | blueswir1 | } else {
|
2084 | 6f27aba6 | blueswir1 | switch(size) {
|
2085 | 6f27aba6 | blueswir1 | case 1: |
2086 | 1a2fb1c0 | blueswir1 | stb_kernel(addr, val); |
2087 | 6f27aba6 | blueswir1 | break;
|
2088 | 6f27aba6 | blueswir1 | case 2: |
2089 | a4e7dd52 | blueswir1 | stw_kernel(addr, val); |
2090 | 6f27aba6 | blueswir1 | break;
|
2091 | 6f27aba6 | blueswir1 | case 4: |
2092 | a4e7dd52 | blueswir1 | stl_kernel(addr, val); |
2093 | 6f27aba6 | blueswir1 | break;
|
2094 | 6f27aba6 | blueswir1 | case 8: |
2095 | 6f27aba6 | blueswir1 | default:
|
2096 | a4e7dd52 | blueswir1 | stq_kernel(addr, val); |
2097 | 6f27aba6 | blueswir1 | break;
|
2098 | 6f27aba6 | blueswir1 | } |
2099 | 81ad8ba2 | blueswir1 | } |
2100 | 81ad8ba2 | blueswir1 | } else {
|
2101 | 81ad8ba2 | blueswir1 | switch(size) {
|
2102 | 81ad8ba2 | blueswir1 | case 1: |
2103 | 1a2fb1c0 | blueswir1 | stb_user(addr, val); |
2104 | 81ad8ba2 | blueswir1 | break;
|
2105 | 81ad8ba2 | blueswir1 | case 2: |
2106 | a4e7dd52 | blueswir1 | stw_user(addr, val); |
2107 | 81ad8ba2 | blueswir1 | break;
|
2108 | 81ad8ba2 | blueswir1 | case 4: |
2109 | a4e7dd52 | blueswir1 | stl_user(addr, val); |
2110 | 81ad8ba2 | blueswir1 | break;
|
2111 | 81ad8ba2 | blueswir1 | case 8: |
2112 | 81ad8ba2 | blueswir1 | default:
|
2113 | a4e7dd52 | blueswir1 | stq_user(addr, val); |
2114 | 81ad8ba2 | blueswir1 | break;
|
2115 | 81ad8ba2 | blueswir1 | } |
2116 | 81ad8ba2 | blueswir1 | } |
2117 | 81ad8ba2 | blueswir1 | break;
|
2118 | 3475187d | bellard | case 0x14: // Bypass |
2119 | 3475187d | bellard | case 0x15: // Bypass, non-cacheable |
2120 | 81ad8ba2 | blueswir1 | case 0x1c: // Bypass LE |
2121 | 81ad8ba2 | blueswir1 | case 0x1d: // Bypass, non-cacheable LE |
2122 | 0f8a249a | blueswir1 | { |
2123 | 02aab46a | bellard | switch(size) {
|
2124 | 02aab46a | bellard | case 1: |
2125 | 1a2fb1c0 | blueswir1 | stb_phys(addr, val); |
2126 | 02aab46a | bellard | break;
|
2127 | 02aab46a | bellard | case 2: |
2128 | a4e7dd52 | blueswir1 | stw_phys(addr, val); |
2129 | 02aab46a | bellard | break;
|
2130 | 02aab46a | bellard | case 4: |
2131 | a4e7dd52 | blueswir1 | stl_phys(addr, val); |
2132 | 02aab46a | bellard | break;
|
2133 | 02aab46a | bellard | case 8: |
2134 | 02aab46a | bellard | default:
|
2135 | a4e7dd52 | blueswir1 | stq_phys(addr, val); |
2136 | 02aab46a | bellard | break;
|
2137 | 02aab46a | bellard | } |
2138 | 0f8a249a | blueswir1 | } |
2139 | 0f8a249a | blueswir1 | return;
|
2140 | db166940 | blueswir1 | case 0x24: // Nucleus quad LDD 128 bit atomic |
2141 | db166940 | blueswir1 | case 0x2c: // Nucleus quad LDD 128 bit atomic LE |
2142 | db166940 | blueswir1 | // Only ldda allowed
|
2143 | db166940 | blueswir1 | raise_exception(TT_ILL_INSN); |
2144 | db166940 | blueswir1 | return;
|
2145 | 83469015 | bellard | case 0x04: // Nucleus |
2146 | 83469015 | bellard | case 0x0c: // Nucleus Little Endian (LE) |
2147 | 83469015 | bellard | case 0x11: // As if user secondary |
2148 | 83469015 | bellard | case 0x19: // As if user secondary LE |
2149 | 83469015 | bellard | case 0x4a: // UPA config |
2150 | 51996525 | blueswir1 | case 0x81: // Secondary |
2151 | 83469015 | bellard | case 0x89: // Secondary LE |
2152 | 0f8a249a | blueswir1 | // XXX
|
2153 | 0f8a249a | blueswir1 | return;
|
2154 | 3475187d | bellard | case 0x45: // LSU |
2155 | 0f8a249a | blueswir1 | { |
2156 | 0f8a249a | blueswir1 | uint64_t oldreg; |
2157 | 0f8a249a | blueswir1 | |
2158 | 0f8a249a | blueswir1 | oldreg = env->lsu; |
2159 | 1a2fb1c0 | blueswir1 | env->lsu = val & (DMMU_E | IMMU_E); |
2160 | 0f8a249a | blueswir1 | // Mappings generated during D/I MMU disabled mode are
|
2161 | 0f8a249a | blueswir1 | // invalid in normal mode
|
2162 | 0f8a249a | blueswir1 | if (oldreg != env->lsu) {
|
2163 | 77f193da | blueswir1 | DPRINTF_MMU("LSU change: 0x%" PRIx64 " -> 0x%" PRIx64 "\n", |
2164 | 77f193da | blueswir1 | oldreg, env->lsu); |
2165 | 83469015 | bellard | #ifdef DEBUG_MMU
|
2166 | 0f8a249a | blueswir1 | dump_mmu(env); |
2167 | 83469015 | bellard | #endif
|
2168 | 0f8a249a | blueswir1 | tlb_flush(env, 1);
|
2169 | 0f8a249a | blueswir1 | } |
2170 | 0f8a249a | blueswir1 | return;
|
2171 | 0f8a249a | blueswir1 | } |
2172 | 3475187d | bellard | case 0x50: // I-MMU regs |
2173 | 0f8a249a | blueswir1 | { |
2174 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 3) & 0xf; |
2175 | 0f8a249a | blueswir1 | uint64_t oldreg; |
2176 | 3b46e624 | ths | |
2177 | 0f8a249a | blueswir1 | oldreg = env->immuregs[reg]; |
2178 | 3475187d | bellard | switch(reg) {
|
2179 | 3475187d | bellard | case 0: // RO |
2180 | 3475187d | bellard | case 4: |
2181 | 3475187d | bellard | return;
|
2182 | 3475187d | bellard | case 1: // Not in I-MMU |
2183 | 3475187d | bellard | case 2: |
2184 | 3475187d | bellard | case 7: |
2185 | 3475187d | bellard | case 8: |
2186 | 3475187d | bellard | return;
|
2187 | 3475187d | bellard | case 3: // SFSR |
2188 | 1a2fb1c0 | blueswir1 | if ((val & 1) == 0) |
2189 | 1a2fb1c0 | blueswir1 | val = 0; // Clear SFSR |
2190 | 3475187d | bellard | break;
|
2191 | 3475187d | bellard | case 5: // TSB access |
2192 | 3475187d | bellard | case 6: // Tag access |
2193 | 3475187d | bellard | default:
|
2194 | 3475187d | bellard | break;
|
2195 | 3475187d | bellard | } |
2196 | 1a2fb1c0 | blueswir1 | env->immuregs[reg] = val; |
2197 | 3475187d | bellard | if (oldreg != env->immuregs[reg]) {
|
2198 | 77f193da | blueswir1 | DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64 " -> 0x%08" |
2199 | 77f193da | blueswir1 | PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
|
2200 | 3475187d | bellard | } |
2201 | 952a328f | blueswir1 | #ifdef DEBUG_MMU
|
2202 | 0f8a249a | blueswir1 | dump_mmu(env); |
2203 | 3475187d | bellard | #endif
|
2204 | 0f8a249a | blueswir1 | return;
|
2205 | 0f8a249a | blueswir1 | } |
2206 | 3475187d | bellard | case 0x54: // I-MMU data in |
2207 | 0f8a249a | blueswir1 | { |
2208 | 0f8a249a | blueswir1 | unsigned int i; |
2209 | 0f8a249a | blueswir1 | |
2210 | 0f8a249a | blueswir1 | // Try finding an invalid entry
|
2211 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
2212 | 0f8a249a | blueswir1 | if ((env->itlb_tte[i] & 0x8000000000000000ULL) == 0) { |
2213 | 0f8a249a | blueswir1 | env->itlb_tag[i] = env->immuregs[6];
|
2214 | 1a2fb1c0 | blueswir1 | env->itlb_tte[i] = val; |
2215 | 0f8a249a | blueswir1 | return;
|
2216 | 0f8a249a | blueswir1 | } |
2217 | 0f8a249a | blueswir1 | } |
2218 | 0f8a249a | blueswir1 | // Try finding an unlocked entry
|
2219 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
2220 | 0f8a249a | blueswir1 | if ((env->itlb_tte[i] & 0x40) == 0) { |
2221 | 0f8a249a | blueswir1 | env->itlb_tag[i] = env->immuregs[6];
|
2222 | 1a2fb1c0 | blueswir1 | env->itlb_tte[i] = val; |
2223 | 0f8a249a | blueswir1 | return;
|
2224 | 0f8a249a | blueswir1 | } |
2225 | 0f8a249a | blueswir1 | } |
2226 | 0f8a249a | blueswir1 | // error state?
|
2227 | 0f8a249a | blueswir1 | return;
|
2228 | 0f8a249a | blueswir1 | } |
2229 | 3475187d | bellard | case 0x55: // I-MMU data access |
2230 | 0f8a249a | blueswir1 | { |
2231 | cc6747f4 | blueswir1 | // TODO: auto demap
|
2232 | cc6747f4 | blueswir1 | |
2233 | 1a2fb1c0 | blueswir1 | unsigned int i = (addr >> 3) & 0x3f; |
2234 | 3475187d | bellard | |
2235 | 0f8a249a | blueswir1 | env->itlb_tag[i] = env->immuregs[6];
|
2236 | 1a2fb1c0 | blueswir1 | env->itlb_tte[i] = val; |
2237 | 0f8a249a | blueswir1 | return;
|
2238 | 0f8a249a | blueswir1 | } |
2239 | 3475187d | bellard | case 0x57: // I-MMU demap |
2240 | cc6747f4 | blueswir1 | { |
2241 | cc6747f4 | blueswir1 | unsigned int i; |
2242 | cc6747f4 | blueswir1 | |
2243 | cc6747f4 | blueswir1 | for (i = 0; i < 64; i++) { |
2244 | cc6747f4 | blueswir1 | if ((env->itlb_tte[i] & 0x8000000000000000ULL) != 0) { |
2245 | cc6747f4 | blueswir1 | target_ulong mask = 0xffffffffffffe000ULL;
|
2246 | cc6747f4 | blueswir1 | |
2247 | cc6747f4 | blueswir1 | mask <<= 3 * ((env->itlb_tte[i] >> 61) & 3); |
2248 | cc6747f4 | blueswir1 | if ((val & mask) == (env->itlb_tag[i] & mask)) {
|
2249 | cc6747f4 | blueswir1 | env->itlb_tag[i] = 0;
|
2250 | cc6747f4 | blueswir1 | env->itlb_tte[i] = 0;
|
2251 | cc6747f4 | blueswir1 | } |
2252 | cc6747f4 | blueswir1 | return;
|
2253 | cc6747f4 | blueswir1 | } |
2254 | cc6747f4 | blueswir1 | } |
2255 | cc6747f4 | blueswir1 | } |
2256 | 0f8a249a | blueswir1 | return;
|
2257 | 3475187d | bellard | case 0x58: // D-MMU regs |
2258 | 0f8a249a | blueswir1 | { |
2259 | 1a2fb1c0 | blueswir1 | int reg = (addr >> 3) & 0xf; |
2260 | 0f8a249a | blueswir1 | uint64_t oldreg; |
2261 | 3b46e624 | ths | |
2262 | 0f8a249a | blueswir1 | oldreg = env->dmmuregs[reg]; |
2263 | 3475187d | bellard | switch(reg) {
|
2264 | 3475187d | bellard | case 0: // RO |
2265 | 3475187d | bellard | case 4: |
2266 | 3475187d | bellard | return;
|
2267 | 3475187d | bellard | case 3: // SFSR |
2268 | 1a2fb1c0 | blueswir1 | if ((val & 1) == 0) { |
2269 | 1a2fb1c0 | blueswir1 | val = 0; // Clear SFSR, Fault address |
2270 | 0f8a249a | blueswir1 | env->dmmuregs[4] = 0; |
2271 | 0f8a249a | blueswir1 | } |
2272 | 1a2fb1c0 | blueswir1 | env->dmmuregs[reg] = val; |
2273 | 3475187d | bellard | break;
|
2274 | 3475187d | bellard | case 1: // Primary context |
2275 | 3475187d | bellard | case 2: // Secondary context |
2276 | 3475187d | bellard | case 5: // TSB access |
2277 | 3475187d | bellard | case 6: // Tag access |
2278 | 3475187d | bellard | case 7: // Virtual Watchpoint |
2279 | 3475187d | bellard | case 8: // Physical Watchpoint |
2280 | 3475187d | bellard | default:
|
2281 | 3475187d | bellard | break;
|
2282 | 3475187d | bellard | } |
2283 | 1a2fb1c0 | blueswir1 | env->dmmuregs[reg] = val; |
2284 | 3475187d | bellard | if (oldreg != env->dmmuregs[reg]) {
|
2285 | 77f193da | blueswir1 | DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64 " -> 0x%08" |
2286 | 77f193da | blueswir1 | PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]);
|
2287 | 3475187d | bellard | } |
2288 | 952a328f | blueswir1 | #ifdef DEBUG_MMU
|
2289 | 0f8a249a | blueswir1 | dump_mmu(env); |
2290 | 3475187d | bellard | #endif
|
2291 | 0f8a249a | blueswir1 | return;
|
2292 | 0f8a249a | blueswir1 | } |
2293 | 3475187d | bellard | case 0x5c: // D-MMU data in |
2294 | 0f8a249a | blueswir1 | { |
2295 | 0f8a249a | blueswir1 | unsigned int i; |
2296 | 0f8a249a | blueswir1 | |
2297 | 0f8a249a | blueswir1 | // Try finding an invalid entry
|
2298 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
2299 | 0f8a249a | blueswir1 | if ((env->dtlb_tte[i] & 0x8000000000000000ULL) == 0) { |
2300 | 0f8a249a | blueswir1 | env->dtlb_tag[i] = env->dmmuregs[6];
|
2301 | 1a2fb1c0 | blueswir1 | env->dtlb_tte[i] = val; |
2302 | 0f8a249a | blueswir1 | return;
|
2303 | 0f8a249a | blueswir1 | } |
2304 | 0f8a249a | blueswir1 | } |
2305 | 0f8a249a | blueswir1 | // Try finding an unlocked entry
|
2306 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
2307 | 0f8a249a | blueswir1 | if ((env->dtlb_tte[i] & 0x40) == 0) { |
2308 | 0f8a249a | blueswir1 | env->dtlb_tag[i] = env->dmmuregs[6];
|
2309 | 1a2fb1c0 | blueswir1 | env->dtlb_tte[i] = val; |
2310 | 0f8a249a | blueswir1 | return;
|
2311 | 0f8a249a | blueswir1 | } |
2312 | 0f8a249a | blueswir1 | } |
2313 | 0f8a249a | blueswir1 | // error state?
|
2314 | 0f8a249a | blueswir1 | return;
|
2315 | 0f8a249a | blueswir1 | } |
2316 | 3475187d | bellard | case 0x5d: // D-MMU data access |
2317 | 0f8a249a | blueswir1 | { |
2318 | 1a2fb1c0 | blueswir1 | unsigned int i = (addr >> 3) & 0x3f; |
2319 | 3475187d | bellard | |
2320 | 0f8a249a | blueswir1 | env->dtlb_tag[i] = env->dmmuregs[6];
|
2321 | 1a2fb1c0 | blueswir1 | env->dtlb_tte[i] = val; |
2322 | 0f8a249a | blueswir1 | return;
|
2323 | 0f8a249a | blueswir1 | } |
2324 | 3475187d | bellard | case 0x5f: // D-MMU demap |
2325 | cc6747f4 | blueswir1 | { |
2326 | cc6747f4 | blueswir1 | unsigned int i; |
2327 | cc6747f4 | blueswir1 | |
2328 | cc6747f4 | blueswir1 | for (i = 0; i < 64; i++) { |
2329 | cc6747f4 | blueswir1 | if ((env->dtlb_tte[i] & 0x8000000000000000ULL) != 0) { |
2330 | cc6747f4 | blueswir1 | target_ulong mask = 0xffffffffffffe000ULL;
|
2331 | cc6747f4 | blueswir1 | |
2332 | cc6747f4 | blueswir1 | mask <<= 3 * ((env->dtlb_tte[i] >> 61) & 3); |
2333 | cc6747f4 | blueswir1 | if ((val & mask) == (env->dtlb_tag[i] & mask)) {
|
2334 | cc6747f4 | blueswir1 | env->dtlb_tag[i] = 0;
|
2335 | cc6747f4 | blueswir1 | env->dtlb_tte[i] = 0;
|
2336 | cc6747f4 | blueswir1 | } |
2337 | cc6747f4 | blueswir1 | return;
|
2338 | cc6747f4 | blueswir1 | } |
2339 | cc6747f4 | blueswir1 | } |
2340 | cc6747f4 | blueswir1 | } |
2341 | cc6747f4 | blueswir1 | return;
|
2342 | 83469015 | bellard | case 0x49: // Interrupt data receive |
2343 | 0f8a249a | blueswir1 | // XXX
|
2344 | 0f8a249a | blueswir1 | return;
|
2345 | f7350b47 | blueswir1 | case 0x46: // D-cache data |
2346 | f7350b47 | blueswir1 | case 0x47: // D-cache tag access |
2347 | a5a52cf2 | blueswir1 | case 0x4b: // E-cache error enable |
2348 | a5a52cf2 | blueswir1 | case 0x4c: // E-cache asynchronous fault status |
2349 | a5a52cf2 | blueswir1 | case 0x4d: // E-cache asynchronous fault address |
2350 | f7350b47 | blueswir1 | case 0x4e: // E-cache tag data |
2351 | f7350b47 | blueswir1 | case 0x66: // I-cache instruction access |
2352 | f7350b47 | blueswir1 | case 0x67: // I-cache tag access |
2353 | f7350b47 | blueswir1 | case 0x6e: // I-cache predecode |
2354 | f7350b47 | blueswir1 | case 0x6f: // I-cache LRU etc. |
2355 | f7350b47 | blueswir1 | case 0x76: // E-cache tag |
2356 | f7350b47 | blueswir1 | case 0x7e: // E-cache tag |
2357 | f7350b47 | blueswir1 | return;
|
2358 | 3475187d | bellard | case 0x51: // I-MMU 8k TSB pointer, RO |
2359 | 3475187d | bellard | case 0x52: // I-MMU 64k TSB pointer, RO |
2360 | 3475187d | bellard | case 0x56: // I-MMU tag read, RO |
2361 | 3475187d | bellard | case 0x59: // D-MMU 8k TSB pointer, RO |
2362 | 3475187d | bellard | case 0x5a: // D-MMU 64k TSB pointer, RO |
2363 | 3475187d | bellard | case 0x5b: // D-MMU data pointer, RO |
2364 | 3475187d | bellard | case 0x5e: // D-MMU tag read, RO |
2365 | 83469015 | bellard | case 0x48: // Interrupt dispatch, RO |
2366 | 83469015 | bellard | case 0x7f: // Incoming interrupt vector, RO |
2367 | 83469015 | bellard | case 0x82: // Primary no-fault, RO |
2368 | 83469015 | bellard | case 0x83: // Secondary no-fault, RO |
2369 | 83469015 | bellard | case 0x8a: // Primary no-fault LE, RO |
2370 | 83469015 | bellard | case 0x8b: // Secondary no-fault LE, RO |
2371 | 3475187d | bellard | default:
|
2372 | e18231a3 | blueswir1 | do_unassigned_access(addr, 1, 0, 1, size); |
2373 | 0f8a249a | blueswir1 | return;
|
2374 | 3475187d | bellard | } |
2375 | 3475187d | bellard | } |
2376 | 81ad8ba2 | blueswir1 | #endif /* CONFIG_USER_ONLY */ |
2377 | 3391c818 | blueswir1 | |
2378 | db166940 | blueswir1 | void helper_ldda_asi(target_ulong addr, int asi, int rd) |
2379 | db166940 | blueswir1 | { |
2380 | db166940 | blueswir1 | if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) |
2381 | 5578ceab | blueswir1 | || ((env->def->features & CPU_FEATURE_HYPV) |
2382 | 5578ceab | blueswir1 | && asi >= 0x30 && asi < 0x80 |
2383 | fb79ceb9 | blueswir1 | && !(env->hpstate & HS_PRIV))) |
2384 | db166940 | blueswir1 | raise_exception(TT_PRIV_ACT); |
2385 | db166940 | blueswir1 | |
2386 | db166940 | blueswir1 | switch (asi) {
|
2387 | db166940 | blueswir1 | case 0x24: // Nucleus quad LDD 128 bit atomic |
2388 | db166940 | blueswir1 | case 0x2c: // Nucleus quad LDD 128 bit atomic LE |
2389 | db166940 | blueswir1 | helper_check_align(addr, 0xf);
|
2390 | db166940 | blueswir1 | if (rd == 0) { |
2391 | db166940 | blueswir1 | env->gregs[1] = ldq_kernel(addr + 8); |
2392 | db166940 | blueswir1 | if (asi == 0x2c) |
2393 | db166940 | blueswir1 | bswap64s(&env->gregs[1]);
|
2394 | db166940 | blueswir1 | } else if (rd < 8) { |
2395 | db166940 | blueswir1 | env->gregs[rd] = ldq_kernel(addr); |
2396 | db166940 | blueswir1 | env->gregs[rd + 1] = ldq_kernel(addr + 8); |
2397 | db166940 | blueswir1 | if (asi == 0x2c) { |
2398 | db166940 | blueswir1 | bswap64s(&env->gregs[rd]); |
2399 | db166940 | blueswir1 | bswap64s(&env->gregs[rd + 1]);
|
2400 | db166940 | blueswir1 | } |
2401 | db166940 | blueswir1 | } else {
|
2402 | db166940 | blueswir1 | env->regwptr[rd] = ldq_kernel(addr); |
2403 | db166940 | blueswir1 | env->regwptr[rd + 1] = ldq_kernel(addr + 8); |
2404 | db166940 | blueswir1 | if (asi == 0x2c) { |
2405 | db166940 | blueswir1 | bswap64s(&env->regwptr[rd]); |
2406 | db166940 | blueswir1 | bswap64s(&env->regwptr[rd + 1]);
|
2407 | db166940 | blueswir1 | } |
2408 | db166940 | blueswir1 | } |
2409 | db166940 | blueswir1 | break;
|
2410 | db166940 | blueswir1 | default:
|
2411 | db166940 | blueswir1 | helper_check_align(addr, 0x3);
|
2412 | db166940 | blueswir1 | if (rd == 0) |
2413 | db166940 | blueswir1 | env->gregs[1] = helper_ld_asi(addr + 4, asi, 4, 0); |
2414 | db166940 | blueswir1 | else if (rd < 8) { |
2415 | db166940 | blueswir1 | env->gregs[rd] = helper_ld_asi(addr, asi, 4, 0); |
2416 | db166940 | blueswir1 | env->gregs[rd + 1] = helper_ld_asi(addr + 4, asi, 4, 0); |
2417 | db166940 | blueswir1 | } else {
|
2418 | db166940 | blueswir1 | env->regwptr[rd] = helper_ld_asi(addr, asi, 4, 0); |
2419 | db166940 | blueswir1 | env->regwptr[rd + 1] = helper_ld_asi(addr + 4, asi, 4, 0); |
2420 | db166940 | blueswir1 | } |
2421 | db166940 | blueswir1 | break;
|
2422 | db166940 | blueswir1 | } |
2423 | db166940 | blueswir1 | } |
2424 | db166940 | blueswir1 | |
2425 | 1a2fb1c0 | blueswir1 | void helper_ldf_asi(target_ulong addr, int asi, int size, int rd) |
2426 | 3391c818 | blueswir1 | { |
2427 | 3391c818 | blueswir1 | unsigned int i; |
2428 | 1a2fb1c0 | blueswir1 | target_ulong val; |
2429 | 3391c818 | blueswir1 | |
2430 | c2bc0e38 | blueswir1 | helper_check_align(addr, 3);
|
2431 | 3391c818 | blueswir1 | switch (asi) {
|
2432 | 3391c818 | blueswir1 | case 0xf0: // Block load primary |
2433 | 3391c818 | blueswir1 | case 0xf1: // Block load secondary |
2434 | 3391c818 | blueswir1 | case 0xf8: // Block load primary LE |
2435 | 3391c818 | blueswir1 | case 0xf9: // Block load secondary LE |
2436 | 51996525 | blueswir1 | if (rd & 7) { |
2437 | 51996525 | blueswir1 | raise_exception(TT_ILL_INSN); |
2438 | 51996525 | blueswir1 | return;
|
2439 | 51996525 | blueswir1 | } |
2440 | c2bc0e38 | blueswir1 | helper_check_align(addr, 0x3f);
|
2441 | 51996525 | blueswir1 | for (i = 0; i < 16; i++) { |
2442 | 77f193da | blueswir1 | *(uint32_t *)&env->fpr[rd++] = helper_ld_asi(addr, asi & 0x8f, 4, |
2443 | 77f193da | blueswir1 | 0);
|
2444 | 1a2fb1c0 | blueswir1 | addr += 4;
|
2445 | 3391c818 | blueswir1 | } |
2446 | 3391c818 | blueswir1 | |
2447 | 3391c818 | blueswir1 | return;
|
2448 | 3391c818 | blueswir1 | default:
|
2449 | 3391c818 | blueswir1 | break;
|
2450 | 3391c818 | blueswir1 | } |
2451 | 3391c818 | blueswir1 | |
2452 | 1a2fb1c0 | blueswir1 | val = helper_ld_asi(addr, asi, size, 0);
|
2453 | 3391c818 | blueswir1 | switch(size) {
|
2454 | 3391c818 | blueswir1 | default:
|
2455 | 3391c818 | blueswir1 | case 4: |
2456 | 714547bb | blueswir1 | *((uint32_t *)&env->fpr[rd]) = val; |
2457 | 3391c818 | blueswir1 | break;
|
2458 | 3391c818 | blueswir1 | case 8: |
2459 | 1a2fb1c0 | blueswir1 | *((int64_t *)&DT0) = val; |
2460 | 3391c818 | blueswir1 | break;
|
2461 | 1f587329 | blueswir1 | case 16: |
2462 | 1f587329 | blueswir1 | // XXX
|
2463 | 1f587329 | blueswir1 | break;
|
2464 | 3391c818 | blueswir1 | } |
2465 | 3391c818 | blueswir1 | } |
2466 | 3391c818 | blueswir1 | |
2467 | 1a2fb1c0 | blueswir1 | void helper_stf_asi(target_ulong addr, int asi, int size, int rd) |
2468 | 3391c818 | blueswir1 | { |
2469 | 3391c818 | blueswir1 | unsigned int i; |
2470 | 1a2fb1c0 | blueswir1 | target_ulong val = 0;
|
2471 | 3391c818 | blueswir1 | |
2472 | c2bc0e38 | blueswir1 | helper_check_align(addr, 3);
|
2473 | 3391c818 | blueswir1 | switch (asi) {
|
2474 | c99657d3 | blueswir1 | case 0xe0: // UA2007 Block commit store primary (cache flush) |
2475 | c99657d3 | blueswir1 | case 0xe1: // UA2007 Block commit store secondary (cache flush) |
2476 | 3391c818 | blueswir1 | case 0xf0: // Block store primary |
2477 | 3391c818 | blueswir1 | case 0xf1: // Block store secondary |
2478 | 3391c818 | blueswir1 | case 0xf8: // Block store primary LE |
2479 | 3391c818 | blueswir1 | case 0xf9: // Block store secondary LE |
2480 | 51996525 | blueswir1 | if (rd & 7) { |
2481 | 51996525 | blueswir1 | raise_exception(TT_ILL_INSN); |
2482 | 51996525 | blueswir1 | return;
|
2483 | 51996525 | blueswir1 | } |
2484 | c2bc0e38 | blueswir1 | helper_check_align(addr, 0x3f);
|
2485 | 51996525 | blueswir1 | for (i = 0; i < 16; i++) { |
2486 | 1a2fb1c0 | blueswir1 | val = *(uint32_t *)&env->fpr[rd++]; |
2487 | 1a2fb1c0 | blueswir1 | helper_st_asi(addr, val, asi & 0x8f, 4); |
2488 | 1a2fb1c0 | blueswir1 | addr += 4;
|
2489 | 3391c818 | blueswir1 | } |
2490 | 3391c818 | blueswir1 | |
2491 | 3391c818 | blueswir1 | return;
|
2492 | 3391c818 | blueswir1 | default:
|
2493 | 3391c818 | blueswir1 | break;
|
2494 | 3391c818 | blueswir1 | } |
2495 | 3391c818 | blueswir1 | |
2496 | 3391c818 | blueswir1 | switch(size) {
|
2497 | 3391c818 | blueswir1 | default:
|
2498 | 3391c818 | blueswir1 | case 4: |
2499 | 714547bb | blueswir1 | val = *((uint32_t *)&env->fpr[rd]); |
2500 | 3391c818 | blueswir1 | break;
|
2501 | 3391c818 | blueswir1 | case 8: |
2502 | 1a2fb1c0 | blueswir1 | val = *((int64_t *)&DT0); |
2503 | 3391c818 | blueswir1 | break;
|
2504 | 1f587329 | blueswir1 | case 16: |
2505 | 1f587329 | blueswir1 | // XXX
|
2506 | 1f587329 | blueswir1 | break;
|
2507 | 3391c818 | blueswir1 | } |
2508 | 1a2fb1c0 | blueswir1 | helper_st_asi(addr, val, asi, size); |
2509 | 1a2fb1c0 | blueswir1 | } |
2510 | 1a2fb1c0 | blueswir1 | |
2511 | 1a2fb1c0 | blueswir1 | target_ulong helper_cas_asi(target_ulong addr, target_ulong val1, |
2512 | 1a2fb1c0 | blueswir1 | target_ulong val2, uint32_t asi) |
2513 | 1a2fb1c0 | blueswir1 | { |
2514 | 1a2fb1c0 | blueswir1 | target_ulong ret; |
2515 | 1a2fb1c0 | blueswir1 | |
2516 | 1121f879 | blueswir1 | val2 &= 0xffffffffUL;
|
2517 | 1a2fb1c0 | blueswir1 | ret = helper_ld_asi(addr, asi, 4, 0); |
2518 | 1a2fb1c0 | blueswir1 | ret &= 0xffffffffUL;
|
2519 | 1121f879 | blueswir1 | if (val2 == ret)
|
2520 | 1121f879 | blueswir1 | helper_st_asi(addr, val1 & 0xffffffffUL, asi, 4); |
2521 | 1a2fb1c0 | blueswir1 | return ret;
|
2522 | 3391c818 | blueswir1 | } |
2523 | 3391c818 | blueswir1 | |
2524 | 1a2fb1c0 | blueswir1 | target_ulong helper_casx_asi(target_ulong addr, target_ulong val1, |
2525 | 1a2fb1c0 | blueswir1 | target_ulong val2, uint32_t asi) |
2526 | 1a2fb1c0 | blueswir1 | { |
2527 | 1a2fb1c0 | blueswir1 | target_ulong ret; |
2528 | 1a2fb1c0 | blueswir1 | |
2529 | 1a2fb1c0 | blueswir1 | ret = helper_ld_asi(addr, asi, 8, 0); |
2530 | 1121f879 | blueswir1 | if (val2 == ret)
|
2531 | 1121f879 | blueswir1 | helper_st_asi(addr, val1, asi, 8);
|
2532 | 1a2fb1c0 | blueswir1 | return ret;
|
2533 | 1a2fb1c0 | blueswir1 | } |
2534 | 81ad8ba2 | blueswir1 | #endif /* TARGET_SPARC64 */ |
2535 | 3475187d | bellard | |
2536 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
2537 | 1a2fb1c0 | blueswir1 | void helper_rett(void) |
2538 | e8af50a3 | bellard | { |
2539 | af7bf89b | bellard | unsigned int cwp; |
2540 | af7bf89b | bellard | |
2541 | d4218d99 | blueswir1 | if (env->psret == 1) |
2542 | d4218d99 | blueswir1 | raise_exception(TT_ILL_INSN); |
2543 | d4218d99 | blueswir1 | |
2544 | e8af50a3 | bellard | env->psret = 1;
|
2545 | 1a14026e | blueswir1 | cwp = cpu_cwp_inc(env, env->cwp + 1) ;
|
2546 | e8af50a3 | bellard | if (env->wim & (1 << cwp)) { |
2547 | e8af50a3 | bellard | raise_exception(TT_WIN_UNF); |
2548 | e8af50a3 | bellard | } |
2549 | e8af50a3 | bellard | set_cwp(cwp); |
2550 | e8af50a3 | bellard | env->psrs = env->psrps; |
2551 | e8af50a3 | bellard | } |
2552 | 3475187d | bellard | #endif
|
2553 | e8af50a3 | bellard | |
2554 | 3b89f26c | blueswir1 | target_ulong helper_udiv(target_ulong a, target_ulong b) |
2555 | 3b89f26c | blueswir1 | { |
2556 | 3b89f26c | blueswir1 | uint64_t x0; |
2557 | 3b89f26c | blueswir1 | uint32_t x1; |
2558 | 3b89f26c | blueswir1 | |
2559 | 7621a90d | blueswir1 | x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); |
2560 | 3b89f26c | blueswir1 | x1 = b; |
2561 | 3b89f26c | blueswir1 | |
2562 | 3b89f26c | blueswir1 | if (x1 == 0) { |
2563 | 3b89f26c | blueswir1 | raise_exception(TT_DIV_ZERO); |
2564 | 3b89f26c | blueswir1 | } |
2565 | 3b89f26c | blueswir1 | |
2566 | 3b89f26c | blueswir1 | x0 = x0 / x1; |
2567 | 3b89f26c | blueswir1 | if (x0 > 0xffffffff) { |
2568 | 3b89f26c | blueswir1 | env->cc_src2 = 1;
|
2569 | 3b89f26c | blueswir1 | return 0xffffffff; |
2570 | 3b89f26c | blueswir1 | } else {
|
2571 | 3b89f26c | blueswir1 | env->cc_src2 = 0;
|
2572 | 3b89f26c | blueswir1 | return x0;
|
2573 | 3b89f26c | blueswir1 | } |
2574 | 3b89f26c | blueswir1 | } |
2575 | 3b89f26c | blueswir1 | |
2576 | 3b89f26c | blueswir1 | target_ulong helper_sdiv(target_ulong a, target_ulong b) |
2577 | 3b89f26c | blueswir1 | { |
2578 | 3b89f26c | blueswir1 | int64_t x0; |
2579 | 3b89f26c | blueswir1 | int32_t x1; |
2580 | 3b89f26c | blueswir1 | |
2581 | 7621a90d | blueswir1 | x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); |
2582 | 3b89f26c | blueswir1 | x1 = b; |
2583 | 3b89f26c | blueswir1 | |
2584 | 3b89f26c | blueswir1 | if (x1 == 0) { |
2585 | 3b89f26c | blueswir1 | raise_exception(TT_DIV_ZERO); |
2586 | 3b89f26c | blueswir1 | } |
2587 | 3b89f26c | blueswir1 | |
2588 | 3b89f26c | blueswir1 | x0 = x0 / x1; |
2589 | 3b89f26c | blueswir1 | if ((int32_t) x0 != x0) {
|
2590 | 3b89f26c | blueswir1 | env->cc_src2 = 1;
|
2591 | 3b89f26c | blueswir1 | return x0 < 0? 0x80000000: 0x7fffffff; |
2592 | 3b89f26c | blueswir1 | } else {
|
2593 | 3b89f26c | blueswir1 | env->cc_src2 = 0;
|
2594 | 3b89f26c | blueswir1 | return x0;
|
2595 | 3b89f26c | blueswir1 | } |
2596 | 3b89f26c | blueswir1 | } |
2597 | 3b89f26c | blueswir1 | |
2598 | 7fa76c0b | blueswir1 | void helper_stdf(target_ulong addr, int mem_idx) |
2599 | 7fa76c0b | blueswir1 | { |
2600 | c2bc0e38 | blueswir1 | helper_check_align(addr, 7);
|
2601 | 7fa76c0b | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
2602 | 7fa76c0b | blueswir1 | switch (mem_idx) {
|
2603 | 7fa76c0b | blueswir1 | case 0: |
2604 | c2bc0e38 | blueswir1 | stfq_user(addr, DT0); |
2605 | 7fa76c0b | blueswir1 | break;
|
2606 | 7fa76c0b | blueswir1 | case 1: |
2607 | c2bc0e38 | blueswir1 | stfq_kernel(addr, DT0); |
2608 | 7fa76c0b | blueswir1 | break;
|
2609 | 7fa76c0b | blueswir1 | #ifdef TARGET_SPARC64
|
2610 | 7fa76c0b | blueswir1 | case 2: |
2611 | c2bc0e38 | blueswir1 | stfq_hypv(addr, DT0); |
2612 | 7fa76c0b | blueswir1 | break;
|
2613 | 7fa76c0b | blueswir1 | #endif
|
2614 | 7fa76c0b | blueswir1 | default:
|
2615 | 7fa76c0b | blueswir1 | break;
|
2616 | 7fa76c0b | blueswir1 | } |
2617 | 7fa76c0b | blueswir1 | #else
|
2618 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
2619 | c2bc0e38 | blueswir1 | stfq_raw(addr, DT0); |
2620 | 7fa76c0b | blueswir1 | #endif
|
2621 | 7fa76c0b | blueswir1 | } |
2622 | 7fa76c0b | blueswir1 | |
2623 | 7fa76c0b | blueswir1 | void helper_lddf(target_ulong addr, int mem_idx) |
2624 | 7fa76c0b | blueswir1 | { |
2625 | c2bc0e38 | blueswir1 | helper_check_align(addr, 7);
|
2626 | 7fa76c0b | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
2627 | 7fa76c0b | blueswir1 | switch (mem_idx) {
|
2628 | 7fa76c0b | blueswir1 | case 0: |
2629 | c2bc0e38 | blueswir1 | DT0 = ldfq_user(addr); |
2630 | 7fa76c0b | blueswir1 | break;
|
2631 | 7fa76c0b | blueswir1 | case 1: |
2632 | c2bc0e38 | blueswir1 | DT0 = ldfq_kernel(addr); |
2633 | 7fa76c0b | blueswir1 | break;
|
2634 | 7fa76c0b | blueswir1 | #ifdef TARGET_SPARC64
|
2635 | 7fa76c0b | blueswir1 | case 2: |
2636 | c2bc0e38 | blueswir1 | DT0 = ldfq_hypv(addr); |
2637 | 7fa76c0b | blueswir1 | break;
|
2638 | 7fa76c0b | blueswir1 | #endif
|
2639 | 7fa76c0b | blueswir1 | default:
|
2640 | 7fa76c0b | blueswir1 | break;
|
2641 | 7fa76c0b | blueswir1 | } |
2642 | 7fa76c0b | blueswir1 | #else
|
2643 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
2644 | c2bc0e38 | blueswir1 | DT0 = ldfq_raw(addr); |
2645 | 7fa76c0b | blueswir1 | #endif
|
2646 | 7fa76c0b | blueswir1 | } |
2647 | 7fa76c0b | blueswir1 | |
2648 | 64a88d5d | blueswir1 | void helper_ldqf(target_ulong addr, int mem_idx) |
2649 | 7fa76c0b | blueswir1 | { |
2650 | 7fa76c0b | blueswir1 | // XXX add 128 bit load
|
2651 | 7fa76c0b | blueswir1 | CPU_QuadU u; |
2652 | 7fa76c0b | blueswir1 | |
2653 | c2bc0e38 | blueswir1 | helper_check_align(addr, 7);
|
2654 | 64a88d5d | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
2655 | 64a88d5d | blueswir1 | switch (mem_idx) {
|
2656 | 64a88d5d | blueswir1 | case 0: |
2657 | c2bc0e38 | blueswir1 | u.ll.upper = ldq_user(addr); |
2658 | c2bc0e38 | blueswir1 | u.ll.lower = ldq_user(addr + 8);
|
2659 | 64a88d5d | blueswir1 | QT0 = u.q; |
2660 | 64a88d5d | blueswir1 | break;
|
2661 | 64a88d5d | blueswir1 | case 1: |
2662 | c2bc0e38 | blueswir1 | u.ll.upper = ldq_kernel(addr); |
2663 | c2bc0e38 | blueswir1 | u.ll.lower = ldq_kernel(addr + 8);
|
2664 | 64a88d5d | blueswir1 | QT0 = u.q; |
2665 | 64a88d5d | blueswir1 | break;
|
2666 | 64a88d5d | blueswir1 | #ifdef TARGET_SPARC64
|
2667 | 64a88d5d | blueswir1 | case 2: |
2668 | c2bc0e38 | blueswir1 | u.ll.upper = ldq_hypv(addr); |
2669 | c2bc0e38 | blueswir1 | u.ll.lower = ldq_hypv(addr + 8);
|
2670 | 64a88d5d | blueswir1 | QT0 = u.q; |
2671 | 64a88d5d | blueswir1 | break;
|
2672 | 64a88d5d | blueswir1 | #endif
|
2673 | 64a88d5d | blueswir1 | default:
|
2674 | 64a88d5d | blueswir1 | break;
|
2675 | 64a88d5d | blueswir1 | } |
2676 | 64a88d5d | blueswir1 | #else
|
2677 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
2678 | c2bc0e38 | blueswir1 | u.ll.upper = ldq_raw(addr); |
2679 | c2bc0e38 | blueswir1 | u.ll.lower = ldq_raw((addr + 8) & 0xffffffffULL); |
2680 | 7fa76c0b | blueswir1 | QT0 = u.q; |
2681 | 64a88d5d | blueswir1 | #endif
|
2682 | 7fa76c0b | blueswir1 | } |
2683 | 7fa76c0b | blueswir1 | |
2684 | 64a88d5d | blueswir1 | void helper_stqf(target_ulong addr, int mem_idx) |
2685 | 7fa76c0b | blueswir1 | { |
2686 | 7fa76c0b | blueswir1 | // XXX add 128 bit store
|
2687 | 7fa76c0b | blueswir1 | CPU_QuadU u; |
2688 | 7fa76c0b | blueswir1 | |
2689 | c2bc0e38 | blueswir1 | helper_check_align(addr, 7);
|
2690 | 64a88d5d | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
2691 | 64a88d5d | blueswir1 | switch (mem_idx) {
|
2692 | 64a88d5d | blueswir1 | case 0: |
2693 | 64a88d5d | blueswir1 | u.q = QT0; |
2694 | c2bc0e38 | blueswir1 | stq_user(addr, u.ll.upper); |
2695 | c2bc0e38 | blueswir1 | stq_user(addr + 8, u.ll.lower);
|
2696 | 64a88d5d | blueswir1 | break;
|
2697 | 64a88d5d | blueswir1 | case 1: |
2698 | 64a88d5d | blueswir1 | u.q = QT0; |
2699 | c2bc0e38 | blueswir1 | stq_kernel(addr, u.ll.upper); |
2700 | c2bc0e38 | blueswir1 | stq_kernel(addr + 8, u.ll.lower);
|
2701 | 64a88d5d | blueswir1 | break;
|
2702 | 64a88d5d | blueswir1 | #ifdef TARGET_SPARC64
|
2703 | 64a88d5d | blueswir1 | case 2: |
2704 | 64a88d5d | blueswir1 | u.q = QT0; |
2705 | c2bc0e38 | blueswir1 | stq_hypv(addr, u.ll.upper); |
2706 | c2bc0e38 | blueswir1 | stq_hypv(addr + 8, u.ll.lower);
|
2707 | 64a88d5d | blueswir1 | break;
|
2708 | 64a88d5d | blueswir1 | #endif
|
2709 | 64a88d5d | blueswir1 | default:
|
2710 | 64a88d5d | blueswir1 | break;
|
2711 | 64a88d5d | blueswir1 | } |
2712 | 64a88d5d | blueswir1 | #else
|
2713 | 7fa76c0b | blueswir1 | u.q = QT0; |
2714 | 2cade6a3 | blueswir1 | address_mask(env, &addr); |
2715 | c2bc0e38 | blueswir1 | stq_raw(addr, u.ll.upper); |
2716 | c2bc0e38 | blueswir1 | stq_raw((addr + 8) & 0xffffffffULL, u.ll.lower); |
2717 | 7fa76c0b | blueswir1 | #endif
|
2718 | 64a88d5d | blueswir1 | } |
2719 | 7fa76c0b | blueswir1 | |
2720 | 3a3b925d | blueswir1 | static inline void set_fsr(void) |
2721 | e8af50a3 | bellard | { |
2722 | 7a0e1f41 | bellard | int rnd_mode;
|
2723 | bb5529bb | blueswir1 | |
2724 | e8af50a3 | bellard | switch (env->fsr & FSR_RD_MASK) {
|
2725 | e8af50a3 | bellard | case FSR_RD_NEAREST:
|
2726 | 7a0e1f41 | bellard | rnd_mode = float_round_nearest_even; |
2727 | 0f8a249a | blueswir1 | break;
|
2728 | ed910241 | bellard | default:
|
2729 | e8af50a3 | bellard | case FSR_RD_ZERO:
|
2730 | 7a0e1f41 | bellard | rnd_mode = float_round_to_zero; |
2731 | 0f8a249a | blueswir1 | break;
|
2732 | e8af50a3 | bellard | case FSR_RD_POS:
|
2733 | 7a0e1f41 | bellard | rnd_mode = float_round_up; |
2734 | 0f8a249a | blueswir1 | break;
|
2735 | e8af50a3 | bellard | case FSR_RD_NEG:
|
2736 | 7a0e1f41 | bellard | rnd_mode = float_round_down; |
2737 | 0f8a249a | blueswir1 | break;
|
2738 | e8af50a3 | bellard | } |
2739 | 7a0e1f41 | bellard | set_float_rounding_mode(rnd_mode, &env->fp_status); |
2740 | e8af50a3 | bellard | } |
2741 | e80cfcfc | bellard | |
2742 | 3a3b925d | blueswir1 | void helper_ldfsr(uint32_t new_fsr)
|
2743 | bb5529bb | blueswir1 | { |
2744 | 3a3b925d | blueswir1 | env->fsr = (new_fsr & FSR_LDFSR_MASK) | (env->fsr & FSR_LDFSR_OLDMASK); |
2745 | 3a3b925d | blueswir1 | set_fsr(); |
2746 | bb5529bb | blueswir1 | } |
2747 | bb5529bb | blueswir1 | |
2748 | 3a3b925d | blueswir1 | #ifdef TARGET_SPARC64
|
2749 | 3a3b925d | blueswir1 | void helper_ldxfsr(uint64_t new_fsr)
|
2750 | 3a3b925d | blueswir1 | { |
2751 | 3a3b925d | blueswir1 | env->fsr = (new_fsr & FSR_LDXFSR_MASK) | (env->fsr & FSR_LDXFSR_OLDMASK); |
2752 | 3a3b925d | blueswir1 | set_fsr(); |
2753 | 3a3b925d | blueswir1 | } |
2754 | 3a3b925d | blueswir1 | #endif
|
2755 | 3a3b925d | blueswir1 | |
2756 | bb5529bb | blueswir1 | void helper_debug(void) |
2757 | e80cfcfc | bellard | { |
2758 | e80cfcfc | bellard | env->exception_index = EXCP_DEBUG; |
2759 | e80cfcfc | bellard | cpu_loop_exit(); |
2760 | e80cfcfc | bellard | } |
2761 | af7bf89b | bellard | |
2762 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
2763 | 72a9747b | blueswir1 | /* XXX: use another pointer for %iN registers to avoid slow wrapping
|
2764 | 72a9747b | blueswir1 | handling ? */
|
2765 | 72a9747b | blueswir1 | void helper_save(void) |
2766 | 72a9747b | blueswir1 | { |
2767 | 72a9747b | blueswir1 | uint32_t cwp; |
2768 | 72a9747b | blueswir1 | |
2769 | 1a14026e | blueswir1 | cwp = cpu_cwp_dec(env, env->cwp - 1);
|
2770 | 72a9747b | blueswir1 | if (env->wim & (1 << cwp)) { |
2771 | 72a9747b | blueswir1 | raise_exception(TT_WIN_OVF); |
2772 | 72a9747b | blueswir1 | } |
2773 | 72a9747b | blueswir1 | set_cwp(cwp); |
2774 | 72a9747b | blueswir1 | } |
2775 | 72a9747b | blueswir1 | |
2776 | 72a9747b | blueswir1 | void helper_restore(void) |
2777 | 72a9747b | blueswir1 | { |
2778 | 72a9747b | blueswir1 | uint32_t cwp; |
2779 | 72a9747b | blueswir1 | |
2780 | 1a14026e | blueswir1 | cwp = cpu_cwp_inc(env, env->cwp + 1);
|
2781 | 72a9747b | blueswir1 | if (env->wim & (1 << cwp)) { |
2782 | 72a9747b | blueswir1 | raise_exception(TT_WIN_UNF); |
2783 | 72a9747b | blueswir1 | } |
2784 | 72a9747b | blueswir1 | set_cwp(cwp); |
2785 | 72a9747b | blueswir1 | } |
2786 | 72a9747b | blueswir1 | |
2787 | 1a2fb1c0 | blueswir1 | void helper_wrpsr(target_ulong new_psr)
|
2788 | af7bf89b | bellard | { |
2789 | 1a14026e | blueswir1 | if ((new_psr & PSR_CWP) >= env->nwindows)
|
2790 | d4218d99 | blueswir1 | raise_exception(TT_ILL_INSN); |
2791 | d4218d99 | blueswir1 | else
|
2792 | 1a2fb1c0 | blueswir1 | PUT_PSR(env, new_psr); |
2793 | af7bf89b | bellard | } |
2794 | af7bf89b | bellard | |
2795 | 1a2fb1c0 | blueswir1 | target_ulong helper_rdpsr(void)
|
2796 | af7bf89b | bellard | { |
2797 | 1a2fb1c0 | blueswir1 | return GET_PSR(env);
|
2798 | af7bf89b | bellard | } |
2799 | 3475187d | bellard | |
2800 | 3475187d | bellard | #else
|
2801 | 72a9747b | blueswir1 | /* XXX: use another pointer for %iN registers to avoid slow wrapping
|
2802 | 72a9747b | blueswir1 | handling ? */
|
2803 | 72a9747b | blueswir1 | void helper_save(void) |
2804 | 72a9747b | blueswir1 | { |
2805 | 72a9747b | blueswir1 | uint32_t cwp; |
2806 | 72a9747b | blueswir1 | |
2807 | 1a14026e | blueswir1 | cwp = cpu_cwp_dec(env, env->cwp - 1);
|
2808 | 72a9747b | blueswir1 | if (env->cansave == 0) { |
2809 | 72a9747b | blueswir1 | raise_exception(TT_SPILL | (env->otherwin != 0 ?
|
2810 | 72a9747b | blueswir1 | (TT_WOTHER | ((env->wstate & 0x38) >> 1)): |
2811 | 72a9747b | blueswir1 | ((env->wstate & 0x7) << 2))); |
2812 | 72a9747b | blueswir1 | } else {
|
2813 | 72a9747b | blueswir1 | if (env->cleanwin - env->canrestore == 0) { |
2814 | 72a9747b | blueswir1 | // XXX Clean windows without trap
|
2815 | 72a9747b | blueswir1 | raise_exception(TT_CLRWIN); |
2816 | 72a9747b | blueswir1 | } else {
|
2817 | 72a9747b | blueswir1 | env->cansave--; |
2818 | 72a9747b | blueswir1 | env->canrestore++; |
2819 | 72a9747b | blueswir1 | set_cwp(cwp); |
2820 | 72a9747b | blueswir1 | } |
2821 | 72a9747b | blueswir1 | } |
2822 | 72a9747b | blueswir1 | } |
2823 | 72a9747b | blueswir1 | |
2824 | 72a9747b | blueswir1 | void helper_restore(void) |
2825 | 72a9747b | blueswir1 | { |
2826 | 72a9747b | blueswir1 | uint32_t cwp; |
2827 | 72a9747b | blueswir1 | |
2828 | 1a14026e | blueswir1 | cwp = cpu_cwp_inc(env, env->cwp + 1);
|
2829 | 72a9747b | blueswir1 | if (env->canrestore == 0) { |
2830 | 72a9747b | blueswir1 | raise_exception(TT_FILL | (env->otherwin != 0 ?
|
2831 | 72a9747b | blueswir1 | (TT_WOTHER | ((env->wstate & 0x38) >> 1)): |
2832 | 72a9747b | blueswir1 | ((env->wstate & 0x7) << 2))); |
2833 | 72a9747b | blueswir1 | } else {
|
2834 | 72a9747b | blueswir1 | env->cansave++; |
2835 | 72a9747b | blueswir1 | env->canrestore--; |
2836 | 72a9747b | blueswir1 | set_cwp(cwp); |
2837 | 72a9747b | blueswir1 | } |
2838 | 72a9747b | blueswir1 | } |
2839 | 72a9747b | blueswir1 | |
2840 | 72a9747b | blueswir1 | void helper_flushw(void) |
2841 | 72a9747b | blueswir1 | { |
2842 | 1a14026e | blueswir1 | if (env->cansave != env->nwindows - 2) { |
2843 | 72a9747b | blueswir1 | raise_exception(TT_SPILL | (env->otherwin != 0 ?
|
2844 | 72a9747b | blueswir1 | (TT_WOTHER | ((env->wstate & 0x38) >> 1)): |
2845 | 72a9747b | blueswir1 | ((env->wstate & 0x7) << 2))); |
2846 | 72a9747b | blueswir1 | } |
2847 | 72a9747b | blueswir1 | } |
2848 | 72a9747b | blueswir1 | |
2849 | 72a9747b | blueswir1 | void helper_saved(void) |
2850 | 72a9747b | blueswir1 | { |
2851 | 72a9747b | blueswir1 | env->cansave++; |
2852 | 72a9747b | blueswir1 | if (env->otherwin == 0) |
2853 | 72a9747b | blueswir1 | env->canrestore--; |
2854 | 72a9747b | blueswir1 | else
|
2855 | 72a9747b | blueswir1 | env->otherwin--; |
2856 | 72a9747b | blueswir1 | } |
2857 | 72a9747b | blueswir1 | |
2858 | 72a9747b | blueswir1 | void helper_restored(void) |
2859 | 72a9747b | blueswir1 | { |
2860 | 72a9747b | blueswir1 | env->canrestore++; |
2861 | 1a14026e | blueswir1 | if (env->cleanwin < env->nwindows - 1) |
2862 | 72a9747b | blueswir1 | env->cleanwin++; |
2863 | 72a9747b | blueswir1 | if (env->otherwin == 0) |
2864 | 72a9747b | blueswir1 | env->cansave--; |
2865 | 72a9747b | blueswir1 | else
|
2866 | 72a9747b | blueswir1 | env->otherwin--; |
2867 | 72a9747b | blueswir1 | } |
2868 | 72a9747b | blueswir1 | |
2869 | d35527d9 | blueswir1 | target_ulong helper_rdccr(void)
|
2870 | d35527d9 | blueswir1 | { |
2871 | d35527d9 | blueswir1 | return GET_CCR(env);
|
2872 | d35527d9 | blueswir1 | } |
2873 | d35527d9 | blueswir1 | |
2874 | d35527d9 | blueswir1 | void helper_wrccr(target_ulong new_ccr)
|
2875 | d35527d9 | blueswir1 | { |
2876 | d35527d9 | blueswir1 | PUT_CCR(env, new_ccr); |
2877 | d35527d9 | blueswir1 | } |
2878 | d35527d9 | blueswir1 | |
2879 | d35527d9 | blueswir1 | // CWP handling is reversed in V9, but we still use the V8 register
|
2880 | d35527d9 | blueswir1 | // order.
|
2881 | d35527d9 | blueswir1 | target_ulong helper_rdcwp(void)
|
2882 | d35527d9 | blueswir1 | { |
2883 | d35527d9 | blueswir1 | return GET_CWP64(env);
|
2884 | d35527d9 | blueswir1 | } |
2885 | d35527d9 | blueswir1 | |
2886 | d35527d9 | blueswir1 | void helper_wrcwp(target_ulong new_cwp)
|
2887 | d35527d9 | blueswir1 | { |
2888 | d35527d9 | blueswir1 | PUT_CWP64(env, new_cwp); |
2889 | d35527d9 | blueswir1 | } |
2890 | 3475187d | bellard | |
2891 | 1f5063fb | blueswir1 | // This function uses non-native bit order
|
2892 | 1f5063fb | blueswir1 | #define GET_FIELD(X, FROM, TO) \
|
2893 | 1f5063fb | blueswir1 | ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1)) |
2894 | 1f5063fb | blueswir1 | |
2895 | 1f5063fb | blueswir1 | // This function uses the order in the manuals, i.e. bit 0 is 2^0
|
2896 | 1f5063fb | blueswir1 | #define GET_FIELD_SP(X, FROM, TO) \
|
2897 | 1f5063fb | blueswir1 | GET_FIELD(X, 63 - (TO), 63 - (FROM)) |
2898 | 1f5063fb | blueswir1 | |
2899 | 1f5063fb | blueswir1 | target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) |
2900 | 1f5063fb | blueswir1 | { |
2901 | 1f5063fb | blueswir1 | return (GET_FIELD_SP(pixel_addr, 60, 63) << (17 + 2 * cubesize)) | |
2902 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 39, 39 + cubesize - 1) << (17 + cubesize)) | |
2903 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 17 + cubesize - 1, 17) << 17) | |
2904 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 56, 59) << 13) | |
2905 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 35, 38) << 9) | |
2906 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 13, 16) << 5) | |
2907 | 1f5063fb | blueswir1 | (((pixel_addr >> 55) & 1) << 4) | |
2908 | 1f5063fb | blueswir1 | (GET_FIELD_SP(pixel_addr, 33, 34) << 2) | |
2909 | 1f5063fb | blueswir1 | GET_FIELD_SP(pixel_addr, 11, 12); |
2910 | 1f5063fb | blueswir1 | } |
2911 | 1f5063fb | blueswir1 | |
2912 | 1f5063fb | blueswir1 | target_ulong helper_alignaddr(target_ulong addr, target_ulong offset) |
2913 | 1f5063fb | blueswir1 | { |
2914 | 1f5063fb | blueswir1 | uint64_t tmp; |
2915 | 1f5063fb | blueswir1 | |
2916 | 1f5063fb | blueswir1 | tmp = addr + offset; |
2917 | 1f5063fb | blueswir1 | env->gsr &= ~7ULL;
|
2918 | 1f5063fb | blueswir1 | env->gsr |= tmp & 7ULL;
|
2919 | 1f5063fb | blueswir1 | return tmp & ~7ULL; |
2920 | 1f5063fb | blueswir1 | } |
2921 | 1f5063fb | blueswir1 | |
2922 | 1a2fb1c0 | blueswir1 | target_ulong helper_popc(target_ulong val) |
2923 | 3475187d | bellard | { |
2924 | 1a2fb1c0 | blueswir1 | return ctpop64(val);
|
2925 | 3475187d | bellard | } |
2926 | 83469015 | bellard | |
2927 | 83469015 | bellard | static inline uint64_t *get_gregset(uint64_t pstate) |
2928 | 83469015 | bellard | { |
2929 | 83469015 | bellard | switch (pstate) {
|
2930 | 83469015 | bellard | default:
|
2931 | 83469015 | bellard | case 0: |
2932 | 0f8a249a | blueswir1 | return env->bgregs;
|
2933 | 83469015 | bellard | case PS_AG:
|
2934 | 0f8a249a | blueswir1 | return env->agregs;
|
2935 | 83469015 | bellard | case PS_MG:
|
2936 | 0f8a249a | blueswir1 | return env->mgregs;
|
2937 | 83469015 | bellard | case PS_IG:
|
2938 | 0f8a249a | blueswir1 | return env->igregs;
|
2939 | 83469015 | bellard | } |
2940 | 83469015 | bellard | } |
2941 | 83469015 | bellard | |
2942 | 91736d37 | blueswir1 | static inline void change_pstate(uint64_t new_pstate) |
2943 | 83469015 | bellard | { |
2944 | 8f1f22f6 | blueswir1 | uint64_t pstate_regs, new_pstate_regs; |
2945 | 83469015 | bellard | uint64_t *src, *dst; |
2946 | 83469015 | bellard | |
2947 | 83469015 | bellard | pstate_regs = env->pstate & 0xc01;
|
2948 | 83469015 | bellard | new_pstate_regs = new_pstate & 0xc01;
|
2949 | 83469015 | bellard | if (new_pstate_regs != pstate_regs) {
|
2950 | 0f8a249a | blueswir1 | // Switch global register bank
|
2951 | 0f8a249a | blueswir1 | src = get_gregset(new_pstate_regs); |
2952 | 0f8a249a | blueswir1 | dst = get_gregset(pstate_regs); |
2953 | 0f8a249a | blueswir1 | memcpy32(dst, env->gregs); |
2954 | 0f8a249a | blueswir1 | memcpy32(env->gregs, src); |
2955 | 83469015 | bellard | } |
2956 | 83469015 | bellard | env->pstate = new_pstate; |
2957 | 83469015 | bellard | } |
2958 | 83469015 | bellard | |
2959 | 1a2fb1c0 | blueswir1 | void helper_wrpstate(target_ulong new_state)
|
2960 | 8f1f22f6 | blueswir1 | { |
2961 | 5578ceab | blueswir1 | if (!(env->def->features & CPU_FEATURE_GL))
|
2962 | fb79ceb9 | blueswir1 | change_pstate(new_state & 0xf3f);
|
2963 | 8f1f22f6 | blueswir1 | } |
2964 | 8f1f22f6 | blueswir1 | |
2965 | 1a2fb1c0 | blueswir1 | void helper_done(void) |
2966 | 83469015 | bellard | { |
2967 | 375ee38b | blueswir1 | env->pc = env->tsptr->tpc; |
2968 | 375ee38b | blueswir1 | env->npc = env->tsptr->tnpc + 4;
|
2969 | 375ee38b | blueswir1 | PUT_CCR(env, env->tsptr->tstate >> 32);
|
2970 | 375ee38b | blueswir1 | env->asi = (env->tsptr->tstate >> 24) & 0xff; |
2971 | 375ee38b | blueswir1 | change_pstate((env->tsptr->tstate >> 8) & 0xf3f); |
2972 | 375ee38b | blueswir1 | PUT_CWP64(env, env->tsptr->tstate & 0xff);
|
2973 | e6bf7d70 | blueswir1 | env->tl--; |
2974 | c19148bd | blueswir1 | env->tsptr = &env->ts[env->tl & MAXTL_MASK]; |
2975 | 83469015 | bellard | } |
2976 | 83469015 | bellard | |
2977 | 1a2fb1c0 | blueswir1 | void helper_retry(void) |
2978 | 83469015 | bellard | { |
2979 | 375ee38b | blueswir1 | env->pc = env->tsptr->tpc; |
2980 | 375ee38b | blueswir1 | env->npc = env->tsptr->tnpc; |
2981 | 375ee38b | blueswir1 | PUT_CCR(env, env->tsptr->tstate >> 32);
|
2982 | 375ee38b | blueswir1 | env->asi = (env->tsptr->tstate >> 24) & 0xff; |
2983 | 375ee38b | blueswir1 | change_pstate((env->tsptr->tstate >> 8) & 0xf3f); |
2984 | 375ee38b | blueswir1 | PUT_CWP64(env, env->tsptr->tstate & 0xff);
|
2985 | e6bf7d70 | blueswir1 | env->tl--; |
2986 | c19148bd | blueswir1 | env->tsptr = &env->ts[env->tl & MAXTL_MASK]; |
2987 | 83469015 | bellard | } |
2988 | 9d926598 | blueswir1 | |
2989 | 9d926598 | blueswir1 | void helper_set_softint(uint64_t value)
|
2990 | 9d926598 | blueswir1 | { |
2991 | 9d926598 | blueswir1 | env->softint |= (uint32_t)value; |
2992 | 9d926598 | blueswir1 | } |
2993 | 9d926598 | blueswir1 | |
2994 | 9d926598 | blueswir1 | void helper_clear_softint(uint64_t value)
|
2995 | 9d926598 | blueswir1 | { |
2996 | 9d926598 | blueswir1 | env->softint &= (uint32_t)~value; |
2997 | 9d926598 | blueswir1 | } |
2998 | 9d926598 | blueswir1 | |
2999 | 9d926598 | blueswir1 | void helper_write_softint(uint64_t value)
|
3000 | 9d926598 | blueswir1 | { |
3001 | 9d926598 | blueswir1 | env->softint = (uint32_t)value; |
3002 | 9d926598 | blueswir1 | } |
3003 | 3475187d | bellard | #endif
|
3004 | ee5bbe38 | bellard | |
3005 | 91736d37 | blueswir1 | void helper_flush(target_ulong addr)
|
3006 | ee5bbe38 | bellard | { |
3007 | 91736d37 | blueswir1 | addr &= ~7;
|
3008 | 91736d37 | blueswir1 | tb_invalidate_page_range(addr, addr + 8);
|
3009 | ee5bbe38 | bellard | } |
3010 | ee5bbe38 | bellard | |
3011 | 91736d37 | blueswir1 | #ifdef TARGET_SPARC64
|
3012 | 91736d37 | blueswir1 | #ifdef DEBUG_PCALL
|
3013 | 91736d37 | blueswir1 | static const char * const excp_names[0x80] = { |
3014 | 91736d37 | blueswir1 | [TT_TFAULT] = "Instruction Access Fault",
|
3015 | 91736d37 | blueswir1 | [TT_TMISS] = "Instruction Access MMU Miss",
|
3016 | 91736d37 | blueswir1 | [TT_CODE_ACCESS] = "Instruction Access Error",
|
3017 | 91736d37 | blueswir1 | [TT_ILL_INSN] = "Illegal Instruction",
|
3018 | 91736d37 | blueswir1 | [TT_PRIV_INSN] = "Privileged Instruction",
|
3019 | 91736d37 | blueswir1 | [TT_NFPU_INSN] = "FPU Disabled",
|
3020 | 91736d37 | blueswir1 | [TT_FP_EXCP] = "FPU Exception",
|
3021 | 91736d37 | blueswir1 | [TT_TOVF] = "Tag Overflow",
|
3022 | 91736d37 | blueswir1 | [TT_CLRWIN] = "Clean Windows",
|
3023 | 91736d37 | blueswir1 | [TT_DIV_ZERO] = "Division By Zero",
|
3024 | 91736d37 | blueswir1 | [TT_DFAULT] = "Data Access Fault",
|
3025 | 91736d37 | blueswir1 | [TT_DMISS] = "Data Access MMU Miss",
|
3026 | 91736d37 | blueswir1 | [TT_DATA_ACCESS] = "Data Access Error",
|
3027 | 91736d37 | blueswir1 | [TT_DPROT] = "Data Protection Error",
|
3028 | 91736d37 | blueswir1 | [TT_UNALIGNED] = "Unaligned Memory Access",
|
3029 | 91736d37 | blueswir1 | [TT_PRIV_ACT] = "Privileged Action",
|
3030 | 91736d37 | blueswir1 | [TT_EXTINT | 0x1] = "External Interrupt 1", |
3031 | 91736d37 | blueswir1 | [TT_EXTINT | 0x2] = "External Interrupt 2", |
3032 | 91736d37 | blueswir1 | [TT_EXTINT | 0x3] = "External Interrupt 3", |
3033 | 91736d37 | blueswir1 | [TT_EXTINT | 0x4] = "External Interrupt 4", |
3034 | 91736d37 | blueswir1 | [TT_EXTINT | 0x5] = "External Interrupt 5", |
3035 | 91736d37 | blueswir1 | [TT_EXTINT | 0x6] = "External Interrupt 6", |
3036 | 91736d37 | blueswir1 | [TT_EXTINT | 0x7] = "External Interrupt 7", |
3037 | 91736d37 | blueswir1 | [TT_EXTINT | 0x8] = "External Interrupt 8", |
3038 | 91736d37 | blueswir1 | [TT_EXTINT | 0x9] = "External Interrupt 9", |
3039 | 91736d37 | blueswir1 | [TT_EXTINT | 0xa] = "External Interrupt 10", |
3040 | 91736d37 | blueswir1 | [TT_EXTINT | 0xb] = "External Interrupt 11", |
3041 | 91736d37 | blueswir1 | [TT_EXTINT | 0xc] = "External Interrupt 12", |
3042 | 91736d37 | blueswir1 | [TT_EXTINT | 0xd] = "External Interrupt 13", |
3043 | 91736d37 | blueswir1 | [TT_EXTINT | 0xe] = "External Interrupt 14", |
3044 | 91736d37 | blueswir1 | [TT_EXTINT | 0xf] = "External Interrupt 15", |
3045 | 91736d37 | blueswir1 | }; |
3046 | 91736d37 | blueswir1 | #endif
|
3047 | 91736d37 | blueswir1 | |
3048 | 91736d37 | blueswir1 | void do_interrupt(CPUState *env)
|
3049 | 91736d37 | blueswir1 | { |
3050 | 91736d37 | blueswir1 | int intno = env->exception_index;
|
3051 | 91736d37 | blueswir1 | |
3052 | 91736d37 | blueswir1 | #ifdef DEBUG_PCALL
|
3053 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_INT)) {
|
3054 | 91736d37 | blueswir1 | static int count; |
3055 | 91736d37 | blueswir1 | const char *name; |
3056 | 91736d37 | blueswir1 | |
3057 | 91736d37 | blueswir1 | if (intno < 0 || intno >= 0x180) |
3058 | 91736d37 | blueswir1 | name = "Unknown";
|
3059 | 91736d37 | blueswir1 | else if (intno >= 0x100) |
3060 | 91736d37 | blueswir1 | name = "Trap Instruction";
|
3061 | 91736d37 | blueswir1 | else if (intno >= 0xc0) |
3062 | 91736d37 | blueswir1 | name = "Window Fill";
|
3063 | 91736d37 | blueswir1 | else if (intno >= 0x80) |
3064 | 91736d37 | blueswir1 | name = "Window Spill";
|
3065 | 91736d37 | blueswir1 | else {
|
3066 | 91736d37 | blueswir1 | name = excp_names[intno]; |
3067 | 91736d37 | blueswir1 | if (!name)
|
3068 | 91736d37 | blueswir1 | name = "Unknown";
|
3069 | 91736d37 | blueswir1 | } |
3070 | 91736d37 | blueswir1 | |
3071 | 93fcfe39 | aliguori | qemu_log("%6d: %s (v=%04x) pc=%016" PRIx64 " npc=%016" PRIx64 |
3072 | 91736d37 | blueswir1 | " SP=%016" PRIx64 "\n", |
3073 | 91736d37 | blueswir1 | count, name, intno, |
3074 | 91736d37 | blueswir1 | env->pc, |
3075 | 91736d37 | blueswir1 | env->npc, env->regwptr[6]);
|
3076 | 93fcfe39 | aliguori | log_cpu_state(env, 0);
|
3077 | 91736d37 | blueswir1 | #if 0
|
3078 | 91736d37 | blueswir1 | {
|
3079 | 91736d37 | blueswir1 | int i;
|
3080 | 91736d37 | blueswir1 | uint8_t *ptr;
|
3081 | 91736d37 | blueswir1 | |
3082 | 93fcfe39 | aliguori | qemu_log(" code=");
|
3083 | 91736d37 | blueswir1 | ptr = (uint8_t *)env->pc;
|
3084 | 91736d37 | blueswir1 | for(i = 0; i < 16; i++) {
|
3085 | 93fcfe39 | aliguori | qemu_log(" %02x", ldub(ptr + i));
|
3086 | 91736d37 | blueswir1 | }
|
3087 | 93fcfe39 | aliguori | qemu_log("\n");
|
3088 | 91736d37 | blueswir1 | }
|
3089 | 91736d37 | blueswir1 | #endif
|
3090 | 91736d37 | blueswir1 | count++; |
3091 | 91736d37 | blueswir1 | } |
3092 | 91736d37 | blueswir1 | #endif
|
3093 | 91736d37 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
3094 | 91736d37 | blueswir1 | if (env->tl >= env->maxtl) {
|
3095 | 91736d37 | blueswir1 | cpu_abort(env, "Trap 0x%04x while trap level (%d) >= MAXTL (%d),"
|
3096 | 91736d37 | blueswir1 | " Error state", env->exception_index, env->tl, env->maxtl);
|
3097 | 91736d37 | blueswir1 | return;
|
3098 | 91736d37 | blueswir1 | } |
3099 | 91736d37 | blueswir1 | #endif
|
3100 | 91736d37 | blueswir1 | if (env->tl < env->maxtl - 1) { |
3101 | 91736d37 | blueswir1 | env->tl++; |
3102 | 91736d37 | blueswir1 | } else {
|
3103 | 91736d37 | blueswir1 | env->pstate |= PS_RED; |
3104 | 91736d37 | blueswir1 | if (env->tl < env->maxtl)
|
3105 | 91736d37 | blueswir1 | env->tl++; |
3106 | 91736d37 | blueswir1 | } |
3107 | 91736d37 | blueswir1 | env->tsptr = &env->ts[env->tl & MAXTL_MASK]; |
3108 | 91736d37 | blueswir1 | env->tsptr->tstate = ((uint64_t)GET_CCR(env) << 32) |
|
3109 | 91736d37 | blueswir1 | ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) | |
3110 | 91736d37 | blueswir1 | GET_CWP64(env); |
3111 | 91736d37 | blueswir1 | env->tsptr->tpc = env->pc; |
3112 | 91736d37 | blueswir1 | env->tsptr->tnpc = env->npc; |
3113 | 91736d37 | blueswir1 | env->tsptr->tt = intno; |
3114 | 91736d37 | blueswir1 | if (!(env->def->features & CPU_FEATURE_GL)) {
|
3115 | 91736d37 | blueswir1 | switch (intno) {
|
3116 | 91736d37 | blueswir1 | case TT_IVEC:
|
3117 | 91736d37 | blueswir1 | change_pstate(PS_PEF | PS_PRIV | PS_IG); |
3118 | 91736d37 | blueswir1 | break;
|
3119 | 91736d37 | blueswir1 | case TT_TFAULT:
|
3120 | 91736d37 | blueswir1 | case TT_TMISS:
|
3121 | 91736d37 | blueswir1 | case TT_DFAULT:
|
3122 | 91736d37 | blueswir1 | case TT_DMISS:
|
3123 | 91736d37 | blueswir1 | case TT_DPROT:
|
3124 | 91736d37 | blueswir1 | change_pstate(PS_PEF | PS_PRIV | PS_MG); |
3125 | 91736d37 | blueswir1 | break;
|
3126 | 91736d37 | blueswir1 | default:
|
3127 | 91736d37 | blueswir1 | change_pstate(PS_PEF | PS_PRIV | PS_AG); |
3128 | 91736d37 | blueswir1 | break;
|
3129 | 91736d37 | blueswir1 | } |
3130 | 91736d37 | blueswir1 | } |
3131 | 91736d37 | blueswir1 | if (intno == TT_CLRWIN)
|
3132 | 91736d37 | blueswir1 | cpu_set_cwp(env, cpu_cwp_dec(env, env->cwp - 1));
|
3133 | 91736d37 | blueswir1 | else if ((intno & 0x1c0) == TT_SPILL) |
3134 | 91736d37 | blueswir1 | cpu_set_cwp(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2));
|
3135 | 91736d37 | blueswir1 | else if ((intno & 0x1c0) == TT_FILL) |
3136 | 91736d37 | blueswir1 | cpu_set_cwp(env, cpu_cwp_inc(env, env->cwp + 1));
|
3137 | 91736d37 | blueswir1 | env->tbr &= ~0x7fffULL;
|
3138 | 91736d37 | blueswir1 | env->tbr |= ((env->tl > 1) ? 1 << 14 : 0) | (intno << 5); |
3139 | 91736d37 | blueswir1 | env->pc = env->tbr; |
3140 | 91736d37 | blueswir1 | env->npc = env->pc + 4;
|
3141 | 91736d37 | blueswir1 | env->exception_index = 0;
|
3142 | ee5bbe38 | bellard | } |
3143 | 91736d37 | blueswir1 | #else
|
3144 | 91736d37 | blueswir1 | #ifdef DEBUG_PCALL
|
3145 | 91736d37 | blueswir1 | static const char * const excp_names[0x80] = { |
3146 | 91736d37 | blueswir1 | [TT_TFAULT] = "Instruction Access Fault",
|
3147 | 91736d37 | blueswir1 | [TT_ILL_INSN] = "Illegal Instruction",
|
3148 | 91736d37 | blueswir1 | [TT_PRIV_INSN] = "Privileged Instruction",
|
3149 | 91736d37 | blueswir1 | [TT_NFPU_INSN] = "FPU Disabled",
|
3150 | 91736d37 | blueswir1 | [TT_WIN_OVF] = "Window Overflow",
|
3151 | 91736d37 | blueswir1 | [TT_WIN_UNF] = "Window Underflow",
|
3152 | 91736d37 | blueswir1 | [TT_UNALIGNED] = "Unaligned Memory Access",
|
3153 | 91736d37 | blueswir1 | [TT_FP_EXCP] = "FPU Exception",
|
3154 | 91736d37 | blueswir1 | [TT_DFAULT] = "Data Access Fault",
|
3155 | 91736d37 | blueswir1 | [TT_TOVF] = "Tag Overflow",
|
3156 | 91736d37 | blueswir1 | [TT_EXTINT | 0x1] = "External Interrupt 1", |
3157 | 91736d37 | blueswir1 | [TT_EXTINT | 0x2] = "External Interrupt 2", |
3158 | 91736d37 | blueswir1 | [TT_EXTINT | 0x3] = "External Interrupt 3", |
3159 | 91736d37 | blueswir1 | [TT_EXTINT | 0x4] = "External Interrupt 4", |
3160 | 91736d37 | blueswir1 | [TT_EXTINT | 0x5] = "External Interrupt 5", |
3161 | 91736d37 | blueswir1 | [TT_EXTINT | 0x6] = "External Interrupt 6", |
3162 | 91736d37 | blueswir1 | [TT_EXTINT | 0x7] = "External Interrupt 7", |
3163 | 91736d37 | blueswir1 | [TT_EXTINT | 0x8] = "External Interrupt 8", |
3164 | 91736d37 | blueswir1 | [TT_EXTINT | 0x9] = "External Interrupt 9", |
3165 | 91736d37 | blueswir1 | [TT_EXTINT | 0xa] = "External Interrupt 10", |
3166 | 91736d37 | blueswir1 | [TT_EXTINT | 0xb] = "External Interrupt 11", |
3167 | 91736d37 | blueswir1 | [TT_EXTINT | 0xc] = "External Interrupt 12", |
3168 | 91736d37 | blueswir1 | [TT_EXTINT | 0xd] = "External Interrupt 13", |
3169 | 91736d37 | blueswir1 | [TT_EXTINT | 0xe] = "External Interrupt 14", |
3170 | 91736d37 | blueswir1 | [TT_EXTINT | 0xf] = "External Interrupt 15", |
3171 | 91736d37 | blueswir1 | [TT_TOVF] = "Tag Overflow",
|
3172 | 91736d37 | blueswir1 | [TT_CODE_ACCESS] = "Instruction Access Error",
|
3173 | 91736d37 | blueswir1 | [TT_DATA_ACCESS] = "Data Access Error",
|
3174 | 91736d37 | blueswir1 | [TT_DIV_ZERO] = "Division By Zero",
|
3175 | 91736d37 | blueswir1 | [TT_NCP_INSN] = "Coprocessor Disabled",
|
3176 | 91736d37 | blueswir1 | }; |
3177 | 91736d37 | blueswir1 | #endif
|
3178 | ee5bbe38 | bellard | |
3179 | 91736d37 | blueswir1 | void do_interrupt(CPUState *env)
|
3180 | ee5bbe38 | bellard | { |
3181 | 91736d37 | blueswir1 | int cwp, intno = env->exception_index;
|
3182 | 91736d37 | blueswir1 | |
3183 | 91736d37 | blueswir1 | #ifdef DEBUG_PCALL
|
3184 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_INT)) {
|
3185 | 91736d37 | blueswir1 | static int count; |
3186 | 91736d37 | blueswir1 | const char *name; |
3187 | 91736d37 | blueswir1 | |
3188 | 91736d37 | blueswir1 | if (intno < 0 || intno >= 0x100) |
3189 | 91736d37 | blueswir1 | name = "Unknown";
|
3190 | 91736d37 | blueswir1 | else if (intno >= 0x80) |
3191 | 91736d37 | blueswir1 | name = "Trap Instruction";
|
3192 | 91736d37 | blueswir1 | else {
|
3193 | 91736d37 | blueswir1 | name = excp_names[intno]; |
3194 | 91736d37 | blueswir1 | if (!name)
|
3195 | 91736d37 | blueswir1 | name = "Unknown";
|
3196 | 91736d37 | blueswir1 | } |
3197 | 91736d37 | blueswir1 | |
3198 | 93fcfe39 | aliguori | qemu_log("%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
|
3199 | 91736d37 | blueswir1 | count, name, intno, |
3200 | 91736d37 | blueswir1 | env->pc, |
3201 | 91736d37 | blueswir1 | env->npc, env->regwptr[6]);
|
3202 | 93fcfe39 | aliguori | log_cpu_state(env, 0);
|
3203 | 91736d37 | blueswir1 | #if 0
|
3204 | 91736d37 | blueswir1 | {
|
3205 | 91736d37 | blueswir1 | int i;
|
3206 | 91736d37 | blueswir1 | uint8_t *ptr;
|
3207 | 91736d37 | blueswir1 | |
3208 | 93fcfe39 | aliguori | qemu_log(" code=");
|
3209 | 91736d37 | blueswir1 | ptr = (uint8_t *)env->pc;
|
3210 | 91736d37 | blueswir1 | for(i = 0; i < 16; i++) {
|
3211 | 93fcfe39 | aliguori | qemu_log(" %02x", ldub(ptr + i));
|
3212 | 91736d37 | blueswir1 | }
|
3213 | 93fcfe39 | aliguori | qemu_log("\n");
|
3214 | 91736d37 | blueswir1 | }
|
3215 | 91736d37 | blueswir1 | #endif
|
3216 | 91736d37 | blueswir1 | count++; |
3217 | 91736d37 | blueswir1 | } |
3218 | 91736d37 | blueswir1 | #endif
|
3219 | 91736d37 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
3220 | 91736d37 | blueswir1 | if (env->psret == 0) { |
3221 | 91736d37 | blueswir1 | cpu_abort(env, "Trap 0x%02x while interrupts disabled, Error state",
|
3222 | 91736d37 | blueswir1 | env->exception_index); |
3223 | 91736d37 | blueswir1 | return;
|
3224 | 91736d37 | blueswir1 | } |
3225 | 91736d37 | blueswir1 | #endif
|
3226 | 91736d37 | blueswir1 | env->psret = 0;
|
3227 | 91736d37 | blueswir1 | cwp = cpu_cwp_dec(env, env->cwp - 1);
|
3228 | 91736d37 | blueswir1 | cpu_set_cwp(env, cwp); |
3229 | 91736d37 | blueswir1 | env->regwptr[9] = env->pc;
|
3230 | 91736d37 | blueswir1 | env->regwptr[10] = env->npc;
|
3231 | 91736d37 | blueswir1 | env->psrps = env->psrs; |
3232 | 91736d37 | blueswir1 | env->psrs = 1;
|
3233 | 91736d37 | blueswir1 | env->tbr = (env->tbr & TBR_BASE_MASK) | (intno << 4);
|
3234 | 91736d37 | blueswir1 | env->pc = env->tbr; |
3235 | 91736d37 | blueswir1 | env->npc = env->pc + 4;
|
3236 | 91736d37 | blueswir1 | env->exception_index = 0;
|
3237 | ee5bbe38 | bellard | } |
3238 | 91736d37 | blueswir1 | #endif
|
3239 | ee5bbe38 | bellard | |
3240 | 5fafdf24 | ths | #if !defined(CONFIG_USER_ONLY)
|
3241 | ee5bbe38 | bellard | |
3242 | d2889a3e | blueswir1 | static void do_unaligned_access(target_ulong addr, int is_write, int is_user, |
3243 | d2889a3e | blueswir1 | void *retaddr);
|
3244 | d2889a3e | blueswir1 | |
3245 | ee5bbe38 | bellard | #define MMUSUFFIX _mmu
|
3246 | d2889a3e | blueswir1 | #define ALIGNED_ONLY
|
3247 | ee5bbe38 | bellard | |
3248 | ee5bbe38 | bellard | #define SHIFT 0 |
3249 | ee5bbe38 | bellard | #include "softmmu_template.h" |
3250 | ee5bbe38 | bellard | |
3251 | ee5bbe38 | bellard | #define SHIFT 1 |
3252 | ee5bbe38 | bellard | #include "softmmu_template.h" |
3253 | ee5bbe38 | bellard | |
3254 | ee5bbe38 | bellard | #define SHIFT 2 |
3255 | ee5bbe38 | bellard | #include "softmmu_template.h" |
3256 | ee5bbe38 | bellard | |
3257 | ee5bbe38 | bellard | #define SHIFT 3 |
3258 | ee5bbe38 | bellard | #include "softmmu_template.h" |
3259 | ee5bbe38 | bellard | |
3260 | c2bc0e38 | blueswir1 | /* XXX: make it generic ? */
|
3261 | c2bc0e38 | blueswir1 | static void cpu_restore_state2(void *retaddr) |
3262 | c2bc0e38 | blueswir1 | { |
3263 | c2bc0e38 | blueswir1 | TranslationBlock *tb; |
3264 | c2bc0e38 | blueswir1 | unsigned long pc; |
3265 | c2bc0e38 | blueswir1 | |
3266 | c2bc0e38 | blueswir1 | if (retaddr) {
|
3267 | c2bc0e38 | blueswir1 | /* now we have a real cpu fault */
|
3268 | c2bc0e38 | blueswir1 | pc = (unsigned long)retaddr; |
3269 | c2bc0e38 | blueswir1 | tb = tb_find_pc(pc); |
3270 | c2bc0e38 | blueswir1 | if (tb) {
|
3271 | c2bc0e38 | blueswir1 | /* the PC is inside the translated code. It means that we have
|
3272 | c2bc0e38 | blueswir1 | a virtual CPU fault */
|
3273 | c2bc0e38 | blueswir1 | cpu_restore_state(tb, env, pc, (void *)(long)env->cond); |
3274 | c2bc0e38 | blueswir1 | } |
3275 | c2bc0e38 | blueswir1 | } |
3276 | c2bc0e38 | blueswir1 | } |
3277 | c2bc0e38 | blueswir1 | |
3278 | d2889a3e | blueswir1 | static void do_unaligned_access(target_ulong addr, int is_write, int is_user, |
3279 | d2889a3e | blueswir1 | void *retaddr)
|
3280 | d2889a3e | blueswir1 | { |
3281 | 94554550 | blueswir1 | #ifdef DEBUG_UNALIGNED
|
3282 | c2bc0e38 | blueswir1 | printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx |
3283 | c2bc0e38 | blueswir1 | "\n", addr, env->pc);
|
3284 | 94554550 | blueswir1 | #endif
|
3285 | c2bc0e38 | blueswir1 | cpu_restore_state2(retaddr); |
3286 | 94554550 | blueswir1 | raise_exception(TT_UNALIGNED); |
3287 | d2889a3e | blueswir1 | } |
3288 | ee5bbe38 | bellard | |
3289 | ee5bbe38 | bellard | /* try to fill the TLB and return an exception if error. If retaddr is
|
3290 | ee5bbe38 | bellard | NULL, it means that the function was called in C code (i.e. not
|
3291 | ee5bbe38 | bellard | from generated code or from helper.c) */
|
3292 | ee5bbe38 | bellard | /* XXX: fix it to restore all registers */
|
3293 | 6ebbf390 | j_mayer | void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr) |
3294 | ee5bbe38 | bellard | { |
3295 | ee5bbe38 | bellard | int ret;
|
3296 | ee5bbe38 | bellard | CPUState *saved_env; |
3297 | ee5bbe38 | bellard | |
3298 | ee5bbe38 | bellard | /* XXX: hack to restore env in all cases, even if not called from
|
3299 | ee5bbe38 | bellard | generated code */
|
3300 | ee5bbe38 | bellard | saved_env = env; |
3301 | ee5bbe38 | bellard | env = cpu_single_env; |
3302 | ee5bbe38 | bellard | |
3303 | 6ebbf390 | j_mayer | ret = cpu_sparc_handle_mmu_fault(env, addr, is_write, mmu_idx, 1);
|
3304 | ee5bbe38 | bellard | if (ret) {
|
3305 | c2bc0e38 | blueswir1 | cpu_restore_state2(retaddr); |
3306 | ee5bbe38 | bellard | cpu_loop_exit(); |
3307 | ee5bbe38 | bellard | } |
3308 | ee5bbe38 | bellard | env = saved_env; |
3309 | ee5bbe38 | bellard | } |
3310 | ee5bbe38 | bellard | |
3311 | ee5bbe38 | bellard | #endif
|
3312 | 6c36d3fa | blueswir1 | |
3313 | 6c36d3fa | blueswir1 | #ifndef TARGET_SPARC64
|
3314 | 5dcb6b91 | blueswir1 | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
3315 | e18231a3 | blueswir1 | int is_asi, int size) |
3316 | 6c36d3fa | blueswir1 | { |
3317 | 6c36d3fa | blueswir1 | CPUState *saved_env; |
3318 | 6c36d3fa | blueswir1 | |
3319 | 6c36d3fa | blueswir1 | /* XXX: hack to restore env in all cases, even if not called from
|
3320 | 6c36d3fa | blueswir1 | generated code */
|
3321 | 6c36d3fa | blueswir1 | saved_env = env; |
3322 | 6c36d3fa | blueswir1 | env = cpu_single_env; |
3323 | 8543e2cf | blueswir1 | #ifdef DEBUG_UNASSIGNED
|
3324 | 8543e2cf | blueswir1 | if (is_asi)
|
3325 | e18231a3 | blueswir1 | printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx
|
3326 | 77f193da | blueswir1 | " asi 0x%02x from " TARGET_FMT_lx "\n", |
3327 | e18231a3 | blueswir1 | is_exec ? "exec" : is_write ? "write" : "read", size, |
3328 | e18231a3 | blueswir1 | size == 1 ? "" : "s", addr, is_asi, env->pc); |
3329 | 8543e2cf | blueswir1 | else
|
3330 | e18231a3 | blueswir1 | printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx
|
3331 | e18231a3 | blueswir1 | " from " TARGET_FMT_lx "\n", |
3332 | e18231a3 | blueswir1 | is_exec ? "exec" : is_write ? "write" : "read", size, |
3333 | e18231a3 | blueswir1 | size == 1 ? "" : "s", addr, env->pc); |
3334 | 8543e2cf | blueswir1 | #endif
|
3335 | 6c36d3fa | blueswir1 | if (env->mmuregs[3]) /* Fault status register */ |
3336 | 0f8a249a | blueswir1 | env->mmuregs[3] = 1; /* overflow (not read before another fault) */ |
3337 | 6c36d3fa | blueswir1 | if (is_asi)
|
3338 | 6c36d3fa | blueswir1 | env->mmuregs[3] |= 1 << 16; |
3339 | 6c36d3fa | blueswir1 | if (env->psrs)
|
3340 | 6c36d3fa | blueswir1 | env->mmuregs[3] |= 1 << 5; |
3341 | 6c36d3fa | blueswir1 | if (is_exec)
|
3342 | 6c36d3fa | blueswir1 | env->mmuregs[3] |= 1 << 6; |
3343 | 6c36d3fa | blueswir1 | if (is_write)
|
3344 | 6c36d3fa | blueswir1 | env->mmuregs[3] |= 1 << 7; |
3345 | 6c36d3fa | blueswir1 | env->mmuregs[3] |= (5 << 2) | 2; |
3346 | 6c36d3fa | blueswir1 | env->mmuregs[4] = addr; /* Fault address register */ |
3347 | 6c36d3fa | blueswir1 | if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) { |
3348 | 1b2e93c1 | blueswir1 | if (is_exec)
|
3349 | 1b2e93c1 | blueswir1 | raise_exception(TT_CODE_ACCESS); |
3350 | 1b2e93c1 | blueswir1 | else
|
3351 | 1b2e93c1 | blueswir1 | raise_exception(TT_DATA_ACCESS); |
3352 | 6c36d3fa | blueswir1 | } |
3353 | 6c36d3fa | blueswir1 | env = saved_env; |
3354 | 6c36d3fa | blueswir1 | } |
3355 | 6c36d3fa | blueswir1 | #else
|
3356 | 5dcb6b91 | blueswir1 | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
3357 | e18231a3 | blueswir1 | int is_asi, int size) |
3358 | 6c36d3fa | blueswir1 | { |
3359 | 6c36d3fa | blueswir1 | #ifdef DEBUG_UNASSIGNED
|
3360 | 6c36d3fa | blueswir1 | CPUState *saved_env; |
3361 | 6c36d3fa | blueswir1 | |
3362 | 6c36d3fa | blueswir1 | /* XXX: hack to restore env in all cases, even if not called from
|
3363 | 6c36d3fa | blueswir1 | generated code */
|
3364 | 6c36d3fa | blueswir1 | saved_env = env; |
3365 | 6c36d3fa | blueswir1 | env = cpu_single_env; |
3366 | 77f193da | blueswir1 | printf("Unassigned mem access to " TARGET_FMT_plx " from " TARGET_FMT_lx |
3367 | 77f193da | blueswir1 | "\n", addr, env->pc);
|
3368 | 6c36d3fa | blueswir1 | env = saved_env; |
3369 | 6c36d3fa | blueswir1 | #endif
|
3370 | 1b2e93c1 | blueswir1 | if (is_exec)
|
3371 | 1b2e93c1 | blueswir1 | raise_exception(TT_CODE_ACCESS); |
3372 | 1b2e93c1 | blueswir1 | else
|
3373 | 1b2e93c1 | blueswir1 | raise_exception(TT_DATA_ACCESS); |
3374 | 6c36d3fa | blueswir1 | } |
3375 | 6c36d3fa | blueswir1 | #endif
|
3376 | 20c9f095 | blueswir1 | |
3377 | f4b1a842 | blueswir1 | #ifdef TARGET_SPARC64
|
3378 | f4b1a842 | blueswir1 | void helper_tick_set_count(void *opaque, uint64_t count) |
3379 | f4b1a842 | blueswir1 | { |
3380 | f4b1a842 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
3381 | f4b1a842 | blueswir1 | cpu_tick_set_count(opaque, count); |
3382 | f4b1a842 | blueswir1 | #endif
|
3383 | f4b1a842 | blueswir1 | } |
3384 | f4b1a842 | blueswir1 | |
3385 | f4b1a842 | blueswir1 | uint64_t helper_tick_get_count(void *opaque)
|
3386 | f4b1a842 | blueswir1 | { |
3387 | f4b1a842 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
3388 | f4b1a842 | blueswir1 | return cpu_tick_get_count(opaque);
|
3389 | f4b1a842 | blueswir1 | #else
|
3390 | f4b1a842 | blueswir1 | return 0; |
3391 | f4b1a842 | blueswir1 | #endif
|
3392 | f4b1a842 | blueswir1 | } |
3393 | f4b1a842 | blueswir1 | |
3394 | f4b1a842 | blueswir1 | void helper_tick_set_limit(void *opaque, uint64_t limit) |
3395 | f4b1a842 | blueswir1 | { |
3396 | f4b1a842 | blueswir1 | #if !defined(CONFIG_USER_ONLY)
|
3397 | f4b1a842 | blueswir1 | cpu_tick_set_limit(opaque, limit); |
3398 | f4b1a842 | blueswir1 | #endif
|
3399 | f4b1a842 | blueswir1 | } |
3400 | f4b1a842 | blueswir1 | #endif |