From 17d996e1f1de8057b3bb88b753e65735a6d8f191 Mon Sep 17 00:00:00 2001 From: blueswir1 Date: Sat, 7 Jul 2007 20:53:22 +0000 Subject: [PATCH] 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 | 14 ++++++++++++-- target-sparc/cpu.h | 10 ++++++++-- target-sparc/op.c | 4 ++-- target-sparc/op_helper.c | 6 +++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 2ec2f33..06cf302 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -383,7 +383,10 @@ static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) } registers[64] = tswapl(env->pc); registers[65] = tswapl(env->npc); - registers[66] = tswapl(env->tstate[env->tl]); + registers[66] = tswapl(((uint64_t)GET_CCR(env) << 32) | + ((env->asi & 0xff) << 24) | + ((env->pstate & 0xfff) << 8) | + GET_CWP64(env)); registers[67] = tswapl(env->fsr); registers[68] = tswapl(env->fprs); registers[69] = tswapl(env->y); @@ -427,7 +430,14 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) } env->pc = tswapl(registers[64]); env->npc = tswapl(registers[65]); - env->tstate[env->tl] = tswapl(registers[66]); + { + uint64_t tmp = tswapl(registers[66]); + + PUT_CCR(env, tmp >> 32); + env->asi = (tmp >> 24) & 0xff; + env->pstate = (tmp >> 8) & 0xfff; + PUT_CWP64(env, tmp & 0xff); + } env->fsr = tswapl(registers[67]); env->fprs = tswapl(registers[68]); env->y = tswapl(registers[69]); diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index a3d762f..06b5865 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -288,11 +288,17 @@ void cpu_set_cwp(CPUSPARCState *env1, int new_cwp); } while (0) #ifdef TARGET_SPARC64 -#define GET_CCR(env) ((env->xcc << 4) | (env->psr & PSR_ICC)) +#define GET_CCR(env) (((env->xcc >> 20) << 4) | ((env->psr & PSR_ICC) >> 20)) #define PUT_CCR(env, val) do { int _tmp = val; \ - env->xcc = _tmp >> 4; \ + env->xcc = (_tmp >> 4) << 20; \ env->psr = (_tmp & 0xf) << 20; \ } while (0) +#define GET_CWP64(env) (NWINDOWS - 1 - (env)->cwp) +#define PUT_CWP64(env, val) do { \ + env->cwp = NWINDOWS - 1 - ((val) & 0xff); \ + cpu_set_cwp(env, env->cwp); \ + } while(0) + #endif int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc); diff --git a/target-sparc/op.c b/target-sparc/op.c index c0aee8f..4ab0667 100644 --- a/target-sparc/op.c +++ b/target-sparc/op.c @@ -1184,12 +1184,12 @@ void OPPROTO op_wrpstate(void) // order. void OPPROTO op_rdcwp(void) { - T0 = NWINDOWS - 1 - env->cwp; + T0 = GET_CWP64(env); } void OPPROTO op_wrcwp(void) { - env->cwp = NWINDOWS - 1 - T0; + PUT_CWP64(env, T0); } /* XXX: use another pointer for %iN registers to avoid slow wrapping diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index 11134cf..cd93727 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -871,7 +871,7 @@ void do_done(void) PUT_CCR(env, env->tstate[env->tl] >> 32); env->asi = (env->tstate[env->tl] >> 24) & 0xff; env->pstate = (env->tstate[env->tl] >> 8) & 0xfff; - set_cwp(env->tstate[env->tl] & 0xff); + PUT_CWP64(env, env->tstate[env->tl] & 0xff); } void do_retry(void) @@ -882,7 +882,7 @@ void do_retry(void) PUT_CCR(env, env->tstate[env->tl] >> 32); env->asi = (env->tstate[env->tl] >> 24) & 0xff; env->pstate = (env->tstate[env->tl] >> 8) & 0xfff; - set_cwp(env->tstate[env->tl] & 0xff); + PUT_CWP64(env, env->tstate[env->tl] & 0xff); } #endif @@ -952,7 +952,7 @@ void do_interrupt(int intno) } #endif env->tstate[env->tl] = ((uint64_t)GET_CCR(env) << 32) | ((env->asi & 0xff) << 24) | - ((env->pstate & 0xfff) << 8) | (env->cwp & 0xff); + ((env->pstate & 0xfff) << 8) | GET_CWP64(env); env->tpc[env->tl] = env->pc; env->tnpc[env->tl] = env->npc; env->tt[env->tl] = intno; -- 2.7.4