win_helper.c (6e040755f12eba34d2fa3d56b18de32d63fea631) win_helper.c (cbc3a6a4cc675516328a2b0d3602355d68b6302d)
1/*
2 * Helpers for CWP and PSTATE handling
3 *
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either

--- 276 unchanged lines hidden (view full) ---

285
286void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp)
287{
288 cpu_put_cwp64(env, new_cwp);
289}
290
291static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
292{
1/*
2 * Helpers for CWP and PSTATE handling
3 *
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either

--- 276 unchanged lines hidden (view full) ---

285
286void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp)
287{
288 cpu_put_cwp64(env, new_cwp);
289}
290
291static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
292{
293 if (env->def->features & CPU_FEATURE_GL) {
294 return env->glregs + (env->gl & 7) * 8;
295 }
296
293 switch (pstate) {
294 default:
295 trace_win_helper_gregset_error(pstate);
296 /* pass through to normal set of global registers */
297 case 0:
298 return env->bgregs;
299 case PS_AG:
300 return env->agregs;
301 case PS_MG:
302 return env->mgregs;
303 case PS_IG:
304 return env->igregs;
305 }
306}
307
297 switch (pstate) {
298 default:
299 trace_win_helper_gregset_error(pstate);
300 /* pass through to normal set of global registers */
301 case 0:
302 return env->bgregs;
303 case PS_AG:
304 return env->agregs;
305 case PS_MG:
306 return env->mgregs;
307 case PS_IG:
308 return env->igregs;
309 }
310}
311
312static inline uint64_t *get_gl_gregset(CPUSPARCState *env, uint32_t gl)
313{
314 return env->glregs + (gl & 7) * 8;
315}
316
317/* Switch global register bank */
318void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl)
319{
320 uint64_t *src, *dst;
321 src = get_gl_gregset(env, new_gl);
322 dst = get_gl_gregset(env, env->gl);
323
324 if (src != dst) {
325 memcpy32(dst, env->gregs);
326 memcpy32(env->gregs, src);
327 }
328}
329
330void helper_wrgl(CPUSPARCState *env, target_ulong new_gl)
331{
332 cpu_gl_switch_gregs(env, new_gl & 7);
333 env->gl = new_gl & 7;
334}
335
308void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
309{
310 uint32_t pstate_regs, new_pstate_regs;
311 uint64_t *src, *dst;
312
313 if (env->def->features & CPU_FEATURE_GL) {
336void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
337{
338 uint32_t pstate_regs, new_pstate_regs;
339 uint64_t *src, *dst;
340
341 if (env->def->features & CPU_FEATURE_GL) {
314 /* PS_AG is not implemented in this case */
315 new_pstate &= ~PS_AG;
342 /* PS_AG, IG and MG are not implemented in this case */
343 new_pstate &= ~(PS_AG | PS_IG | PS_MG);
344 env->pstate = new_pstate;
345 return;
316 }
317
318 pstate_regs = env->pstate & 0xc01;
319 new_pstate_regs = new_pstate & 0xc01;
320
321 if (new_pstate_regs != pstate_regs) {
322 trace_win_helper_switch_pstate(pstate_regs, new_pstate_regs);
323

--- 38 unchanged lines hidden (view full) ---

362
363 env->pc = tsptr->tnpc;
364 env->npc = tsptr->tnpc + 4;
365 cpu_put_ccr(env, tsptr->tstate >> 32);
366 env->asi = (tsptr->tstate >> 24) & 0xff;
367 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);
368 cpu_put_cwp64(env, tsptr->tstate & 0xff);
369 if (cpu_has_hypervisor(env)) {
346 }
347
348 pstate_regs = env->pstate & 0xc01;
349 new_pstate_regs = new_pstate & 0xc01;
350
351 if (new_pstate_regs != pstate_regs) {
352 trace_win_helper_switch_pstate(pstate_regs, new_pstate_regs);
353

--- 38 unchanged lines hidden (view full) ---

392
393 env->pc = tsptr->tnpc;
394 env->npc = tsptr->tnpc + 4;
395 cpu_put_ccr(env, tsptr->tstate >> 32);
396 env->asi = (tsptr->tstate >> 24) & 0xff;
397 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);
398 cpu_put_cwp64(env, tsptr->tstate & 0xff);
399 if (cpu_has_hypervisor(env)) {
400 uint32_t new_gl = (tsptr->tstate >> 40) & 7;
370 env->hpstate = env->htstate[env->tl];
401 env->hpstate = env->htstate[env->tl];
402 cpu_gl_switch_gregs(env, new_gl);
403 env->gl = new_gl;
371 }
372 env->tl--;
373
374 trace_win_helper_done(env->tl);
375
376#if !defined(CONFIG_USER_ONLY)
377 if (cpu_interrupts_enabled(env)) {
378 cpu_check_irqs(env);

--- 7 unchanged lines hidden (view full) ---

386
387 env->pc = tsptr->tpc;
388 env->npc = tsptr->tnpc;
389 cpu_put_ccr(env, tsptr->tstate >> 32);
390 env->asi = (tsptr->tstate >> 24) & 0xff;
391 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);
392 cpu_put_cwp64(env, tsptr->tstate & 0xff);
393 if (cpu_has_hypervisor(env)) {
404 }
405 env->tl--;
406
407 trace_win_helper_done(env->tl);
408
409#if !defined(CONFIG_USER_ONLY)
410 if (cpu_interrupts_enabled(env)) {
411 cpu_check_irqs(env);

--- 7 unchanged lines hidden (view full) ---

419
420 env->pc = tsptr->tpc;
421 env->npc = tsptr->tnpc;
422 cpu_put_ccr(env, tsptr->tstate >> 32);
423 env->asi = (tsptr->tstate >> 24) & 0xff;
424 cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);
425 cpu_put_cwp64(env, tsptr->tstate & 0xff);
426 if (cpu_has_hypervisor(env)) {
427 uint32_t new_gl = (tsptr->tstate >> 40) & 7;
394 env->hpstate = env->htstate[env->tl];
428 env->hpstate = env->htstate[env->tl];
429 cpu_gl_switch_gregs(env, new_gl);
430 env->gl = new_gl;
395 }
396 env->tl--;
397
398 trace_win_helper_retry(env->tl);
399
400#if !defined(CONFIG_USER_ONLY)
401 if (cpu_interrupts_enabled(env)) {
402 cpu_check_irqs(env);
403 }
404#endif
405}
406#endif
431 }
432 env->tl--;
433
434 trace_win_helper_retry(env->tl);
435
436#if !defined(CONFIG_USER_ONLY)
437 if (cpu_interrupts_enabled(env)) {
438 cpu_check_irqs(env);
439 }
440#endif
441}
442#endif