qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 5/9] target-sh4: define FPSCR constants
Date: Tue, 11 Jan 2011 22:01:34 +0100	[thread overview]
Message-ID: <1294779698-17694-6-git-send-email-aurelien@aurel32.net> (raw)
In-Reply-To: <1294779698-17694-1-git-send-email-aurelien@aurel32.net>

Define FPSCR constants for all field and use them instead of hardcoded
values.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-sh4/cpu.h       |   35 +++++++++++++++++++++++++++++++----
 target-sh4/op_helper.c |    7 ++++---
 target-sh4/translate.c |    4 ++--
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h
index 8ccf25c..fe33b8a 100644
--- a/target-sh4/cpu.h
+++ b/target-sh4/cpu.h
@@ -61,10 +61,37 @@
 #define SR_S  (1 << 1)
 #define SR_T  (1 << 0)
 
-#define FPSCR_FR (1 << 21)
-#define FPSCR_SZ (1 << 20)
-#define FPSCR_PR (1 << 19)
-#define FPSCR_DN (1 << 18)
+#define FPSCR_MASK             (0x003fffff)
+#define FPSCR_FR               (1 << 21)
+#define FPSCR_SZ               (1 << 20)
+#define FPSCR_PR               (1 << 19)
+#define FPSCR_DN               (1 << 18)
+#define FPSCR_CAUSE_MASK       (0x3f << 12)
+#define FPSCR_CAUSE_SHIFT      (12)
+#define FPSCR_CAUSE_E          (1 << 17)
+#define FPSCR_CAUSE_V          (1 << 16)
+#define FPSCR_CAUSE_Z          (1 << 15)
+#define FPSCR_CAUSE_O          (1 << 14)
+#define FPSCR_CAUSE_U          (1 << 13)
+#define FPSCR_CAUSE_I          (1 << 12)
+#define FPSCR_ENABLE_MASK      (0x1f << 7)
+#define FPSCR_ENABLE_SHIFT     (7)
+#define FPSCR_ENABLE_V         (1 << 11)
+#define FPSCR_ENABLE_Z         (1 << 10)
+#define FPSCR_ENABLE_O         (1 << 9)
+#define FPSCR_ENABLE_U         (1 << 8)
+#define FPSCR_ENABLE_I         (1 << 7)
+#define FPSCR_FLAG_MASK        (0x1f << 2)
+#define FPSCR_FLAG_SHIFT       (2)
+#define FPSCR_FLAG_V           (1 << 6)
+#define FPSCR_FLAG_Z           (1 << 5)
+#define FPSCR_FLAG_O           (1 << 4)
+#define FPSCR_FLAG_U           (1 << 3)
+#define FPSCR_FLAG_I           (1 << 2)
+#define FPSCR_RM_MASK          (0x03 << 0)
+#define FPSCR_RM_NEAREST       (0 << 0)
+#define FPSCR_RM_ZERO          (1 << 0)
+
 #define DELAY_SLOT             (1 << 0)
 #define DELAY_SLOT_CONDITIONAL (1 << 1)
 #define DELAY_SLOT_TRUE        (1 << 2)
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index d8d0bb4..9915e42 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -428,11 +428,12 @@ static inline void clr_t(void)
 
 void helper_ld_fpscr(uint32_t val)
 {
-    env->fpscr = val & 0x003fffff;
-    if (val & 0x01)
+    env->fpscr = val & FPSCR_MASK;
+    if ((val & FPSCR_RM_MASK) == FPSCR_RM_ZERO) {
 	set_float_rounding_mode(float_round_to_zero, &env->fp_status);
-    else
+    } else {
 	set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
+    }
 }
 
 uint32_t helper_fabs_FT(uint32_t t0)
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index 8d59bf9..bdfa31a 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -203,10 +203,10 @@ static void cpu_sh4_reset(CPUSH4State * env)
     env->fpscr = FPSCR_PR; /* value for userspace according to the kernel */
     set_float_rounding_mode(float_round_nearest_even, &env->fp_status); /* ?! */
 #else
-    env->fpscr = 0x00040001; /* CPU reset value according to SH4 manual */
+    env->fpscr = FPSCR_DN | FPSCR_RM_ZERO; /* CPU reset value according to SH4 manual */
     set_float_rounding_mode(float_round_to_zero, &env->fp_status);
 #endif
-    set_default_nan_mode(1, &env->vfp.fp_status);
+    set_default_nan_mode(1, &env->fp_status);
     env->mmucr = 0;
 }
 
-- 
1.7.2.3

  parent reply	other threads:[~2011-01-11 21:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 21:01 [Qemu-devel] target-sh4: improve FPU emulation Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 1/9] target-sh4: switch sh4 to softfloat Aurelien Jarno
2011-01-11 21:22   ` Nathan Froyd
2011-01-11 21:35     ` Peter Maydell
2011-01-11 21:45       ` Aurelien Jarno
2011-01-11 22:02       ` Edgar E. Iglesias
2011-01-11 21:44     ` Aurelien Jarno
2011-01-12 11:05   ` [Qemu-devel] [PATCH v2 " Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 2/9] softfloat: SH4 has the sNaN bit set Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 3/9] softfloat: fix default-NaN mode Aurelien Jarno
2011-01-11 21:29   ` [Qemu-devel] " Peter Maydell
2011-01-11 21:01 ` [Qemu-devel] [PATCH 4/9] target-sh4: use " Aurelien Jarno
2011-01-11 21:01 ` Aurelien Jarno [this message]
2011-01-11 21:01 ` [Qemu-devel] [PATCH 6/9] target-sh4: implement flush-to-zero Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 7/9] target-sh4: implement FPU exceptions Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 8/9] target-sh4: add fipr instruction Aurelien Jarno
2011-01-11 21:01 ` [Qemu-devel] [PATCH 9/9] target-sh4: add ftrv instruction Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294779698-17694-6-git-send-email-aurelien@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).