From 9e83fcafc47c3c1efae41278567ea60ce874eb73 Mon Sep 17 00:00:00 2001
From: Grall Julien <julien.grall@gmail.com>
Date: Mon, 23 May 2011 13:57:23 +0200
Subject: [PATCH] fix TA0_SHUTDOWN feature


Signed-off-by: Grall Julien <julien.grall@gmail.com>
---
 target-sparc/helper.h    |    1 +
 target-sparc/op_helper.c |   14 ++++++++++++++
 target-sparc/translate.c |    6 ++----
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index 61ef03a..7f50c7a 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -86,6 +86,7 @@ DEF_HELPER_0(fcmpeq_fcc3, void)
 #endif
 DEF_HELPER_1(raise_exception, void, int)
 DEF_HELPER_1(trap_always, void, int)
+DEF_HELPER_1(trap_0, void, int)
 DEF_HELPER_0(shutdown, void)
 #define F_HELPER_0_0(name) DEF_HELPER_0(f ## name, void)
 #define F_HELPER_DQ_0_0(name)                   \
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index 8f9d579..266080d 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -330,6 +330,19 @@ void HELPER(trap_always)(int tt)
     do_interrupt(env);
 }
 
+void HELPER(trap_0)(int tt)
+{
+#ifndef TARGET_SPARC64
+    if (env->psret == 0) {
+        helper_shutdown();
+    } else {
+        helper_trap_always(tt);
+    }
+#else
+    helper_trap_always(tt);
+#endif
+}
+
 void helper_shutdown(void)
 {
 #if !defined(CONFIG_USER_ONLY)
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 64035fc..13181ef 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -2037,10 +2037,8 @@ static void disas_sparc_insn(DisasContext * dc)
                     tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
 
                     if (rs2 == 0 &&
-                        dc->def->features & CPU_FEATURE_TA0_SHUTDOWN) {
-
-                        gen_helper_shutdown();
-
+                        (dc->def->features & CPU_FEATURE_TA0_SHUTDOWN)) {
+                        gen_helper_trap_0(cpu_tmp32);
                     } else {
                         gen_helper_trap_always(cpu_tmp32);
                     }
-- 
1.7.4.4

