Commit 17d996e1f1de8057b3bb88b753e65735a6d8f191

Authored by blueswir1
1 parent dc011987

Report normalised CWP values to userland and GDB, not internal representation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3052 c046a42c-6fe2-441c-8c8c-71466251a162
gdbstub.c
... ... @@ -383,7 +383,10 @@ static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
383 383 }
384 384 registers[64] = tswapl(env->pc);
385 385 registers[65] = tswapl(env->npc);
386   - registers[66] = tswapl(env->tstate[env->tl]);
  386 + registers[66] = tswapl(((uint64_t)GET_CCR(env) << 32) |
  387 + ((env->asi & 0xff) << 24) |
  388 + ((env->pstate & 0xfff) << 8) |
  389 + GET_CWP64(env));
387 390 registers[67] = tswapl(env->fsr);
388 391 registers[68] = tswapl(env->fprs);
389 392 registers[69] = tswapl(env->y);
... ... @@ -427,7 +430,14 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
427 430 }
428 431 env->pc = tswapl(registers[64]);
429 432 env->npc = tswapl(registers[65]);
430   - env->tstate[env->tl] = tswapl(registers[66]);
  433 + {
  434 + uint64_t tmp = tswapl(registers[66]);
  435 +
  436 + PUT_CCR(env, tmp >> 32);
  437 + env->asi = (tmp >> 24) & 0xff;
  438 + env->pstate = (tmp >> 8) & 0xfff;
  439 + PUT_CWP64(env, tmp & 0xff);
  440 + }
431 441 env->fsr = tswapl(registers[67]);
432 442 env->fprs = tswapl(registers[68]);
433 443 env->y = tswapl(registers[69]);
... ...
target-sparc/cpu.h
... ... @@ -288,11 +288,17 @@ void cpu_set_cwp(CPUSPARCState *env1, int new_cwp);
288 288 } while (0)
289 289  
290 290 #ifdef TARGET_SPARC64
291   -#define GET_CCR(env) ((env->xcc << 4) | (env->psr & PSR_ICC))
  291 +#define GET_CCR(env) (((env->xcc >> 20) << 4) | ((env->psr & PSR_ICC) >> 20))
292 292 #define PUT_CCR(env, val) do { int _tmp = val; \
293   - env->xcc = _tmp >> 4; \
  293 + env->xcc = (_tmp >> 4) << 20; \
294 294 env->psr = (_tmp & 0xf) << 20; \
295 295 } while (0)
  296 +#define GET_CWP64(env) (NWINDOWS - 1 - (env)->cwp)
  297 +#define PUT_CWP64(env, val) do { \
  298 + env->cwp = NWINDOWS - 1 - ((val) & 0xff); \
  299 + cpu_set_cwp(env, env->cwp); \
  300 + } while(0)
  301 +
296 302 #endif
297 303  
298 304 int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
... ...
target-sparc/op.c
... ... @@ -1184,12 +1184,12 @@ void OPPROTO op_wrpstate(void)
1184 1184 // order.
1185 1185 void OPPROTO op_rdcwp(void)
1186 1186 {
1187   - T0 = NWINDOWS - 1 - env->cwp;
  1187 + T0 = GET_CWP64(env);
1188 1188 }
1189 1189  
1190 1190 void OPPROTO op_wrcwp(void)
1191 1191 {
1192   - env->cwp = NWINDOWS - 1 - T0;
  1192 + PUT_CWP64(env, T0);
1193 1193 }
1194 1194  
1195 1195 /* XXX: use another pointer for %iN registers to avoid slow wrapping
... ...
target-sparc/op_helper.c
... ... @@ -871,7 +871,7 @@ void do_done(void)
871 871 PUT_CCR(env, env->tstate[env->tl] >> 32);
872 872 env->asi = (env->tstate[env->tl] >> 24) & 0xff;
873 873 env->pstate = (env->tstate[env->tl] >> 8) & 0xfff;
874   - set_cwp(env->tstate[env->tl] & 0xff);
  874 + PUT_CWP64(env, env->tstate[env->tl] & 0xff);
875 875 }
876 876  
877 877 void do_retry(void)
... ... @@ -882,7 +882,7 @@ void do_retry(void)
882 882 PUT_CCR(env, env->tstate[env->tl] >> 32);
883 883 env->asi = (env->tstate[env->tl] >> 24) & 0xff;
884 884 env->pstate = (env->tstate[env->tl] >> 8) & 0xfff;
885   - set_cwp(env->tstate[env->tl] & 0xff);
  885 + PUT_CWP64(env, env->tstate[env->tl] & 0xff);
886 886 }
887 887 #endif
888 888  
... ... @@ -952,7 +952,7 @@ void do_interrupt(int intno)
952 952 }
953 953 #endif
954 954 env->tstate[env->tl] = ((uint64_t)GET_CCR(env) << 32) | ((env->asi & 0xff) << 24) |
955   - ((env->pstate & 0xfff) << 8) | (env->cwp & 0xff);
  955 + ((env->pstate & 0xfff) << 8) | GET_CWP64(env);
956 956 env->tpc[env->tl] = env->pc;
957 957 env->tnpc[env->tl] = env->npc;
958 958 env->tt[env->tl] = intno;
... ...