summaryrefslogtreecommitdiff
path: root/Linux/spim/include/fpuctl.h
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2009-04-01 22:54:06 +0000
committerCharles.Forsyth <devnull@localhost>2009-04-01 22:54:06 +0000
commit4eb166cf184c1f102fb79e31b1465ea3e2021c39 (patch)
tree0e1bd8c059324d5cb99d625a67398e48a9ffce95 /Linux/spim/include/fpuctl.h
parenta9b1d9c7f57ec21ff8be147f5c949966b966e519 (diff)
20090401-2350
Diffstat (limited to 'Linux/spim/include/fpuctl.h')
-rw-r--r--Linux/spim/include/fpuctl.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/Linux/spim/include/fpuctl.h b/Linux/spim/include/fpuctl.h
new file mode 100644
index 00000000..ad5dcba7
--- /dev/null
+++ b/Linux/spim/include/fpuctl.h
@@ -0,0 +1,65 @@
+/* FCR */
+#define FCRBITS 0x00000F83
+#define FPINEX (1<<7)
+#define FPUNFL (1<<8)
+#define FPOVFL (1<<9)
+#define FPZDIV (1<<10)
+#define FPINVAL (1<<11)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FSRBITS 0x0003F07C
+#define FPAINEX (1<<2)
+#define FPAOVFL (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAZDIV (1<<5)
+#define FPAINVAL (1<<6)
+
+/*
+ * Linux mips fpu support
+ * Mimic Plan9 floating point support
+ */
+
+static void
+setfcr(ulong fcr)
+{
+ __asm__("ctc1 %0,$31\n"
+ : :"r" (fcr)
+ );
+}
+
+static ulong
+getfcr(void)
+{
+ ulong fcr = 0;
+ __asm__("cfc1 %0,$31\n"
+ : "=r" (fcr)
+ );
+ fcr &= FCRBITS;
+ return fcr;
+}
+
+static ulong
+getfsr(void)
+{
+ ulong fsr = 0;
+ __asm__("cfc1 %0,$31\n"
+ : "=r" (fsr)
+ );
+ fsr &= FSRBITS;
+ return fsr;
+}
+
+static void
+setfsr(ulong fsr)
+{
+ fsr |= getfcr();
+ setfcr(getfcr()|fsr);
+}