root / target-mips / op_helper.c @ a1f6684d
History | View | Annotate | Download (88.5 kB)
1 | 6af0bf9c | bellard | /*
|
---|---|---|---|
2 | 6af0bf9c | bellard | * MIPS emulation helpers for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 6af0bf9c | bellard | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 6af0bf9c | bellard | *
|
6 | 6af0bf9c | bellard | * This library is free software; you can redistribute it and/or
|
7 | 6af0bf9c | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 6af0bf9c | bellard | * License as published by the Free Software Foundation; either
|
9 | 6af0bf9c | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 6af0bf9c | bellard | *
|
11 | 6af0bf9c | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 6af0bf9c | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 6af0bf9c | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 6af0bf9c | bellard | * Lesser General Public License for more details.
|
15 | 6af0bf9c | bellard | *
|
16 | 6af0bf9c | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 6af0bf9c | bellard | * License along with this library; if not, write to the Free Software
|
18 | fad6cb1a | aurel32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
|
19 | 6af0bf9c | bellard | */
|
20 | 2d0e944d | ths | #include <stdlib.h> |
21 | 6af0bf9c | bellard | #include "exec.h" |
22 | 6af0bf9c | bellard | |
23 | 05f778c8 | ths | #include "host-utils.h" |
24 | 05f778c8 | ths | |
25 | a7812ae4 | pbrook | #include "helper.h" |
26 | 6af0bf9c | bellard | /*****************************************************************************/
|
27 | 6af0bf9c | bellard | /* Exceptions processing helpers */
|
28 | 6af0bf9c | bellard | |
29 | c01fccd2 | aurel32 | void helper_raise_exception_err (uint32_t exception, int error_code) |
30 | 6af0bf9c | bellard | { |
31 | 6af0bf9c | bellard | #if 1 |
32 | 93fcfe39 | aliguori | if (exception < 0x100) |
33 | 93fcfe39 | aliguori | qemu_log("%s: %d %d\n", __func__, exception, error_code);
|
34 | 6af0bf9c | bellard | #endif
|
35 | 6af0bf9c | bellard | env->exception_index = exception; |
36 | 6af0bf9c | bellard | env->error_code = error_code; |
37 | 6af0bf9c | bellard | cpu_loop_exit(); |
38 | 6af0bf9c | bellard | } |
39 | 6af0bf9c | bellard | |
40 | c01fccd2 | aurel32 | void helper_raise_exception (uint32_t exception)
|
41 | 6af0bf9c | bellard | { |
42 | c01fccd2 | aurel32 | helper_raise_exception_err(exception, 0);
|
43 | 6af0bf9c | bellard | } |
44 | 6af0bf9c | bellard | |
45 | c01fccd2 | aurel32 | void helper_interrupt_restart (void) |
46 | 48d38ca5 | ths | { |
47 | 48d38ca5 | ths | if (!(env->CP0_Status & (1 << CP0St_EXL)) && |
48 | 48d38ca5 | ths | !(env->CP0_Status & (1 << CP0St_ERL)) &&
|
49 | 48d38ca5 | ths | !(env->hflags & MIPS_HFLAG_DM) && |
50 | 48d38ca5 | ths | (env->CP0_Status & (1 << CP0St_IE)) &&
|
51 | 48d38ca5 | ths | (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask)) { |
52 | 48d38ca5 | ths | env->CP0_Cause &= ~(0x1f << CP0Ca_EC);
|
53 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_EXT_INTERRUPT); |
54 | 48d38ca5 | ths | } |
55 | 48d38ca5 | ths | } |
56 | 48d38ca5 | ths | |
57 | f9480ffc | ths | #if !defined(CONFIG_USER_ONLY)
|
58 | f9480ffc | ths | static void do_restore_state (void *pc_ptr) |
59 | 4ad40f36 | bellard | { |
60 | a607922c | bellard | TranslationBlock *tb; |
61 | a607922c | bellard | unsigned long pc = (unsigned long) pc_ptr; |
62 | a607922c | bellard | |
63 | a607922c | bellard | tb = tb_find_pc (pc); |
64 | a607922c | bellard | if (tb) {
|
65 | a607922c | bellard | cpu_restore_state (tb, env, pc, NULL);
|
66 | a607922c | bellard | } |
67 | 4ad40f36 | bellard | } |
68 | f9480ffc | ths | #endif
|
69 | 4ad40f36 | bellard | |
70 | c01fccd2 | aurel32 | target_ulong helper_clo (target_ulong t0) |
71 | 30898801 | ths | { |
72 | be24bb4f | ths | return clo32(t0);
|
73 | 30898801 | ths | } |
74 | 30898801 | ths | |
75 | c01fccd2 | aurel32 | target_ulong helper_clz (target_ulong t0) |
76 | 30898801 | ths | { |
77 | be24bb4f | ths | return clz32(t0);
|
78 | 30898801 | ths | } |
79 | 30898801 | ths | |
80 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
81 | c01fccd2 | aurel32 | target_ulong helper_dclo (target_ulong t0) |
82 | 05f778c8 | ths | { |
83 | be24bb4f | ths | return clo64(t0);
|
84 | 05f778c8 | ths | } |
85 | 05f778c8 | ths | |
86 | c01fccd2 | aurel32 | target_ulong helper_dclz (target_ulong t0) |
87 | 05f778c8 | ths | { |
88 | be24bb4f | ths | return clz64(t0);
|
89 | 05f778c8 | ths | } |
90 | d26bc211 | ths | #endif /* TARGET_MIPS64 */ |
91 | c570fd16 | ths | |
92 | 6af0bf9c | bellard | /* 64 bits arithmetic for 32 bits hosts */
|
93 | c904ef0e | ths | static inline uint64_t get_HILO (void) |
94 | 6af0bf9c | bellard | { |
95 | b5dc7732 | ths | return ((uint64_t)(env->active_tc.HI[0]) << 32) | (uint32_t)env->active_tc.LO[0]; |
96 | 6af0bf9c | bellard | } |
97 | 6af0bf9c | bellard | |
98 | c904ef0e | ths | static inline void set_HILO (uint64_t HILO) |
99 | 6af0bf9c | bellard | { |
100 | b5dc7732 | ths | env->active_tc.LO[0] = (int32_t)HILO;
|
101 | b5dc7732 | ths | env->active_tc.HI[0] = (int32_t)(HILO >> 32); |
102 | 6af0bf9c | bellard | } |
103 | 6af0bf9c | bellard | |
104 | c904ef0e | ths | static inline void set_HIT0_LO (target_ulong t0, uint64_t HILO) |
105 | e9c71dd1 | ths | { |
106 | b5dc7732 | ths | env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF); |
107 | b5dc7732 | ths | t0 = env->active_tc.HI[0] = (int32_t)(HILO >> 32); |
108 | e9c71dd1 | ths | } |
109 | e9c71dd1 | ths | |
110 | c904ef0e | ths | static inline void set_HI_LOT0 (target_ulong t0, uint64_t HILO) |
111 | e9c71dd1 | ths | { |
112 | b5dc7732 | ths | t0 = env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF); |
113 | b5dc7732 | ths | env->active_tc.HI[0] = (int32_t)(HILO >> 32); |
114 | e9c71dd1 | ths | } |
115 | e9c71dd1 | ths | |
116 | e9c71dd1 | ths | /* Multiplication variants of the vr54xx. */
|
117 | c01fccd2 | aurel32 | target_ulong helper_muls (target_ulong t0, target_ulong t1) |
118 | e9c71dd1 | ths | { |
119 | be24bb4f | ths | set_HI_LOT0(t0, 0 - ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1));
|
120 | be24bb4f | ths | |
121 | be24bb4f | ths | return t0;
|
122 | e9c71dd1 | ths | } |
123 | e9c71dd1 | ths | |
124 | c01fccd2 | aurel32 | target_ulong helper_mulsu (target_ulong t0, target_ulong t1) |
125 | e9c71dd1 | ths | { |
126 | be24bb4f | ths | set_HI_LOT0(t0, 0 - ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1));
|
127 | be24bb4f | ths | |
128 | be24bb4f | ths | return t0;
|
129 | e9c71dd1 | ths | } |
130 | e9c71dd1 | ths | |
131 | c01fccd2 | aurel32 | target_ulong helper_macc (target_ulong t0, target_ulong t1) |
132 | e9c71dd1 | ths | { |
133 | be24bb4f | ths | set_HI_LOT0(t0, ((int64_t)get_HILO()) + ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1)); |
134 | be24bb4f | ths | |
135 | be24bb4f | ths | return t0;
|
136 | e9c71dd1 | ths | } |
137 | e9c71dd1 | ths | |
138 | c01fccd2 | aurel32 | target_ulong helper_macchi (target_ulong t0, target_ulong t1) |
139 | e9c71dd1 | ths | { |
140 | be24bb4f | ths | set_HIT0_LO(t0, ((int64_t)get_HILO()) + ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1)); |
141 | be24bb4f | ths | |
142 | be24bb4f | ths | return t0;
|
143 | e9c71dd1 | ths | } |
144 | e9c71dd1 | ths | |
145 | c01fccd2 | aurel32 | target_ulong helper_maccu (target_ulong t0, target_ulong t1) |
146 | e9c71dd1 | ths | { |
147 | be24bb4f | ths | set_HI_LOT0(t0, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1)); |
148 | be24bb4f | ths | |
149 | be24bb4f | ths | return t0;
|
150 | e9c71dd1 | ths | } |
151 | e9c71dd1 | ths | |
152 | c01fccd2 | aurel32 | target_ulong helper_macchiu (target_ulong t0, target_ulong t1) |
153 | e9c71dd1 | ths | { |
154 | be24bb4f | ths | set_HIT0_LO(t0, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1)); |
155 | be24bb4f | ths | |
156 | be24bb4f | ths | return t0;
|
157 | e9c71dd1 | ths | } |
158 | e9c71dd1 | ths | |
159 | c01fccd2 | aurel32 | target_ulong helper_msac (target_ulong t0, target_ulong t1) |
160 | e9c71dd1 | ths | { |
161 | be24bb4f | ths | set_HI_LOT0(t0, ((int64_t)get_HILO()) - ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1)); |
162 | be24bb4f | ths | |
163 | be24bb4f | ths | return t0;
|
164 | e9c71dd1 | ths | } |
165 | e9c71dd1 | ths | |
166 | c01fccd2 | aurel32 | target_ulong helper_msachi (target_ulong t0, target_ulong t1) |
167 | e9c71dd1 | ths | { |
168 | be24bb4f | ths | set_HIT0_LO(t0, ((int64_t)get_HILO()) - ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1)); |
169 | be24bb4f | ths | |
170 | be24bb4f | ths | return t0;
|
171 | e9c71dd1 | ths | } |
172 | e9c71dd1 | ths | |
173 | c01fccd2 | aurel32 | target_ulong helper_msacu (target_ulong t0, target_ulong t1) |
174 | e9c71dd1 | ths | { |
175 | be24bb4f | ths | set_HI_LOT0(t0, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1)); |
176 | be24bb4f | ths | |
177 | be24bb4f | ths | return t0;
|
178 | e9c71dd1 | ths | } |
179 | e9c71dd1 | ths | |
180 | c01fccd2 | aurel32 | target_ulong helper_msachiu (target_ulong t0, target_ulong t1) |
181 | e9c71dd1 | ths | { |
182 | be24bb4f | ths | set_HIT0_LO(t0, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1)); |
183 | be24bb4f | ths | |
184 | be24bb4f | ths | return t0;
|
185 | e9c71dd1 | ths | } |
186 | e9c71dd1 | ths | |
187 | c01fccd2 | aurel32 | target_ulong helper_mulhi (target_ulong t0, target_ulong t1) |
188 | e9c71dd1 | ths | { |
189 | be24bb4f | ths | set_HIT0_LO(t0, (int64_t)(int32_t)t0 * (int64_t)(int32_t)t1); |
190 | be24bb4f | ths | |
191 | be24bb4f | ths | return t0;
|
192 | e9c71dd1 | ths | } |
193 | e9c71dd1 | ths | |
194 | c01fccd2 | aurel32 | target_ulong helper_mulhiu (target_ulong t0, target_ulong t1) |
195 | e9c71dd1 | ths | { |
196 | be24bb4f | ths | set_HIT0_LO(t0, (uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1); |
197 | be24bb4f | ths | |
198 | be24bb4f | ths | return t0;
|
199 | e9c71dd1 | ths | } |
200 | e9c71dd1 | ths | |
201 | c01fccd2 | aurel32 | target_ulong helper_mulshi (target_ulong t0, target_ulong t1) |
202 | e9c71dd1 | ths | { |
203 | be24bb4f | ths | set_HIT0_LO(t0, 0 - ((int64_t)(int32_t)t0 * (int64_t)(int32_t)t1));
|
204 | be24bb4f | ths | |
205 | be24bb4f | ths | return t0;
|
206 | e9c71dd1 | ths | } |
207 | e9c71dd1 | ths | |
208 | c01fccd2 | aurel32 | target_ulong helper_mulshiu (target_ulong t0, target_ulong t1) |
209 | e9c71dd1 | ths | { |
210 | be24bb4f | ths | set_HIT0_LO(t0, 0 - ((uint64_t)(uint32_t)t0 * (uint64_t)(uint32_t)t1));
|
211 | be24bb4f | ths | |
212 | be24bb4f | ths | return t0;
|
213 | e9c71dd1 | ths | } |
214 | 6af0bf9c | bellard | |
215 | 214c465f | ths | #ifdef TARGET_MIPS64
|
216 | c01fccd2 | aurel32 | void helper_dmult (target_ulong t0, target_ulong t1)
|
217 | 214c465f | ths | { |
218 | b5dc7732 | ths | muls64(&(env->active_tc.LO[0]), &(env->active_tc.HI[0]), t0, t1); |
219 | 214c465f | ths | } |
220 | 214c465f | ths | |
221 | c01fccd2 | aurel32 | void helper_dmultu (target_ulong t0, target_ulong t1)
|
222 | 214c465f | ths | { |
223 | b5dc7732 | ths | mulu64(&(env->active_tc.LO[0]), &(env->active_tc.HI[0]), t0, t1); |
224 | 214c465f | ths | } |
225 | 214c465f | ths | #endif
|
226 | 214c465f | ths | |
227 | c8c2227e | ths | #ifdef TARGET_WORDS_BIGENDIAN
|
228 | c8c2227e | ths | #define GET_LMASK(v) ((v) & 3) |
229 | c8c2227e | ths | #define GET_OFFSET(addr, offset) (addr + (offset))
|
230 | c8c2227e | ths | #else
|
231 | c8c2227e | ths | #define GET_LMASK(v) (((v) & 3) ^ 3) |
232 | c8c2227e | ths | #define GET_OFFSET(addr, offset) (addr - (offset))
|
233 | c8c2227e | ths | #endif
|
234 | c8c2227e | ths | |
235 | c01fccd2 | aurel32 | target_ulong helper_lwl(target_ulong t0, target_ulong t1, int mem_idx)
|
236 | c8c2227e | ths | { |
237 | c8c2227e | ths | target_ulong tmp; |
238 | c8c2227e | ths | |
239 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
240 | c8c2227e | ths | #define ldfun ldub_raw
|
241 | c8c2227e | ths | #else
|
242 | c8c2227e | ths | int (*ldfun)(target_ulong);
|
243 | c8c2227e | ths | |
244 | c8c2227e | ths | switch (mem_idx)
|
245 | c8c2227e | ths | { |
246 | c8c2227e | ths | case 0: ldfun = ldub_kernel; break; |
247 | c8c2227e | ths | case 1: ldfun = ldub_super; break; |
248 | c8c2227e | ths | default:
|
249 | c8c2227e | ths | case 2: ldfun = ldub_user; break; |
250 | c8c2227e | ths | } |
251 | c8c2227e | ths | #endif
|
252 | be24bb4f | ths | tmp = ldfun(t0); |
253 | be24bb4f | ths | t1 = (t1 & 0x00FFFFFF) | (tmp << 24); |
254 | c8c2227e | ths | |
255 | be24bb4f | ths | if (GET_LMASK(t0) <= 2) { |
256 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 1));
|
257 | be24bb4f | ths | t1 = (t1 & 0xFF00FFFF) | (tmp << 16); |
258 | c8c2227e | ths | } |
259 | c8c2227e | ths | |
260 | be24bb4f | ths | if (GET_LMASK(t0) <= 1) { |
261 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 2));
|
262 | be24bb4f | ths | t1 = (t1 & 0xFFFF00FF) | (tmp << 8); |
263 | c8c2227e | ths | } |
264 | c8c2227e | ths | |
265 | be24bb4f | ths | if (GET_LMASK(t0) == 0) { |
266 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 3));
|
267 | be24bb4f | ths | t1 = (t1 & 0xFFFFFF00) | tmp;
|
268 | c8c2227e | ths | } |
269 | be24bb4f | ths | return (int32_t)t1;
|
270 | c8c2227e | ths | } |
271 | c8c2227e | ths | |
272 | c01fccd2 | aurel32 | target_ulong helper_lwr(target_ulong t0, target_ulong t1, int mem_idx)
|
273 | c8c2227e | ths | { |
274 | c8c2227e | ths | target_ulong tmp; |
275 | c8c2227e | ths | |
276 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
277 | c8c2227e | ths | #define ldfun ldub_raw
|
278 | c8c2227e | ths | #else
|
279 | c8c2227e | ths | int (*ldfun)(target_ulong);
|
280 | c8c2227e | ths | |
281 | c8c2227e | ths | switch (mem_idx)
|
282 | c8c2227e | ths | { |
283 | c8c2227e | ths | case 0: ldfun = ldub_kernel; break; |
284 | c8c2227e | ths | case 1: ldfun = ldub_super; break; |
285 | c8c2227e | ths | default:
|
286 | c8c2227e | ths | case 2: ldfun = ldub_user; break; |
287 | c8c2227e | ths | } |
288 | c8c2227e | ths | #endif
|
289 | be24bb4f | ths | tmp = ldfun(t0); |
290 | be24bb4f | ths | t1 = (t1 & 0xFFFFFF00) | tmp;
|
291 | c8c2227e | ths | |
292 | be24bb4f | ths | if (GET_LMASK(t0) >= 1) { |
293 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -1));
|
294 | be24bb4f | ths | t1 = (t1 & 0xFFFF00FF) | (tmp << 8); |
295 | c8c2227e | ths | } |
296 | c8c2227e | ths | |
297 | be24bb4f | ths | if (GET_LMASK(t0) >= 2) { |
298 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -2));
|
299 | be24bb4f | ths | t1 = (t1 & 0xFF00FFFF) | (tmp << 16); |
300 | c8c2227e | ths | } |
301 | c8c2227e | ths | |
302 | be24bb4f | ths | if (GET_LMASK(t0) == 3) { |
303 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -3));
|
304 | be24bb4f | ths | t1 = (t1 & 0x00FFFFFF) | (tmp << 24); |
305 | c8c2227e | ths | } |
306 | be24bb4f | ths | return (int32_t)t1;
|
307 | c8c2227e | ths | } |
308 | c8c2227e | ths | |
309 | c01fccd2 | aurel32 | void helper_swl(target_ulong t0, target_ulong t1, int mem_idx) |
310 | c8c2227e | ths | { |
311 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
312 | c8c2227e | ths | #define stfun stb_raw
|
313 | c8c2227e | ths | #else
|
314 | c8c2227e | ths | void (*stfun)(target_ulong, int); |
315 | c8c2227e | ths | |
316 | c8c2227e | ths | switch (mem_idx)
|
317 | c8c2227e | ths | { |
318 | c8c2227e | ths | case 0: stfun = stb_kernel; break; |
319 | c8c2227e | ths | case 1: stfun = stb_super; break; |
320 | c8c2227e | ths | default:
|
321 | c8c2227e | ths | case 2: stfun = stb_user; break; |
322 | c8c2227e | ths | } |
323 | c8c2227e | ths | #endif
|
324 | be24bb4f | ths | stfun(t0, (uint8_t)(t1 >> 24));
|
325 | c8c2227e | ths | |
326 | be24bb4f | ths | if (GET_LMASK(t0) <= 2) |
327 | be24bb4f | ths | stfun(GET_OFFSET(t0, 1), (uint8_t)(t1 >> 16)); |
328 | c8c2227e | ths | |
329 | be24bb4f | ths | if (GET_LMASK(t0) <= 1) |
330 | be24bb4f | ths | stfun(GET_OFFSET(t0, 2), (uint8_t)(t1 >> 8)); |
331 | c8c2227e | ths | |
332 | be24bb4f | ths | if (GET_LMASK(t0) == 0) |
333 | be24bb4f | ths | stfun(GET_OFFSET(t0, 3), (uint8_t)t1);
|
334 | c8c2227e | ths | } |
335 | c8c2227e | ths | |
336 | c01fccd2 | aurel32 | void helper_swr(target_ulong t0, target_ulong t1, int mem_idx) |
337 | c8c2227e | ths | { |
338 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
339 | c8c2227e | ths | #define stfun stb_raw
|
340 | c8c2227e | ths | #else
|
341 | c8c2227e | ths | void (*stfun)(target_ulong, int); |
342 | c8c2227e | ths | |
343 | c8c2227e | ths | switch (mem_idx)
|
344 | c8c2227e | ths | { |
345 | c8c2227e | ths | case 0: stfun = stb_kernel; break; |
346 | c8c2227e | ths | case 1: stfun = stb_super; break; |
347 | c8c2227e | ths | default:
|
348 | c8c2227e | ths | case 2: stfun = stb_user; break; |
349 | c8c2227e | ths | } |
350 | c8c2227e | ths | #endif
|
351 | be24bb4f | ths | stfun(t0, (uint8_t)t1); |
352 | c8c2227e | ths | |
353 | be24bb4f | ths | if (GET_LMASK(t0) >= 1) |
354 | be24bb4f | ths | stfun(GET_OFFSET(t0, -1), (uint8_t)(t1 >> 8)); |
355 | c8c2227e | ths | |
356 | be24bb4f | ths | if (GET_LMASK(t0) >= 2) |
357 | be24bb4f | ths | stfun(GET_OFFSET(t0, -2), (uint8_t)(t1 >> 16)); |
358 | c8c2227e | ths | |
359 | be24bb4f | ths | if (GET_LMASK(t0) == 3) |
360 | be24bb4f | ths | stfun(GET_OFFSET(t0, -3), (uint8_t)(t1 >> 24)); |
361 | c8c2227e | ths | } |
362 | c8c2227e | ths | |
363 | c8c2227e | ths | #if defined(TARGET_MIPS64)
|
364 | c8c2227e | ths | /* "half" load and stores. We must do the memory access inline,
|
365 | c8c2227e | ths | or fault handling won't work. */
|
366 | c8c2227e | ths | |
367 | c8c2227e | ths | #ifdef TARGET_WORDS_BIGENDIAN
|
368 | c8c2227e | ths | #define GET_LMASK64(v) ((v) & 7) |
369 | c8c2227e | ths | #else
|
370 | c8c2227e | ths | #define GET_LMASK64(v) (((v) & 7) ^ 7) |
371 | c8c2227e | ths | #endif
|
372 | c8c2227e | ths | |
373 | c01fccd2 | aurel32 | target_ulong helper_ldl(target_ulong t0, target_ulong t1, int mem_idx)
|
374 | c8c2227e | ths | { |
375 | c8c2227e | ths | uint64_t tmp; |
376 | c8c2227e | ths | |
377 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
378 | c8c2227e | ths | #define ldfun ldub_raw
|
379 | c8c2227e | ths | #else
|
380 | be24bb4f | ths | int (*ldfun)(target_ulong);
|
381 | c8c2227e | ths | |
382 | c8c2227e | ths | switch (mem_idx)
|
383 | c8c2227e | ths | { |
384 | c8c2227e | ths | case 0: ldfun = ldub_kernel; break; |
385 | c8c2227e | ths | case 1: ldfun = ldub_super; break; |
386 | c8c2227e | ths | default:
|
387 | c8c2227e | ths | case 2: ldfun = ldub_user; break; |
388 | c8c2227e | ths | } |
389 | c8c2227e | ths | #endif
|
390 | be24bb4f | ths | tmp = ldfun(t0); |
391 | be24bb4f | ths | t1 = (t1 & 0x00FFFFFFFFFFFFFFULL) | (tmp << 56); |
392 | c8c2227e | ths | |
393 | be24bb4f | ths | if (GET_LMASK64(t0) <= 6) { |
394 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 1));
|
395 | be24bb4f | ths | t1 = (t1 & 0xFF00FFFFFFFFFFFFULL) | (tmp << 48); |
396 | c8c2227e | ths | } |
397 | c8c2227e | ths | |
398 | be24bb4f | ths | if (GET_LMASK64(t0) <= 5) { |
399 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 2));
|
400 | be24bb4f | ths | t1 = (t1 & 0xFFFF00FFFFFFFFFFULL) | (tmp << 40); |
401 | c8c2227e | ths | } |
402 | c8c2227e | ths | |
403 | be24bb4f | ths | if (GET_LMASK64(t0) <= 4) { |
404 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 3));
|
405 | be24bb4f | ths | t1 = (t1 & 0xFFFFFF00FFFFFFFFULL) | (tmp << 32); |
406 | c8c2227e | ths | } |
407 | c8c2227e | ths | |
408 | be24bb4f | ths | if (GET_LMASK64(t0) <= 3) { |
409 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 4));
|
410 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFF00FFFFFFULL) | (tmp << 24); |
411 | c8c2227e | ths | } |
412 | c8c2227e | ths | |
413 | be24bb4f | ths | if (GET_LMASK64(t0) <= 2) { |
414 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 5));
|
415 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFF00FFFFULL) | (tmp << 16); |
416 | c8c2227e | ths | } |
417 | c8c2227e | ths | |
418 | be24bb4f | ths | if (GET_LMASK64(t0) <= 1) { |
419 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 6));
|
420 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFFFF00FFULL) | (tmp << 8); |
421 | c8c2227e | ths | } |
422 | c8c2227e | ths | |
423 | be24bb4f | ths | if (GET_LMASK64(t0) == 0) { |
424 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, 7));
|
425 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFFFFFF00ULL) | tmp;
|
426 | c8c2227e | ths | } |
427 | be24bb4f | ths | |
428 | be24bb4f | ths | return t1;
|
429 | c8c2227e | ths | } |
430 | c8c2227e | ths | |
431 | c01fccd2 | aurel32 | target_ulong helper_ldr(target_ulong t0, target_ulong t1, int mem_idx)
|
432 | c8c2227e | ths | { |
433 | c8c2227e | ths | uint64_t tmp; |
434 | c8c2227e | ths | |
435 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
436 | c8c2227e | ths | #define ldfun ldub_raw
|
437 | c8c2227e | ths | #else
|
438 | be24bb4f | ths | int (*ldfun)(target_ulong);
|
439 | c8c2227e | ths | |
440 | c8c2227e | ths | switch (mem_idx)
|
441 | c8c2227e | ths | { |
442 | c8c2227e | ths | case 0: ldfun = ldub_kernel; break; |
443 | c8c2227e | ths | case 1: ldfun = ldub_super; break; |
444 | c8c2227e | ths | default:
|
445 | c8c2227e | ths | case 2: ldfun = ldub_user; break; |
446 | c8c2227e | ths | } |
447 | c8c2227e | ths | #endif
|
448 | be24bb4f | ths | tmp = ldfun(t0); |
449 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFFFFFF00ULL) | tmp;
|
450 | c8c2227e | ths | |
451 | be24bb4f | ths | if (GET_LMASK64(t0) >= 1) { |
452 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -1));
|
453 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFFFF00FFULL) | (tmp << 8); |
454 | c8c2227e | ths | } |
455 | c8c2227e | ths | |
456 | be24bb4f | ths | if (GET_LMASK64(t0) >= 2) { |
457 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -2));
|
458 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFFFF00FFFFULL) | (tmp << 16); |
459 | c8c2227e | ths | } |
460 | c8c2227e | ths | |
461 | be24bb4f | ths | if (GET_LMASK64(t0) >= 3) { |
462 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -3));
|
463 | be24bb4f | ths | t1 = (t1 & 0xFFFFFFFF00FFFFFFULL) | (tmp << 24); |
464 | c8c2227e | ths | } |
465 | c8c2227e | ths | |
466 | be24bb4f | ths | if (GET_LMASK64(t0) >= 4) { |
467 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -4));
|
468 | be24bb4f | ths | t1 = (t1 & 0xFFFFFF00FFFFFFFFULL) | (tmp << 32); |
469 | c8c2227e | ths | } |
470 | c8c2227e | ths | |
471 | be24bb4f | ths | if (GET_LMASK64(t0) >= 5) { |
472 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -5));
|
473 | be24bb4f | ths | t1 = (t1 & 0xFFFF00FFFFFFFFFFULL) | (tmp << 40); |
474 | c8c2227e | ths | } |
475 | c8c2227e | ths | |
476 | be24bb4f | ths | if (GET_LMASK64(t0) >= 6) { |
477 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -6));
|
478 | be24bb4f | ths | t1 = (t1 & 0xFF00FFFFFFFFFFFFULL) | (tmp << 48); |
479 | c8c2227e | ths | } |
480 | c8c2227e | ths | |
481 | be24bb4f | ths | if (GET_LMASK64(t0) == 7) { |
482 | be24bb4f | ths | tmp = ldfun(GET_OFFSET(t0, -7));
|
483 | be24bb4f | ths | t1 = (t1 & 0x00FFFFFFFFFFFFFFULL) | (tmp << 56); |
484 | c8c2227e | ths | } |
485 | be24bb4f | ths | |
486 | be24bb4f | ths | return t1;
|
487 | c8c2227e | ths | } |
488 | c8c2227e | ths | |
489 | c01fccd2 | aurel32 | void helper_sdl(target_ulong t0, target_ulong t1, int mem_idx) |
490 | c8c2227e | ths | { |
491 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
492 | c8c2227e | ths | #define stfun stb_raw
|
493 | c8c2227e | ths | #else
|
494 | c8c2227e | ths | void (*stfun)(target_ulong, int); |
495 | c8c2227e | ths | |
496 | c8c2227e | ths | switch (mem_idx)
|
497 | c8c2227e | ths | { |
498 | c8c2227e | ths | case 0: stfun = stb_kernel; break; |
499 | c8c2227e | ths | case 1: stfun = stb_super; break; |
500 | c8c2227e | ths | default:
|
501 | c8c2227e | ths | case 2: stfun = stb_user; break; |
502 | c8c2227e | ths | } |
503 | c8c2227e | ths | #endif
|
504 | be24bb4f | ths | stfun(t0, (uint8_t)(t1 >> 56));
|
505 | c8c2227e | ths | |
506 | be24bb4f | ths | if (GET_LMASK64(t0) <= 6) |
507 | be24bb4f | ths | stfun(GET_OFFSET(t0, 1), (uint8_t)(t1 >> 48)); |
508 | c8c2227e | ths | |
509 | be24bb4f | ths | if (GET_LMASK64(t0) <= 5) |
510 | be24bb4f | ths | stfun(GET_OFFSET(t0, 2), (uint8_t)(t1 >> 40)); |
511 | c8c2227e | ths | |
512 | be24bb4f | ths | if (GET_LMASK64(t0) <= 4) |
513 | be24bb4f | ths | stfun(GET_OFFSET(t0, 3), (uint8_t)(t1 >> 32)); |
514 | c8c2227e | ths | |
515 | be24bb4f | ths | if (GET_LMASK64(t0) <= 3) |
516 | be24bb4f | ths | stfun(GET_OFFSET(t0, 4), (uint8_t)(t1 >> 24)); |
517 | c8c2227e | ths | |
518 | be24bb4f | ths | if (GET_LMASK64(t0) <= 2) |
519 | be24bb4f | ths | stfun(GET_OFFSET(t0, 5), (uint8_t)(t1 >> 16)); |
520 | c8c2227e | ths | |
521 | be24bb4f | ths | if (GET_LMASK64(t0) <= 1) |
522 | be24bb4f | ths | stfun(GET_OFFSET(t0, 6), (uint8_t)(t1 >> 8)); |
523 | c8c2227e | ths | |
524 | be24bb4f | ths | if (GET_LMASK64(t0) <= 0) |
525 | be24bb4f | ths | stfun(GET_OFFSET(t0, 7), (uint8_t)t1);
|
526 | c8c2227e | ths | } |
527 | c8c2227e | ths | |
528 | c01fccd2 | aurel32 | void helper_sdr(target_ulong t0, target_ulong t1, int mem_idx) |
529 | c8c2227e | ths | { |
530 | c8c2227e | ths | #ifdef CONFIG_USER_ONLY
|
531 | c8c2227e | ths | #define stfun stb_raw
|
532 | c8c2227e | ths | #else
|
533 | c8c2227e | ths | void (*stfun)(target_ulong, int); |
534 | c8c2227e | ths | |
535 | c8c2227e | ths | switch (mem_idx)
|
536 | c8c2227e | ths | { |
537 | c8c2227e | ths | case 0: stfun = stb_kernel; break; |
538 | c8c2227e | ths | case 1: stfun = stb_super; break; |
539 | c8c2227e | ths | default:
|
540 | c8c2227e | ths | case 2: stfun = stb_user; break; |
541 | c8c2227e | ths | } |
542 | c8c2227e | ths | #endif
|
543 | be24bb4f | ths | stfun(t0, (uint8_t)t1); |
544 | c8c2227e | ths | |
545 | be24bb4f | ths | if (GET_LMASK64(t0) >= 1) |
546 | be24bb4f | ths | stfun(GET_OFFSET(t0, -1), (uint8_t)(t1 >> 8)); |
547 | c8c2227e | ths | |
548 | be24bb4f | ths | if (GET_LMASK64(t0) >= 2) |
549 | be24bb4f | ths | stfun(GET_OFFSET(t0, -2), (uint8_t)(t1 >> 16)); |
550 | c8c2227e | ths | |
551 | be24bb4f | ths | if (GET_LMASK64(t0) >= 3) |
552 | be24bb4f | ths | stfun(GET_OFFSET(t0, -3), (uint8_t)(t1 >> 24)); |
553 | c8c2227e | ths | |
554 | be24bb4f | ths | if (GET_LMASK64(t0) >= 4) |
555 | be24bb4f | ths | stfun(GET_OFFSET(t0, -4), (uint8_t)(t1 >> 32)); |
556 | c8c2227e | ths | |
557 | be24bb4f | ths | if (GET_LMASK64(t0) >= 5) |
558 | be24bb4f | ths | stfun(GET_OFFSET(t0, -5), (uint8_t)(t1 >> 40)); |
559 | c8c2227e | ths | |
560 | be24bb4f | ths | if (GET_LMASK64(t0) >= 6) |
561 | be24bb4f | ths | stfun(GET_OFFSET(t0, -6), (uint8_t)(t1 >> 48)); |
562 | c8c2227e | ths | |
563 | be24bb4f | ths | if (GET_LMASK64(t0) == 7) |
564 | be24bb4f | ths | stfun(GET_OFFSET(t0, -7), (uint8_t)(t1 >> 56)); |
565 | c8c2227e | ths | } |
566 | c8c2227e | ths | #endif /* TARGET_MIPS64 */ |
567 | c8c2227e | ths | |
568 | 0eaef5aa | ths | #ifndef CONFIG_USER_ONLY
|
569 | 6af0bf9c | bellard | /* CP0 helpers */
|
570 | c01fccd2 | aurel32 | target_ulong helper_mfc0_mvpcontrol (void)
|
571 | f1aa6320 | ths | { |
572 | be24bb4f | ths | return env->mvp->CP0_MVPControl;
|
573 | f1aa6320 | ths | } |
574 | f1aa6320 | ths | |
575 | c01fccd2 | aurel32 | target_ulong helper_mfc0_mvpconf0 (void)
|
576 | f1aa6320 | ths | { |
577 | be24bb4f | ths | return env->mvp->CP0_MVPConf0;
|
578 | f1aa6320 | ths | } |
579 | f1aa6320 | ths | |
580 | c01fccd2 | aurel32 | target_ulong helper_mfc0_mvpconf1 (void)
|
581 | f1aa6320 | ths | { |
582 | be24bb4f | ths | return env->mvp->CP0_MVPConf1;
|
583 | f1aa6320 | ths | } |
584 | f1aa6320 | ths | |
585 | c01fccd2 | aurel32 | target_ulong helper_mfc0_random (void)
|
586 | 6af0bf9c | bellard | { |
587 | be24bb4f | ths | return (int32_t)cpu_mips_get_random(env);
|
588 | 873eb012 | ths | } |
589 | 6af0bf9c | bellard | |
590 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tcstatus (void)
|
591 | f1aa6320 | ths | { |
592 | b5dc7732 | ths | return env->active_tc.CP0_TCStatus;
|
593 | f1aa6320 | ths | } |
594 | f1aa6320 | ths | |
595 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tcstatus(void)
|
596 | f1aa6320 | ths | { |
597 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
598 | f1aa6320 | ths | |
599 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
600 | b5dc7732 | ths | return env->active_tc.CP0_TCStatus;
|
601 | b5dc7732 | ths | else
|
602 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCStatus;
|
603 | f1aa6320 | ths | } |
604 | f1aa6320 | ths | |
605 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tcbind (void)
|
606 | f1aa6320 | ths | { |
607 | b5dc7732 | ths | return env->active_tc.CP0_TCBind;
|
608 | f1aa6320 | ths | } |
609 | f1aa6320 | ths | |
610 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tcbind(void)
|
611 | f1aa6320 | ths | { |
612 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
613 | f1aa6320 | ths | |
614 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
615 | b5dc7732 | ths | return env->active_tc.CP0_TCBind;
|
616 | b5dc7732 | ths | else
|
617 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCBind;
|
618 | f1aa6320 | ths | } |
619 | f1aa6320 | ths | |
620 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tcrestart (void)
|
621 | f1aa6320 | ths | { |
622 | b5dc7732 | ths | return env->active_tc.PC;
|
623 | f1aa6320 | ths | } |
624 | f1aa6320 | ths | |
625 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tcrestart(void)
|
626 | f1aa6320 | ths | { |
627 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
628 | f1aa6320 | ths | |
629 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
630 | b5dc7732 | ths | return env->active_tc.PC;
|
631 | b5dc7732 | ths | else
|
632 | b5dc7732 | ths | return env->tcs[other_tc].PC;
|
633 | f1aa6320 | ths | } |
634 | f1aa6320 | ths | |
635 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tchalt (void)
|
636 | f1aa6320 | ths | { |
637 | b5dc7732 | ths | return env->active_tc.CP0_TCHalt;
|
638 | f1aa6320 | ths | } |
639 | f1aa6320 | ths | |
640 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tchalt(void)
|
641 | f1aa6320 | ths | { |
642 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
643 | f1aa6320 | ths | |
644 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
645 | b5dc7732 | ths | return env->active_tc.CP0_TCHalt;
|
646 | b5dc7732 | ths | else
|
647 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCHalt;
|
648 | f1aa6320 | ths | } |
649 | f1aa6320 | ths | |
650 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tccontext (void)
|
651 | f1aa6320 | ths | { |
652 | b5dc7732 | ths | return env->active_tc.CP0_TCContext;
|
653 | f1aa6320 | ths | } |
654 | f1aa6320 | ths | |
655 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tccontext(void)
|
656 | f1aa6320 | ths | { |
657 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
658 | f1aa6320 | ths | |
659 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
660 | b5dc7732 | ths | return env->active_tc.CP0_TCContext;
|
661 | b5dc7732 | ths | else
|
662 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCContext;
|
663 | f1aa6320 | ths | } |
664 | f1aa6320 | ths | |
665 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tcschedule (void)
|
666 | f1aa6320 | ths | { |
667 | b5dc7732 | ths | return env->active_tc.CP0_TCSchedule;
|
668 | f1aa6320 | ths | } |
669 | f1aa6320 | ths | |
670 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tcschedule(void)
|
671 | f1aa6320 | ths | { |
672 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
673 | f1aa6320 | ths | |
674 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
675 | b5dc7732 | ths | return env->active_tc.CP0_TCSchedule;
|
676 | b5dc7732 | ths | else
|
677 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCSchedule;
|
678 | f1aa6320 | ths | } |
679 | f1aa6320 | ths | |
680 | c01fccd2 | aurel32 | target_ulong helper_mfc0_tcschefback (void)
|
681 | f1aa6320 | ths | { |
682 | b5dc7732 | ths | return env->active_tc.CP0_TCScheFBack;
|
683 | f1aa6320 | ths | } |
684 | f1aa6320 | ths | |
685 | c01fccd2 | aurel32 | target_ulong helper_mftc0_tcschefback(void)
|
686 | f1aa6320 | ths | { |
687 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
688 | f1aa6320 | ths | |
689 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
690 | b5dc7732 | ths | return env->active_tc.CP0_TCScheFBack;
|
691 | b5dc7732 | ths | else
|
692 | b5dc7732 | ths | return env->tcs[other_tc].CP0_TCScheFBack;
|
693 | f1aa6320 | ths | } |
694 | f1aa6320 | ths | |
695 | c01fccd2 | aurel32 | target_ulong helper_mfc0_count (void)
|
696 | 873eb012 | ths | { |
697 | be24bb4f | ths | return (int32_t)cpu_mips_get_count(env);
|
698 | 6af0bf9c | bellard | } |
699 | 6af0bf9c | bellard | |
700 | c01fccd2 | aurel32 | target_ulong helper_mftc0_entryhi(void)
|
701 | f1aa6320 | ths | { |
702 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
703 | b5dc7732 | ths | int32_t tcstatus; |
704 | f1aa6320 | ths | |
705 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
706 | b5dc7732 | ths | tcstatus = env->active_tc.CP0_TCStatus; |
707 | b5dc7732 | ths | else
|
708 | b5dc7732 | ths | tcstatus = env->tcs[other_tc].CP0_TCStatus; |
709 | b5dc7732 | ths | |
710 | b5dc7732 | ths | return (env->CP0_EntryHi & ~0xff) | (tcstatus & 0xff); |
711 | f1aa6320 | ths | } |
712 | f1aa6320 | ths | |
713 | c01fccd2 | aurel32 | target_ulong helper_mftc0_status(void)
|
714 | f1aa6320 | ths | { |
715 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
716 | 1a3fd9c3 | ths | target_ulong t0; |
717 | b5dc7732 | ths | int32_t tcstatus; |
718 | b5dc7732 | ths | |
719 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
720 | b5dc7732 | ths | tcstatus = env->active_tc.CP0_TCStatus; |
721 | b5dc7732 | ths | else
|
722 | b5dc7732 | ths | tcstatus = env->tcs[other_tc].CP0_TCStatus; |
723 | f1aa6320 | ths | |
724 | be24bb4f | ths | t0 = env->CP0_Status & ~0xf1000018;
|
725 | be24bb4f | ths | t0 |= tcstatus & (0xf << CP0TCSt_TCU0);
|
726 | be24bb4f | ths | t0 |= (tcstatus & (1 << CP0TCSt_TMX)) >> (CP0TCSt_TMX - CP0St_MX);
|
727 | be24bb4f | ths | t0 |= (tcstatus & (0x3 << CP0TCSt_TKSU)) >> (CP0TCSt_TKSU - CP0St_KSU);
|
728 | be24bb4f | ths | |
729 | be24bb4f | ths | return t0;
|
730 | f1aa6320 | ths | } |
731 | f1aa6320 | ths | |
732 | c01fccd2 | aurel32 | target_ulong helper_mfc0_lladdr (void)
|
733 | f1aa6320 | ths | { |
734 | be24bb4f | ths | return (int32_t)env->CP0_LLAddr >> 4; |
735 | f1aa6320 | ths | } |
736 | f1aa6320 | ths | |
737 | c01fccd2 | aurel32 | target_ulong helper_mfc0_watchlo (uint32_t sel) |
738 | f1aa6320 | ths | { |
739 | be24bb4f | ths | return (int32_t)env->CP0_WatchLo[sel];
|
740 | f1aa6320 | ths | } |
741 | f1aa6320 | ths | |
742 | c01fccd2 | aurel32 | target_ulong helper_mfc0_watchhi (uint32_t sel) |
743 | f1aa6320 | ths | { |
744 | be24bb4f | ths | return env->CP0_WatchHi[sel];
|
745 | f1aa6320 | ths | } |
746 | f1aa6320 | ths | |
747 | c01fccd2 | aurel32 | target_ulong helper_mfc0_debug (void)
|
748 | f1aa6320 | ths | { |
749 | 1a3fd9c3 | ths | target_ulong t0 = env->CP0_Debug; |
750 | f1aa6320 | ths | if (env->hflags & MIPS_HFLAG_DM)
|
751 | be24bb4f | ths | t0 |= 1 << CP0DB_DM;
|
752 | be24bb4f | ths | |
753 | be24bb4f | ths | return t0;
|
754 | f1aa6320 | ths | } |
755 | f1aa6320 | ths | |
756 | c01fccd2 | aurel32 | target_ulong helper_mftc0_debug(void)
|
757 | f1aa6320 | ths | { |
758 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
759 | b5dc7732 | ths | int32_t tcstatus; |
760 | b5dc7732 | ths | |
761 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
762 | b5dc7732 | ths | tcstatus = env->active_tc.CP0_Debug_tcstatus; |
763 | b5dc7732 | ths | else
|
764 | b5dc7732 | ths | tcstatus = env->tcs[other_tc].CP0_Debug_tcstatus; |
765 | f1aa6320 | ths | |
766 | f1aa6320 | ths | /* XXX: Might be wrong, check with EJTAG spec. */
|
767 | be24bb4f | ths | return (env->CP0_Debug & ~((1 << CP0DB_SSt) | (1 << CP0DB_Halt))) | |
768 | b5dc7732 | ths | (tcstatus & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt))); |
769 | f1aa6320 | ths | } |
770 | f1aa6320 | ths | |
771 | f1aa6320 | ths | #if defined(TARGET_MIPS64)
|
772 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_tcrestart (void)
|
773 | f1aa6320 | ths | { |
774 | b5dc7732 | ths | return env->active_tc.PC;
|
775 | f1aa6320 | ths | } |
776 | f1aa6320 | ths | |
777 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_tchalt (void)
|
778 | f1aa6320 | ths | { |
779 | b5dc7732 | ths | return env->active_tc.CP0_TCHalt;
|
780 | f1aa6320 | ths | } |
781 | f1aa6320 | ths | |
782 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_tccontext (void)
|
783 | f1aa6320 | ths | { |
784 | b5dc7732 | ths | return env->active_tc.CP0_TCContext;
|
785 | f1aa6320 | ths | } |
786 | f1aa6320 | ths | |
787 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_tcschedule (void)
|
788 | f1aa6320 | ths | { |
789 | b5dc7732 | ths | return env->active_tc.CP0_TCSchedule;
|
790 | f1aa6320 | ths | } |
791 | f1aa6320 | ths | |
792 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_tcschefback (void)
|
793 | f1aa6320 | ths | { |
794 | b5dc7732 | ths | return env->active_tc.CP0_TCScheFBack;
|
795 | f1aa6320 | ths | } |
796 | f1aa6320 | ths | |
797 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_lladdr (void)
|
798 | f1aa6320 | ths | { |
799 | be24bb4f | ths | return env->CP0_LLAddr >> 4; |
800 | f1aa6320 | ths | } |
801 | f1aa6320 | ths | |
802 | c01fccd2 | aurel32 | target_ulong helper_dmfc0_watchlo (uint32_t sel) |
803 | f1aa6320 | ths | { |
804 | be24bb4f | ths | return env->CP0_WatchLo[sel];
|
805 | f1aa6320 | ths | } |
806 | f1aa6320 | ths | #endif /* TARGET_MIPS64 */ |
807 | f1aa6320 | ths | |
808 | c01fccd2 | aurel32 | void helper_mtc0_index (target_ulong t0)
|
809 | f1aa6320 | ths | { |
810 | f1aa6320 | ths | int num = 1; |
811 | f1aa6320 | ths | unsigned int tmp = env->tlb->nb_tlb; |
812 | f1aa6320 | ths | |
813 | f1aa6320 | ths | do {
|
814 | f1aa6320 | ths | tmp >>= 1;
|
815 | f1aa6320 | ths | num <<= 1;
|
816 | f1aa6320 | ths | } while (tmp);
|
817 | be24bb4f | ths | env->CP0_Index = (env->CP0_Index & 0x80000000) | (t0 & (num - 1)); |
818 | f1aa6320 | ths | } |
819 | f1aa6320 | ths | |
820 | c01fccd2 | aurel32 | void helper_mtc0_mvpcontrol (target_ulong t0)
|
821 | f1aa6320 | ths | { |
822 | f1aa6320 | ths | uint32_t mask = 0;
|
823 | f1aa6320 | ths | uint32_t newval; |
824 | f1aa6320 | ths | |
825 | f1aa6320 | ths | if (env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) |
826 | f1aa6320 | ths | mask |= (1 << CP0MVPCo_CPA) | (1 << CP0MVPCo_VPC) | |
827 | f1aa6320 | ths | (1 << CP0MVPCo_EVP);
|
828 | f1aa6320 | ths | if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC)) |
829 | f1aa6320 | ths | mask |= (1 << CP0MVPCo_STLB);
|
830 | be24bb4f | ths | newval = (env->mvp->CP0_MVPControl & ~mask) | (t0 & mask); |
831 | f1aa6320 | ths | |
832 | f1aa6320 | ths | // TODO: Enable/disable shared TLB, enable/disable VPEs.
|
833 | f1aa6320 | ths | |
834 | f1aa6320 | ths | env->mvp->CP0_MVPControl = newval; |
835 | f1aa6320 | ths | } |
836 | f1aa6320 | ths | |
837 | c01fccd2 | aurel32 | void helper_mtc0_vpecontrol (target_ulong t0)
|
838 | f1aa6320 | ths | { |
839 | f1aa6320 | ths | uint32_t mask; |
840 | f1aa6320 | ths | uint32_t newval; |
841 | f1aa6320 | ths | |
842 | f1aa6320 | ths | mask = (1 << CP0VPECo_YSI) | (1 << CP0VPECo_GSI) | |
843 | f1aa6320 | ths | (1 << CP0VPECo_TE) | (0xff << CP0VPECo_TargTC); |
844 | be24bb4f | ths | newval = (env->CP0_VPEControl & ~mask) | (t0 & mask); |
845 | f1aa6320 | ths | |
846 | f1aa6320 | ths | /* Yield scheduler intercept not implemented. */
|
847 | f1aa6320 | ths | /* Gating storage scheduler intercept not implemented. */
|
848 | f1aa6320 | ths | |
849 | f1aa6320 | ths | // TODO: Enable/disable TCs.
|
850 | f1aa6320 | ths | |
851 | f1aa6320 | ths | env->CP0_VPEControl = newval; |
852 | f1aa6320 | ths | } |
853 | f1aa6320 | ths | |
854 | c01fccd2 | aurel32 | void helper_mtc0_vpeconf0 (target_ulong t0)
|
855 | f1aa6320 | ths | { |
856 | f1aa6320 | ths | uint32_t mask = 0;
|
857 | f1aa6320 | ths | uint32_t newval; |
858 | f1aa6320 | ths | |
859 | f1aa6320 | ths | if (env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) { |
860 | f1aa6320 | ths | if (env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA)) |
861 | f1aa6320 | ths | mask |= (0xff << CP0VPEC0_XTC);
|
862 | f1aa6320 | ths | mask |= (1 << CP0VPEC0_MVP) | (1 << CP0VPEC0_VPA); |
863 | f1aa6320 | ths | } |
864 | be24bb4f | ths | newval = (env->CP0_VPEConf0 & ~mask) | (t0 & mask); |
865 | f1aa6320 | ths | |
866 | f1aa6320 | ths | // TODO: TC exclusive handling due to ERL/EXL.
|
867 | f1aa6320 | ths | |
868 | f1aa6320 | ths | env->CP0_VPEConf0 = newval; |
869 | f1aa6320 | ths | } |
870 | f1aa6320 | ths | |
871 | c01fccd2 | aurel32 | void helper_mtc0_vpeconf1 (target_ulong t0)
|
872 | f1aa6320 | ths | { |
873 | f1aa6320 | ths | uint32_t mask = 0;
|
874 | f1aa6320 | ths | uint32_t newval; |
875 | f1aa6320 | ths | |
876 | f1aa6320 | ths | if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC)) |
877 | f1aa6320 | ths | mask |= (0xff << CP0VPEC1_NCX) | (0xff << CP0VPEC1_NCP2) | |
878 | f1aa6320 | ths | (0xff << CP0VPEC1_NCP1);
|
879 | be24bb4f | ths | newval = (env->CP0_VPEConf1 & ~mask) | (t0 & mask); |
880 | f1aa6320 | ths | |
881 | f1aa6320 | ths | /* UDI not implemented. */
|
882 | f1aa6320 | ths | /* CP2 not implemented. */
|
883 | f1aa6320 | ths | |
884 | f1aa6320 | ths | // TODO: Handle FPU (CP1) binding.
|
885 | f1aa6320 | ths | |
886 | f1aa6320 | ths | env->CP0_VPEConf1 = newval; |
887 | f1aa6320 | ths | } |
888 | f1aa6320 | ths | |
889 | c01fccd2 | aurel32 | void helper_mtc0_yqmask (target_ulong t0)
|
890 | f1aa6320 | ths | { |
891 | f1aa6320 | ths | /* Yield qualifier inputs not implemented. */
|
892 | f1aa6320 | ths | env->CP0_YQMask = 0x00000000;
|
893 | f1aa6320 | ths | } |
894 | f1aa6320 | ths | |
895 | c01fccd2 | aurel32 | void helper_mtc0_vpeopt (target_ulong t0)
|
896 | f1aa6320 | ths | { |
897 | be24bb4f | ths | env->CP0_VPEOpt = t0 & 0x0000ffff;
|
898 | f1aa6320 | ths | } |
899 | f1aa6320 | ths | |
900 | c01fccd2 | aurel32 | void helper_mtc0_entrylo0 (target_ulong t0)
|
901 | f1aa6320 | ths | { |
902 | f1aa6320 | ths | /* Large physaddr (PABITS) not implemented */
|
903 | f1aa6320 | ths | /* 1k pages not implemented */
|
904 | be24bb4f | ths | env->CP0_EntryLo0 = t0 & 0x3FFFFFFF;
|
905 | f1aa6320 | ths | } |
906 | f1aa6320 | ths | |
907 | c01fccd2 | aurel32 | void helper_mtc0_tcstatus (target_ulong t0)
|
908 | f1aa6320 | ths | { |
909 | f1aa6320 | ths | uint32_t mask = env->CP0_TCStatus_rw_bitmask; |
910 | f1aa6320 | ths | uint32_t newval; |
911 | f1aa6320 | ths | |
912 | b5dc7732 | ths | newval = (env->active_tc.CP0_TCStatus & ~mask) | (t0 & mask); |
913 | f1aa6320 | ths | |
914 | f1aa6320 | ths | // TODO: Sync with CP0_Status.
|
915 | f1aa6320 | ths | |
916 | b5dc7732 | ths | env->active_tc.CP0_TCStatus = newval; |
917 | f1aa6320 | ths | } |
918 | f1aa6320 | ths | |
919 | c01fccd2 | aurel32 | void helper_mttc0_tcstatus (target_ulong t0)
|
920 | f1aa6320 | ths | { |
921 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
922 | f1aa6320 | ths | |
923 | f1aa6320 | ths | // TODO: Sync with CP0_Status.
|
924 | f1aa6320 | ths | |
925 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
926 | b5dc7732 | ths | env->active_tc.CP0_TCStatus = t0; |
927 | b5dc7732 | ths | else
|
928 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCStatus = t0; |
929 | f1aa6320 | ths | } |
930 | f1aa6320 | ths | |
931 | c01fccd2 | aurel32 | void helper_mtc0_tcbind (target_ulong t0)
|
932 | f1aa6320 | ths | { |
933 | f1aa6320 | ths | uint32_t mask = (1 << CP0TCBd_TBE);
|
934 | f1aa6320 | ths | uint32_t newval; |
935 | f1aa6320 | ths | |
936 | f1aa6320 | ths | if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC)) |
937 | f1aa6320 | ths | mask |= (1 << CP0TCBd_CurVPE);
|
938 | b5dc7732 | ths | newval = (env->active_tc.CP0_TCBind & ~mask) | (t0 & mask); |
939 | b5dc7732 | ths | env->active_tc.CP0_TCBind = newval; |
940 | f1aa6320 | ths | } |
941 | f1aa6320 | ths | |
942 | c01fccd2 | aurel32 | void helper_mttc0_tcbind (target_ulong t0)
|
943 | f1aa6320 | ths | { |
944 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
945 | f1aa6320 | ths | uint32_t mask = (1 << CP0TCBd_TBE);
|
946 | f1aa6320 | ths | uint32_t newval; |
947 | f1aa6320 | ths | |
948 | f1aa6320 | ths | if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC)) |
949 | f1aa6320 | ths | mask |= (1 << CP0TCBd_CurVPE);
|
950 | b5dc7732 | ths | if (other_tc == env->current_tc) {
|
951 | b5dc7732 | ths | newval = (env->active_tc.CP0_TCBind & ~mask) | (t0 & mask); |
952 | b5dc7732 | ths | env->active_tc.CP0_TCBind = newval; |
953 | b5dc7732 | ths | } else {
|
954 | b5dc7732 | ths | newval = (env->tcs[other_tc].CP0_TCBind & ~mask) | (t0 & mask); |
955 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCBind = newval; |
956 | b5dc7732 | ths | } |
957 | f1aa6320 | ths | } |
958 | f1aa6320 | ths | |
959 | c01fccd2 | aurel32 | void helper_mtc0_tcrestart (target_ulong t0)
|
960 | f1aa6320 | ths | { |
961 | b5dc7732 | ths | env->active_tc.PC = t0; |
962 | b5dc7732 | ths | env->active_tc.CP0_TCStatus &= ~(1 << CP0TCSt_TDS);
|
963 | f1aa6320 | ths | env->CP0_LLAddr = 0ULL;
|
964 | f1aa6320 | ths | /* MIPS16 not implemented. */
|
965 | f1aa6320 | ths | } |
966 | f1aa6320 | ths | |
967 | c01fccd2 | aurel32 | void helper_mttc0_tcrestart (target_ulong t0)
|
968 | f1aa6320 | ths | { |
969 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
970 | f1aa6320 | ths | |
971 | b5dc7732 | ths | if (other_tc == env->current_tc) {
|
972 | b5dc7732 | ths | env->active_tc.PC = t0; |
973 | b5dc7732 | ths | env->active_tc.CP0_TCStatus &= ~(1 << CP0TCSt_TDS);
|
974 | b5dc7732 | ths | env->CP0_LLAddr = 0ULL;
|
975 | b5dc7732 | ths | /* MIPS16 not implemented. */
|
976 | b5dc7732 | ths | } else {
|
977 | b5dc7732 | ths | env->tcs[other_tc].PC = t0; |
978 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCStatus &= ~(1 << CP0TCSt_TDS);
|
979 | b5dc7732 | ths | env->CP0_LLAddr = 0ULL;
|
980 | b5dc7732 | ths | /* MIPS16 not implemented. */
|
981 | b5dc7732 | ths | } |
982 | f1aa6320 | ths | } |
983 | f1aa6320 | ths | |
984 | c01fccd2 | aurel32 | void helper_mtc0_tchalt (target_ulong t0)
|
985 | f1aa6320 | ths | { |
986 | b5dc7732 | ths | env->active_tc.CP0_TCHalt = t0 & 0x1;
|
987 | f1aa6320 | ths | |
988 | f1aa6320 | ths | // TODO: Halt TC / Restart (if allocated+active) TC.
|
989 | f1aa6320 | ths | } |
990 | f1aa6320 | ths | |
991 | c01fccd2 | aurel32 | void helper_mttc0_tchalt (target_ulong t0)
|
992 | f1aa6320 | ths | { |
993 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
994 | f1aa6320 | ths | |
995 | f1aa6320 | ths | // TODO: Halt TC / Restart (if allocated+active) TC.
|
996 | f1aa6320 | ths | |
997 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
998 | b5dc7732 | ths | env->active_tc.CP0_TCHalt = t0; |
999 | b5dc7732 | ths | else
|
1000 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCHalt = t0; |
1001 | f1aa6320 | ths | } |
1002 | f1aa6320 | ths | |
1003 | c01fccd2 | aurel32 | void helper_mtc0_tccontext (target_ulong t0)
|
1004 | f1aa6320 | ths | { |
1005 | b5dc7732 | ths | env->active_tc.CP0_TCContext = t0; |
1006 | f1aa6320 | ths | } |
1007 | f1aa6320 | ths | |
1008 | c01fccd2 | aurel32 | void helper_mttc0_tccontext (target_ulong t0)
|
1009 | f1aa6320 | ths | { |
1010 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1011 | f1aa6320 | ths | |
1012 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1013 | b5dc7732 | ths | env->active_tc.CP0_TCContext = t0; |
1014 | b5dc7732 | ths | else
|
1015 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCContext = t0; |
1016 | f1aa6320 | ths | } |
1017 | f1aa6320 | ths | |
1018 | c01fccd2 | aurel32 | void helper_mtc0_tcschedule (target_ulong t0)
|
1019 | f1aa6320 | ths | { |
1020 | b5dc7732 | ths | env->active_tc.CP0_TCSchedule = t0; |
1021 | f1aa6320 | ths | } |
1022 | f1aa6320 | ths | |
1023 | c01fccd2 | aurel32 | void helper_mttc0_tcschedule (target_ulong t0)
|
1024 | f1aa6320 | ths | { |
1025 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1026 | f1aa6320 | ths | |
1027 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1028 | b5dc7732 | ths | env->active_tc.CP0_TCSchedule = t0; |
1029 | b5dc7732 | ths | else
|
1030 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCSchedule = t0; |
1031 | f1aa6320 | ths | } |
1032 | f1aa6320 | ths | |
1033 | c01fccd2 | aurel32 | void helper_mtc0_tcschefback (target_ulong t0)
|
1034 | f1aa6320 | ths | { |
1035 | b5dc7732 | ths | env->active_tc.CP0_TCScheFBack = t0; |
1036 | f1aa6320 | ths | } |
1037 | f1aa6320 | ths | |
1038 | c01fccd2 | aurel32 | void helper_mttc0_tcschefback (target_ulong t0)
|
1039 | f1aa6320 | ths | { |
1040 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1041 | f1aa6320 | ths | |
1042 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1043 | b5dc7732 | ths | env->active_tc.CP0_TCScheFBack = t0; |
1044 | b5dc7732 | ths | else
|
1045 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCScheFBack = t0; |
1046 | f1aa6320 | ths | } |
1047 | f1aa6320 | ths | |
1048 | c01fccd2 | aurel32 | void helper_mtc0_entrylo1 (target_ulong t0)
|
1049 | f1aa6320 | ths | { |
1050 | f1aa6320 | ths | /* Large physaddr (PABITS) not implemented */
|
1051 | f1aa6320 | ths | /* 1k pages not implemented */
|
1052 | be24bb4f | ths | env->CP0_EntryLo1 = t0 & 0x3FFFFFFF;
|
1053 | f1aa6320 | ths | } |
1054 | f1aa6320 | ths | |
1055 | c01fccd2 | aurel32 | void helper_mtc0_context (target_ulong t0)
|
1056 | f1aa6320 | ths | { |
1057 | be24bb4f | ths | env->CP0_Context = (env->CP0_Context & 0x007FFFFF) | (t0 & ~0x007FFFFF); |
1058 | f1aa6320 | ths | } |
1059 | f1aa6320 | ths | |
1060 | c01fccd2 | aurel32 | void helper_mtc0_pagemask (target_ulong t0)
|
1061 | f1aa6320 | ths | { |
1062 | f1aa6320 | ths | /* 1k pages not implemented */
|
1063 | be24bb4f | ths | env->CP0_PageMask = t0 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1)); |
1064 | f1aa6320 | ths | } |
1065 | f1aa6320 | ths | |
1066 | c01fccd2 | aurel32 | void helper_mtc0_pagegrain (target_ulong t0)
|
1067 | f1aa6320 | ths | { |
1068 | f1aa6320 | ths | /* SmartMIPS not implemented */
|
1069 | f1aa6320 | ths | /* Large physaddr (PABITS) not implemented */
|
1070 | f1aa6320 | ths | /* 1k pages not implemented */
|
1071 | f1aa6320 | ths | env->CP0_PageGrain = 0;
|
1072 | f1aa6320 | ths | } |
1073 | f1aa6320 | ths | |
1074 | c01fccd2 | aurel32 | void helper_mtc0_wired (target_ulong t0)
|
1075 | f1aa6320 | ths | { |
1076 | be24bb4f | ths | env->CP0_Wired = t0 % env->tlb->nb_tlb; |
1077 | f1aa6320 | ths | } |
1078 | f1aa6320 | ths | |
1079 | c01fccd2 | aurel32 | void helper_mtc0_srsconf0 (target_ulong t0)
|
1080 | f1aa6320 | ths | { |
1081 | be24bb4f | ths | env->CP0_SRSConf0 |= t0 & env->CP0_SRSConf0_rw_bitmask; |
1082 | f1aa6320 | ths | } |
1083 | f1aa6320 | ths | |
1084 | c01fccd2 | aurel32 | void helper_mtc0_srsconf1 (target_ulong t0)
|
1085 | f1aa6320 | ths | { |
1086 | be24bb4f | ths | env->CP0_SRSConf1 |= t0 & env->CP0_SRSConf1_rw_bitmask; |
1087 | f1aa6320 | ths | } |
1088 | f1aa6320 | ths | |
1089 | c01fccd2 | aurel32 | void helper_mtc0_srsconf2 (target_ulong t0)
|
1090 | f1aa6320 | ths | { |
1091 | be24bb4f | ths | env->CP0_SRSConf2 |= t0 & env->CP0_SRSConf2_rw_bitmask; |
1092 | f1aa6320 | ths | } |
1093 | f1aa6320 | ths | |
1094 | c01fccd2 | aurel32 | void helper_mtc0_srsconf3 (target_ulong t0)
|
1095 | f1aa6320 | ths | { |
1096 | be24bb4f | ths | env->CP0_SRSConf3 |= t0 & env->CP0_SRSConf3_rw_bitmask; |
1097 | f1aa6320 | ths | } |
1098 | f1aa6320 | ths | |
1099 | c01fccd2 | aurel32 | void helper_mtc0_srsconf4 (target_ulong t0)
|
1100 | f1aa6320 | ths | { |
1101 | be24bb4f | ths | env->CP0_SRSConf4 |= t0 & env->CP0_SRSConf4_rw_bitmask; |
1102 | f1aa6320 | ths | } |
1103 | f1aa6320 | ths | |
1104 | c01fccd2 | aurel32 | void helper_mtc0_hwrena (target_ulong t0)
|
1105 | f1aa6320 | ths | { |
1106 | be24bb4f | ths | env->CP0_HWREna = t0 & 0x0000000F;
|
1107 | f1aa6320 | ths | } |
1108 | f1aa6320 | ths | |
1109 | c01fccd2 | aurel32 | void helper_mtc0_count (target_ulong t0)
|
1110 | f1aa6320 | ths | { |
1111 | be24bb4f | ths | cpu_mips_store_count(env, t0); |
1112 | f1aa6320 | ths | } |
1113 | f1aa6320 | ths | |
1114 | c01fccd2 | aurel32 | void helper_mtc0_entryhi (target_ulong t0)
|
1115 | f1aa6320 | ths | { |
1116 | f1aa6320 | ths | target_ulong old, val; |
1117 | f1aa6320 | ths | |
1118 | f1aa6320 | ths | /* 1k pages not implemented */
|
1119 | be24bb4f | ths | val = t0 & ((TARGET_PAGE_MASK << 1) | 0xFF); |
1120 | f1aa6320 | ths | #if defined(TARGET_MIPS64)
|
1121 | f1aa6320 | ths | val &= env->SEGMask; |
1122 | f1aa6320 | ths | #endif
|
1123 | f1aa6320 | ths | old = env->CP0_EntryHi; |
1124 | f1aa6320 | ths | env->CP0_EntryHi = val; |
1125 | f1aa6320 | ths | if (env->CP0_Config3 & (1 << CP0C3_MT)) { |
1126 | b5dc7732 | ths | uint32_t tcst = env->active_tc.CP0_TCStatus & ~0xff;
|
1127 | b5dc7732 | ths | env->active_tc.CP0_TCStatus = tcst | (val & 0xff);
|
1128 | f1aa6320 | ths | } |
1129 | f1aa6320 | ths | /* If the ASID changes, flush qemu's TLB. */
|
1130 | f1aa6320 | ths | if ((old & 0xFF) != (val & 0xFF)) |
1131 | f1aa6320 | ths | cpu_mips_tlb_flush(env, 1);
|
1132 | f1aa6320 | ths | } |
1133 | f1aa6320 | ths | |
1134 | c01fccd2 | aurel32 | void helper_mttc0_entryhi(target_ulong t0)
|
1135 | f1aa6320 | ths | { |
1136 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1137 | b5dc7732 | ths | int32_t tcstatus; |
1138 | f1aa6320 | ths | |
1139 | be24bb4f | ths | env->CP0_EntryHi = (env->CP0_EntryHi & 0xff) | (t0 & ~0xff); |
1140 | b5dc7732 | ths | if (other_tc == env->current_tc) {
|
1141 | b5dc7732 | ths | tcstatus = (env->active_tc.CP0_TCStatus & ~0xff) | (t0 & 0xff); |
1142 | b5dc7732 | ths | env->active_tc.CP0_TCStatus = tcstatus; |
1143 | b5dc7732 | ths | } else {
|
1144 | b5dc7732 | ths | tcstatus = (env->tcs[other_tc].CP0_TCStatus & ~0xff) | (t0 & 0xff); |
1145 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCStatus = tcstatus; |
1146 | b5dc7732 | ths | } |
1147 | f1aa6320 | ths | } |
1148 | f1aa6320 | ths | |
1149 | c01fccd2 | aurel32 | void helper_mtc0_compare (target_ulong t0)
|
1150 | f1aa6320 | ths | { |
1151 | be24bb4f | ths | cpu_mips_store_compare(env, t0); |
1152 | f1aa6320 | ths | } |
1153 | f1aa6320 | ths | |
1154 | c01fccd2 | aurel32 | void helper_mtc0_status (target_ulong t0)
|
1155 | f1aa6320 | ths | { |
1156 | f1aa6320 | ths | uint32_t val, old; |
1157 | f1aa6320 | ths | uint32_t mask = env->CP0_Status_rw_bitmask; |
1158 | f1aa6320 | ths | |
1159 | be24bb4f | ths | val = t0 & mask; |
1160 | f1aa6320 | ths | old = env->CP0_Status; |
1161 | f1aa6320 | ths | env->CP0_Status = (env->CP0_Status & ~mask) | val; |
1162 | f1aa6320 | ths | compute_hflags(env); |
1163 | c01fccd2 | aurel32 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
|
1164 | c01fccd2 | aurel32 | qemu_log("Status %08x (%08x) => %08x (%08x) Cause %08x",
|
1165 | c01fccd2 | aurel32 | old, old & env->CP0_Cause & CP0Ca_IP_mask, |
1166 | c01fccd2 | aurel32 | val, val & env->CP0_Cause & CP0Ca_IP_mask, |
1167 | c01fccd2 | aurel32 | env->CP0_Cause); |
1168 | c01fccd2 | aurel32 | switch (env->hflags & MIPS_HFLAG_KSU) {
|
1169 | c01fccd2 | aurel32 | case MIPS_HFLAG_UM: qemu_log(", UM\n"); break; |
1170 | c01fccd2 | aurel32 | case MIPS_HFLAG_SM: qemu_log(", SM\n"); break; |
1171 | c01fccd2 | aurel32 | case MIPS_HFLAG_KM: qemu_log("\n"); break; |
1172 | c01fccd2 | aurel32 | default: cpu_abort(env, "Invalid MMU mode!\n"); break; |
1173 | c01fccd2 | aurel32 | } |
1174 | c01fccd2 | aurel32 | } |
1175 | f1aa6320 | ths | cpu_mips_update_irq(env); |
1176 | f1aa6320 | ths | } |
1177 | f1aa6320 | ths | |
1178 | c01fccd2 | aurel32 | void helper_mttc0_status(target_ulong t0)
|
1179 | f1aa6320 | ths | { |
1180 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1181 | b5dc7732 | ths | int32_t tcstatus = env->tcs[other_tc].CP0_TCStatus; |
1182 | f1aa6320 | ths | |
1183 | be24bb4f | ths | env->CP0_Status = t0 & ~0xf1000018;
|
1184 | be24bb4f | ths | tcstatus = (tcstatus & ~(0xf << CP0TCSt_TCU0)) | (t0 & (0xf << CP0St_CU0)); |
1185 | be24bb4f | ths | tcstatus = (tcstatus & ~(1 << CP0TCSt_TMX)) | ((t0 & (1 << CP0St_MX)) << (CP0TCSt_TMX - CP0St_MX)); |
1186 | be24bb4f | ths | tcstatus = (tcstatus & ~(0x3 << CP0TCSt_TKSU)) | ((t0 & (0x3 << CP0St_KSU)) << (CP0TCSt_TKSU - CP0St_KSU)); |
1187 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1188 | b5dc7732 | ths | env->active_tc.CP0_TCStatus = tcstatus; |
1189 | b5dc7732 | ths | else
|
1190 | b5dc7732 | ths | env->tcs[other_tc].CP0_TCStatus = tcstatus; |
1191 | f1aa6320 | ths | } |
1192 | f1aa6320 | ths | |
1193 | c01fccd2 | aurel32 | void helper_mtc0_intctl (target_ulong t0)
|
1194 | f1aa6320 | ths | { |
1195 | f1aa6320 | ths | /* vectored interrupts not implemented, no performance counters. */
|
1196 | be24bb4f | ths | env->CP0_IntCtl = (env->CP0_IntCtl & ~0x000002e0) | (t0 & 0x000002e0); |
1197 | f1aa6320 | ths | } |
1198 | f1aa6320 | ths | |
1199 | c01fccd2 | aurel32 | void helper_mtc0_srsctl (target_ulong t0)
|
1200 | f1aa6320 | ths | { |
1201 | f1aa6320 | ths | uint32_t mask = (0xf << CP0SRSCtl_ESS) | (0xf << CP0SRSCtl_PSS); |
1202 | be24bb4f | ths | env->CP0_SRSCtl = (env->CP0_SRSCtl & ~mask) | (t0 & mask); |
1203 | f1aa6320 | ths | } |
1204 | f1aa6320 | ths | |
1205 | c01fccd2 | aurel32 | void helper_mtc0_cause (target_ulong t0)
|
1206 | f1aa6320 | ths | { |
1207 | f1aa6320 | ths | uint32_t mask = 0x00C00300;
|
1208 | f1aa6320 | ths | uint32_t old = env->CP0_Cause; |
1209 | f1aa6320 | ths | |
1210 | f1aa6320 | ths | if (env->insn_flags & ISA_MIPS32R2)
|
1211 | f1aa6320 | ths | mask |= 1 << CP0Ca_DC;
|
1212 | f1aa6320 | ths | |
1213 | be24bb4f | ths | env->CP0_Cause = (env->CP0_Cause & ~mask) | (t0 & mask); |
1214 | f1aa6320 | ths | |
1215 | f1aa6320 | ths | if ((old ^ env->CP0_Cause) & (1 << CP0Ca_DC)) { |
1216 | f1aa6320 | ths | if (env->CP0_Cause & (1 << CP0Ca_DC)) |
1217 | f1aa6320 | ths | cpu_mips_stop_count(env); |
1218 | f1aa6320 | ths | else
|
1219 | f1aa6320 | ths | cpu_mips_start_count(env); |
1220 | f1aa6320 | ths | } |
1221 | f1aa6320 | ths | |
1222 | f1aa6320 | ths | /* Handle the software interrupt as an hardware one, as they
|
1223 | f1aa6320 | ths | are very similar */
|
1224 | be24bb4f | ths | if (t0 & CP0Ca_IP_mask) {
|
1225 | f1aa6320 | ths | cpu_mips_update_irq(env); |
1226 | f1aa6320 | ths | } |
1227 | f1aa6320 | ths | } |
1228 | f1aa6320 | ths | |
1229 | c01fccd2 | aurel32 | void helper_mtc0_ebase (target_ulong t0)
|
1230 | f1aa6320 | ths | { |
1231 | f1aa6320 | ths | /* vectored interrupts not implemented */
|
1232 | f1aa6320 | ths | /* Multi-CPU not implemented */
|
1233 | be24bb4f | ths | env->CP0_EBase = 0x80000000 | (t0 & 0x3FFFF000); |
1234 | f1aa6320 | ths | } |
1235 | f1aa6320 | ths | |
1236 | c01fccd2 | aurel32 | void helper_mtc0_config0 (target_ulong t0)
|
1237 | f1aa6320 | ths | { |
1238 | be24bb4f | ths | env->CP0_Config0 = (env->CP0_Config0 & 0x81FFFFF8) | (t0 & 0x00000007); |
1239 | f1aa6320 | ths | } |
1240 | f1aa6320 | ths | |
1241 | c01fccd2 | aurel32 | void helper_mtc0_config2 (target_ulong t0)
|
1242 | f1aa6320 | ths | { |
1243 | f1aa6320 | ths | /* tertiary/secondary caches not implemented */
|
1244 | f1aa6320 | ths | env->CP0_Config2 = (env->CP0_Config2 & 0x8FFF0FFF);
|
1245 | f1aa6320 | ths | } |
1246 | f1aa6320 | ths | |
1247 | c01fccd2 | aurel32 | void helper_mtc0_watchlo (target_ulong t0, uint32_t sel)
|
1248 | f1aa6320 | ths | { |
1249 | f1aa6320 | ths | /* Watch exceptions for instructions, data loads, data stores
|
1250 | f1aa6320 | ths | not implemented. */
|
1251 | be24bb4f | ths | env->CP0_WatchLo[sel] = (t0 & ~0x7);
|
1252 | f1aa6320 | ths | } |
1253 | f1aa6320 | ths | |
1254 | c01fccd2 | aurel32 | void helper_mtc0_watchhi (target_ulong t0, uint32_t sel)
|
1255 | f1aa6320 | ths | { |
1256 | be24bb4f | ths | env->CP0_WatchHi[sel] = (t0 & 0x40FF0FF8);
|
1257 | be24bb4f | ths | env->CP0_WatchHi[sel] &= ~(env->CP0_WatchHi[sel] & t0 & 0x7);
|
1258 | f1aa6320 | ths | } |
1259 | f1aa6320 | ths | |
1260 | c01fccd2 | aurel32 | void helper_mtc0_xcontext (target_ulong t0)
|
1261 | f1aa6320 | ths | { |
1262 | f1aa6320 | ths | target_ulong mask = (1ULL << (env->SEGBITS - 7)) - 1; |
1263 | be24bb4f | ths | env->CP0_XContext = (env->CP0_XContext & mask) | (t0 & ~mask); |
1264 | f1aa6320 | ths | } |
1265 | f1aa6320 | ths | |
1266 | c01fccd2 | aurel32 | void helper_mtc0_framemask (target_ulong t0)
|
1267 | f1aa6320 | ths | { |
1268 | be24bb4f | ths | env->CP0_Framemask = t0; /* XXX */
|
1269 | f1aa6320 | ths | } |
1270 | f1aa6320 | ths | |
1271 | c01fccd2 | aurel32 | void helper_mtc0_debug (target_ulong t0)
|
1272 | f1aa6320 | ths | { |
1273 | be24bb4f | ths | env->CP0_Debug = (env->CP0_Debug & 0x8C03FC1F) | (t0 & 0x13300120); |
1274 | be24bb4f | ths | if (t0 & (1 << CP0DB_DM)) |
1275 | f1aa6320 | ths | env->hflags |= MIPS_HFLAG_DM; |
1276 | f1aa6320 | ths | else
|
1277 | f1aa6320 | ths | env->hflags &= ~MIPS_HFLAG_DM; |
1278 | f1aa6320 | ths | } |
1279 | f1aa6320 | ths | |
1280 | c01fccd2 | aurel32 | void helper_mttc0_debug(target_ulong t0)
|
1281 | f1aa6320 | ths | { |
1282 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1283 | b5dc7732 | ths | uint32_t val = t0 & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt)); |
1284 | f1aa6320 | ths | |
1285 | f1aa6320 | ths | /* XXX: Might be wrong, check with EJTAG spec. */
|
1286 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1287 | b5dc7732 | ths | env->active_tc.CP0_Debug_tcstatus = val; |
1288 | b5dc7732 | ths | else
|
1289 | b5dc7732 | ths | env->tcs[other_tc].CP0_Debug_tcstatus = val; |
1290 | f1aa6320 | ths | env->CP0_Debug = (env->CP0_Debug & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt))) | |
1291 | be24bb4f | ths | (t0 & ~((1 << CP0DB_SSt) | (1 << CP0DB_Halt))); |
1292 | f1aa6320 | ths | } |
1293 | f1aa6320 | ths | |
1294 | c01fccd2 | aurel32 | void helper_mtc0_performance0 (target_ulong t0)
|
1295 | f1aa6320 | ths | { |
1296 | be24bb4f | ths | env->CP0_Performance0 = t0 & 0x000007ff;
|
1297 | f1aa6320 | ths | } |
1298 | f1aa6320 | ths | |
1299 | c01fccd2 | aurel32 | void helper_mtc0_taglo (target_ulong t0)
|
1300 | f1aa6320 | ths | { |
1301 | be24bb4f | ths | env->CP0_TagLo = t0 & 0xFFFFFCF6;
|
1302 | f1aa6320 | ths | } |
1303 | f1aa6320 | ths | |
1304 | c01fccd2 | aurel32 | void helper_mtc0_datalo (target_ulong t0)
|
1305 | f1aa6320 | ths | { |
1306 | be24bb4f | ths | env->CP0_DataLo = t0; /* XXX */
|
1307 | f1aa6320 | ths | } |
1308 | f1aa6320 | ths | |
1309 | c01fccd2 | aurel32 | void helper_mtc0_taghi (target_ulong t0)
|
1310 | f1aa6320 | ths | { |
1311 | be24bb4f | ths | env->CP0_TagHi = t0; /* XXX */
|
1312 | f1aa6320 | ths | } |
1313 | f1aa6320 | ths | |
1314 | c01fccd2 | aurel32 | void helper_mtc0_datahi (target_ulong t0)
|
1315 | f1aa6320 | ths | { |
1316 | be24bb4f | ths | env->CP0_DataHi = t0; /* XXX */
|
1317 | f1aa6320 | ths | } |
1318 | f1aa6320 | ths | |
1319 | f1aa6320 | ths | /* MIPS MT functions */
|
1320 | c01fccd2 | aurel32 | target_ulong helper_mftgpr(uint32_t sel) |
1321 | f1aa6320 | ths | { |
1322 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1323 | f1aa6320 | ths | |
1324 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1325 | b5dc7732 | ths | return env->active_tc.gpr[sel];
|
1326 | b5dc7732 | ths | else
|
1327 | b5dc7732 | ths | return env->tcs[other_tc].gpr[sel];
|
1328 | f1aa6320 | ths | } |
1329 | f1aa6320 | ths | |
1330 | c01fccd2 | aurel32 | target_ulong helper_mftlo(uint32_t sel) |
1331 | f1aa6320 | ths | { |
1332 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1333 | f1aa6320 | ths | |
1334 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1335 | b5dc7732 | ths | return env->active_tc.LO[sel];
|
1336 | b5dc7732 | ths | else
|
1337 | b5dc7732 | ths | return env->tcs[other_tc].LO[sel];
|
1338 | f1aa6320 | ths | } |
1339 | f1aa6320 | ths | |
1340 | c01fccd2 | aurel32 | target_ulong helper_mfthi(uint32_t sel) |
1341 | f1aa6320 | ths | { |
1342 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1343 | f1aa6320 | ths | |
1344 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1345 | b5dc7732 | ths | return env->active_tc.HI[sel];
|
1346 | b5dc7732 | ths | else
|
1347 | b5dc7732 | ths | return env->tcs[other_tc].HI[sel];
|
1348 | f1aa6320 | ths | } |
1349 | f1aa6320 | ths | |
1350 | c01fccd2 | aurel32 | target_ulong helper_mftacx(uint32_t sel) |
1351 | f1aa6320 | ths | { |
1352 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1353 | f1aa6320 | ths | |
1354 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1355 | b5dc7732 | ths | return env->active_tc.ACX[sel];
|
1356 | b5dc7732 | ths | else
|
1357 | b5dc7732 | ths | return env->tcs[other_tc].ACX[sel];
|
1358 | f1aa6320 | ths | } |
1359 | f1aa6320 | ths | |
1360 | c01fccd2 | aurel32 | target_ulong helper_mftdsp(void)
|
1361 | f1aa6320 | ths | { |
1362 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1363 | f1aa6320 | ths | |
1364 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1365 | b5dc7732 | ths | return env->active_tc.DSPControl;
|
1366 | b5dc7732 | ths | else
|
1367 | b5dc7732 | ths | return env->tcs[other_tc].DSPControl;
|
1368 | f1aa6320 | ths | } |
1369 | 6af0bf9c | bellard | |
1370 | c01fccd2 | aurel32 | void helper_mttgpr(target_ulong t0, uint32_t sel)
|
1371 | f1aa6320 | ths | { |
1372 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1373 | f1aa6320 | ths | |
1374 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1375 | b5dc7732 | ths | env->active_tc.gpr[sel] = t0; |
1376 | b5dc7732 | ths | else
|
1377 | b5dc7732 | ths | env->tcs[other_tc].gpr[sel] = t0; |
1378 | f1aa6320 | ths | } |
1379 | f1aa6320 | ths | |
1380 | c01fccd2 | aurel32 | void helper_mttlo(target_ulong t0, uint32_t sel)
|
1381 | f1aa6320 | ths | { |
1382 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1383 | f1aa6320 | ths | |
1384 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1385 | b5dc7732 | ths | env->active_tc.LO[sel] = t0; |
1386 | b5dc7732 | ths | else
|
1387 | b5dc7732 | ths | env->tcs[other_tc].LO[sel] = t0; |
1388 | f1aa6320 | ths | } |
1389 | f1aa6320 | ths | |
1390 | c01fccd2 | aurel32 | void helper_mtthi(target_ulong t0, uint32_t sel)
|
1391 | f1aa6320 | ths | { |
1392 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1393 | f1aa6320 | ths | |
1394 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1395 | b5dc7732 | ths | env->active_tc.HI[sel] = t0; |
1396 | b5dc7732 | ths | else
|
1397 | b5dc7732 | ths | env->tcs[other_tc].HI[sel] = t0; |
1398 | f1aa6320 | ths | } |
1399 | f1aa6320 | ths | |
1400 | c01fccd2 | aurel32 | void helper_mttacx(target_ulong t0, uint32_t sel)
|
1401 | f1aa6320 | ths | { |
1402 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1403 | f1aa6320 | ths | |
1404 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1405 | b5dc7732 | ths | env->active_tc.ACX[sel] = t0; |
1406 | b5dc7732 | ths | else
|
1407 | b5dc7732 | ths | env->tcs[other_tc].ACX[sel] = t0; |
1408 | f1aa6320 | ths | } |
1409 | f1aa6320 | ths | |
1410 | c01fccd2 | aurel32 | void helper_mttdsp(target_ulong t0)
|
1411 | f1aa6320 | ths | { |
1412 | f1aa6320 | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
1413 | f1aa6320 | ths | |
1414 | b5dc7732 | ths | if (other_tc == env->current_tc)
|
1415 | b5dc7732 | ths | env->active_tc.DSPControl = t0; |
1416 | b5dc7732 | ths | else
|
1417 | b5dc7732 | ths | env->tcs[other_tc].DSPControl = t0; |
1418 | f1aa6320 | ths | } |
1419 | f1aa6320 | ths | |
1420 | f1aa6320 | ths | /* MIPS MT functions */
|
1421 | c01fccd2 | aurel32 | target_ulong helper_dmt(target_ulong t0) |
1422 | f1aa6320 | ths | { |
1423 | f1aa6320 | ths | // TODO
|
1424 | be24bb4f | ths | t0 = 0;
|
1425 | be24bb4f | ths | // rt = t0
|
1426 | be24bb4f | ths | |
1427 | be24bb4f | ths | return t0;
|
1428 | f1aa6320 | ths | } |
1429 | f1aa6320 | ths | |
1430 | c01fccd2 | aurel32 | target_ulong helper_emt(target_ulong t0) |
1431 | f1aa6320 | ths | { |
1432 | f1aa6320 | ths | // TODO
|
1433 | be24bb4f | ths | t0 = 0;
|
1434 | be24bb4f | ths | // rt = t0
|
1435 | be24bb4f | ths | |
1436 | be24bb4f | ths | return t0;
|
1437 | f1aa6320 | ths | } |
1438 | f1aa6320 | ths | |
1439 | c01fccd2 | aurel32 | target_ulong helper_dvpe(target_ulong t0) |
1440 | f1aa6320 | ths | { |
1441 | f1aa6320 | ths | // TODO
|
1442 | be24bb4f | ths | t0 = 0;
|
1443 | be24bb4f | ths | // rt = t0
|
1444 | be24bb4f | ths | |
1445 | be24bb4f | ths | return t0;
|
1446 | f1aa6320 | ths | } |
1447 | f1aa6320 | ths | |
1448 | c01fccd2 | aurel32 | target_ulong helper_evpe(target_ulong t0) |
1449 | f1aa6320 | ths | { |
1450 | f1aa6320 | ths | // TODO
|
1451 | be24bb4f | ths | t0 = 0;
|
1452 | be24bb4f | ths | // rt = t0
|
1453 | be24bb4f | ths | |
1454 | be24bb4f | ths | return t0;
|
1455 | f1aa6320 | ths | } |
1456 | f9480ffc | ths | #endif /* !CONFIG_USER_ONLY */ |
1457 | f1aa6320 | ths | |
1458 | c01fccd2 | aurel32 | void helper_fork(target_ulong t0, target_ulong t1)
|
1459 | f1aa6320 | ths | { |
1460 | be24bb4f | ths | // t0 = rt, t1 = rs
|
1461 | be24bb4f | ths | t0 = 0;
|
1462 | f1aa6320 | ths | // TODO: store to TC register
|
1463 | f1aa6320 | ths | } |
1464 | f1aa6320 | ths | |
1465 | c01fccd2 | aurel32 | target_ulong helper_yield(target_ulong t0) |
1466 | f1aa6320 | ths | { |
1467 | be24bb4f | ths | if (t0 < 0) { |
1468 | f1aa6320 | ths | /* No scheduling policy implemented. */
|
1469 | be24bb4f | ths | if (t0 != -2) { |
1470 | f1aa6320 | ths | if (env->CP0_VPEControl & (1 << CP0VPECo_YSI) && |
1471 | b5dc7732 | ths | env->active_tc.CP0_TCStatus & (1 << CP0TCSt_DT)) {
|
1472 | f1aa6320 | ths | env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
|
1473 | f1aa6320 | ths | env->CP0_VPEControl |= 4 << CP0VPECo_EXCPT;
|
1474 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_THREAD); |
1475 | f1aa6320 | ths | } |
1476 | f1aa6320 | ths | } |
1477 | be24bb4f | ths | } else if (t0 == 0) { |
1478 | 6958549d | aurel32 | if (0 /* TODO: TC underflow */) { |
1479 | f1aa6320 | ths | env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
|
1480 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_THREAD); |
1481 | f1aa6320 | ths | } else {
|
1482 | f1aa6320 | ths | // TODO: Deallocate TC
|
1483 | f1aa6320 | ths | } |
1484 | be24bb4f | ths | } else if (t0 > 0) { |
1485 | f1aa6320 | ths | /* Yield qualifier inputs not implemented. */
|
1486 | f1aa6320 | ths | env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
|
1487 | f1aa6320 | ths | env->CP0_VPEControl |= 2 << CP0VPECo_EXCPT;
|
1488 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_THREAD); |
1489 | f1aa6320 | ths | } |
1490 | be24bb4f | ths | return env->CP0_YQMask;
|
1491 | f1aa6320 | ths | } |
1492 | f1aa6320 | ths | |
1493 | f1aa6320 | ths | #ifndef CONFIG_USER_ONLY
|
1494 | 6af0bf9c | bellard | /* TLB management */
|
1495 | 814b9a47 | ths | void cpu_mips_tlb_flush (CPUState *env, int flush_global) |
1496 | 814b9a47 | ths | { |
1497 | 814b9a47 | ths | /* Flush qemu's TLB and discard all shadowed entries. */
|
1498 | 814b9a47 | ths | tlb_flush (env, flush_global); |
1499 | ead9360e | ths | env->tlb->tlb_in_use = env->tlb->nb_tlb; |
1500 | 814b9a47 | ths | } |
1501 | 814b9a47 | ths | |
1502 | 29929e34 | ths | static void r4k_mips_tlb_flush_extra (CPUState *env, int first) |
1503 | 814b9a47 | ths | { |
1504 | 814b9a47 | ths | /* Discard entries from env->tlb[first] onwards. */
|
1505 | ead9360e | ths | while (env->tlb->tlb_in_use > first) {
|
1506 | ead9360e | ths | r4k_invalidate_tlb(env, --env->tlb->tlb_in_use, 0);
|
1507 | 814b9a47 | ths | } |
1508 | 814b9a47 | ths | } |
1509 | 814b9a47 | ths | |
1510 | 29929e34 | ths | static void r4k_fill_tlb (int idx) |
1511 | 6af0bf9c | bellard | { |
1512 | 29929e34 | ths | r4k_tlb_t *tlb; |
1513 | 6af0bf9c | bellard | |
1514 | 6af0bf9c | bellard | /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
|
1515 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[idx]; |
1516 | f2e9ebef | ths | tlb->VPN = env->CP0_EntryHi & (TARGET_PAGE_MASK << 1);
|
1517 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1518 | e034e2c3 | ths | tlb->VPN &= env->SEGMask; |
1519 | 100ce988 | ths | #endif
|
1520 | 98c1b82b | pbrook | tlb->ASID = env->CP0_EntryHi & 0xFF;
|
1521 | 3b1c8be4 | ths | tlb->PageMask = env->CP0_PageMask; |
1522 | 6af0bf9c | bellard | tlb->G = env->CP0_EntryLo0 & env->CP0_EntryLo1 & 1;
|
1523 | 98c1b82b | pbrook | tlb->V0 = (env->CP0_EntryLo0 & 2) != 0; |
1524 | 98c1b82b | pbrook | tlb->D0 = (env->CP0_EntryLo0 & 4) != 0; |
1525 | 98c1b82b | pbrook | tlb->C0 = (env->CP0_EntryLo0 >> 3) & 0x7; |
1526 | 6af0bf9c | bellard | tlb->PFN[0] = (env->CP0_EntryLo0 >> 6) << 12; |
1527 | 98c1b82b | pbrook | tlb->V1 = (env->CP0_EntryLo1 & 2) != 0; |
1528 | 98c1b82b | pbrook | tlb->D1 = (env->CP0_EntryLo1 & 4) != 0; |
1529 | 98c1b82b | pbrook | tlb->C1 = (env->CP0_EntryLo1 >> 3) & 0x7; |
1530 | 6af0bf9c | bellard | tlb->PFN[1] = (env->CP0_EntryLo1 >> 6) << 12; |
1531 | 6af0bf9c | bellard | } |
1532 | 6af0bf9c | bellard | |
1533 | c01fccd2 | aurel32 | void r4k_helper_tlbwi (void) |
1534 | 6af0bf9c | bellard | { |
1535 | bbc0d79c | aurel32 | int idx;
|
1536 | bbc0d79c | aurel32 | |
1537 | bbc0d79c | aurel32 | idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb;
|
1538 | bbc0d79c | aurel32 | |
1539 | 814b9a47 | ths | /* Discard cached TLB entries. We could avoid doing this if the
|
1540 | 814b9a47 | ths | tlbwi is just upgrading access permissions on the current entry;
|
1541 | 814b9a47 | ths | that might be a further win. */
|
1542 | ead9360e | ths | r4k_mips_tlb_flush_extra (env, env->tlb->nb_tlb); |
1543 | 814b9a47 | ths | |
1544 | bbc0d79c | aurel32 | r4k_invalidate_tlb(env, idx, 0);
|
1545 | bbc0d79c | aurel32 | r4k_fill_tlb(idx); |
1546 | 6af0bf9c | bellard | } |
1547 | 6af0bf9c | bellard | |
1548 | c01fccd2 | aurel32 | void r4k_helper_tlbwr (void) |
1549 | 6af0bf9c | bellard | { |
1550 | 6af0bf9c | bellard | int r = cpu_mips_get_random(env);
|
1551 | 6af0bf9c | bellard | |
1552 | 29929e34 | ths | r4k_invalidate_tlb(env, r, 1);
|
1553 | 29929e34 | ths | r4k_fill_tlb(r); |
1554 | 6af0bf9c | bellard | } |
1555 | 6af0bf9c | bellard | |
1556 | c01fccd2 | aurel32 | void r4k_helper_tlbp (void) |
1557 | 6af0bf9c | bellard | { |
1558 | 29929e34 | ths | r4k_tlb_t *tlb; |
1559 | f2e9ebef | ths | target_ulong mask; |
1560 | 6af0bf9c | bellard | target_ulong tag; |
1561 | f2e9ebef | ths | target_ulong VPN; |
1562 | 6af0bf9c | bellard | uint8_t ASID; |
1563 | 6af0bf9c | bellard | int i;
|
1564 | 6af0bf9c | bellard | |
1565 | 3d9fb9fe | bellard | ASID = env->CP0_EntryHi & 0xFF;
|
1566 | ead9360e | ths | for (i = 0; i < env->tlb->nb_tlb; i++) { |
1567 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[i]; |
1568 | f2e9ebef | ths | /* 1k pages are not supported. */
|
1569 | f2e9ebef | ths | mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
|
1570 | f2e9ebef | ths | tag = env->CP0_EntryHi & ~mask; |
1571 | f2e9ebef | ths | VPN = tlb->VPN & ~mask; |
1572 | 6af0bf9c | bellard | /* Check ASID, virtual page number & size */
|
1573 | f2e9ebef | ths | if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { |
1574 | 6af0bf9c | bellard | /* TLB match */
|
1575 | 9c2149c8 | ths | env->CP0_Index = i; |
1576 | 6af0bf9c | bellard | break;
|
1577 | 6af0bf9c | bellard | } |
1578 | 6af0bf9c | bellard | } |
1579 | ead9360e | ths | if (i == env->tlb->nb_tlb) {
|
1580 | 814b9a47 | ths | /* No match. Discard any shadow entries, if any of them match. */
|
1581 | ead9360e | ths | for (i = env->tlb->nb_tlb; i < env->tlb->tlb_in_use; i++) {
|
1582 | 6958549d | aurel32 | tlb = &env->tlb->mmu.r4k.tlb[i]; |
1583 | 6958549d | aurel32 | /* 1k pages are not supported. */
|
1584 | 6958549d | aurel32 | mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
|
1585 | 6958549d | aurel32 | tag = env->CP0_EntryHi & ~mask; |
1586 | 6958549d | aurel32 | VPN = tlb->VPN & ~mask; |
1587 | 6958549d | aurel32 | /* Check ASID, virtual page number & size */
|
1588 | 6958549d | aurel32 | if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { |
1589 | 29929e34 | ths | r4k_mips_tlb_flush_extra (env, i); |
1590 | 6958549d | aurel32 | break;
|
1591 | 6958549d | aurel32 | } |
1592 | 6958549d | aurel32 | } |
1593 | 814b9a47 | ths | |
1594 | 9c2149c8 | ths | env->CP0_Index |= 0x80000000;
|
1595 | 6af0bf9c | bellard | } |
1596 | 6af0bf9c | bellard | } |
1597 | 6af0bf9c | bellard | |
1598 | c01fccd2 | aurel32 | void r4k_helper_tlbr (void) |
1599 | 6af0bf9c | bellard | { |
1600 | 29929e34 | ths | r4k_tlb_t *tlb; |
1601 | 09c56b84 | pbrook | uint8_t ASID; |
1602 | bbc0d79c | aurel32 | int idx;
|
1603 | 6af0bf9c | bellard | |
1604 | 09c56b84 | pbrook | ASID = env->CP0_EntryHi & 0xFF;
|
1605 | bbc0d79c | aurel32 | idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb;
|
1606 | bbc0d79c | aurel32 | tlb = &env->tlb->mmu.r4k.tlb[idx]; |
1607 | 4ad40f36 | bellard | |
1608 | 4ad40f36 | bellard | /* If this will change the current ASID, flush qemu's TLB. */
|
1609 | 814b9a47 | ths | if (ASID != tlb->ASID)
|
1610 | 814b9a47 | ths | cpu_mips_tlb_flush (env, 1);
|
1611 | 814b9a47 | ths | |
1612 | ead9360e | ths | r4k_mips_tlb_flush_extra(env, env->tlb->nb_tlb); |
1613 | 4ad40f36 | bellard | |
1614 | 6af0bf9c | bellard | env->CP0_EntryHi = tlb->VPN | tlb->ASID; |
1615 | 3b1c8be4 | ths | env->CP0_PageMask = tlb->PageMask; |
1616 | 7495fd0f | ths | env->CP0_EntryLo0 = tlb->G | (tlb->V0 << 1) | (tlb->D0 << 2) | |
1617 | 7495fd0f | ths | (tlb->C0 << 3) | (tlb->PFN[0] >> 6); |
1618 | 7495fd0f | ths | env->CP0_EntryLo1 = tlb->G | (tlb->V1 << 1) | (tlb->D1 << 2) | |
1619 | 7495fd0f | ths | (tlb->C1 << 3) | (tlb->PFN[1] >> 6); |
1620 | 6af0bf9c | bellard | } |
1621 | 6af0bf9c | bellard | |
1622 | c01fccd2 | aurel32 | void helper_tlbwi(void) |
1623 | a7812ae4 | pbrook | { |
1624 | c01fccd2 | aurel32 | env->tlb->helper_tlbwi(); |
1625 | a7812ae4 | pbrook | } |
1626 | a7812ae4 | pbrook | |
1627 | c01fccd2 | aurel32 | void helper_tlbwr(void) |
1628 | a7812ae4 | pbrook | { |
1629 | c01fccd2 | aurel32 | env->tlb->helper_tlbwr(); |
1630 | a7812ae4 | pbrook | } |
1631 | a7812ae4 | pbrook | |
1632 | c01fccd2 | aurel32 | void helper_tlbp(void) |
1633 | a7812ae4 | pbrook | { |
1634 | c01fccd2 | aurel32 | env->tlb->helper_tlbp(); |
1635 | a7812ae4 | pbrook | } |
1636 | a7812ae4 | pbrook | |
1637 | c01fccd2 | aurel32 | void helper_tlbr(void) |
1638 | a7812ae4 | pbrook | { |
1639 | c01fccd2 | aurel32 | env->tlb->helper_tlbr(); |
1640 | a7812ae4 | pbrook | } |
1641 | a7812ae4 | pbrook | |
1642 | 2b0233ab | ths | /* Specials */
|
1643 | c01fccd2 | aurel32 | target_ulong helper_di (void)
|
1644 | 2b0233ab | ths | { |
1645 | 2796188e | ths | target_ulong t0 = env->CP0_Status; |
1646 | 2796188e | ths | |
1647 | be24bb4f | ths | env->CP0_Status = t0 & ~(1 << CP0St_IE);
|
1648 | 2b0233ab | ths | cpu_mips_update_irq(env); |
1649 | be24bb4f | ths | |
1650 | be24bb4f | ths | return t0;
|
1651 | 2b0233ab | ths | } |
1652 | 2b0233ab | ths | |
1653 | c01fccd2 | aurel32 | target_ulong helper_ei (void)
|
1654 | 2b0233ab | ths | { |
1655 | 2796188e | ths | target_ulong t0 = env->CP0_Status; |
1656 | 2796188e | ths | |
1657 | be24bb4f | ths | env->CP0_Status = t0 | (1 << CP0St_IE);
|
1658 | 2b0233ab | ths | cpu_mips_update_irq(env); |
1659 | be24bb4f | ths | |
1660 | be24bb4f | ths | return t0;
|
1661 | 2b0233ab | ths | } |
1662 | 2b0233ab | ths | |
1663 | cd5158ea | aurel32 | static void debug_pre_eret (void) |
1664 | 6af0bf9c | bellard | { |
1665 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
|
1666 | 93fcfe39 | aliguori | qemu_log("ERET: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx, |
1667 | 93fcfe39 | aliguori | env->active_tc.PC, env->CP0_EPC); |
1668 | 93fcfe39 | aliguori | if (env->CP0_Status & (1 << CP0St_ERL)) |
1669 | 93fcfe39 | aliguori | qemu_log(" ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
|
1670 | 93fcfe39 | aliguori | if (env->hflags & MIPS_HFLAG_DM)
|
1671 | 93fcfe39 | aliguori | qemu_log(" DEPC " TARGET_FMT_lx, env->CP0_DEPC);
|
1672 | 93fcfe39 | aliguori | qemu_log("\n");
|
1673 | 93fcfe39 | aliguori | } |
1674 | f41c52f1 | ths | } |
1675 | f41c52f1 | ths | |
1676 | cd5158ea | aurel32 | static void debug_post_eret (void) |
1677 | f41c52f1 | ths | { |
1678 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
|
1679 | 93fcfe39 | aliguori | qemu_log(" => PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx, |
1680 | 93fcfe39 | aliguori | env->active_tc.PC, env->CP0_EPC); |
1681 | 93fcfe39 | aliguori | if (env->CP0_Status & (1 << CP0St_ERL)) |
1682 | 93fcfe39 | aliguori | qemu_log(" ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
|
1683 | 93fcfe39 | aliguori | if (env->hflags & MIPS_HFLAG_DM)
|
1684 | 93fcfe39 | aliguori | qemu_log(" DEPC " TARGET_FMT_lx, env->CP0_DEPC);
|
1685 | 93fcfe39 | aliguori | switch (env->hflags & MIPS_HFLAG_KSU) {
|
1686 | 93fcfe39 | aliguori | case MIPS_HFLAG_UM: qemu_log(", UM\n"); break; |
1687 | 93fcfe39 | aliguori | case MIPS_HFLAG_SM: qemu_log(", SM\n"); break; |
1688 | 93fcfe39 | aliguori | case MIPS_HFLAG_KM: qemu_log("\n"); break; |
1689 | 93fcfe39 | aliguori | default: cpu_abort(env, "Invalid MMU mode!\n"); break; |
1690 | 93fcfe39 | aliguori | } |
1691 | 623a930e | ths | } |
1692 | 6af0bf9c | bellard | } |
1693 | 6af0bf9c | bellard | |
1694 | c01fccd2 | aurel32 | void helper_eret (void) |
1695 | 2b0233ab | ths | { |
1696 | 93fcfe39 | aliguori | debug_pre_eret(); |
1697 | 2b0233ab | ths | if (env->CP0_Status & (1 << CP0St_ERL)) { |
1698 | b5dc7732 | ths | env->active_tc.PC = env->CP0_ErrorEPC; |
1699 | 2b0233ab | ths | env->CP0_Status &= ~(1 << CP0St_ERL);
|
1700 | 2b0233ab | ths | } else {
|
1701 | b5dc7732 | ths | env->active_tc.PC = env->CP0_EPC; |
1702 | 2b0233ab | ths | env->CP0_Status &= ~(1 << CP0St_EXL);
|
1703 | 2b0233ab | ths | } |
1704 | 2b0233ab | ths | compute_hflags(env); |
1705 | 93fcfe39 | aliguori | debug_post_eret(); |
1706 | 2b0233ab | ths | env->CP0_LLAddr = 1;
|
1707 | 2b0233ab | ths | } |
1708 | 2b0233ab | ths | |
1709 | c01fccd2 | aurel32 | void helper_deret (void) |
1710 | 2b0233ab | ths | { |
1711 | 93fcfe39 | aliguori | debug_pre_eret(); |
1712 | b5dc7732 | ths | env->active_tc.PC = env->CP0_DEPC; |
1713 | 2b0233ab | ths | env->hflags &= MIPS_HFLAG_DM; |
1714 | 2b0233ab | ths | compute_hflags(env); |
1715 | 93fcfe39 | aliguori | debug_post_eret(); |
1716 | 2b0233ab | ths | env->CP0_LLAddr = 1;
|
1717 | 2b0233ab | ths | } |
1718 | 0eaef5aa | ths | #endif /* !CONFIG_USER_ONLY */ |
1719 | 2b0233ab | ths | |
1720 | c01fccd2 | aurel32 | target_ulong helper_rdhwr_cpunum(void)
|
1721 | 2b0233ab | ths | { |
1722 | 2b0233ab | ths | if ((env->hflags & MIPS_HFLAG_CP0) ||
|
1723 | 2b0233ab | ths | (env->CP0_HWREna & (1 << 0))) |
1724 | 2796188e | ths | return env->CP0_EBase & 0x3ff; |
1725 | 2b0233ab | ths | else
|
1726 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_RI); |
1727 | be24bb4f | ths | |
1728 | 2796188e | ths | return 0; |
1729 | 2b0233ab | ths | } |
1730 | 2b0233ab | ths | |
1731 | c01fccd2 | aurel32 | target_ulong helper_rdhwr_synci_step(void)
|
1732 | 2b0233ab | ths | { |
1733 | 2b0233ab | ths | if ((env->hflags & MIPS_HFLAG_CP0) ||
|
1734 | 2b0233ab | ths | (env->CP0_HWREna & (1 << 1))) |
1735 | 2796188e | ths | return env->SYNCI_Step;
|
1736 | 2b0233ab | ths | else
|
1737 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_RI); |
1738 | be24bb4f | ths | |
1739 | 2796188e | ths | return 0; |
1740 | 2b0233ab | ths | } |
1741 | 2b0233ab | ths | |
1742 | c01fccd2 | aurel32 | target_ulong helper_rdhwr_cc(void)
|
1743 | 2b0233ab | ths | { |
1744 | 2b0233ab | ths | if ((env->hflags & MIPS_HFLAG_CP0) ||
|
1745 | 2b0233ab | ths | (env->CP0_HWREna & (1 << 2))) |
1746 | 2796188e | ths | return env->CP0_Count;
|
1747 | 2b0233ab | ths | else
|
1748 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_RI); |
1749 | be24bb4f | ths | |
1750 | 2796188e | ths | return 0; |
1751 | 2b0233ab | ths | } |
1752 | 2b0233ab | ths | |
1753 | c01fccd2 | aurel32 | target_ulong helper_rdhwr_ccres(void)
|
1754 | 2b0233ab | ths | { |
1755 | 2b0233ab | ths | if ((env->hflags & MIPS_HFLAG_CP0) ||
|
1756 | 2b0233ab | ths | (env->CP0_HWREna & (1 << 3))) |
1757 | 2796188e | ths | return env->CCRes;
|
1758 | 2b0233ab | ths | else
|
1759 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_RI); |
1760 | be24bb4f | ths | |
1761 | 2796188e | ths | return 0; |
1762 | 2b0233ab | ths | } |
1763 | 2b0233ab | ths | |
1764 | c01fccd2 | aurel32 | void helper_pmon (int function) |
1765 | 6af0bf9c | bellard | { |
1766 | 6af0bf9c | bellard | function /= 2;
|
1767 | 6af0bf9c | bellard | switch (function) {
|
1768 | 6af0bf9c | bellard | case 2: /* TODO: char inbyte(int waitflag); */ |
1769 | b5dc7732 | ths | if (env->active_tc.gpr[4] == 0) |
1770 | b5dc7732 | ths | env->active_tc.gpr[2] = -1; |
1771 | 6af0bf9c | bellard | /* Fall through */
|
1772 | 6af0bf9c | bellard | case 11: /* TODO: char inbyte (void); */ |
1773 | b5dc7732 | ths | env->active_tc.gpr[2] = -1; |
1774 | 6af0bf9c | bellard | break;
|
1775 | 6af0bf9c | bellard | case 3: |
1776 | 6af0bf9c | bellard | case 12: |
1777 | b5dc7732 | ths | printf("%c", (char)(env->active_tc.gpr[4] & 0xFF)); |
1778 | 6af0bf9c | bellard | break;
|
1779 | 6af0bf9c | bellard | case 17: |
1780 | 6af0bf9c | bellard | break;
|
1781 | 6af0bf9c | bellard | case 158: |
1782 | 6af0bf9c | bellard | { |
1783 | b5dc7732 | ths | unsigned char *fmt = (void *)(unsigned long)env->active_tc.gpr[4]; |
1784 | 6af0bf9c | bellard | printf("%s", fmt);
|
1785 | 6af0bf9c | bellard | } |
1786 | 6af0bf9c | bellard | break;
|
1787 | 6af0bf9c | bellard | } |
1788 | 6af0bf9c | bellard | } |
1789 | e37e863f | bellard | |
1790 | c01fccd2 | aurel32 | void helper_wait (void) |
1791 | 08ba7963 | ths | { |
1792 | 08ba7963 | ths | env->halted = 1;
|
1793 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_HLT); |
1794 | 08ba7963 | ths | } |
1795 | 08ba7963 | ths | |
1796 | 5fafdf24 | ths | #if !defined(CONFIG_USER_ONLY)
|
1797 | e37e863f | bellard | |
1798 | 4ad40f36 | bellard | static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr); |
1799 | 4ad40f36 | bellard | |
1800 | e37e863f | bellard | #define MMUSUFFIX _mmu
|
1801 | 4ad40f36 | bellard | #define ALIGNED_ONLY
|
1802 | e37e863f | bellard | |
1803 | e37e863f | bellard | #define SHIFT 0 |
1804 | e37e863f | bellard | #include "softmmu_template.h" |
1805 | e37e863f | bellard | |
1806 | e37e863f | bellard | #define SHIFT 1 |
1807 | e37e863f | bellard | #include "softmmu_template.h" |
1808 | e37e863f | bellard | |
1809 | e37e863f | bellard | #define SHIFT 2 |
1810 | e37e863f | bellard | #include "softmmu_template.h" |
1811 | e37e863f | bellard | |
1812 | e37e863f | bellard | #define SHIFT 3 |
1813 | e37e863f | bellard | #include "softmmu_template.h" |
1814 | e37e863f | bellard | |
1815 | 4ad40f36 | bellard | static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr) |
1816 | 4ad40f36 | bellard | { |
1817 | 4ad40f36 | bellard | env->CP0_BadVAddr = addr; |
1818 | 4ad40f36 | bellard | do_restore_state (retaddr); |
1819 | c01fccd2 | aurel32 | helper_raise_exception ((is_write == 1) ? EXCP_AdES : EXCP_AdEL);
|
1820 | 4ad40f36 | bellard | } |
1821 | 4ad40f36 | bellard | |
1822 | 6ebbf390 | j_mayer | void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr) |
1823 | e37e863f | bellard | { |
1824 | e37e863f | bellard | TranslationBlock *tb; |
1825 | e37e863f | bellard | CPUState *saved_env; |
1826 | e37e863f | bellard | unsigned long pc; |
1827 | e37e863f | bellard | int ret;
|
1828 | e37e863f | bellard | |
1829 | e37e863f | bellard | /* XXX: hack to restore env in all cases, even if not called from
|
1830 | e37e863f | bellard | generated code */
|
1831 | e37e863f | bellard | saved_env = env; |
1832 | e37e863f | bellard | env = cpu_single_env; |
1833 | 6ebbf390 | j_mayer | ret = cpu_mips_handle_mmu_fault(env, addr, is_write, mmu_idx, 1);
|
1834 | e37e863f | bellard | if (ret) {
|
1835 | e37e863f | bellard | if (retaddr) {
|
1836 | e37e863f | bellard | /* now we have a real cpu fault */
|
1837 | e37e863f | bellard | pc = (unsigned long)retaddr; |
1838 | e37e863f | bellard | tb = tb_find_pc(pc); |
1839 | e37e863f | bellard | if (tb) {
|
1840 | e37e863f | bellard | /* the PC is inside the translated code. It means that we have
|
1841 | e37e863f | bellard | a virtual CPU fault */
|
1842 | e37e863f | bellard | cpu_restore_state(tb, env, pc, NULL);
|
1843 | e37e863f | bellard | } |
1844 | e37e863f | bellard | } |
1845 | c01fccd2 | aurel32 | helper_raise_exception_err(env->exception_index, env->error_code); |
1846 | e37e863f | bellard | } |
1847 | e37e863f | bellard | env = saved_env; |
1848 | e37e863f | bellard | } |
1849 | e37e863f | bellard | |
1850 | 647de6ca | ths | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
1851 | e18231a3 | blueswir1 | int unused, int size) |
1852 | 647de6ca | ths | { |
1853 | 647de6ca | ths | if (is_exec)
|
1854 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_IBE); |
1855 | 647de6ca | ths | else
|
1856 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_DBE); |
1857 | 647de6ca | ths | } |
1858 | f1aa6320 | ths | #endif /* !CONFIG_USER_ONLY */ |
1859 | fd4a04eb | ths | |
1860 | fd4a04eb | ths | /* Complex FPU operations which may need stack space. */
|
1861 | fd4a04eb | ths | |
1862 | f090c9d4 | pbrook | #define FLOAT_ONE32 make_float32(0x3f8 << 20) |
1863 | f090c9d4 | pbrook | #define FLOAT_ONE64 make_float64(0x3ffULL << 52) |
1864 | f090c9d4 | pbrook | #define FLOAT_TWO32 make_float32(1 << 30) |
1865 | f090c9d4 | pbrook | #define FLOAT_TWO64 make_float64(1ULL << 62) |
1866 | 54454097 | ths | #define FLOAT_QNAN32 0x7fbfffff |
1867 | 54454097 | ths | #define FLOAT_QNAN64 0x7ff7ffffffffffffULL |
1868 | 54454097 | ths | #define FLOAT_SNAN32 0x7fffffff |
1869 | 54454097 | ths | #define FLOAT_SNAN64 0x7fffffffffffffffULL |
1870 | 8dfdb87c | ths | |
1871 | fd4a04eb | ths | /* convert MIPS rounding mode in FCR31 to IEEE library */
|
1872 | fd4a04eb | ths | unsigned int ieee_rm[] = { |
1873 | fd4a04eb | ths | float_round_nearest_even, |
1874 | fd4a04eb | ths | float_round_to_zero, |
1875 | fd4a04eb | ths | float_round_up, |
1876 | fd4a04eb | ths | float_round_down |
1877 | fd4a04eb | ths | }; |
1878 | fd4a04eb | ths | |
1879 | fd4a04eb | ths | #define RESTORE_ROUNDING_MODE \
|
1880 | f01be154 | ths | set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], &env->active_fpu.fp_status)
|
1881 | fd4a04eb | ths | |
1882 | c01fccd2 | aurel32 | target_ulong helper_cfc1 (uint32_t reg) |
1883 | fd4a04eb | ths | { |
1884 | 6c5c1e20 | ths | target_ulong t0; |
1885 | 6c5c1e20 | ths | |
1886 | ead9360e | ths | switch (reg) {
|
1887 | ead9360e | ths | case 0: |
1888 | f01be154 | ths | t0 = (int32_t)env->active_fpu.fcr0; |
1889 | ead9360e | ths | break;
|
1890 | ead9360e | ths | case 25: |
1891 | f01be154 | ths | t0 = ((env->active_fpu.fcr31 >> 24) & 0xfe) | ((env->active_fpu.fcr31 >> 23) & 0x1); |
1892 | ead9360e | ths | break;
|
1893 | ead9360e | ths | case 26: |
1894 | f01be154 | ths | t0 = env->active_fpu.fcr31 & 0x0003f07c;
|
1895 | ead9360e | ths | break;
|
1896 | ead9360e | ths | case 28: |
1897 | f01be154 | ths | t0 = (env->active_fpu.fcr31 & 0x00000f83) | ((env->active_fpu.fcr31 >> 22) & 0x4); |
1898 | ead9360e | ths | break;
|
1899 | ead9360e | ths | default:
|
1900 | f01be154 | ths | t0 = (int32_t)env->active_fpu.fcr31; |
1901 | ead9360e | ths | break;
|
1902 | ead9360e | ths | } |
1903 | be24bb4f | ths | |
1904 | be24bb4f | ths | return t0;
|
1905 | ead9360e | ths | } |
1906 | ead9360e | ths | |
1907 | c01fccd2 | aurel32 | void helper_ctc1 (target_ulong t0, uint32_t reg)
|
1908 | ead9360e | ths | { |
1909 | ead9360e | ths | switch(reg) {
|
1910 | fd4a04eb | ths | case 25: |
1911 | be24bb4f | ths | if (t0 & 0xffffff00) |
1912 | fd4a04eb | ths | return;
|
1913 | f01be154 | ths | env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0x017fffff) | ((t0 & 0xfe) << 24) | |
1914 | be24bb4f | ths | ((t0 & 0x1) << 23); |
1915 | fd4a04eb | ths | break;
|
1916 | fd4a04eb | ths | case 26: |
1917 | be24bb4f | ths | if (t0 & 0x007c0000) |
1918 | fd4a04eb | ths | return;
|
1919 | f01be154 | ths | env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfffc0f83) | (t0 & 0x0003f07c); |
1920 | fd4a04eb | ths | break;
|
1921 | fd4a04eb | ths | case 28: |
1922 | be24bb4f | ths | if (t0 & 0x007c0000) |
1923 | fd4a04eb | ths | return;
|
1924 | f01be154 | ths | env->active_fpu.fcr31 = (env->active_fpu.fcr31 & 0xfefff07c) | (t0 & 0x00000f83) | |
1925 | be24bb4f | ths | ((t0 & 0x4) << 22); |
1926 | fd4a04eb | ths | break;
|
1927 | fd4a04eb | ths | case 31: |
1928 | be24bb4f | ths | if (t0 & 0x007c0000) |
1929 | fd4a04eb | ths | return;
|
1930 | f01be154 | ths | env->active_fpu.fcr31 = t0; |
1931 | fd4a04eb | ths | break;
|
1932 | fd4a04eb | ths | default:
|
1933 | fd4a04eb | ths | return;
|
1934 | fd4a04eb | ths | } |
1935 | fd4a04eb | ths | /* set rounding mode */
|
1936 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
1937 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
1938 | f01be154 | ths | if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31)) |
1939 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_FPE); |
1940 | fd4a04eb | ths | } |
1941 | fd4a04eb | ths | |
1942 | c904ef0e | ths | static inline char ieee_ex_to_mips(char xcpt) |
1943 | fd4a04eb | ths | { |
1944 | fd4a04eb | ths | return (xcpt & float_flag_inexact) >> 5 | |
1945 | fd4a04eb | ths | (xcpt & float_flag_underflow) >> 3 |
|
1946 | fd4a04eb | ths | (xcpt & float_flag_overflow) >> 1 |
|
1947 | fd4a04eb | ths | (xcpt & float_flag_divbyzero) << 1 |
|
1948 | fd4a04eb | ths | (xcpt & float_flag_invalid) << 4;
|
1949 | fd4a04eb | ths | } |
1950 | fd4a04eb | ths | |
1951 | c904ef0e | ths | static inline char mips_ex_to_ieee(char xcpt) |
1952 | fd4a04eb | ths | { |
1953 | fd4a04eb | ths | return (xcpt & FP_INEXACT) << 5 | |
1954 | fd4a04eb | ths | (xcpt & FP_UNDERFLOW) << 3 |
|
1955 | fd4a04eb | ths | (xcpt & FP_OVERFLOW) << 1 |
|
1956 | fd4a04eb | ths | (xcpt & FP_DIV0) >> 1 |
|
1957 | fd4a04eb | ths | (xcpt & FP_INVALID) >> 4;
|
1958 | fd4a04eb | ths | } |
1959 | fd4a04eb | ths | |
1960 | c904ef0e | ths | static inline void update_fcr31(void) |
1961 | fd4a04eb | ths | { |
1962 | f01be154 | ths | int tmp = ieee_ex_to_mips(get_float_exception_flags(&env->active_fpu.fp_status));
|
1963 | fd4a04eb | ths | |
1964 | f01be154 | ths | SET_FP_CAUSE(env->active_fpu.fcr31, tmp); |
1965 | f01be154 | ths | if (GET_FP_ENABLE(env->active_fpu.fcr31) & tmp)
|
1966 | c01fccd2 | aurel32 | helper_raise_exception(EXCP_FPE); |
1967 | fd4a04eb | ths | else
|
1968 | f01be154 | ths | UPDATE_FP_FLAGS(env->active_fpu.fcr31, tmp); |
1969 | fd4a04eb | ths | } |
1970 | fd4a04eb | ths | |
1971 | a16336e4 | ths | /* Float support.
|
1972 | a16336e4 | ths | Single precition routines have a "s" suffix, double precision a
|
1973 | a16336e4 | ths | "d" suffix, 32bit integer "w", 64bit integer "l", paired single "ps",
|
1974 | a16336e4 | ths | paired single lower "pl", paired single upper "pu". */
|
1975 | a16336e4 | ths | |
1976 | a16336e4 | ths | /* unary operations, modifying fp status */
|
1977 | c01fccd2 | aurel32 | uint64_t helper_float_sqrt_d(uint64_t fdt0) |
1978 | b6d96bed | ths | { |
1979 | f01be154 | ths | return float64_sqrt(fdt0, &env->active_fpu.fp_status);
|
1980 | b6d96bed | ths | } |
1981 | b6d96bed | ths | |
1982 | c01fccd2 | aurel32 | uint32_t helper_float_sqrt_s(uint32_t fst0) |
1983 | b6d96bed | ths | { |
1984 | f01be154 | ths | return float32_sqrt(fst0, &env->active_fpu.fp_status);
|
1985 | b6d96bed | ths | } |
1986 | a16336e4 | ths | |
1987 | c01fccd2 | aurel32 | uint64_t helper_float_cvtd_s(uint32_t fst0) |
1988 | fd4a04eb | ths | { |
1989 | b6d96bed | ths | uint64_t fdt2; |
1990 | b6d96bed | ths | |
1991 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
1992 | f01be154 | ths | fdt2 = float32_to_float64(fst0, &env->active_fpu.fp_status); |
1993 | fd4a04eb | ths | update_fcr31(); |
1994 | b6d96bed | ths | return fdt2;
|
1995 | fd4a04eb | ths | } |
1996 | b6d96bed | ths | |
1997 | c01fccd2 | aurel32 | uint64_t helper_float_cvtd_w(uint32_t wt0) |
1998 | fd4a04eb | ths | { |
1999 | b6d96bed | ths | uint64_t fdt2; |
2000 | b6d96bed | ths | |
2001 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2002 | f01be154 | ths | fdt2 = int32_to_float64(wt0, &env->active_fpu.fp_status); |
2003 | fd4a04eb | ths | update_fcr31(); |
2004 | b6d96bed | ths | return fdt2;
|
2005 | fd4a04eb | ths | } |
2006 | b6d96bed | ths | |
2007 | c01fccd2 | aurel32 | uint64_t helper_float_cvtd_l(uint64_t dt0) |
2008 | fd4a04eb | ths | { |
2009 | b6d96bed | ths | uint64_t fdt2; |
2010 | b6d96bed | ths | |
2011 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2012 | f01be154 | ths | fdt2 = int64_to_float64(dt0, &env->active_fpu.fp_status); |
2013 | fd4a04eb | ths | update_fcr31(); |
2014 | b6d96bed | ths | return fdt2;
|
2015 | fd4a04eb | ths | } |
2016 | b6d96bed | ths | |
2017 | c01fccd2 | aurel32 | uint64_t helper_float_cvtl_d(uint64_t fdt0) |
2018 | fd4a04eb | ths | { |
2019 | b6d96bed | ths | uint64_t dt2; |
2020 | b6d96bed | ths | |
2021 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2022 | f01be154 | ths | dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status); |
2023 | fd4a04eb | ths | update_fcr31(); |
2024 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2025 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2026 | b6d96bed | ths | return dt2;
|
2027 | fd4a04eb | ths | } |
2028 | b6d96bed | ths | |
2029 | c01fccd2 | aurel32 | uint64_t helper_float_cvtl_s(uint32_t fst0) |
2030 | fd4a04eb | ths | { |
2031 | b6d96bed | ths | uint64_t dt2; |
2032 | b6d96bed | ths | |
2033 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2034 | f01be154 | ths | dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status); |
2035 | fd4a04eb | ths | update_fcr31(); |
2036 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2037 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2038 | b6d96bed | ths | return dt2;
|
2039 | fd4a04eb | ths | } |
2040 | fd4a04eb | ths | |
2041 | c01fccd2 | aurel32 | uint64_t helper_float_cvtps_pw(uint64_t dt0) |
2042 | fd4a04eb | ths | { |
2043 | b6d96bed | ths | uint32_t fst2; |
2044 | b6d96bed | ths | uint32_t fsth2; |
2045 | b6d96bed | ths | |
2046 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2047 | f01be154 | ths | fst2 = int32_to_float32(dt0 & 0XFFFFFFFF, &env->active_fpu.fp_status);
|
2048 | f01be154 | ths | fsth2 = int32_to_float32(dt0 >> 32, &env->active_fpu.fp_status);
|
2049 | fd4a04eb | ths | update_fcr31(); |
2050 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2051 | fd4a04eb | ths | } |
2052 | b6d96bed | ths | |
2053 | c01fccd2 | aurel32 | uint64_t helper_float_cvtpw_ps(uint64_t fdt0) |
2054 | fd4a04eb | ths | { |
2055 | b6d96bed | ths | uint32_t wt2; |
2056 | b6d96bed | ths | uint32_t wth2; |
2057 | b6d96bed | ths | |
2058 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2059 | f01be154 | ths | wt2 = float32_to_int32(fdt0 & 0XFFFFFFFF, &env->active_fpu.fp_status);
|
2060 | f01be154 | ths | wth2 = float32_to_int32(fdt0 >> 32, &env->active_fpu.fp_status);
|
2061 | fd4a04eb | ths | update_fcr31(); |
2062 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID)) {
|
2063 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2064 | b6d96bed | ths | wth2 = FLOAT_SNAN32; |
2065 | b6d96bed | ths | } |
2066 | b6d96bed | ths | return ((uint64_t)wth2 << 32) | wt2; |
2067 | fd4a04eb | ths | } |
2068 | b6d96bed | ths | |
2069 | c01fccd2 | aurel32 | uint32_t helper_float_cvts_d(uint64_t fdt0) |
2070 | fd4a04eb | ths | { |
2071 | b6d96bed | ths | uint32_t fst2; |
2072 | b6d96bed | ths | |
2073 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2074 | f01be154 | ths | fst2 = float64_to_float32(fdt0, &env->active_fpu.fp_status); |
2075 | fd4a04eb | ths | update_fcr31(); |
2076 | b6d96bed | ths | return fst2;
|
2077 | fd4a04eb | ths | } |
2078 | b6d96bed | ths | |
2079 | c01fccd2 | aurel32 | uint32_t helper_float_cvts_w(uint32_t wt0) |
2080 | fd4a04eb | ths | { |
2081 | b6d96bed | ths | uint32_t fst2; |
2082 | b6d96bed | ths | |
2083 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2084 | f01be154 | ths | fst2 = int32_to_float32(wt0, &env->active_fpu.fp_status); |
2085 | fd4a04eb | ths | update_fcr31(); |
2086 | b6d96bed | ths | return fst2;
|
2087 | fd4a04eb | ths | } |
2088 | b6d96bed | ths | |
2089 | c01fccd2 | aurel32 | uint32_t helper_float_cvts_l(uint64_t dt0) |
2090 | fd4a04eb | ths | { |
2091 | b6d96bed | ths | uint32_t fst2; |
2092 | b6d96bed | ths | |
2093 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2094 | f01be154 | ths | fst2 = int64_to_float32(dt0, &env->active_fpu.fp_status); |
2095 | fd4a04eb | ths | update_fcr31(); |
2096 | b6d96bed | ths | return fst2;
|
2097 | fd4a04eb | ths | } |
2098 | b6d96bed | ths | |
2099 | c01fccd2 | aurel32 | uint32_t helper_float_cvts_pl(uint32_t wt0) |
2100 | fd4a04eb | ths | { |
2101 | b6d96bed | ths | uint32_t wt2; |
2102 | b6d96bed | ths | |
2103 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2104 | b6d96bed | ths | wt2 = wt0; |
2105 | fd4a04eb | ths | update_fcr31(); |
2106 | b6d96bed | ths | return wt2;
|
2107 | fd4a04eb | ths | } |
2108 | b6d96bed | ths | |
2109 | c01fccd2 | aurel32 | uint32_t helper_float_cvts_pu(uint32_t wth0) |
2110 | fd4a04eb | ths | { |
2111 | b6d96bed | ths | uint32_t wt2; |
2112 | b6d96bed | ths | |
2113 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2114 | b6d96bed | ths | wt2 = wth0; |
2115 | fd4a04eb | ths | update_fcr31(); |
2116 | b6d96bed | ths | return wt2;
|
2117 | fd4a04eb | ths | } |
2118 | b6d96bed | ths | |
2119 | c01fccd2 | aurel32 | uint32_t helper_float_cvtw_s(uint32_t fst0) |
2120 | fd4a04eb | ths | { |
2121 | b6d96bed | ths | uint32_t wt2; |
2122 | b6d96bed | ths | |
2123 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2124 | f01be154 | ths | wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status); |
2125 | fd4a04eb | ths | update_fcr31(); |
2126 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2127 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2128 | b6d96bed | ths | return wt2;
|
2129 | fd4a04eb | ths | } |
2130 | b6d96bed | ths | |
2131 | c01fccd2 | aurel32 | uint32_t helper_float_cvtw_d(uint64_t fdt0) |
2132 | fd4a04eb | ths | { |
2133 | b6d96bed | ths | uint32_t wt2; |
2134 | b6d96bed | ths | |
2135 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2136 | f01be154 | ths | wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status); |
2137 | fd4a04eb | ths | update_fcr31(); |
2138 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2139 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2140 | b6d96bed | ths | return wt2;
|
2141 | fd4a04eb | ths | } |
2142 | fd4a04eb | ths | |
2143 | c01fccd2 | aurel32 | uint64_t helper_float_roundl_d(uint64_t fdt0) |
2144 | fd4a04eb | ths | { |
2145 | b6d96bed | ths | uint64_t dt2; |
2146 | b6d96bed | ths | |
2147 | f01be154 | ths | set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status); |
2148 | f01be154 | ths | dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status); |
2149 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2150 | fd4a04eb | ths | update_fcr31(); |
2151 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2152 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2153 | b6d96bed | ths | return dt2;
|
2154 | fd4a04eb | ths | } |
2155 | b6d96bed | ths | |
2156 | c01fccd2 | aurel32 | uint64_t helper_float_roundl_s(uint32_t fst0) |
2157 | fd4a04eb | ths | { |
2158 | b6d96bed | ths | uint64_t dt2; |
2159 | b6d96bed | ths | |
2160 | f01be154 | ths | set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status); |
2161 | f01be154 | ths | dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status); |
2162 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2163 | fd4a04eb | ths | update_fcr31(); |
2164 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2165 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2166 | b6d96bed | ths | return dt2;
|
2167 | fd4a04eb | ths | } |
2168 | b6d96bed | ths | |
2169 | c01fccd2 | aurel32 | uint32_t helper_float_roundw_d(uint64_t fdt0) |
2170 | fd4a04eb | ths | { |
2171 | b6d96bed | ths | uint32_t wt2; |
2172 | b6d96bed | ths | |
2173 | f01be154 | ths | set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status); |
2174 | f01be154 | ths | wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status); |
2175 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2176 | fd4a04eb | ths | update_fcr31(); |
2177 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2178 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2179 | b6d96bed | ths | return wt2;
|
2180 | fd4a04eb | ths | } |
2181 | b6d96bed | ths | |
2182 | c01fccd2 | aurel32 | uint32_t helper_float_roundw_s(uint32_t fst0) |
2183 | fd4a04eb | ths | { |
2184 | b6d96bed | ths | uint32_t wt2; |
2185 | b6d96bed | ths | |
2186 | f01be154 | ths | set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status); |
2187 | f01be154 | ths | wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status); |
2188 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2189 | fd4a04eb | ths | update_fcr31(); |
2190 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2191 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2192 | b6d96bed | ths | return wt2;
|
2193 | fd4a04eb | ths | } |
2194 | fd4a04eb | ths | |
2195 | c01fccd2 | aurel32 | uint64_t helper_float_truncl_d(uint64_t fdt0) |
2196 | fd4a04eb | ths | { |
2197 | b6d96bed | ths | uint64_t dt2; |
2198 | b6d96bed | ths | |
2199 | f01be154 | ths | dt2 = float64_to_int64_round_to_zero(fdt0, &env->active_fpu.fp_status); |
2200 | fd4a04eb | ths | update_fcr31(); |
2201 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2202 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2203 | b6d96bed | ths | return dt2;
|
2204 | fd4a04eb | ths | } |
2205 | b6d96bed | ths | |
2206 | c01fccd2 | aurel32 | uint64_t helper_float_truncl_s(uint32_t fst0) |
2207 | fd4a04eb | ths | { |
2208 | b6d96bed | ths | uint64_t dt2; |
2209 | b6d96bed | ths | |
2210 | f01be154 | ths | dt2 = float32_to_int64_round_to_zero(fst0, &env->active_fpu.fp_status); |
2211 | fd4a04eb | ths | update_fcr31(); |
2212 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2213 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2214 | b6d96bed | ths | return dt2;
|
2215 | fd4a04eb | ths | } |
2216 | b6d96bed | ths | |
2217 | c01fccd2 | aurel32 | uint32_t helper_float_truncw_d(uint64_t fdt0) |
2218 | fd4a04eb | ths | { |
2219 | b6d96bed | ths | uint32_t wt2; |
2220 | b6d96bed | ths | |
2221 | f01be154 | ths | wt2 = float64_to_int32_round_to_zero(fdt0, &env->active_fpu.fp_status); |
2222 | fd4a04eb | ths | update_fcr31(); |
2223 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2224 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2225 | b6d96bed | ths | return wt2;
|
2226 | fd4a04eb | ths | } |
2227 | b6d96bed | ths | |
2228 | c01fccd2 | aurel32 | uint32_t helper_float_truncw_s(uint32_t fst0) |
2229 | fd4a04eb | ths | { |
2230 | b6d96bed | ths | uint32_t wt2; |
2231 | b6d96bed | ths | |
2232 | f01be154 | ths | wt2 = float32_to_int32_round_to_zero(fst0, &env->active_fpu.fp_status); |
2233 | fd4a04eb | ths | update_fcr31(); |
2234 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2235 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2236 | b6d96bed | ths | return wt2;
|
2237 | fd4a04eb | ths | } |
2238 | fd4a04eb | ths | |
2239 | c01fccd2 | aurel32 | uint64_t helper_float_ceill_d(uint64_t fdt0) |
2240 | fd4a04eb | ths | { |
2241 | b6d96bed | ths | uint64_t dt2; |
2242 | b6d96bed | ths | |
2243 | f01be154 | ths | set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status); |
2244 | f01be154 | ths | dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status); |
2245 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2246 | fd4a04eb | ths | update_fcr31(); |
2247 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2248 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2249 | b6d96bed | ths | return dt2;
|
2250 | fd4a04eb | ths | } |
2251 | b6d96bed | ths | |
2252 | c01fccd2 | aurel32 | uint64_t helper_float_ceill_s(uint32_t fst0) |
2253 | fd4a04eb | ths | { |
2254 | b6d96bed | ths | uint64_t dt2; |
2255 | b6d96bed | ths | |
2256 | f01be154 | ths | set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status); |
2257 | f01be154 | ths | dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status); |
2258 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2259 | fd4a04eb | ths | update_fcr31(); |
2260 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2261 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2262 | b6d96bed | ths | return dt2;
|
2263 | fd4a04eb | ths | } |
2264 | b6d96bed | ths | |
2265 | c01fccd2 | aurel32 | uint32_t helper_float_ceilw_d(uint64_t fdt0) |
2266 | fd4a04eb | ths | { |
2267 | b6d96bed | ths | uint32_t wt2; |
2268 | b6d96bed | ths | |
2269 | f01be154 | ths | set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status); |
2270 | f01be154 | ths | wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status); |
2271 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2272 | fd4a04eb | ths | update_fcr31(); |
2273 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2274 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2275 | b6d96bed | ths | return wt2;
|
2276 | fd4a04eb | ths | } |
2277 | b6d96bed | ths | |
2278 | c01fccd2 | aurel32 | uint32_t helper_float_ceilw_s(uint32_t fst0) |
2279 | fd4a04eb | ths | { |
2280 | b6d96bed | ths | uint32_t wt2; |
2281 | b6d96bed | ths | |
2282 | f01be154 | ths | set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status); |
2283 | f01be154 | ths | wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status); |
2284 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2285 | fd4a04eb | ths | update_fcr31(); |
2286 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2287 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2288 | b6d96bed | ths | return wt2;
|
2289 | fd4a04eb | ths | } |
2290 | fd4a04eb | ths | |
2291 | c01fccd2 | aurel32 | uint64_t helper_float_floorl_d(uint64_t fdt0) |
2292 | fd4a04eb | ths | { |
2293 | b6d96bed | ths | uint64_t dt2; |
2294 | b6d96bed | ths | |
2295 | f01be154 | ths | set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status); |
2296 | f01be154 | ths | dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status); |
2297 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2298 | fd4a04eb | ths | update_fcr31(); |
2299 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2300 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2301 | b6d96bed | ths | return dt2;
|
2302 | fd4a04eb | ths | } |
2303 | b6d96bed | ths | |
2304 | c01fccd2 | aurel32 | uint64_t helper_float_floorl_s(uint32_t fst0) |
2305 | fd4a04eb | ths | { |
2306 | b6d96bed | ths | uint64_t dt2; |
2307 | b6d96bed | ths | |
2308 | f01be154 | ths | set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status); |
2309 | f01be154 | ths | dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status); |
2310 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2311 | fd4a04eb | ths | update_fcr31(); |
2312 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2313 | b6d96bed | ths | dt2 = FLOAT_SNAN64; |
2314 | b6d96bed | ths | return dt2;
|
2315 | fd4a04eb | ths | } |
2316 | b6d96bed | ths | |
2317 | c01fccd2 | aurel32 | uint32_t helper_float_floorw_d(uint64_t fdt0) |
2318 | fd4a04eb | ths | { |
2319 | b6d96bed | ths | uint32_t wt2; |
2320 | b6d96bed | ths | |
2321 | f01be154 | ths | set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status); |
2322 | f01be154 | ths | wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status); |
2323 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2324 | fd4a04eb | ths | update_fcr31(); |
2325 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2326 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2327 | b6d96bed | ths | return wt2;
|
2328 | fd4a04eb | ths | } |
2329 | b6d96bed | ths | |
2330 | c01fccd2 | aurel32 | uint32_t helper_float_floorw_s(uint32_t fst0) |
2331 | fd4a04eb | ths | { |
2332 | b6d96bed | ths | uint32_t wt2; |
2333 | b6d96bed | ths | |
2334 | f01be154 | ths | set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status); |
2335 | f01be154 | ths | wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status); |
2336 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
2337 | fd4a04eb | ths | update_fcr31(); |
2338 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & (FP_OVERFLOW | FP_INVALID))
|
2339 | b6d96bed | ths | wt2 = FLOAT_SNAN32; |
2340 | b6d96bed | ths | return wt2;
|
2341 | fd4a04eb | ths | } |
2342 | fd4a04eb | ths | |
2343 | a16336e4 | ths | /* unary operations, not modifying fp status */
|
2344 | b6d96bed | ths | #define FLOAT_UNOP(name) \
|
2345 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name ## _d(uint64_t fdt0) \ |
2346 | b6d96bed | ths | { \ |
2347 | b6d96bed | ths | return float64_ ## name(fdt0); \ |
2348 | b6d96bed | ths | } \ |
2349 | c01fccd2 | aurel32 | uint32_t helper_float_ ## name ## _s(uint32_t fst0) \ |
2350 | b6d96bed | ths | { \ |
2351 | b6d96bed | ths | return float32_ ## name(fst0); \ |
2352 | b6d96bed | ths | } \ |
2353 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name ## _ps(uint64_t fdt0) \ |
2354 | b6d96bed | ths | { \ |
2355 | b6d96bed | ths | uint32_t wt0; \ |
2356 | b6d96bed | ths | uint32_t wth0; \ |
2357 | b6d96bed | ths | \ |
2358 | b6d96bed | ths | wt0 = float32_ ## name(fdt0 & 0XFFFFFFFF); \ |
2359 | b6d96bed | ths | wth0 = float32_ ## name(fdt0 >> 32); \ |
2360 | b6d96bed | ths | return ((uint64_t)wth0 << 32) | wt0; \ |
2361 | a16336e4 | ths | } |
2362 | a16336e4 | ths | FLOAT_UNOP(abs) |
2363 | a16336e4 | ths | FLOAT_UNOP(chs) |
2364 | a16336e4 | ths | #undef FLOAT_UNOP
|
2365 | a16336e4 | ths | |
2366 | 8dfdb87c | ths | /* MIPS specific unary operations */
|
2367 | c01fccd2 | aurel32 | uint64_t helper_float_recip_d(uint64_t fdt0) |
2368 | 8dfdb87c | ths | { |
2369 | b6d96bed | ths | uint64_t fdt2; |
2370 | b6d96bed | ths | |
2371 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2372 | f01be154 | ths | fdt2 = float64_div(FLOAT_ONE64, fdt0, &env->active_fpu.fp_status); |
2373 | 8dfdb87c | ths | update_fcr31(); |
2374 | b6d96bed | ths | return fdt2;
|
2375 | 8dfdb87c | ths | } |
2376 | b6d96bed | ths | |
2377 | c01fccd2 | aurel32 | uint32_t helper_float_recip_s(uint32_t fst0) |
2378 | 8dfdb87c | ths | { |
2379 | b6d96bed | ths | uint32_t fst2; |
2380 | b6d96bed | ths | |
2381 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2382 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fst0, &env->active_fpu.fp_status); |
2383 | 8dfdb87c | ths | update_fcr31(); |
2384 | b6d96bed | ths | return fst2;
|
2385 | 57fa1fb3 | ths | } |
2386 | 57fa1fb3 | ths | |
2387 | c01fccd2 | aurel32 | uint64_t helper_float_rsqrt_d(uint64_t fdt0) |
2388 | 8dfdb87c | ths | { |
2389 | b6d96bed | ths | uint64_t fdt2; |
2390 | b6d96bed | ths | |
2391 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2392 | f01be154 | ths | fdt2 = float64_sqrt(fdt0, &env->active_fpu.fp_status); |
2393 | f01be154 | ths | fdt2 = float64_div(FLOAT_ONE64, fdt2, &env->active_fpu.fp_status); |
2394 | 8dfdb87c | ths | update_fcr31(); |
2395 | b6d96bed | ths | return fdt2;
|
2396 | 8dfdb87c | ths | } |
2397 | b6d96bed | ths | |
2398 | c01fccd2 | aurel32 | uint32_t helper_float_rsqrt_s(uint32_t fst0) |
2399 | 8dfdb87c | ths | { |
2400 | b6d96bed | ths | uint32_t fst2; |
2401 | b6d96bed | ths | |
2402 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2403 | f01be154 | ths | fst2 = float32_sqrt(fst0, &env->active_fpu.fp_status); |
2404 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fst2, &env->active_fpu.fp_status); |
2405 | 8dfdb87c | ths | update_fcr31(); |
2406 | b6d96bed | ths | return fst2;
|
2407 | 8dfdb87c | ths | } |
2408 | 8dfdb87c | ths | |
2409 | c01fccd2 | aurel32 | uint64_t helper_float_recip1_d(uint64_t fdt0) |
2410 | 8dfdb87c | ths | { |
2411 | b6d96bed | ths | uint64_t fdt2; |
2412 | b6d96bed | ths | |
2413 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2414 | f01be154 | ths | fdt2 = float64_div(FLOAT_ONE64, fdt0, &env->active_fpu.fp_status); |
2415 | 8dfdb87c | ths | update_fcr31(); |
2416 | b6d96bed | ths | return fdt2;
|
2417 | 8dfdb87c | ths | } |
2418 | b6d96bed | ths | |
2419 | c01fccd2 | aurel32 | uint32_t helper_float_recip1_s(uint32_t fst0) |
2420 | 8dfdb87c | ths | { |
2421 | b6d96bed | ths | uint32_t fst2; |
2422 | b6d96bed | ths | |
2423 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2424 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fst0, &env->active_fpu.fp_status); |
2425 | 8dfdb87c | ths | update_fcr31(); |
2426 | b6d96bed | ths | return fst2;
|
2427 | 8dfdb87c | ths | } |
2428 | b6d96bed | ths | |
2429 | c01fccd2 | aurel32 | uint64_t helper_float_recip1_ps(uint64_t fdt0) |
2430 | 8dfdb87c | ths | { |
2431 | b6d96bed | ths | uint32_t fst2; |
2432 | b6d96bed | ths | uint32_t fsth2; |
2433 | b6d96bed | ths | |
2434 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2435 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fdt0 & 0XFFFFFFFF, &env->active_fpu.fp_status);
|
2436 | f01be154 | ths | fsth2 = float32_div(FLOAT_ONE32, fdt0 >> 32, &env->active_fpu.fp_status);
|
2437 | 8dfdb87c | ths | update_fcr31(); |
2438 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2439 | 8dfdb87c | ths | } |
2440 | 8dfdb87c | ths | |
2441 | c01fccd2 | aurel32 | uint64_t helper_float_rsqrt1_d(uint64_t fdt0) |
2442 | 8dfdb87c | ths | { |
2443 | b6d96bed | ths | uint64_t fdt2; |
2444 | b6d96bed | ths | |
2445 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2446 | f01be154 | ths | fdt2 = float64_sqrt(fdt0, &env->active_fpu.fp_status); |
2447 | f01be154 | ths | fdt2 = float64_div(FLOAT_ONE64, fdt2, &env->active_fpu.fp_status); |
2448 | 8dfdb87c | ths | update_fcr31(); |
2449 | b6d96bed | ths | return fdt2;
|
2450 | 8dfdb87c | ths | } |
2451 | b6d96bed | ths | |
2452 | c01fccd2 | aurel32 | uint32_t helper_float_rsqrt1_s(uint32_t fst0) |
2453 | 8dfdb87c | ths | { |
2454 | b6d96bed | ths | uint32_t fst2; |
2455 | b6d96bed | ths | |
2456 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2457 | f01be154 | ths | fst2 = float32_sqrt(fst0, &env->active_fpu.fp_status); |
2458 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fst2, &env->active_fpu.fp_status); |
2459 | 8dfdb87c | ths | update_fcr31(); |
2460 | b6d96bed | ths | return fst2;
|
2461 | 8dfdb87c | ths | } |
2462 | b6d96bed | ths | |
2463 | c01fccd2 | aurel32 | uint64_t helper_float_rsqrt1_ps(uint64_t fdt0) |
2464 | 8dfdb87c | ths | { |
2465 | b6d96bed | ths | uint32_t fst2; |
2466 | b6d96bed | ths | uint32_t fsth2; |
2467 | b6d96bed | ths | |
2468 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2469 | f01be154 | ths | fst2 = float32_sqrt(fdt0 & 0XFFFFFFFF, &env->active_fpu.fp_status);
|
2470 | f01be154 | ths | fsth2 = float32_sqrt(fdt0 >> 32, &env->active_fpu.fp_status);
|
2471 | f01be154 | ths | fst2 = float32_div(FLOAT_ONE32, fst2, &env->active_fpu.fp_status); |
2472 | f01be154 | ths | fsth2 = float32_div(FLOAT_ONE32, fsth2, &env->active_fpu.fp_status); |
2473 | 8dfdb87c | ths | update_fcr31(); |
2474 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2475 | 57fa1fb3 | ths | } |
2476 | 57fa1fb3 | ths | |
2477 | c01fccd2 | aurel32 | #define FLOAT_OP(name, p) void helper_float_##name##_##p(void) |
2478 | b6d96bed | ths | |
2479 | fd4a04eb | ths | /* binary operations */
|
2480 | b6d96bed | ths | #define FLOAT_BINOP(name) \
|
2481 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name ## _d(uint64_t fdt0, uint64_t fdt1) \ |
2482 | b6d96bed | ths | { \ |
2483 | b6d96bed | ths | uint64_t dt2; \ |
2484 | b6d96bed | ths | \ |
2485 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status); \
|
2486 | f01be154 | ths | dt2 = float64_ ## name (fdt0, fdt1, &env->active_fpu.fp_status); \ |
2487 | ead9360e | ths | update_fcr31(); \ |
2488 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INVALID) \
|
2489 | b6d96bed | ths | dt2 = FLOAT_QNAN64; \ |
2490 | b6d96bed | ths | return dt2; \
|
2491 | b6d96bed | ths | } \ |
2492 | b6d96bed | ths | \ |
2493 | c01fccd2 | aurel32 | uint32_t helper_float_ ## name ## _s(uint32_t fst0, uint32_t fst1) \ |
2494 | b6d96bed | ths | { \ |
2495 | b6d96bed | ths | uint32_t wt2; \ |
2496 | b6d96bed | ths | \ |
2497 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status); \
|
2498 | f01be154 | ths | wt2 = float32_ ## name (fst0, fst1, &env->active_fpu.fp_status); \ |
2499 | ead9360e | ths | update_fcr31(); \ |
2500 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INVALID) \
|
2501 | b6d96bed | ths | wt2 = FLOAT_QNAN32; \ |
2502 | b6d96bed | ths | return wt2; \
|
2503 | b6d96bed | ths | } \ |
2504 | b6d96bed | ths | \ |
2505 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name ## _ps(uint64_t fdt0, uint64_t fdt1) \ |
2506 | b6d96bed | ths | { \ |
2507 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF; \
|
2508 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32; \
|
2509 | b6d96bed | ths | uint32_t fst1 = fdt1 & 0XFFFFFFFF; \
|
2510 | b6d96bed | ths | uint32_t fsth1 = fdt1 >> 32; \
|
2511 | b6d96bed | ths | uint32_t wt2; \ |
2512 | b6d96bed | ths | uint32_t wth2; \ |
2513 | b6d96bed | ths | \ |
2514 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status); \
|
2515 | f01be154 | ths | wt2 = float32_ ## name (fst0, fst1, &env->active_fpu.fp_status); \ |
2516 | f01be154 | ths | wth2 = float32_ ## name (fsth0, fsth1, &env->active_fpu.fp_status); \ |
2517 | b6d96bed | ths | update_fcr31(); \ |
2518 | f01be154 | ths | if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INVALID) { \
|
2519 | b6d96bed | ths | wt2 = FLOAT_QNAN32; \ |
2520 | b6d96bed | ths | wth2 = FLOAT_QNAN32; \ |
2521 | b6d96bed | ths | } \ |
2522 | b6d96bed | ths | return ((uint64_t)wth2 << 32) | wt2; \ |
2523 | fd4a04eb | ths | } |
2524 | b6d96bed | ths | |
2525 | fd4a04eb | ths | FLOAT_BINOP(add) |
2526 | fd4a04eb | ths | FLOAT_BINOP(sub) |
2527 | fd4a04eb | ths | FLOAT_BINOP(mul) |
2528 | fd4a04eb | ths | FLOAT_BINOP(div) |
2529 | fd4a04eb | ths | #undef FLOAT_BINOP
|
2530 | fd4a04eb | ths | |
2531 | a16336e4 | ths | /* ternary operations */
|
2532 | b6d96bed | ths | #define FLOAT_TERNOP(name1, name2) \
|
2533 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name1 ## name2 ## _d(uint64_t fdt0, uint64_t fdt1, \ |
2534 | b6d96bed | ths | uint64_t fdt2) \ |
2535 | b6d96bed | ths | { \ |
2536 | f01be154 | ths | fdt0 = float64_ ## name1 (fdt0, fdt1, &env->active_fpu.fp_status); \ |
2537 | f01be154 | ths | return float64_ ## name2 (fdt0, fdt2, &env->active_fpu.fp_status); \ |
2538 | b6d96bed | ths | } \ |
2539 | b6d96bed | ths | \ |
2540 | c01fccd2 | aurel32 | uint32_t helper_float_ ## name1 ## name2 ## _s(uint32_t fst0, uint32_t fst1, \ |
2541 | b6d96bed | ths | uint32_t fst2) \ |
2542 | b6d96bed | ths | { \ |
2543 | f01be154 | ths | fst0 = float32_ ## name1 (fst0, fst1, &env->active_fpu.fp_status); \ |
2544 | f01be154 | ths | return float32_ ## name2 (fst0, fst2, &env->active_fpu.fp_status); \ |
2545 | b6d96bed | ths | } \ |
2546 | b6d96bed | ths | \ |
2547 | c01fccd2 | aurel32 | uint64_t helper_float_ ## name1 ## name2 ## _ps(uint64_t fdt0, uint64_t fdt1, \ |
2548 | b6d96bed | ths | uint64_t fdt2) \ |
2549 | b6d96bed | ths | { \ |
2550 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF; \
|
2551 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32; \
|
2552 | b6d96bed | ths | uint32_t fst1 = fdt1 & 0XFFFFFFFF; \
|
2553 | b6d96bed | ths | uint32_t fsth1 = fdt1 >> 32; \
|
2554 | b6d96bed | ths | uint32_t fst2 = fdt2 & 0XFFFFFFFF; \
|
2555 | b6d96bed | ths | uint32_t fsth2 = fdt2 >> 32; \
|
2556 | b6d96bed | ths | \ |
2557 | f01be154 | ths | fst0 = float32_ ## name1 (fst0, fst1, &env->active_fpu.fp_status); \ |
2558 | f01be154 | ths | fsth0 = float32_ ## name1 (fsth0, fsth1, &env->active_fpu.fp_status); \ |
2559 | f01be154 | ths | fst2 = float32_ ## name2 (fst0, fst2, &env->active_fpu.fp_status); \ |
2560 | f01be154 | ths | fsth2 = float32_ ## name2 (fsth0, fsth2, &env->active_fpu.fp_status); \ |
2561 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; \ |
2562 | a16336e4 | ths | } |
2563 | b6d96bed | ths | |
2564 | a16336e4 | ths | FLOAT_TERNOP(mul, add) |
2565 | a16336e4 | ths | FLOAT_TERNOP(mul, sub) |
2566 | a16336e4 | ths | #undef FLOAT_TERNOP
|
2567 | a16336e4 | ths | |
2568 | a16336e4 | ths | /* negated ternary operations */
|
2569 | b6d96bed | ths | #define FLOAT_NTERNOP(name1, name2) \
|
2570 | c01fccd2 | aurel32 | uint64_t helper_float_n ## name1 ## name2 ## _d(uint64_t fdt0, uint64_t fdt1, \ |
2571 | b6d96bed | ths | uint64_t fdt2) \ |
2572 | b6d96bed | ths | { \ |
2573 | f01be154 | ths | fdt0 = float64_ ## name1 (fdt0, fdt1, &env->active_fpu.fp_status); \ |
2574 | f01be154 | ths | fdt2 = float64_ ## name2 (fdt0, fdt2, &env->active_fpu.fp_status); \ |
2575 | b6d96bed | ths | return float64_chs(fdt2); \
|
2576 | b6d96bed | ths | } \ |
2577 | b6d96bed | ths | \ |
2578 | c01fccd2 | aurel32 | uint32_t helper_float_n ## name1 ## name2 ## _s(uint32_t fst0, uint32_t fst1, \ |
2579 | b6d96bed | ths | uint32_t fst2) \ |
2580 | b6d96bed | ths | { \ |
2581 | f01be154 | ths | fst0 = float32_ ## name1 (fst0, fst1, &env->active_fpu.fp_status); \ |
2582 | f01be154 | ths | fst2 = float32_ ## name2 (fst0, fst2, &env->active_fpu.fp_status); \ |
2583 | b6d96bed | ths | return float32_chs(fst2); \
|
2584 | b6d96bed | ths | } \ |
2585 | b6d96bed | ths | \ |
2586 | c01fccd2 | aurel32 | uint64_t helper_float_n ## name1 ## name2 ## _ps(uint64_t fdt0, uint64_t fdt1,\ |
2587 | b6d96bed | ths | uint64_t fdt2) \ |
2588 | b6d96bed | ths | { \ |
2589 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF; \
|
2590 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32; \
|
2591 | b6d96bed | ths | uint32_t fst1 = fdt1 & 0XFFFFFFFF; \
|
2592 | b6d96bed | ths | uint32_t fsth1 = fdt1 >> 32; \
|
2593 | b6d96bed | ths | uint32_t fst2 = fdt2 & 0XFFFFFFFF; \
|
2594 | b6d96bed | ths | uint32_t fsth2 = fdt2 >> 32; \
|
2595 | b6d96bed | ths | \ |
2596 | f01be154 | ths | fst0 = float32_ ## name1 (fst0, fst1, &env->active_fpu.fp_status); \ |
2597 | f01be154 | ths | fsth0 = float32_ ## name1 (fsth0, fsth1, &env->active_fpu.fp_status); \ |
2598 | f01be154 | ths | fst2 = float32_ ## name2 (fst0, fst2, &env->active_fpu.fp_status); \ |
2599 | f01be154 | ths | fsth2 = float32_ ## name2 (fsth0, fsth2, &env->active_fpu.fp_status); \ |
2600 | b6d96bed | ths | fst2 = float32_chs(fst2); \ |
2601 | b6d96bed | ths | fsth2 = float32_chs(fsth2); \ |
2602 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; \ |
2603 | a16336e4 | ths | } |
2604 | b6d96bed | ths | |
2605 | a16336e4 | ths | FLOAT_NTERNOP(mul, add) |
2606 | a16336e4 | ths | FLOAT_NTERNOP(mul, sub) |
2607 | a16336e4 | ths | #undef FLOAT_NTERNOP
|
2608 | a16336e4 | ths | |
2609 | 8dfdb87c | ths | /* MIPS specific binary operations */
|
2610 | c01fccd2 | aurel32 | uint64_t helper_float_recip2_d(uint64_t fdt0, uint64_t fdt2) |
2611 | 8dfdb87c | ths | { |
2612 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2613 | f01be154 | ths | fdt2 = float64_mul(fdt0, fdt2, &env->active_fpu.fp_status); |
2614 | f01be154 | ths | fdt2 = float64_chs(float64_sub(fdt2, FLOAT_ONE64, &env->active_fpu.fp_status)); |
2615 | 8dfdb87c | ths | update_fcr31(); |
2616 | b6d96bed | ths | return fdt2;
|
2617 | 8dfdb87c | ths | } |
2618 | b6d96bed | ths | |
2619 | c01fccd2 | aurel32 | uint32_t helper_float_recip2_s(uint32_t fst0, uint32_t fst2) |
2620 | 8dfdb87c | ths | { |
2621 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2622 | f01be154 | ths | fst2 = float32_mul(fst0, fst2, &env->active_fpu.fp_status); |
2623 | f01be154 | ths | fst2 = float32_chs(float32_sub(fst2, FLOAT_ONE32, &env->active_fpu.fp_status)); |
2624 | 8dfdb87c | ths | update_fcr31(); |
2625 | b6d96bed | ths | return fst2;
|
2626 | 8dfdb87c | ths | } |
2627 | b6d96bed | ths | |
2628 | c01fccd2 | aurel32 | uint64_t helper_float_recip2_ps(uint64_t fdt0, uint64_t fdt2) |
2629 | 8dfdb87c | ths | { |
2630 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF;
|
2631 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32;
|
2632 | b6d96bed | ths | uint32_t fst2 = fdt2 & 0XFFFFFFFF;
|
2633 | b6d96bed | ths | uint32_t fsth2 = fdt2 >> 32;
|
2634 | b6d96bed | ths | |
2635 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2636 | f01be154 | ths | fst2 = float32_mul(fst0, fst2, &env->active_fpu.fp_status); |
2637 | f01be154 | ths | fsth2 = float32_mul(fsth0, fsth2, &env->active_fpu.fp_status); |
2638 | f01be154 | ths | fst2 = float32_chs(float32_sub(fst2, FLOAT_ONE32, &env->active_fpu.fp_status)); |
2639 | f01be154 | ths | fsth2 = float32_chs(float32_sub(fsth2, FLOAT_ONE32, &env->active_fpu.fp_status)); |
2640 | 8dfdb87c | ths | update_fcr31(); |
2641 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2642 | 8dfdb87c | ths | } |
2643 | 8dfdb87c | ths | |
2644 | c01fccd2 | aurel32 | uint64_t helper_float_rsqrt2_d(uint64_t fdt0, uint64_t fdt2) |
2645 | 8dfdb87c | ths | { |
2646 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2647 | f01be154 | ths | fdt2 = float64_mul(fdt0, fdt2, &env->active_fpu.fp_status); |
2648 | f01be154 | ths | fdt2 = float64_sub(fdt2, FLOAT_ONE64, &env->active_fpu.fp_status); |
2649 | f01be154 | ths | fdt2 = float64_chs(float64_div(fdt2, FLOAT_TWO64, &env->active_fpu.fp_status)); |
2650 | 8dfdb87c | ths | update_fcr31(); |
2651 | b6d96bed | ths | return fdt2;
|
2652 | 8dfdb87c | ths | } |
2653 | b6d96bed | ths | |
2654 | c01fccd2 | aurel32 | uint32_t helper_float_rsqrt2_s(uint32_t fst0, uint32_t fst2) |
2655 | 8dfdb87c | ths | { |
2656 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2657 | f01be154 | ths | fst2 = float32_mul(fst0, fst2, &env->active_fpu.fp_status); |
2658 | f01be154 | ths | fst2 = float32_sub(fst2, FLOAT_ONE32, &env->active_fpu.fp_status); |
2659 | f01be154 | ths | fst2 = float32_chs(float32_div(fst2, FLOAT_TWO32, &env->active_fpu.fp_status)); |
2660 | 8dfdb87c | ths | update_fcr31(); |
2661 | b6d96bed | ths | return fst2;
|
2662 | 8dfdb87c | ths | } |
2663 | b6d96bed | ths | |
2664 | c01fccd2 | aurel32 | uint64_t helper_float_rsqrt2_ps(uint64_t fdt0, uint64_t fdt2) |
2665 | 8dfdb87c | ths | { |
2666 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF;
|
2667 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32;
|
2668 | b6d96bed | ths | uint32_t fst2 = fdt2 & 0XFFFFFFFF;
|
2669 | b6d96bed | ths | uint32_t fsth2 = fdt2 >> 32;
|
2670 | b6d96bed | ths | |
2671 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2672 | f01be154 | ths | fst2 = float32_mul(fst0, fst2, &env->active_fpu.fp_status); |
2673 | f01be154 | ths | fsth2 = float32_mul(fsth0, fsth2, &env->active_fpu.fp_status); |
2674 | f01be154 | ths | fst2 = float32_sub(fst2, FLOAT_ONE32, &env->active_fpu.fp_status); |
2675 | f01be154 | ths | fsth2 = float32_sub(fsth2, FLOAT_ONE32, &env->active_fpu.fp_status); |
2676 | f01be154 | ths | fst2 = float32_chs(float32_div(fst2, FLOAT_TWO32, &env->active_fpu.fp_status)); |
2677 | f01be154 | ths | fsth2 = float32_chs(float32_div(fsth2, FLOAT_TWO32, &env->active_fpu.fp_status)); |
2678 | 8dfdb87c | ths | update_fcr31(); |
2679 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2680 | 57fa1fb3 | ths | } |
2681 | 57fa1fb3 | ths | |
2682 | c01fccd2 | aurel32 | uint64_t helper_float_addr_ps(uint64_t fdt0, uint64_t fdt1) |
2683 | fd4a04eb | ths | { |
2684 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF;
|
2685 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32;
|
2686 | b6d96bed | ths | uint32_t fst1 = fdt1 & 0XFFFFFFFF;
|
2687 | b6d96bed | ths | uint32_t fsth1 = fdt1 >> 32;
|
2688 | b6d96bed | ths | uint32_t fst2; |
2689 | b6d96bed | ths | uint32_t fsth2; |
2690 | b6d96bed | ths | |
2691 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2692 | f01be154 | ths | fst2 = float32_add (fst0, fsth0, &env->active_fpu.fp_status); |
2693 | f01be154 | ths | fsth2 = float32_add (fst1, fsth1, &env->active_fpu.fp_status); |
2694 | fd4a04eb | ths | update_fcr31(); |
2695 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2696 | fd4a04eb | ths | } |
2697 | fd4a04eb | ths | |
2698 | c01fccd2 | aurel32 | uint64_t helper_float_mulr_ps(uint64_t fdt0, uint64_t fdt1) |
2699 | 57fa1fb3 | ths | { |
2700 | b6d96bed | ths | uint32_t fst0 = fdt0 & 0XFFFFFFFF;
|
2701 | b6d96bed | ths | uint32_t fsth0 = fdt0 >> 32;
|
2702 | b6d96bed | ths | uint32_t fst1 = fdt1 & 0XFFFFFFFF;
|
2703 | b6d96bed | ths | uint32_t fsth1 = fdt1 >> 32;
|
2704 | b6d96bed | ths | uint32_t fst2; |
2705 | b6d96bed | ths | uint32_t fsth2; |
2706 | b6d96bed | ths | |
2707 | f01be154 | ths | set_float_exception_flags(0, &env->active_fpu.fp_status);
|
2708 | f01be154 | ths | fst2 = float32_mul (fst0, fsth0, &env->active_fpu.fp_status); |
2709 | f01be154 | ths | fsth2 = float32_mul (fst1, fsth1, &env->active_fpu.fp_status); |
2710 | 57fa1fb3 | ths | update_fcr31(); |
2711 | b6d96bed | ths | return ((uint64_t)fsth2 << 32) | fst2; |
2712 | 57fa1fb3 | ths | } |
2713 | 57fa1fb3 | ths | |
2714 | 8dfdb87c | ths | /* compare operations */
|
2715 | b6d96bed | ths | #define FOP_COND_D(op, cond) \
|
2716 | c01fccd2 | aurel32 | void helper_cmp_d_ ## op (uint64_t fdt0, uint64_t fdt1, int cc) \ |
2717 | b6d96bed | ths | { \ |
2718 | b6d96bed | ths | int c = cond; \
|
2719 | b6d96bed | ths | update_fcr31(); \ |
2720 | b6d96bed | ths | if (c) \
|
2721 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2722 | b6d96bed | ths | else \
|
2723 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2724 | b6d96bed | ths | } \ |
2725 | c01fccd2 | aurel32 | void helper_cmpabs_d_ ## op (uint64_t fdt0, uint64_t fdt1, int cc) \ |
2726 | b6d96bed | ths | { \ |
2727 | b6d96bed | ths | int c; \
|
2728 | b6d96bed | ths | fdt0 = float64_abs(fdt0); \ |
2729 | b6d96bed | ths | fdt1 = float64_abs(fdt1); \ |
2730 | b6d96bed | ths | c = cond; \ |
2731 | b6d96bed | ths | update_fcr31(); \ |
2732 | b6d96bed | ths | if (c) \
|
2733 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2734 | b6d96bed | ths | else \
|
2735 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2736 | fd4a04eb | ths | } |
2737 | fd4a04eb | ths | |
2738 | cd5158ea | aurel32 | static int float64_is_unordered(int sig, float64 a, float64 b STATUS_PARAM) |
2739 | fd4a04eb | ths | { |
2740 | fd4a04eb | ths | if (float64_is_signaling_nan(a) ||
|
2741 | fd4a04eb | ths | float64_is_signaling_nan(b) || |
2742 | fd4a04eb | ths | (sig && (float64_is_nan(a) || float64_is_nan(b)))) { |
2743 | fd4a04eb | ths | float_raise(float_flag_invalid, status); |
2744 | fd4a04eb | ths | return 1; |
2745 | fd4a04eb | ths | } else if (float64_is_nan(a) || float64_is_nan(b)) { |
2746 | fd4a04eb | ths | return 1; |
2747 | fd4a04eb | ths | } else {
|
2748 | fd4a04eb | ths | return 0; |
2749 | fd4a04eb | ths | } |
2750 | fd4a04eb | ths | } |
2751 | fd4a04eb | ths | |
2752 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2753 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2754 | f01be154 | ths | FOP_COND_D(f, (float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status), 0)) |
2755 | f01be154 | ths | FOP_COND_D(un, float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status))
|
2756 | f01be154 | ths | FOP_COND_D(eq, !float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) && float64_eq(fdt0, fdt1, &env->active_fpu.fp_status))
|
2757 | f01be154 | ths | FOP_COND_D(ueq, float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) || float64_eq(fdt0, fdt1, &env->active_fpu.fp_status))
|
2758 | f01be154 | ths | FOP_COND_D(olt, !float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) && float64_lt(fdt0, fdt1, &env->active_fpu.fp_status))
|
2759 | f01be154 | ths | FOP_COND_D(ult, float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) || float64_lt(fdt0, fdt1, &env->active_fpu.fp_status))
|
2760 | f01be154 | ths | FOP_COND_D(ole, !float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) && float64_le(fdt0, fdt1, &env->active_fpu.fp_status))
|
2761 | f01be154 | ths | FOP_COND_D(ule, float64_is_unordered(0, fdt1, fdt0, &env->active_fpu.fp_status) || float64_le(fdt0, fdt1, &env->active_fpu.fp_status))
|
2762 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2763 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2764 | f01be154 | ths | FOP_COND_D(sf, (float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status), 0)) |
2765 | f01be154 | ths | FOP_COND_D(ngle,float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status))
|
2766 | f01be154 | ths | FOP_COND_D(seq, !float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) && float64_eq(fdt0, fdt1, &env->active_fpu.fp_status))
|
2767 | f01be154 | ths | FOP_COND_D(ngl, float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) || float64_eq(fdt0, fdt1, &env->active_fpu.fp_status))
|
2768 | f01be154 | ths | FOP_COND_D(lt, !float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) && float64_lt(fdt0, fdt1, &env->active_fpu.fp_status))
|
2769 | f01be154 | ths | FOP_COND_D(nge, float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) || float64_lt(fdt0, fdt1, &env->active_fpu.fp_status))
|
2770 | f01be154 | ths | FOP_COND_D(le, !float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) && float64_le(fdt0, fdt1, &env->active_fpu.fp_status))
|
2771 | f01be154 | ths | FOP_COND_D(ngt, float64_is_unordered(1, fdt1, fdt0, &env->active_fpu.fp_status) || float64_le(fdt0, fdt1, &env->active_fpu.fp_status))
|
2772 | b6d96bed | ths | |
2773 | b6d96bed | ths | #define FOP_COND_S(op, cond) \
|
2774 | c01fccd2 | aurel32 | void helper_cmp_s_ ## op (uint32_t fst0, uint32_t fst1, int cc) \ |
2775 | b6d96bed | ths | { \ |
2776 | b6d96bed | ths | int c = cond; \
|
2777 | b6d96bed | ths | update_fcr31(); \ |
2778 | b6d96bed | ths | if (c) \
|
2779 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2780 | b6d96bed | ths | else \
|
2781 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2782 | b6d96bed | ths | } \ |
2783 | c01fccd2 | aurel32 | void helper_cmpabs_s_ ## op (uint32_t fst0, uint32_t fst1, int cc) \ |
2784 | b6d96bed | ths | { \ |
2785 | b6d96bed | ths | int c; \
|
2786 | b6d96bed | ths | fst0 = float32_abs(fst0); \ |
2787 | b6d96bed | ths | fst1 = float32_abs(fst1); \ |
2788 | b6d96bed | ths | c = cond; \ |
2789 | b6d96bed | ths | update_fcr31(); \ |
2790 | b6d96bed | ths | if (c) \
|
2791 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2792 | b6d96bed | ths | else \
|
2793 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2794 | fd4a04eb | ths | } |
2795 | fd4a04eb | ths | |
2796 | cd5158ea | aurel32 | static flag float32_is_unordered(int sig, float32 a, float32 b STATUS_PARAM) |
2797 | fd4a04eb | ths | { |
2798 | fd4a04eb | ths | if (float32_is_signaling_nan(a) ||
|
2799 | fd4a04eb | ths | float32_is_signaling_nan(b) || |
2800 | fd4a04eb | ths | (sig && (float32_is_nan(a) || float32_is_nan(b)))) { |
2801 | fd4a04eb | ths | float_raise(float_flag_invalid, status); |
2802 | fd4a04eb | ths | return 1; |
2803 | fd4a04eb | ths | } else if (float32_is_nan(a) || float32_is_nan(b)) { |
2804 | fd4a04eb | ths | return 1; |
2805 | fd4a04eb | ths | } else {
|
2806 | fd4a04eb | ths | return 0; |
2807 | fd4a04eb | ths | } |
2808 | fd4a04eb | ths | } |
2809 | fd4a04eb | ths | |
2810 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2811 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2812 | f01be154 | ths | FOP_COND_S(f, (float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status), 0)) |
2813 | f01be154 | ths | FOP_COND_S(un, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status))
|
2814 | f01be154 | ths | FOP_COND_S(eq, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_eq(fst0, fst1, &env->active_fpu.fp_status))
|
2815 | f01be154 | ths | FOP_COND_S(ueq, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_eq(fst0, fst1, &env->active_fpu.fp_status))
|
2816 | f01be154 | ths | FOP_COND_S(olt, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_lt(fst0, fst1, &env->active_fpu.fp_status))
|
2817 | f01be154 | ths | FOP_COND_S(ult, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_lt(fst0, fst1, &env->active_fpu.fp_status))
|
2818 | f01be154 | ths | FOP_COND_S(ole, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_le(fst0, fst1, &env->active_fpu.fp_status))
|
2819 | f01be154 | ths | FOP_COND_S(ule, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_le(fst0, fst1, &env->active_fpu.fp_status))
|
2820 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2821 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2822 | f01be154 | ths | FOP_COND_S(sf, (float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status), 0)) |
2823 | f01be154 | ths | FOP_COND_S(ngle,float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status))
|
2824 | f01be154 | ths | FOP_COND_S(seq, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_eq(fst0, fst1, &env->active_fpu.fp_status))
|
2825 | f01be154 | ths | FOP_COND_S(ngl, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_eq(fst0, fst1, &env->active_fpu.fp_status))
|
2826 | f01be154 | ths | FOP_COND_S(lt, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_lt(fst0, fst1, &env->active_fpu.fp_status))
|
2827 | f01be154 | ths | FOP_COND_S(nge, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_lt(fst0, fst1, &env->active_fpu.fp_status))
|
2828 | f01be154 | ths | FOP_COND_S(le, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_le(fst0, fst1, &env->active_fpu.fp_status))
|
2829 | f01be154 | ths | FOP_COND_S(ngt, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_le(fst0, fst1, &env->active_fpu.fp_status))
|
2830 | b6d96bed | ths | |
2831 | b6d96bed | ths | #define FOP_COND_PS(op, condl, condh) \
|
2832 | c01fccd2 | aurel32 | void helper_cmp_ps_ ## op (uint64_t fdt0, uint64_t fdt1, int cc) \ |
2833 | b6d96bed | ths | { \ |
2834 | b6d96bed | ths | uint32_t fst0 = float32_abs(fdt0 & 0XFFFFFFFF); \
|
2835 | b6d96bed | ths | uint32_t fsth0 = float32_abs(fdt0 >> 32); \
|
2836 | b6d96bed | ths | uint32_t fst1 = float32_abs(fdt1 & 0XFFFFFFFF); \
|
2837 | b6d96bed | ths | uint32_t fsth1 = float32_abs(fdt1 >> 32); \
|
2838 | b6d96bed | ths | int cl = condl; \
|
2839 | b6d96bed | ths | int ch = condh; \
|
2840 | b6d96bed | ths | \ |
2841 | b6d96bed | ths | update_fcr31(); \ |
2842 | b6d96bed | ths | if (cl) \
|
2843 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2844 | b6d96bed | ths | else \
|
2845 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2846 | b6d96bed | ths | if (ch) \
|
2847 | f01be154 | ths | SET_FP_COND(cc + 1, env->active_fpu); \
|
2848 | b6d96bed | ths | else \
|
2849 | f01be154 | ths | CLEAR_FP_COND(cc + 1, env->active_fpu); \
|
2850 | b6d96bed | ths | } \ |
2851 | c01fccd2 | aurel32 | void helper_cmpabs_ps_ ## op (uint64_t fdt0, uint64_t fdt1, int cc) \ |
2852 | b6d96bed | ths | { \ |
2853 | b6d96bed | ths | uint32_t fst0 = float32_abs(fdt0 & 0XFFFFFFFF); \
|
2854 | b6d96bed | ths | uint32_t fsth0 = float32_abs(fdt0 >> 32); \
|
2855 | b6d96bed | ths | uint32_t fst1 = float32_abs(fdt1 & 0XFFFFFFFF); \
|
2856 | b6d96bed | ths | uint32_t fsth1 = float32_abs(fdt1 >> 32); \
|
2857 | b6d96bed | ths | int cl = condl; \
|
2858 | b6d96bed | ths | int ch = condh; \
|
2859 | b6d96bed | ths | \ |
2860 | b6d96bed | ths | update_fcr31(); \ |
2861 | b6d96bed | ths | if (cl) \
|
2862 | f01be154 | ths | SET_FP_COND(cc, env->active_fpu); \ |
2863 | b6d96bed | ths | else \
|
2864 | f01be154 | ths | CLEAR_FP_COND(cc, env->active_fpu); \ |
2865 | b6d96bed | ths | if (ch) \
|
2866 | f01be154 | ths | SET_FP_COND(cc + 1, env->active_fpu); \
|
2867 | b6d96bed | ths | else \
|
2868 | f01be154 | ths | CLEAR_FP_COND(cc + 1, env->active_fpu); \
|
2869 | fd4a04eb | ths | } |
2870 | fd4a04eb | ths | |
2871 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2872 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2873 | f01be154 | ths | FOP_COND_PS(f, (float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status), 0), |
2874 | f01be154 | ths | (float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status), 0)) |
2875 | f01be154 | ths | FOP_COND_PS(un, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status),
|
2876 | f01be154 | ths | float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status))
|
2877 | f01be154 | ths | FOP_COND_PS(eq, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_eq(fst0, fst1, &env->active_fpu.fp_status),
|
2878 | f01be154 | ths | !float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) && float32_eq(fsth0, fsth1, &env->active_fpu.fp_status))
|
2879 | f01be154 | ths | FOP_COND_PS(ueq, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_eq(fst0, fst1, &env->active_fpu.fp_status),
|
2880 | f01be154 | ths | float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) || float32_eq(fsth0, fsth1, &env->active_fpu.fp_status))
|
2881 | f01be154 | ths | FOP_COND_PS(olt, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_lt(fst0, fst1, &env->active_fpu.fp_status),
|
2882 | f01be154 | ths | !float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) && float32_lt(fsth0, fsth1, &env->active_fpu.fp_status))
|
2883 | f01be154 | ths | FOP_COND_PS(ult, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_lt(fst0, fst1, &env->active_fpu.fp_status),
|
2884 | f01be154 | ths | float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) || float32_lt(fsth0, fsth1, &env->active_fpu.fp_status))
|
2885 | f01be154 | ths | FOP_COND_PS(ole, !float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) && float32_le(fst0, fst1, &env->active_fpu.fp_status),
|
2886 | f01be154 | ths | !float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) && float32_le(fsth0, fsth1, &env->active_fpu.fp_status))
|
2887 | f01be154 | ths | FOP_COND_PS(ule, float32_is_unordered(0, fst1, fst0, &env->active_fpu.fp_status) || float32_le(fst0, fst1, &env->active_fpu.fp_status),
|
2888 | f01be154 | ths | float32_is_unordered(0, fsth1, fsth0, &env->active_fpu.fp_status) || float32_le(fsth0, fsth1, &env->active_fpu.fp_status))
|
2889 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
2890 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
2891 | f01be154 | ths | FOP_COND_PS(sf, (float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status), 0), |
2892 | f01be154 | ths | (float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status), 0)) |
2893 | f01be154 | ths | FOP_COND_PS(ngle,float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status),
|
2894 | f01be154 | ths | float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status))
|
2895 | f01be154 | ths | FOP_COND_PS(seq, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_eq(fst0, fst1, &env->active_fpu.fp_status),
|
2896 | f01be154 | ths | !float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) && float32_eq(fsth0, fsth1, &env->active_fpu.fp_status))
|
2897 | f01be154 | ths | FOP_COND_PS(ngl, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_eq(fst0, fst1, &env->active_fpu.fp_status),
|
2898 | f01be154 | ths | float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) || float32_eq(fsth0, fsth1, &env->active_fpu.fp_status))
|
2899 | f01be154 | ths | FOP_COND_PS(lt, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_lt(fst0, fst1, &env->active_fpu.fp_status),
|
2900 | f01be154 | ths | !float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) && float32_lt(fsth0, fsth1, &env->active_fpu.fp_status))
|
2901 | f01be154 | ths | FOP_COND_PS(nge, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_lt(fst0, fst1, &env->active_fpu.fp_status),
|
2902 | f01be154 | ths | float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) || float32_lt(fsth0, fsth1, &env->active_fpu.fp_status))
|
2903 | f01be154 | ths | FOP_COND_PS(le, !float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) && float32_le(fst0, fst1, &env->active_fpu.fp_status),
|
2904 | f01be154 | ths | !float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) && float32_le(fsth0, fsth1, &env->active_fpu.fp_status))
|
2905 | f01be154 | ths | FOP_COND_PS(ngt, float32_is_unordered(1, fst1, fst0, &env->active_fpu.fp_status) || float32_le(fst0, fst1, &env->active_fpu.fp_status),
|
2906 | f01be154 | ths | float32_is_unordered(1, fsth1, fsth0, &env->active_fpu.fp_status) || float32_le(fsth0, fsth1, &env->active_fpu.fp_status)) |