Module Name: src
Committed By: tsutsui
Date: Tue Nov 15 12:23:23 UTC 2011
Modified Files:
src/sys/arch/atari/conf: files.atari
src/sys/arch/atari/include: cpu.h
src/sys/arch/m68k/include: m68k.h
src/sys/arch/mac68k/conf: files.mac68k
src/sys/arch/sun3/conf: files.sun3
src/sys/arch/x68k/conf: files.x68k
src/sys/arch/x68k/include: cpu.h
Added Files:
src/sys/arch/atari/atari: fpu_machdep.c
src/sys/arch/m68k/m68k: fpu.c
src/sys/arch/mac68k/mac68k: fpu_machdep.c
src/sys/arch/sun3/sun3: fpu_machdep.c
Removed Files:
src/sys/arch/atari/atari: fpu.c
src/sys/arch/mac68k/mac68k: fpu.c
src/sys/arch/sun3/sun3: fpu.c
src/sys/arch/x68k/x68k: fpu.c
Log Message:
Merge copy-and-pasted fpu_probe() function (to share it among more m68k ports).
Tested on TT030, Sun3/80, and X68030.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r0 src/sys/arch/atari/atari/fpu.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/atari/atari/fpu_machdep.c
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/atari/conf/files.atari
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/atari/include/cpu.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/m68k/include/m68k.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/m68k/m68k/fpu.c
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/mac68k/conf/files.mac68k
cvs rdiff -u -r1.38 -r0 src/sys/arch/mac68k/mac68k/fpu.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/mac68k/mac68k/fpu_machdep.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sun3/conf/files.sun3
cvs rdiff -u -r1.25 -r0 src/sys/arch/sun3/sun3/fpu.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sun3/sun3/fpu_machdep.c
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/x68k/conf/files.x68k
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/x68k/include/cpu.h
cvs rdiff -u -r1.14 -r0 src/sys/arch/x68k/x68k/fpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/atari/conf/files.atari
diff -u src/sys/arch/atari/conf/files.atari:1.119 src/sys/arch/atari/conf/files.atari:1.120
--- src/sys/arch/atari/conf/files.atari:1.119 Sun Jun 12 03:35:39 2011
+++ src/sys/arch/atari/conf/files.atari Tue Nov 15 12:23:21 2011
@@ -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/mainbus.c
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
Index: src/sys/arch/atari/include/cpu.h
diff -u src/sys/arch/atari/include/cpu.h:1.67 src/sys/arch/atari/include/cpu.h:1.68
--- src/sys/arch/atari/include/cpu.h:1.67 Mon May 16 13:22:52 2011
+++ src/sys/arch/atari/include/cpu.h Tue Nov 15 12:23:22 2011
@@ -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 @@ void config_console(void);
* Prototypes from fpu.c
*/
const char *fpu_describe(int);
-int fpu_probe(void);
/*
* Prototypes from locore.s
Index: src/sys/arch/m68k/include/m68k.h
diff -u src/sys/arch/m68k/include/m68k.h:1.19 src/sys/arch/m68k/include/m68k.h:1.20
--- src/sys/arch/m68k/include/m68k.h:1.19 Mon May 16 13:22:53 2011
+++ src/sys/arch/m68k/include/m68k.h Tue Nov 15 12:23:22 2011
@@ -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 setfunc_trampoline(void);
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);
Index: src/sys/arch/mac68k/conf/files.mac68k
diff -u src/sys/arch/mac68k/conf/files.mac68k:1.124 src/sys/arch/mac68k/conf/files.mac68k:1.125
--- src/sys/arch/mac68k/conf/files.mac68k:1.124 Sun Jun 12 03:35:43 2011
+++ src/sys/arch/mac68k/conf/files.mac68k Tue Nov 15 12:23:22 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.mac68k,v 1.124 2011/06/12 03:35:43 rmind Exp $
+# $NetBSD: files.mac68k,v 1.125 2011/11/15 12:23:22 tsutsui Exp $
# mac68k-specific configuration info
@@ -158,7 +158,7 @@ file arch/mac68k/mac68k/bus_space.c
file arch/mac68k/mac68k/clock.c
file arch/mac68k/mac68k/conf.c
file arch/mac68k/mac68k/disksubr.c disk
-file arch/mac68k/mac68k/fpu.c
+file arch/mac68k/mac68k/fpu_machdep.c
file arch/mac68k/mac68k/intr.c
file arch/mac68k/mac68k/iop.c
file arch/mac68k/mac68k/machdep.c
@@ -174,6 +174,7 @@ file arch/mac68k/mac68k/via.c
file arch/m68k/m68k/bus_dma.c
file arch/m68k/m68k/cacheops.c
file arch/m68k/m68k/db_memrw.c ddb | kgdb
+file arch/m68k/m68k/fpu.c
file arch/m68k/m68k/kgdb_machdep.c kgdb
file arch/m68k/m68k/pmap_motorola.c
file arch/m68k/m68k/procfs_machdep.c procfs
Index: src/sys/arch/sun3/conf/files.sun3
diff -u src/sys/arch/sun3/conf/files.sun3:1.79 src/sys/arch/sun3/conf/files.sun3:1.80
--- src/sys/arch/sun3/conf/files.sun3:1.79 Sun Jun 12 03:35:48 2011
+++ src/sys/arch/sun3/conf/files.sun3 Tue Nov 15 12:23:22 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.sun3,v 1.79 2011/06/12 03:35:48 rmind Exp $
+# $NetBSD: files.sun3,v 1.80 2011/11/15 12:23:22 tsutsui Exp $
#
# sun3-specific configuration info
@@ -33,12 +33,13 @@ file arch/sun3/sun3x/pmap.c _sun3x_
file arch/sun3/sun3/autoconf.c
file arch/sun3/sun3/db_machdep.c ddb
file arch/sun3/sun3/db_memrw.c ddb | kgdb
-file arch/sun3/sun3/fpu.c
+file arch/sun3/sun3/fpu_machdep.c
file arch/sun3/sun3/leds.c
file arch/sun3/sun3/sunmon.c
file arch/sun3/sun3/sys_machdep.c
file arch/sun3/sun3/trap.c
file arch/m68k/m68k/cacheops.c _sun3x_
+file arch/m68k/m68k/fpu.c
include "arch/m68k/fpe/files.fpe"
Index: src/sys/arch/x68k/conf/files.x68k
diff -u src/sys/arch/x68k/conf/files.x68k:1.74 src/sys/arch/x68k/conf/files.x68k:1.75
--- src/sys/arch/x68k/conf/files.x68k:1.74 Sun Jun 12 03:35:49 2011
+++ src/sys/arch/x68k/conf/files.x68k Tue Nov 15 12:23:22 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.x68k,v 1.74 2011/06/12 03:35:49 rmind Exp $
+# $NetBSD: files.x68k,v 1.75 2011/11/15 12:23:22 tsutsui Exp $
#
# new style config file for x68k architecture
#
@@ -30,10 +30,10 @@ file arch/x68k/x68k/disksubr.c disk
file arch/x68k/x68k/machdep.c
file arch/x68k/x68k/pmap_bootstrap.c compile-with "${NOPROF_C}"
file arch/x68k/x68k/trap.c
-file arch/x68k/x68k/fpu.c
file arch/x68k/x68k/bus.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
Index: src/sys/arch/x68k/include/cpu.h
diff -u src/sys/arch/x68k/include/cpu.h:1.54 src/sys/arch/x68k/include/cpu.h:1.55
--- src/sys/arch/x68k/include/cpu.h:1.54 Mon May 16 13:22:55 2011
+++ src/sys/arch/x68k/include/cpu.h Tue Nov 15 12:23:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.54 2011/05/16 13:22:55 tsutsui Exp $ */
+/* $NetBSD: cpu.h,v 1.55 2011/11/15 12:23:23 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -127,9 +127,6 @@ extern int machineid;
extern uint8_t *intiobase;
extern uint8_t *intiolimit;
-/* fpu.c functions */
-int fpu_probe(void);
-
/* machdep.c functions */
void dumpsys(void);
Added files:
Index: src/sys/arch/atari/atari/fpu_machdep.c
diff -u /dev/null src/sys/arch/atari/atari/fpu_machdep.c:1.1
--- /dev/null Tue Nov 15 12:23:23 2011
+++ src/sys/arch/atari/atari/fpu_machdep.c Tue Nov 15 12:23:21 2011
@@ -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];
+}
Index: src/sys/arch/m68k/m68k/fpu.c
diff -u /dev/null src/sys/arch/m68k/m68k/fpu.c:1.1
--- /dev/null Tue Nov 15 12:23:23 2011
+++ src/sys/arch/m68k/m68k/fpu.c Tue Nov 15 12:23:22 2011
@@ -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
+ * 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/060)
+ * Probe for the FPU at early bootstrap.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.1 2011/11/15 12:23:22 tsutsui Exp $");
+
+#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 *nofault;
+
+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;
+ uint8_t b;
+
+ nofault = (int *)&faultbuf;
+ if (setjmp(&faultbuf)) {
+ nofault = (int *)0;
+ return FPU_NONE;
+ }
+
+ /*
+ * 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 = NULL;
+
+ /*
+ * Presumably, if we're an 040/060 and did not take exception
+ * above, we have an FPU. Don't bother probing.
+ */
+ if (cputype == CPU_68060)
+ return FPU_68060;
+ if (cputype == CPU_68040)
+ return FPU_68040;
+
+ /*
+ * 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("fsave %0@" : : "a" (&fpframe) : "memory");
+
+ b = fpframe.fpf_fsize;
+
+ /*
+ * Now, restore a NULL state to reset the FPU.
+ */
+ fpframe.fpf_null = 0;
+ fpframe.fpf_idle.fpf_ccr = 0;
+ m68881_restore(&fpframe);
+
+ /*
+ * The size of a 68881 IDLE frame is 0x18
+ * and a 68882 frame is 0x38
+ */
+ if (b == 0x18)
+ return FPU_68881;
+ if (b == 0x38)
+ return FPU_68882;
+
+ /*
+ * If it's not one of the above, we have no clue what it is.
+ */
+ return FPU_UNKNOWN;
+}
Index: src/sys/arch/mac68k/mac68k/fpu_machdep.c
diff -u /dev/null src/sys/arch/mac68k/mac68k/fpu_machdep.c:1.1
--- /dev/null Tue Nov 15 12:23:23 2011
+++ src/sys/arch/mac68k/mac68k/fpu_machdep.c Tue Nov 15 12:23:22 2011
@@ -0,0 +1,82 @@
+/* $NetBSD: fpu_machdep.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
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: fpu_machdep.c,v 1.1 2011/11/15 12:23:22 tsutsui Exp $");
+
+#include "opt_fpu_emulate.h"
+
+/*
+ * Floating Point Unit (MC68881/882/040) initialization.
+ */
+
+#include <sys/param.h>
+
+#include <machine/cpu.h>
+#include <machine/frame.h>
+
+/*
+ * FPU type; emulator uses FPU_NONE
+ */
+
+extern label_t *nofault;
+
+static const char *fpu_descr[] = {
+#ifdef FPU_EMULATE
+ [FPU_NONE] = "emulator",
+#else
+ [FPU_NONE] = "no math support",
+#endif
+ [FPU_68881] = "mc68881",
+ [FPU_68882] = "mc68882",
+ [FPU_68040] = "mc68040",
+ [FPU_68060] = "mc68060",
+ [FPU_UNKNOWN] = "unknown"
+};
+
+void
+initfpu(void)
+{
+ const char *descr;
+
+ fputype = fpu_probe();
+
+ /* Generate a reference FPU idle frame. */
+ if (fputype != FPU_NONE)
+ m68k_make_fpu_idle_frame();
+
+ if ((0 <= fputype) && (fputype <= 3))
+ descr = fpu_descr[fputype];
+ else
+ descr = "unknown type";
+
+ printf("fpu: %s\n", descr);
+}
Index: src/sys/arch/sun3/sun3/fpu_machdep.c
diff -u /dev/null src/sys/arch/sun3/sun3/fpu_machdep.c:1.1
--- /dev/null Tue Nov 15 12:23:23 2011
+++ src/sys/arch/sun3/sun3/fpu_machdep.c Tue Nov 15 12:23:22 2011
@@ -0,0 +1,83 @@
+/* $NetBSD: fpu_machdep.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
+ * 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) initialization.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD");
+
+#include "opt_fpu_emulate.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/frame.h>
+
+#include <sun3/sun3/machdep.h>
+
+static const char *fpu_descr[] = {
+#ifdef FPU_EMULATE
+ "emulator", /* 0 */
+#else
+ "no math support", /* 0 */
+#endif
+ "mc68881", /* 1 */
+ "mc68882", /* 2 */
+ "mc68040 internal", /* 3 */
+ "mc68060 internal", /* 4 */
+ "unknown type" }; /* 5 */
+
+void
+initfpu(void)
+{
+ const char *descr;
+ int maxtype = sizeof(fpu_descr) / sizeof(fpu_descr[0]) - 1;
+
+ /* Set the FPU bit in the "system enable register" */
+ enable_fpu(1);
+
+ fputype = fpu_probe();
+ if (fputype < 0 || fputype > maxtype)
+ fputype = FPU_UNKNOWN;
+
+ descr = fpu_descr[fputype];
+
+ printf("fpu: %s\n", descr);
+
+ if (fputype == FPU_NONE) {
+ /* Might as well turn the enable bit back off. */
+ enable_fpu(0);
+ } else
+ m68k_make_fpu_idle_frame();
+}