removed stdout reference (not portable)
[qemu] / target-ppc / op.c
index 94ead45..f439a81 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+//#define DEBUG_OP
+
 #include "config.h"
 #include "exec.h"
 
-//#define DEBUG_OP
-
 #define regs (env)
 #define Ts0 (int32_t)T0
 #define Ts1 (int32_t)T1
@@ -208,22 +208,29 @@ PPC_OP(set_T2)
 }
 
 /* Generate exceptions */
-PPC_OP(queue_exception_err)
+PPC_OP(raise_exception_err)
 {
-    do_queue_exception_err(PARAM(1), PARAM(2));
+    do_raise_exception_err(PARAM(1), PARAM(2));
 }
 
-PPC_OP(queue_exception)
+PPC_OP(raise_exception)
 {
-    do_queue_exception(PARAM(1));
+    do_raise_exception(PARAM(1));
 }
 
-PPC_OP(process_exceptions)
+PPC_OP(update_nip)
 {
     env->nip = PARAM(1);
-    if (env->exceptions != 0) {
-        do_check_exception_state();
-    }
+}
+
+PPC_OP(debug)
+{
+    env->nip = PARAM(1);
+#if defined (DEBUG_OP)
+    dump_state();
+#endif
+    do_raise_exception(EXCP_DEBUG);
+    RETURN();
 }
 
 /* Segment registers load and store with immediate index */
@@ -235,10 +242,7 @@ PPC_OP(load_srin)
 
 PPC_OP(store_srin)
 {
-#if defined (DEBUG_OP)
-    dump_store_sr(T1 >> 28);
-#endif
-    regs->sr[T1 >> 28] = T0;
+    do_store_sr(T1 >> 28);
     RETURN();
 }
 
@@ -353,58 +357,38 @@ PPC_OP(store_ctr)
     RETURN();
 }
 
-/* Update time base */
-PPC_OP(update_tb)
+PPC_OP(load_tbl)
 {
-    T0 = regs->tb[0];
-    T1 = T0;
-    T0 += PARAM(1);
-#if defined (DEBUG_OP)
-    dump_update_tb(PARAM(1));
-#endif
-    if (T0 < T1) {
-        T1 = regs->tb[1] + 1;
-        regs->tb[1] = T1;
-    }
-    regs->tb[0] = T0;
+    T0 = cpu_ppc_load_tbl(regs);
     RETURN();
 }
 
-PPC_OP(load_tb)
+PPC_OP(load_tbu)
 {
-    T0 = regs->tb[PARAM(1)];
+    T0 = cpu_ppc_load_tbu(regs);
     RETURN();
 }
 
-PPC_OP(store_tb)
+PPC_OP(store_tbl)
 {
-    regs->tb[PARAM(1)] = T0;
-#if defined (DEBUG_OP)
-    dump_store_tb(PARAM(1));
-#endif
+    cpu_ppc_store_tbl(regs, T0);
     RETURN();
 }
 
-/* Update decrementer */
-PPC_OP(update_decr)
+PPC_OP(store_tbu)
 {
-    T0 = regs->decr;
-    T1 = T0;
-    T0 -= PARAM(1);
-    regs->decr = T0;
-    if (PARAM(1) > T1) {
-        do_queue_exception(EXCP_DECR);
-    }
+    cpu_ppc_store_tbu(regs, T0);
     RETURN();
 }
 
-PPC_OP(store_decr)
+PPC_OP(load_decr)
 {
-    T1 = regs->decr;
-    regs->decr = T0;
-    if (Ts0 < 0 && Ts1 > 0) {
-        do_queue_exception(EXCP_DECR);
+    T0 = cpu_ppc_load_decr(regs);
     }
+
+PPC_OP(store_decr)
+{
+    cpu_ppc_store_decr(regs, T0);
     RETURN();
 }
 
@@ -415,10 +399,7 @@ PPC_OP(load_ibat)
 
 PPC_OP(store_ibat)
 {
-#if defined (DEBUG_OP)
-    dump_store_ibat(PARAM(1), PARAM(2));
-#endif
-    regs->IBAT[PARAM(1)][PARAM(2)] = T0;
+    do_store_ibat(PARAM(1), PARAM(2));
 }
 
 PPC_OP(load_dbat)
@@ -428,10 +409,7 @@ PPC_OP(load_dbat)
 
 PPC_OP(store_dbat)
 {
-#if defined (DEBUG_OP)
-    dump_store_dbat(PARAM(1), PARAM(2));
-#endif
-    regs->DBAT[PARAM(1)][PARAM(2)] = T0;
+    do_store_dbat(PARAM(1), PARAM(2));
 }
 
 /* FPSCR */
@@ -524,7 +502,7 @@ PPC_OP(movl_T1_lr)
 
 PPC_OP(test_ctr)
 {
-    T0 = (regs->ctr != 0);
+    T0 = regs->ctr;
 }
 
 PPC_OP(test_ctr_true)
@@ -554,7 +532,7 @@ PPC_OP(test_ctrz_false)
 
 PPC_OP(test_true)
 {
-    T0 = ((T0 & PARAM(1)) != 0);
+    T0 = (T0 & PARAM(1));
 }
 
 PPC_OP(test_false)
@@ -1357,28 +1335,28 @@ PPC_OP(fmsubs)
 /* fnmadd - fnmadd. - fnmadds - fnmadds. */
 PPC_OP(fnmadd)
 {
-    FT0 = -((FT0 * FT1) + FT2);
+    do_fnmadd();
     RETURN();
 }
 
 /* fnmadds - fnmadds. */
 PPC_OP(fnmadds)
 {
-    FTS0 = -((FTS0 * FTS1) + FTS2);
+    do_fnmadds();
     RETURN();
 }
 
 /* fnmsub - fnmsub. */
 PPC_OP(fnmsub)
 {
-    FT0 = -((FT0 * FT1) - FT2);
+    do_fnmsub();
     RETURN();
 }
 
 /* fnmsubs - fnmsubs. */
 PPC_OP(fnmsubs)
 {
-    FTS0 = -((FTS0 * FTS1) - FTS2);
+    do_fnmsubs();
     RETURN();
 }
 
@@ -1443,10 +1421,9 @@ PPC_OP(fneg)
 }
 
 /* Load and store */
-#if defined(CONFIG_USER_ONLY)
 #define MEMSUFFIX _raw
 #include "op_mem.h"
-#else
+#if !defined(CONFIG_USER_ONLY)
 #define MEMSUFFIX _user
 #include "op_mem.h"
 
@@ -1454,17 +1431,28 @@ PPC_OP(fneg)
 #include "op_mem.h"
 #endif
 
+/* Special op to check and maybe clear reservation */
+PPC_OP(check_reservation)
+{
+    do_check_reservation();
+    RETURN();
+}
+
 /* Return from interrupt */
 PPC_OP(rfi)
 {
+    regs->nip = regs->spr[SRR0] & ~0x00000003;
+#if 1 // TRY
+    T0 = regs->spr[SRR1] & ~0xFFF00000;
+#else
     T0 = regs->spr[SRR1] & ~0xFFFF0000;
+#endif
     do_store_msr();
-    do_tlbia();
+#if defined (DEBUG_OP)
     dump_rfi();
-    regs->nip = regs->spr[SRR0] & ~0x00000003;
-    if (env->exceptions != 0) {
-        do_check_exception_state();
-    }
+#endif
+    //    do_tlbia();
+    do_raise_exception(EXCP_RFI);
     RETURN();
 }
 
@@ -1476,7 +1464,7 @@ PPC_OP(tw)
         (Ts0 == Ts1 && (PARAM(1) & 0x04)) ||
         (T0 < T1 && (PARAM(1) & 0x02)) ||
         (T0 > T1 && (PARAM(1) & 0x01)))
-        do_queue_exception_err(EXCP_PROGRAM, EXCP_TRAP);
+        do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
     RETURN();
 }
 
@@ -1487,7 +1475,7 @@ PPC_OP(twi)
         (Ts0 == SPARAM(1) && (PARAM(2) & 0x04)) ||
         (T0 < (uint32_t)SPARAM(1) && (PARAM(2) & 0x02)) ||
         (T0 > (uint32_t)SPARAM(1) && (PARAM(2) & 0x01)))
-        do_queue_exception_err(EXCP_PROGRAM, EXCP_TRAP);
+        do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
     RETURN();
 }