Lines Matching refs:env
32 static inline int get_reg_index(CPUSPARCState *env, int cwp, int index) in get_reg_index() argument
34 index = (index + cwp * 16) % (16 * env->nwindows); in get_reg_index()
37 if (index < 8 && env->cwp == env->nwindows - 1) in get_reg_index()
38 index += 16 * env->nwindows; in get_reg_index()
43 static inline void save_window_offset(CPUSPARCState *env, int cwp1) in save_window_offset() argument
48 sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; in save_window_offset()
59 put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr); in save_window_offset()
64 static void save_window(CPUSPARCState *env) in save_window() argument
68 new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) & in save_window()
69 ((1LL << env->nwindows) - 1); in save_window()
70 save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); in save_window()
71 env->wim = new_wim; in save_window()
77 save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); in save_window()
78 env->cansave++; in save_window()
79 env->canrestore--; in save_window()
83 static void restore_window(CPUSPARCState *env) in restore_window() argument
92 new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) & in restore_window()
93 ((1LL << env->nwindows) - 1); in restore_window()
97 cwp1 = cpu_cwp_inc(env, env->cwp + 1); in restore_window()
98 sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; in restore_window()
109 get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr); in restore_window()
113 env->canrestore++; in restore_window()
114 if (env->cleanwin < env->nwindows - 1) in restore_window()
115 env->cleanwin++; in restore_window()
116 env->cansave--; in restore_window()
118 env->wim = new_wim; in restore_window()
122 static void flush_windows(CPUSPARCState *env) in flush_windows() argument
129 cwp1 = cpu_cwp_inc(env, env->cwp + offset); in flush_windows()
131 if (env->wim & (1 << cwp1)) in flush_windows()
134 if (env->canrestore == 0) in flush_windows()
136 env->cansave++; in flush_windows()
137 env->canrestore--; in flush_windows()
139 save_window_offset(env, cwp1); in flush_windows()
142 cwp1 = cpu_cwp_inc(env, env->cwp + 1); in flush_windows()
145 env->wim = 1 << cwp1; in flush_windows()
152 static void next_instruction(CPUSPARCState *env) in next_instruction() argument
154 env->pc = env->npc; in next_instruction()
155 env->npc = env->npc + 4; in next_instruction()
158 static uint32_t do_getcc(CPUSPARCState *env) in do_getcc() argument
161 return cpu_get_ccr(env) & 0xf; in do_getcc()
163 return extract32(cpu_get_psr(env), 20, 4); in do_getcc()
167 static void do_setcc(CPUSPARCState *env, uint32_t icc) in do_setcc() argument
170 cpu_put_ccr(env, (cpu_get_ccr(env) & 0xf0) | (icc & 0xf)); in do_setcc()
172 cpu_put_psr(env, deposit32(cpu_get_psr(env), 20, 4, icc)); in do_setcc()
176 static uint32_t do_getpsr(CPUSPARCState *env) in do_getpsr() argument
184 uint64_t tstate = sparc64_tstate(env); in do_getpsr()
193 return (cpu_get_psr(env) & (PSR_ICC | PSR_CWP)) | PSR_S; in do_getpsr()
213 void cpu_loop (CPUSPARCState *env) in cpu_loop() argument
215 CPUState *cs = env_cpu(env); in cpu_loop()
227 ret = do_syscall (env, env->gregs[1], in cpu_loop()
228 env->regwptr[0], env->regwptr[1], in cpu_loop()
229 env->regwptr[2], env->regwptr[3], in cpu_loop()
230 env->regwptr[4], env->regwptr[5], in cpu_loop()
236 set_syscall_C(env, 1); in cpu_loop()
239 set_syscall_C(env, 0); in cpu_loop()
241 env->regwptr[0] = ret; in cpu_loop()
243 env->pc = env->npc; in cpu_loop()
244 env->npc = env->npc + 4; in cpu_loop()
249 force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); in cpu_loop()
254 force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc); in cpu_loop()
258 flush_windows(env); in cpu_loop()
259 next_instruction(env); in cpu_loop()
263 env->gregs[1] = do_getcc(env); in cpu_loop()
264 next_instruction(env); in cpu_loop()
267 do_setcc(env, env->gregs[1]); in cpu_loop()
268 next_instruction(env); in cpu_loop()
271 env->gregs[1] = do_getpsr(env); in cpu_loop()
272 next_instruction(env); in cpu_loop()
277 flush_windows(env); in cpu_loop()
278 sparc64_get_context(env); in cpu_loop()
281 flush_windows(env); in cpu_loop()
282 sparc64_set_context(env); in cpu_loop()
287 save_window(env); in cpu_loop()
290 restore_window(env); in cpu_loop()
296 target_ulong fsr = cpu_get_fsr(env); in cpu_loop()
311 force_sig_fault(TARGET_SIGFPE, code, env->pc); in cpu_loop()
319 force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); in cpu_loop()
322 force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); in cpu_loop()
325 force_sig_fault(TARGET_SIGEMT, TARGET_EMT_TAGOVF, env->pc); in cpu_loop()
330 force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); in cpu_loop()
334 force_sig_fault(TARGET_SIGILL, TARGET_ILL_COPROC, env->pc); in cpu_loop()
337 next_instruction(env); in cpu_loop()
349 force_sig_fault(TARGET_SIGILL, ILL_ILLTRP, env->pc); in cpu_loop()
356 process_pending_signals (env); in cpu_loop()
360 void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) in target_cpu_copy_regs() argument
363 env->pc = regs->pc; in target_cpu_copy_regs()
364 env->npc = regs->npc; in target_cpu_copy_regs()
365 env->y = regs->y; in target_cpu_copy_regs()
367 env->gregs[i] = regs->u_regs[i]; in target_cpu_copy_regs()
369 env->regwptr[i] = regs->u_regs[i + 8]; in target_cpu_copy_regs()