Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sh5 Put bit definitions for the FP control/status r...



details:   https://anonhg.NetBSD.org/src/rev/fe5ca76c04e7
branches:  trunk
changeset: 538650:fe5ca76c04e7
user:      scw <scw%NetBSD.org@localhost>
date:      Thu Oct 24 13:58:48 2002 +0000

description:
Put bit definitions for the FP control/status register in <sh5/fpu.h> and
use them instead of "magic" numbers in the source.

diffstat:

 sys/arch/sh5/include/Makefile       |   4 +-
 sys/arch/sh5/include/fpu.h          |  81 +++++++++++++++++++++++++++++++++++++
 sys/arch/sh5/sh5/netbsd32_machdep.c |   6 +-
 sys/arch/sh5/sh5/process_machdep.c  |   5 +-
 4 files changed, 90 insertions(+), 6 deletions(-)

diffs (156 lines):

diff -r 083a510f138c -r fe5ca76c04e7 sys/arch/sh5/include/Makefile
--- a/sys/arch/sh5/include/Makefile     Thu Oct 24 13:48:44 2002 +0000
+++ b/sys/arch/sh5/include/Makefile     Thu Oct 24 13:58:48 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.8 2002/10/23 13:26:35 scw Exp $
+#      $NetBSD: Makefile,v 1.9 2002/10/24 13:58:48 scw Exp $
 
 KDIR=  /sys/arch/sh5/include
 INCSDIR= /usr/include/sh5
@@ -8,7 +8,7 @@
        cdefs.h conreg.h cpu.h cputypes.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       float.h fpu.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        limits.h lock.h \
diff -r 083a510f138c -r fe5ca76c04e7 sys/arch/sh5/include/fpu.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sh5/include/fpu.h        Thu Oct 24 13:58:48 2002 +0000
@@ -0,0 +1,81 @@
+/*     $NetBSD: fpu.h,v 1.1 2002/10/24 13:58:48 scw Exp $      */
+
+/*
+ * Copyright 2002 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Definitions for the SH5's Floating Point Unit
+ */
+
+#ifndef _SH5_FPU_H
+#define _SH5_FPU_H
+
+/*
+ * Bits in the Floating Point Status and Control Register
+ */
+
+/* Rounding mode */
+#define        SH5_FPSCR_RM_MASK               0x00001
+#define        SH5_FPSCR_RM_TO_NEAREST         0x00000
+#define        SH5_FPSCR_RM_TO_ZERO            0x00001
+
+/* Sticky Flags */
+#define        SH5_FPSCR_FLAG_I                0x00004 /* Inexact */
+#define        SH5_FPSCR_FLAG_U                0x00008 /* Underflow */
+#define        SH5_FPSCR_FLAG_O                0x00010 /* Overflow */
+#define        SH5_FPSCR_FLAG_Z                0x00020 /* Divide by Zero */
+#define        SH5_FPSCR_FLAG_V                0x00040 /* Invalid */
+
+/* Enable Flags */
+#define        SH5_FPSCR_ENABLE_I              0x00080 /* Inexact */
+#define        SH5_FPSCR_ENABLE_U              0x00100 /* Underflow */
+#define        SH5_FPSCR_ENABLE_O              0x00200 /* Overflow */
+#define        SH5_FPSCR_ENABLE_Z              0x00400 /* Divide by Zero */
+#define        SH5_FPSCR_ENABLE_V              0x00800 /* Invalid */
+
+/* Cause Flags */
+#define        SH5_FPSCR_CAUSE_I               0x01000 /* Inexact */
+#define        SH5_FPSCR_CAUSE_U               0x02000 /* Underflow */
+#define        SH5_FPSCR_CAUSE_O               0x04000 /* Overflow */
+#define        SH5_FPSCR_CAUSE_Z               0x08000 /* Divide by Zero */
+#define        SH5_FPSCR_CAUSE_V               0x10000 /* Invalid */
+#define        SH5_FPSCR_CAUSE_E               0x20000 /* FPU Error */
+
+/* Treatment of denormalised source operands */
+#define        SH5_FPSCR_DN_MASK               0x40000
+#define        SH5_FPSCR_DN_RAISE              0x00000 /* Raise an exception */
+#define        SH5_FPSCR_DN_FLUSH_ZERO         0x40000 /* Flush to zero */
+
+#endif /* _SH5_FPU_H */
diff -r 083a510f138c -r fe5ca76c04e7 sys/arch/sh5/sh5/netbsd32_machdep.c
--- a/sys/arch/sh5/sh5/netbsd32_machdep.c       Thu Oct 24 13:48:44 2002 +0000
+++ b/sys/arch/sh5/sh5/netbsd32_machdep.c       Thu Oct 24 13:58:48 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.1 2002/10/23 13:26:37 scw Exp $ */
+/*     $NetBSD: netbsd32_machdep.c,v 1.2 2002/10/24 13:58:48 scw Exp $ */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -66,6 +66,8 @@
 #include <machine/cpu.h>
 #include <machine/reg.h>
 
+#include <sh5/fpu.h>
+
 char   machine_arch32[] = "sh5";
 
 int
@@ -163,7 +165,7 @@
         *
         * With FPSCR.DN set, denormalised numbers are quietly flushed to zero.
         */
-       p->p_addr->u_pcb.pcb_ctx.sf_fpregs.fpscr = 0x20000;
+       p->p_addr->u_pcb.pcb_ctx.sf_fpregs.fpscr = SH5_FPSCR_DN_FLUSH_ZERO;
 
        sh5_fprestore(SH5_CONREG_USR_FPRS_MASK << SH5_CONREG_USR_FPRS_SHIFT,
            &p->p_addr->u_pcb);
diff -r 083a510f138c -r fe5ca76c04e7 sys/arch/sh5/sh5/process_machdep.c
--- a/sys/arch/sh5/sh5/process_machdep.c        Thu Oct 24 13:48:44 2002 +0000
+++ b/sys/arch/sh5/sh5/process_machdep.c        Thu Oct 24 13:58:48 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.6 2002/10/09 20:27:35 scw Exp $  */
+/*     $NetBSD: process_machdep.c,v 1.7 2002/10/24 13:58:48 scw Exp $  */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -49,6 +49,7 @@
 #include <machine/reg.h>
 
 #include <sh5/conreg.h>
+#include <sh5/fpu.h>
 
 void
 setregs(struct proc *p, struct exec_package *pack, u_long stack)
@@ -105,7 +106,7 @@
         *
         * With FPSCR.DN set, denormalised numbers are quietly flushed to zero.
         */
-       p->p_addr->u_pcb.pcb_ctx.sf_fpregs.fpscr = 0x20000;
+       p->p_addr->u_pcb.pcb_ctx.sf_fpregs.fpscr = SH5_FPSCR_DN_FLUSH_ZERO;
 
        sh5_fprestore(SH5_CONREG_USR_FPRS_MASK << SH5_CONREG_USR_FPRS_SHIFT,
            &p->p_addr->u_pcb);



Home | Main Index | Thread Index | Old Index