Lines Matching full:env
39 void cpu_set_cwp(CPUSPARCState *env, int new_cwp) in cpu_set_cwp() argument
42 if (env->cwp == env->nwindows - 1) { in cpu_set_cwp()
43 memcpy32(env->regbase, env->regbase + env->nwindows * 16); in cpu_set_cwp()
45 env->cwp = new_cwp; in cpu_set_cwp()
48 if (new_cwp == env->nwindows - 1) { in cpu_set_cwp()
49 memcpy32(env->regbase + env->nwindows * 16, env->regbase); in cpu_set_cwp()
51 env->regwptr = env->regbase + (new_cwp * 16); in cpu_set_cwp()
54 target_ulong cpu_get_psr(CPUSPARCState *env) in cpu_get_psr() argument
58 icc |= ((int32_t)env->cc_N < 0) << PSR_NEG_SHIFT; in cpu_get_psr()
59 icc |= ((int32_t)env->cc_V < 0) << PSR_OVF_SHIFT; in cpu_get_psr()
60 icc |= ((int32_t)env->icc_Z == 0) << PSR_ZERO_SHIFT; in cpu_get_psr()
62 icc |= extract64(env->icc_C, 32, 1) << PSR_CARRY_SHIFT; in cpu_get_psr()
64 icc |= env->icc_C << PSR_CARRY_SHIFT; in cpu_get_psr()
68 return env->version | icc | in cpu_get_psr()
69 (env->psref ? PSR_EF : 0) | in cpu_get_psr()
70 (env->psrpil << 8) | in cpu_get_psr()
71 (env->psrs ? PSR_S : 0) | in cpu_get_psr()
72 (env->psrps ? PSR_PS : 0) | in cpu_get_psr()
73 (env->psret ? PSR_ET : 0) | env->cwp; in cpu_get_psr()
79 void cpu_put_psr_icc(CPUSPARCState *env, target_ulong val) in cpu_put_psr_icc() argument
83 env->cc_N = deposit64(env->cc_N, 0, 32, -(val & PSR_NEG)); in cpu_put_psr_icc()
84 env->cc_V = deposit64(env->cc_V, 0, 32, -(val & PSR_OVF)); in cpu_put_psr_icc()
85 env->icc_C = -(val & PSR_CARRY); in cpu_put_psr_icc()
87 env->cc_N = -(val & PSR_NEG); in cpu_put_psr_icc()
88 env->cc_V = -(val & PSR_OVF); in cpu_put_psr_icc()
89 env->icc_C = (val >> PSR_CARRY_SHIFT) & 1; in cpu_put_psr_icc()
91 env->icc_Z = ~val & PSR_ZERO; in cpu_put_psr_icc()
94 void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) in cpu_put_psr_raw() argument
96 cpu_put_psr_icc(env, val); in cpu_put_psr_raw()
98 env->psref = (val & PSR_EF) ? 1 : 0; in cpu_put_psr_raw()
99 env->psrpil = (val & PSR_PIL) >> 8; in cpu_put_psr_raw()
100 env->psrs = (val & PSR_S) ? 1 : 0; in cpu_put_psr_raw()
101 env->psrps = (val & PSR_PS) ? 1 : 0; in cpu_put_psr_raw()
102 env->psret = (val & PSR_ET) ? 1 : 0; in cpu_put_psr_raw()
105 cpu_set_cwp(env, val & PSR_CWP); in cpu_put_psr_raw()
110 void cpu_put_psr(CPUSPARCState *env, target_ulong val) in cpu_put_psr() argument
112 cpu_put_psr_raw(env, val); in cpu_put_psr()
114 cpu_check_irqs(env); in cpu_put_psr()
118 int cpu_cwp_inc(CPUSPARCState *env, int cwp) in cpu_cwp_inc() argument
120 if (unlikely(cwp >= env->nwindows)) { in cpu_cwp_inc()
121 cwp -= env->nwindows; in cpu_cwp_inc()
126 int cpu_cwp_dec(CPUSPARCState *env, int cwp) in cpu_cwp_dec() argument
129 cwp += env->nwindows; in cpu_cwp_dec()
135 void helper_rett(CPUSPARCState *env) in helper_rett() argument
139 if (env->psret == 1) { in helper_rett()
140 cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); in helper_rett()
143 env->psret = 1; in helper_rett()
144 cwp = cpu_cwp_inc(env, env->cwp + 1) ; in helper_rett()
145 if (env->wim & (1 << cwp)) { in helper_rett()
146 cpu_raise_exception_ra(env, TT_WIN_UNF, GETPC()); in helper_rett()
148 cpu_set_cwp(env, cwp); in helper_rett()
149 env->psrs = env->psrps; in helper_rett()
154 void helper_save(CPUSPARCState *env) in helper_save() argument
158 cwp = cpu_cwp_dec(env, env->cwp - 1); in helper_save()
159 if (env->wim & (1 << cwp)) { in helper_save()
160 cpu_raise_exception_ra(env, TT_WIN_OVF, GETPC()); in helper_save()
162 cpu_set_cwp(env, cwp); in helper_save()
165 void helper_restore(CPUSPARCState *env) in helper_restore() argument
169 cwp = cpu_cwp_inc(env, env->cwp + 1); in helper_restore()
170 if (env->wim & (1 << cwp)) { in helper_restore()
171 cpu_raise_exception_ra(env, TT_WIN_UNF, GETPC()); in helper_restore()
173 cpu_set_cwp(env, cwp); in helper_restore()
176 void helper_wrpsr(CPUSPARCState *env, target_ulong new_psr) in helper_wrpsr() argument
178 if ((new_psr & PSR_CWP) >= env->nwindows) { in helper_wrpsr()
179 cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); in helper_wrpsr()
183 cpu_put_psr(env, new_psr); in helper_wrpsr()
188 target_ulong helper_rdpsr(CPUSPARCState *env) in helper_rdpsr() argument
190 return cpu_get_psr(env); in helper_rdpsr()
196 void helper_save(CPUSPARCState *env) in helper_save() argument
200 cwp = cpu_cwp_dec(env, env->cwp - 1); in helper_save()
201 if (env->cansave == 0) { in helper_save()
202 int tt = TT_SPILL | (env->otherwin != 0 in helper_save()
203 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_save()
204 : ((env->wstate & 0x7) << 2)); in helper_save()
205 cpu_raise_exception_ra(env, tt, GETPC()); in helper_save()
207 if (env->cleanwin - env->canrestore == 0) { in helper_save()
209 cpu_raise_exception_ra(env, TT_CLRWIN, GETPC()); in helper_save()
211 env->cansave--; in helper_save()
212 env->canrestore++; in helper_save()
213 cpu_set_cwp(env, cwp); in helper_save()
218 void helper_restore(CPUSPARCState *env) in helper_restore() argument
222 cwp = cpu_cwp_inc(env, env->cwp + 1); in helper_restore()
223 if (env->canrestore == 0) { in helper_restore()
224 int tt = TT_FILL | (env->otherwin != 0 in helper_restore()
225 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_restore()
226 : ((env->wstate & 0x7) << 2)); in helper_restore()
227 cpu_raise_exception_ra(env, tt, GETPC()); in helper_restore()
229 env->cansave++; in helper_restore()
230 env->canrestore--; in helper_restore()
231 cpu_set_cwp(env, cwp); in helper_restore()
235 void helper_flushw(CPUSPARCState *env) in helper_flushw() argument
237 if (env->cansave != env->nwindows - 2) { in helper_flushw()
238 int tt = TT_SPILL | (env->otherwin != 0 in helper_flushw()
239 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_flushw()
240 : ((env->wstate & 0x7) << 2)); in helper_flushw()
241 cpu_raise_exception_ra(env, tt, GETPC()); in helper_flushw()
245 void helper_saved(CPUSPARCState *env) in helper_saved() argument
247 env->cansave++; in helper_saved()
248 if (env->otherwin == 0) { in helper_saved()
249 env->canrestore--; in helper_saved()
251 env->otherwin--; in helper_saved()
255 void helper_restored(CPUSPARCState *env) in helper_restored() argument
257 env->canrestore++; in helper_restored()
258 if (env->cleanwin < env->nwindows - 1) { in helper_restored()
259 env->cleanwin++; in helper_restored()
261 if (env->otherwin == 0) { in helper_restored()
262 env->cansave--; in helper_restored()
264 env->otherwin--; in helper_restored()
268 target_ulong cpu_get_ccr(CPUSPARCState *env) in cpu_get_ccr() argument
272 ccr |= (env->icc_C >> 32) & 1; in cpu_get_ccr()
273 ccr |= ((int32_t)env->cc_V < 0) << 1; in cpu_get_ccr()
274 ccr |= ((int32_t)env->icc_Z == 0) << 2; in cpu_get_ccr()
275 ccr |= ((int32_t)env->cc_N < 0) << 3; in cpu_get_ccr()
277 ccr |= env->xcc_C << 4; in cpu_get_ccr()
278 ccr |= (env->cc_V < 0) << 5; in cpu_get_ccr()
279 ccr |= (env->xcc_Z == 0) << 6; in cpu_get_ccr()
280 ccr |= (env->cc_N < 0) << 7; in cpu_get_ccr()
285 void cpu_put_ccr(CPUSPARCState *env, target_ulong val) in cpu_put_ccr() argument
287 env->cc_N = deposit64(-(val & 0x08), 32, 32, -(val & 0x80)); in cpu_put_ccr()
288 env->cc_V = deposit64(-(val & 0x02), 32, 32, -(val & 0x20)); in cpu_put_ccr()
289 env->icc_C = (uint64_t)val << 32; in cpu_put_ccr()
290 env->xcc_C = (val >> 4) & 1; in cpu_put_ccr()
291 env->icc_Z = ~val & 0x04; in cpu_put_ccr()
292 env->xcc_Z = ~val & 0x40; in cpu_put_ccr()
295 target_ulong cpu_get_cwp64(CPUSPARCState *env) in cpu_get_cwp64() argument
297 return env->nwindows - 1 - env->cwp; in cpu_get_cwp64()
300 void cpu_put_cwp64(CPUSPARCState *env, int cwp) in cpu_put_cwp64() argument
302 if (unlikely(cwp >= env->nwindows || cwp < 0)) { in cpu_put_cwp64()
303 cwp %= env->nwindows; in cpu_put_cwp64()
305 cpu_set_cwp(env, env->nwindows - 1 - cwp); in cpu_put_cwp64()
308 target_ulong helper_rdccr(CPUSPARCState *env) in helper_rdccr() argument
310 return cpu_get_ccr(env); in helper_rdccr()
313 void helper_wrccr(CPUSPARCState *env, target_ulong new_ccr) in helper_wrccr() argument
315 cpu_put_ccr(env, new_ccr); in helper_wrccr()
320 target_ulong helper_rdcwp(CPUSPARCState *env) in helper_rdcwp() argument
322 return cpu_get_cwp64(env); in helper_rdcwp()
325 void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp) in helper_wrcwp() argument
327 cpu_put_cwp64(env, new_cwp); in helper_wrcwp()
330 static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate) in get_gregset() argument
332 if (env->def.features & CPU_FEATURE_GL) { in get_gregset()
333 return env->glregs + (env->gl & 7) * 8; in get_gregset()
341 return env->bgregs; in get_gregset()
343 return env->agregs; in get_gregset()
345 return env->mgregs; in get_gregset()
347 return env->igregs; in get_gregset()
351 static inline uint64_t *get_gl_gregset(CPUSPARCState *env, uint32_t gl) in get_gl_gregset() argument
353 return env->glregs + (gl & 7) * 8; in get_gl_gregset()
357 void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl) in cpu_gl_switch_gregs() argument
360 src = get_gl_gregset(env, new_gl); in cpu_gl_switch_gregs()
361 dst = get_gl_gregset(env, env->gl); in cpu_gl_switch_gregs()
364 memcpy32(dst, env->gregs); in cpu_gl_switch_gregs()
365 memcpy32(env->gregs, src); in cpu_gl_switch_gregs()
369 void helper_wrgl(CPUSPARCState *env, target_ulong new_gl) in helper_wrgl() argument
371 cpu_gl_switch_gregs(env, new_gl & 7); in helper_wrgl()
372 env->gl = new_gl & 7; in helper_wrgl()
375 void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate) in cpu_change_pstate() argument
380 if (env->def.features & CPU_FEATURE_GL) { in cpu_change_pstate()
383 env->pstate = new_pstate; in cpu_change_pstate()
387 pstate_regs = env->pstate & 0xc01; in cpu_change_pstate()
394 src = get_gregset(env, new_pstate_regs); in cpu_change_pstate()
395 dst = get_gregset(env, pstate_regs); in cpu_change_pstate()
396 memcpy32(dst, env->gregs); in cpu_change_pstate()
397 memcpy32(env->gregs, src); in cpu_change_pstate()
401 env->pstate = new_pstate; in cpu_change_pstate()
404 void helper_wrpstate(CPUSPARCState *env, target_ulong new_state) in helper_wrpstate() argument
406 cpu_change_pstate(env, new_state & 0xf3f); in helper_wrpstate()
409 if (cpu_interrupts_enabled(env)) { in helper_wrpstate()
411 cpu_check_irqs(env); in helper_wrpstate()
417 void helper_wrpil(CPUSPARCState *env, target_ulong new_pil) in helper_wrpil() argument
420 trace_win_helper_wrpil(env->psrpil, (uint32_t)new_pil); in helper_wrpil()
422 env->psrpil = new_pil; in helper_wrpil()
424 if (cpu_interrupts_enabled(env)) { in helper_wrpil()
426 cpu_check_irqs(env); in helper_wrpil()
432 void helper_done(CPUSPARCState *env) in helper_done() argument
434 trap_state *tsptr = cpu_tsptr(env); in helper_done()
436 env->pc = tsptr->tnpc; in helper_done()
437 env->npc = tsptr->tnpc + 4; in helper_done()
438 cpu_put_ccr(env, tsptr->tstate >> 32); in helper_done()
439 env->asi = (tsptr->tstate >> 24) & 0xff; in helper_done()
440 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f); in helper_done()
441 cpu_put_cwp64(env, tsptr->tstate & 0xff); in helper_done()
442 if (cpu_has_hypervisor(env)) { in helper_done()
444 env->hpstate = env->htstate[env->tl]; in helper_done()
445 cpu_gl_switch_gregs(env, new_gl); in helper_done()
446 env->gl = new_gl; in helper_done()
448 env->tl--; in helper_done()
450 trace_win_helper_done(env->tl); in helper_done()
453 if (cpu_interrupts_enabled(env)) { in helper_done()
455 cpu_check_irqs(env); in helper_done()
461 void helper_retry(CPUSPARCState *env) in helper_retry() argument
463 trap_state *tsptr = cpu_tsptr(env); in helper_retry()
465 env->pc = tsptr->tpc; in helper_retry()
466 env->npc = tsptr->tnpc; in helper_retry()
467 cpu_put_ccr(env, tsptr->tstate >> 32); in helper_retry()
468 env->asi = (tsptr->tstate >> 24) & 0xff; in helper_retry()
469 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f); in helper_retry()
470 cpu_put_cwp64(env, tsptr->tstate & 0xff); in helper_retry()
471 if (cpu_has_hypervisor(env)) { in helper_retry()
473 env->hpstate = env->htstate[env->tl]; in helper_retry()
474 cpu_gl_switch_gregs(env, new_gl); in helper_retry()
475 env->gl = new_gl; in helper_retry()
477 env->tl--; in helper_retry()
479 trace_win_helper_retry(env->tl); in helper_retry()
482 if (cpu_interrupts_enabled(env)) { in helper_retry()
484 cpu_check_irqs(env); in helper_retry()