Lines Matching full:env

26 void cpu_set_cwp(CPUSPARCState *env, int new_cwp)  in cpu_set_cwp()  argument
29 if (env->cwp == env->nwindows - 1) { in cpu_set_cwp()
30 memcpy(env->regbase, env->regbase + env->nwindows * 16, in cpu_set_cwp()
31 sizeof(env->gregs)); in cpu_set_cwp()
33 env->cwp = new_cwp; in cpu_set_cwp()
36 if (new_cwp == env->nwindows - 1) { in cpu_set_cwp()
37 memcpy(env->regbase + env->nwindows * 16, env->regbase, in cpu_set_cwp()
38 sizeof(env->gregs)); in cpu_set_cwp()
40 env->regwptr = env->regbase + (new_cwp * 16); in cpu_set_cwp()
43 target_ulong cpu_get_psr(CPUSPARCState *env) in cpu_get_psr() argument
47 icc |= ((int32_t)env->cc_N < 0) << PSR_NEG_SHIFT; in cpu_get_psr()
48 icc |= ((int32_t)env->cc_V < 0) << PSR_OVF_SHIFT; in cpu_get_psr()
49 icc |= ((int32_t)env->icc_Z == 0) << PSR_ZERO_SHIFT; in cpu_get_psr()
51 icc |= extract64(env->icc_C, 32, 1) << PSR_CARRY_SHIFT; in cpu_get_psr()
53 icc |= env->icc_C << PSR_CARRY_SHIFT; in cpu_get_psr()
57 return env->version | icc | in cpu_get_psr()
58 (env->psref ? PSR_EF : 0) | in cpu_get_psr()
59 (env->psrpil << 8) | in cpu_get_psr()
60 (env->psrs ? PSR_S : 0) | in cpu_get_psr()
61 (env->psrps ? PSR_PS : 0) | in cpu_get_psr()
62 (env->psret ? PSR_ET : 0) | env->cwp; in cpu_get_psr()
68 void cpu_put_psr_icc(CPUSPARCState *env, target_ulong val) in cpu_put_psr_icc() argument
72 env->cc_N = deposit64(env->cc_N, 0, 32, -(val & PSR_NEG)); in cpu_put_psr_icc()
73 env->cc_V = deposit64(env->cc_V, 0, 32, -(val & PSR_OVF)); in cpu_put_psr_icc()
74 env->icc_C = -(val & PSR_CARRY); in cpu_put_psr_icc()
76 env->cc_N = -(val & PSR_NEG); in cpu_put_psr_icc()
77 env->cc_V = -(val & PSR_OVF); in cpu_put_psr_icc()
78 env->icc_C = (val >> PSR_CARRY_SHIFT) & 1; in cpu_put_psr_icc()
80 env->icc_Z = ~val & PSR_ZERO; in cpu_put_psr_icc()
83 void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) in cpu_put_psr_raw() argument
85 cpu_put_psr_icc(env, val); in cpu_put_psr_raw()
87 env->psref = (val & PSR_EF) ? 1 : 0; in cpu_put_psr_raw()
88 env->psrpil = (val & PSR_PIL) >> 8; in cpu_put_psr_raw()
89 env->psrs = (val & PSR_S) ? 1 : 0; in cpu_put_psr_raw()
90 env->psrps = (val & PSR_PS) ? 1 : 0; in cpu_put_psr_raw()
91 env->psret = (val & PSR_ET) ? 1 : 0; in cpu_put_psr_raw()
94 cpu_set_cwp(env, val & PSR_CWP); in cpu_put_psr_raw()
99 void cpu_put_psr(CPUSPARCState *env, target_ulong val) in cpu_put_psr() argument
101 cpu_put_psr_raw(env, val); in cpu_put_psr()
103 cpu_check_irqs(env); in cpu_put_psr()
107 int cpu_cwp_inc(CPUSPARCState *env, int cwp) in cpu_cwp_inc() argument
109 if (unlikely(cwp >= env->nwindows)) { in cpu_cwp_inc()
110 cwp -= env->nwindows; in cpu_cwp_inc()
115 int cpu_cwp_dec(CPUSPARCState *env, int cwp) in cpu_cwp_dec() argument
118 cwp += env->nwindows; in cpu_cwp_dec()
124 void helper_rett(CPUSPARCState *env) in helper_rett() argument
128 if (env->psret == 1) { in helper_rett()
129 cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); in helper_rett()
132 env->psret = 1; in helper_rett()
133 cwp = cpu_cwp_inc(env, env->cwp + 1) ; in helper_rett()
134 if (env->wim & (1 << cwp)) { in helper_rett()
135 cpu_raise_exception_ra(env, TT_WIN_UNF, GETPC()); in helper_rett()
137 cpu_set_cwp(env, cwp); in helper_rett()
138 env->psrs = env->psrps; in helper_rett()
143 void helper_save(CPUSPARCState *env) in helper_save() argument
147 cwp = cpu_cwp_dec(env, env->cwp - 1); in helper_save()
148 if (env->wim & (1 << cwp)) { in helper_save()
149 cpu_raise_exception_ra(env, TT_WIN_OVF, GETPC()); in helper_save()
151 cpu_set_cwp(env, cwp); in helper_save()
154 void helper_restore(CPUSPARCState *env) in helper_restore() argument
158 cwp = cpu_cwp_inc(env, env->cwp + 1); in helper_restore()
159 if (env->wim & (1 << cwp)) { in helper_restore()
160 cpu_raise_exception_ra(env, TT_WIN_UNF, GETPC()); in helper_restore()
162 cpu_set_cwp(env, cwp); in helper_restore()
165 void helper_wrpsr(CPUSPARCState *env, target_ulong new_psr) in helper_wrpsr() argument
167 if ((new_psr & PSR_CWP) >= env->nwindows) { in helper_wrpsr()
168 cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); in helper_wrpsr()
172 cpu_put_psr(env, new_psr); in helper_wrpsr()
177 target_ulong helper_rdpsr(CPUSPARCState *env) in helper_rdpsr() argument
179 return cpu_get_psr(env); in helper_rdpsr()
185 void helper_save(CPUSPARCState *env) in helper_save() argument
189 cwp = cpu_cwp_dec(env, env->cwp - 1); in helper_save()
190 if (env->cansave == 0) { in helper_save()
191 int tt = TT_SPILL | (env->otherwin != 0 in helper_save()
192 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_save()
193 : ((env->wstate & 0x7) << 2)); in helper_save()
194 cpu_raise_exception_ra(env, tt, GETPC()); in helper_save()
196 if (env->cleanwin - env->canrestore == 0) { in helper_save()
198 cpu_raise_exception_ra(env, TT_CLRWIN, GETPC()); in helper_save()
200 env->cansave--; in helper_save()
201 env->canrestore++; in helper_save()
202 cpu_set_cwp(env, cwp); in helper_save()
207 void helper_restore(CPUSPARCState *env) in helper_restore() argument
211 cwp = cpu_cwp_inc(env, env->cwp + 1); in helper_restore()
212 if (env->canrestore == 0) { in helper_restore()
213 int tt = TT_FILL | (env->otherwin != 0 in helper_restore()
214 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_restore()
215 : ((env->wstate & 0x7) << 2)); in helper_restore()
216 cpu_raise_exception_ra(env, tt, GETPC()); in helper_restore()
218 env->cansave++; in helper_restore()
219 env->canrestore--; in helper_restore()
220 cpu_set_cwp(env, cwp); in helper_restore()
224 void helper_flushw(CPUSPARCState *env) in helper_flushw() argument
226 if (env->cansave != env->nwindows - 2) { in helper_flushw()
227 int tt = TT_SPILL | (env->otherwin != 0 in helper_flushw()
228 ? (TT_WOTHER | ((env->wstate & 0x38) >> 1)) in helper_flushw()
229 : ((env->wstate & 0x7) << 2)); in helper_flushw()
230 cpu_raise_exception_ra(env, tt, GETPC()); in helper_flushw()
234 void helper_saved(CPUSPARCState *env) in helper_saved() argument
236 env->cansave++; in helper_saved()
237 if (env->otherwin == 0) { in helper_saved()
238 env->canrestore--; in helper_saved()
240 env->otherwin--; in helper_saved()
244 void helper_restored(CPUSPARCState *env) in helper_restored() argument
246 env->canrestore++; in helper_restored()
247 if (env->cleanwin < env->nwindows - 1) { in helper_restored()
248 env->cleanwin++; in helper_restored()
250 if (env->otherwin == 0) { in helper_restored()
251 env->cansave--; in helper_restored()
253 env->otherwin--; in helper_restored()
257 target_ulong cpu_get_ccr(CPUSPARCState *env) in cpu_get_ccr() argument
261 ccr |= (env->icc_C >> 32) & 1; in cpu_get_ccr()
262 ccr |= ((int32_t)env->cc_V < 0) << 1; in cpu_get_ccr()
263 ccr |= ((int32_t)env->icc_Z == 0) << 2; in cpu_get_ccr()
264 ccr |= ((int32_t)env->cc_N < 0) << 3; in cpu_get_ccr()
266 ccr |= env->xcc_C << 4; in cpu_get_ccr()
267 ccr |= (env->cc_V < 0) << 5; in cpu_get_ccr()
268 ccr |= (env->xcc_Z == 0) << 6; in cpu_get_ccr()
269 ccr |= (env->cc_N < 0) << 7; in cpu_get_ccr()
274 void cpu_put_ccr(CPUSPARCState *env, target_ulong val) in cpu_put_ccr() argument
276 env->cc_N = deposit64(-(val & 0x08), 32, 32, -(val & 0x80)); in cpu_put_ccr()
277 env->cc_V = deposit64(-(val & 0x02), 32, 32, -(val & 0x20)); in cpu_put_ccr()
278 env->icc_C = (uint64_t)val << 32; in cpu_put_ccr()
279 env->xcc_C = (val >> 4) & 1; in cpu_put_ccr()
280 env->icc_Z = ~val & 0x04; in cpu_put_ccr()
281 env->xcc_Z = ~val & 0x40; in cpu_put_ccr()
284 target_ulong cpu_get_cwp64(CPUSPARCState *env) in cpu_get_cwp64() argument
286 return env->nwindows - 1 - env->cwp; in cpu_get_cwp64()
289 void cpu_put_cwp64(CPUSPARCState *env, int cwp) in cpu_put_cwp64() argument
291 if (unlikely(cwp >= env->nwindows || cwp < 0)) { in cpu_put_cwp64()
292 cwp %= env->nwindows; in cpu_put_cwp64()
294 cpu_set_cwp(env, env->nwindows - 1 - cwp); in cpu_put_cwp64()
297 target_ulong helper_rdccr(CPUSPARCState *env) in helper_rdccr() argument
299 return cpu_get_ccr(env); in helper_rdccr()
302 void helper_wrccr(CPUSPARCState *env, target_ulong new_ccr) in helper_wrccr() argument
304 cpu_put_ccr(env, new_ccr); in helper_wrccr()
309 target_ulong helper_rdcwp(CPUSPARCState *env) in helper_rdcwp() argument
311 return cpu_get_cwp64(env); in helper_rdcwp()
314 void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp) in helper_wrcwp() argument
316 cpu_put_cwp64(env, new_cwp); in helper_wrcwp()
319 static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate) in get_gregset() argument
321 if (env->def.features & CPU_FEATURE_GL) { in get_gregset()
322 return env->glregs + (env->gl & 7) * 8; in get_gregset()
330 return env->bgregs; in get_gregset()
332 return env->agregs; in get_gregset()
334 return env->mgregs; in get_gregset()
336 return env->igregs; in get_gregset()
340 static inline uint64_t *get_gl_gregset(CPUSPARCState *env, uint32_t gl) in get_gl_gregset() argument
342 return env->glregs + (gl & 7) * 8; in get_gl_gregset()
346 void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl) in cpu_gl_switch_gregs() argument
349 src = get_gl_gregset(env, new_gl); in cpu_gl_switch_gregs()
350 dst = get_gl_gregset(env, env->gl); in cpu_gl_switch_gregs()
353 memcpy(dst, env->gregs, sizeof(env->gregs)); in cpu_gl_switch_gregs()
354 memcpy(env->gregs, src, sizeof(env->gregs)); in cpu_gl_switch_gregs()
358 void helper_wrgl(CPUSPARCState *env, target_ulong new_gl) in helper_wrgl() argument
360 cpu_gl_switch_gregs(env, new_gl & 7); in helper_wrgl()
361 env->gl = new_gl & 7; in helper_wrgl()
364 void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate) in cpu_change_pstate() argument
369 if (env->def.features & CPU_FEATURE_GL) { in cpu_change_pstate()
372 env->pstate = new_pstate; in cpu_change_pstate()
376 pstate_regs = env->pstate & 0xc01; in cpu_change_pstate()
383 src = get_gregset(env, new_pstate_regs); in cpu_change_pstate()
384 dst = get_gregset(env, pstate_regs); in cpu_change_pstate()
385 memcpy(dst, env->gregs, sizeof(env->gregs)); in cpu_change_pstate()
386 memcpy(env->gregs, src, sizeof(env->gregs)); in cpu_change_pstate()
390 env->pstate = new_pstate; in cpu_change_pstate()
393 void helper_wrpstate(CPUSPARCState *env, target_ulong new_state) in helper_wrpstate() argument
395 cpu_change_pstate(env, new_state & 0xf3f); in helper_wrpstate()
398 if (cpu_interrupts_enabled(env)) { in helper_wrpstate()
400 cpu_check_irqs(env); in helper_wrpstate()
406 void helper_wrpil(CPUSPARCState *env, target_ulong new_pil) in helper_wrpil() argument
409 trace_win_helper_wrpil(env->psrpil, (uint32_t)new_pil); in helper_wrpil()
411 env->psrpil = new_pil; in helper_wrpil()
413 if (cpu_interrupts_enabled(env)) { in helper_wrpil()
415 cpu_check_irqs(env); in helper_wrpil()
421 void helper_done(CPUSPARCState *env) in helper_done() argument
423 trap_state *tsptr = cpu_tsptr(env); in helper_done()
425 env->pc = tsptr->tnpc; in helper_done()
426 env->npc = tsptr->tnpc + 4; in helper_done()
427 cpu_put_ccr(env, tsptr->tstate >> 32); in helper_done()
428 env->asi = (tsptr->tstate >> 24) & 0xff; in helper_done()
429 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f); in helper_done()
430 cpu_put_cwp64(env, tsptr->tstate & 0xff); in helper_done()
431 if (cpu_has_hypervisor(env)) { in helper_done()
433 env->hpstate = env->htstate[env->tl]; in helper_done()
434 cpu_gl_switch_gregs(env, new_gl); in helper_done()
435 env->gl = new_gl; in helper_done()
437 env->tl--; in helper_done()
439 trace_win_helper_done(env->tl); in helper_done()
442 if (cpu_interrupts_enabled(env)) { in helper_done()
444 cpu_check_irqs(env); in helper_done()
450 void helper_retry(CPUSPARCState *env) in helper_retry() argument
452 trap_state *tsptr = cpu_tsptr(env); in helper_retry()
454 env->pc = tsptr->tpc; in helper_retry()
455 env->npc = tsptr->tnpc; in helper_retry()
456 cpu_put_ccr(env, tsptr->tstate >> 32); in helper_retry()
457 env->asi = (tsptr->tstate >> 24) & 0xff; in helper_retry()
458 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f); in helper_retry()
459 cpu_put_cwp64(env, tsptr->tstate & 0xff); in helper_retry()
460 if (cpu_has_hypervisor(env)) { in helper_retry()
462 env->hpstate = env->htstate[env->tl]; in helper_retry()
463 cpu_gl_switch_gregs(env, new_gl); in helper_retry()
464 env->gl = new_gl; in helper_retry()
466 env->tl--; in helper_retry()
468 trace_win_helper_retry(env->tl); in helper_retry()
471 if (cpu_interrupts_enabled(env)) { in helper_retry()
473 cpu_check_irqs(env); in helper_retry()