Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Merge copy-and-pasted fpu_probe() function (to shar...



details:   https://anonhg.NetBSD.org/src/rev/ae138b5627fa
branches:  trunk
changeset: 771230:ae138b5627fa
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue Nov 15 12:23:21 2011 +0000

description:
Merge copy-and-pasted fpu_probe() function (to share it among more m68k ports).
Tested on TT030, Sun3/80, and X68030.

diffstat:

 sys/arch/atari/atari/fpu.c           |  138 --------------------------------
 sys/arch/atari/atari/fpu_machdep.c   |   75 +++++++++++++++++
 sys/arch/atari/conf/files.atari      |    5 +-
 sys/arch/atari/include/cpu.h         |    3 +-
 sys/arch/m68k/include/m68k.h         |    5 +-
 sys/arch/m68k/m68k/fpu.c             |  117 +++++++++++++++++++++++++++
 sys/arch/mac68k/conf/files.mac68k    |    5 +-
 sys/arch/mac68k/mac68k/fpu.c         |  148 -----------------------------------
 sys/arch/mac68k/mac68k/fpu_machdep.c |   82 +++++++++++++++++++
 sys/arch/sun3/conf/files.sun3        |    5 +-
 sys/arch/sun3/sun3/fpu.c             |  139 --------------------------------
 sys/arch/sun3/sun3/fpu_machdep.c     |   83 +++++++++++++++++++
 sys/arch/x68k/conf/files.x68k        |    4 +-
 sys/arch/x68k/include/cpu.h          |    5 +-
 sys/arch/x68k/x68k/fpu.c             |  116 ---------------------------
 15 files changed, 374 insertions(+), 556 deletions(-)

diffs (truncated from 1080 to 300 lines):

diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/atari/atari/fpu.c
--- a/sys/arch/atari/atari/fpu.c        Tue Nov 15 10:57:00 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*     $NetBSD: fpu.c,v 1.15 2009/03/18 10:22:24 cegger Exp $  */
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Gordon W. Ross.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``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 THE FOUNDATION OR CONTRIBUTORS
- * 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.
- */
-
-/*
- * Floating Point Unit (MC68881/882/040)
- * Probe for the FPU at autoconfig time.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.15 2009/03/18 10:22:24 cegger Exp $");
-
-#include "opt_fpu_emulate.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-
-#include <machine/psl.h>
-#include <machine/cpu.h>
-#include <machine/frame.h>
-
-extern int fpu_type;
-extern int *nofault;
-
-static const char *fpu_descr[] = {
-#ifdef FPU_EMULATE
-       " emulated ",           /* 0 */
-#else
-       " no ",                 /* 0 */
-#endif
-       " mc68881 ",            /* 1 */
-       " mc68882 ",            /* 2 */
-       "/",                    /* 3 68040 internal */
-       "??? " };
-
-const char *
-fpu_describe(int type)
-{
-       int     maxtype = sizeof(fpu_descr)/sizeof(fpu_descr[0]) - 1;
-
-       if ((type < 0) || (type > maxtype))
-               type = 0;
-       return(fpu_descr[type]);
-}
-
-int
-fpu_probe(void)
-{
-       /*
-        * A 68881 idle frame is 28 bytes and a 68882's is 60 bytes.
-        * We, of course, need to have enough room for either.
-        */
-       struct  fpframe fpframe;
-       label_t         faultbuf;
-       u_char          b;
-
-       nofault = (int *) &faultbuf;
-       if (setjmp((label_t *)nofault)) {
-               nofault = (int *) 0;
-               return(0);
-       }
-
-       /*
-        * Synchronize FPU or cause a fault.
-        * This should leave the 881/882 in the IDLE state,
-        * state, so we can determine which we have by
-        * examining the size of the FP state frame
-        */
-       __asm("fnop");
-
-       nofault = (int *) 0;
-
-       /*
-        * Presumably, if we're an 040 and did not take exception
-        * above, we have an FPU.  Don't bother probing.
-        */
-       if (mmutype == MMU_68040) {
-               return 3;
-       }
-
-       /*
-        * Presumably, this will not cause a fault--the fnop should
-        * have if this will.  We save the state in order to get the
-        * size of the frame.
-        */
-       __asm("movl %0, %%a0; fsave %%a0@" : : "a" (&fpframe) : "a0" );
-
-       b = fpframe.fpf_fsize;
-
-       /*
-        * Now, restore a NULL state to reset the FPU.
-        */
-       fpframe.fpf_null = 0;
-       fpframe.fpf_idle.fpf_ccr = 0;   /* XXX: really needed? */
-       m68881_restore(&fpframe);
-
-       /*
-        * The size of a 68881 IDLE frame is 0x18
-        *         and a 68882 frame is 0x38
-        */
-       if (b == 0x18) return 1;
-       if (b == 0x38) return 2;
-
-       /*
-        * If it's not one of the above, we have no clue what it is.
-        */
-       return 4;
-}
diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/atari/atari/fpu_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/atari/fpu_machdep.c        Tue Nov 15 12:23:21 2011 +0000
@@ -0,0 +1,75 @@
+/*     $NetBSD: fpu_machdep.c,v 1.1 2011/11/15 12:23:21 tsutsui Exp $  */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Gordon W. Ross.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 THE FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * Floating Point Unit (MC68881/882/040) initialization.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: fpu_machdep.c,v 1.1 2011/11/15 12:23:21 tsutsui Exp $");
+
+#include "opt_fpu_emulate.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <machine/psl.h>
+#include <machine/cpu.h>
+#include <machine/frame.h>
+
+extern int fpu_type;
+extern int *nofault;
+
+static const char *fpu_descr[] = {
+#ifdef FPU_EMULATE
+       [FPU_NONE] = " emulated ",
+#else
+       [FPU_NONE] = " no ",
+#endif
+       [FPU_68881] = " mc68881 ",
+       [FPU_68882] = " mc68882 ",
+       [FPU_68040] = "/",
+       [FPU_68060] = "/",
+       [FPU_UNKNOWN] = "??? "
+};
+
+const char *
+fpu_describe(int type)
+{
+       int     maxtype = sizeof(fpu_descr)/sizeof(fpu_descr[0]) - 1;
+
+       if ((type < 0) || (type > maxtype))
+               type = 0;
+       return fpu_descr[type];
+}
diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/atari/conf/files.atari
--- a/sys/arch/atari/conf/files.atari   Tue Nov 15 10:57:00 2011 +0000
+++ b/sys/arch/atari/conf/files.atari   Tue Nov 15 12:23:21 2011 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: files.atari,v 1.119 2011/06/12 03:35:39 rmind Exp $
+#      $NetBSD: files.atari,v 1.120 2011/11/15 12:23:21 tsutsui Exp $
 
 maxpartitions 16
 
@@ -212,11 +212,12 @@
 file   arch/atari/atari/pmap_bootstrap.c
 file   arch/atari/atari/trap.c
 file   arch/atari/atari/stalloc.c
-file   arch/atari/atari/fpu.c
+file   arch/atari/atari/fpu_machdep.c
 file   arch/atari/dev/ym2149.c                 _atarihw_
 file   arch/atari/atari/intr.c
 file   arch/m68k/m68k/cacheops.c
 file   arch/m68k/m68k/db_memrw.c               ddb
+file   arch/m68k/m68k/fpu.c
 file   arch/m68k/m68k/pmap_motorola.c
 file   arch/m68k/m68k/procfs_machdep.c         procfs
 file   arch/m68k/m68k/sys_machdep.c
diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/atari/include/cpu.h
--- a/sys/arch/atari/include/cpu.h      Tue Nov 15 10:57:00 2011 +0000
+++ b/sys/arch/atari/include/cpu.h      Tue Nov 15 12:23:21 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.67 2011/05/16 13:22:52 tsutsui Exp $ */
+/*     $NetBSD: cpu.h,v 1.68 2011/11/15 12:23:22 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -160,7 +160,6 @@
  * Prototypes from fpu.c
  */
 const char *fpu_describe(int);
-int    fpu_probe(void);
 
 /*
  * Prototypes from locore.s
diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/m68k/include/m68k.h
--- a/sys/arch/m68k/include/m68k.h      Tue Nov 15 10:57:00 2011 +0000
+++ b/sys/arch/m68k/include/m68k.h      Tue Nov 15 12:23:21 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m68k.h,v 1.19 2011/05/16 13:22:53 tsutsui Exp $        */
+/*     $NetBSD: m68k.h,v 1.20 2011/11/15 12:23:22 tsutsui Exp $        */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -118,6 +118,9 @@
 void   w16zero(void *, u_int);
 void   w16copy(const void *, void *, u_int);
 
+/* fpu.c */
+int    fpu_probe(void);
+
 #ifdef MAPPEDCOPY
 /* mappedcopy.c */
 int    mappedcopyin(void *fromp, void *top, size_t count);
diff -r 4001e51a77e0 -r ae138b5627fa sys/arch/m68k/m68k/fpu.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/m68k/m68k/fpu.c  Tue Nov 15 12:23:21 2011 +0000
@@ -0,0 +1,117 @@
+/*     $NetBSD: fpu.c,v 1.1 2011/11/15 12:23:22 tsutsui Exp $  */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Gordon W. Ross.
+ *
+ * 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



Home | Main Index | Thread Index | Old Index