Fix saving and loading of trap state
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 17 Jul 2008 19:17:19 +0000 (19:17 +0000)
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 17 Jul 2008 19:17:19 +0000 (19:17 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4883 c046a42c-6fe2-441c-8c8c-71466251a162

target-sparc/helper.c
target-sparc/op_helper.c

index 14364fb..baf761a 100644 (file)
@@ -742,6 +742,14 @@ void do_interrupt(CPUState *env)
         return;
     }
 #endif
+    if (env->tl < MAXTL - 1) {
+        env->tl++;
+    } else {
+        env->pstate |= PS_RED;
+        if (env->tl != MAXTL)
+            env->tl++;
+    }
+    env->tsptr = &env->ts[env->tl];
     env->tsptr->tstate = ((uint64_t)GET_CCR(env) << 32) |
         ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) |
         GET_CWP64(env);
@@ -758,14 +766,6 @@ void do_interrupt(CPUState *env)
         cpu_set_cwp(env, cpu_cwp_inc(env, env->cwp + 1));
     env->tbr &= ~0x7fffULL;
     env->tbr |= ((env->tl > 1) ? 1 << 14 : 0) | (intno << 5);
-    if (env->tl < MAXTL - 1) {
-        env->tl++;
-    } else {
-        env->pstate |= PS_RED;
-        if (env->tl != MAXTL)
-            env->tl++;
-    }
-    env->tsptr = &env->ts[env->tl];
     env->pc = env->tbr;
     env->npc = env->pc + 4;
     env->exception_index = 0;
index b168f9c..3f50827 100644 (file)
@@ -2680,26 +2680,26 @@ void helper_wrpstate(target_ulong new_state)
 
 void helper_done(void)
 {
-    env->tl--;
-    env->tsptr = &env->ts[env->tl];
     env->pc = env->tsptr->tpc;
     env->npc = env->tsptr->tnpc + 4;
     PUT_CCR(env, env->tsptr->tstate >> 32);
     env->asi = (env->tsptr->tstate >> 24) & 0xff;
     change_pstate((env->tsptr->tstate >> 8) & 0xf3f);
     PUT_CWP64(env, env->tsptr->tstate & 0xff);
+    env->tl--;
+    env->tsptr = &env->ts[env->tl];
 }
 
 void helper_retry(void)
 {
-    env->tl--;
-    env->tsptr = &env->ts[env->tl];
     env->pc = env->tsptr->tpc;
     env->npc = env->tsptr->tnpc;
     PUT_CCR(env, env->tsptr->tstate >> 32);
     env->asi = (env->tsptr->tstate >> 24) & 0xff;
     change_pstate((env->tsptr->tstate >> 8) & 0xf3f);
     PUT_CWP64(env, env->tsptr->tstate & 0xff);
+    env->tl--;
+    env->tsptr = &env->ts[env->tl];
 }
 #endif