diff --git a/sys/arch/sun3/conf/files.sun3.newconf b/sys/arch/sun3/conf/files.sun3.newconf index 5865ac3dbce6..90a3b2420943 100644 --- a/sys/arch/sun3/conf/files.sun3.newconf +++ b/sys/arch/sun3/conf/files.sun3.newconf @@ -1,4 +1,4 @@ -# $NetBSD: files.sun3.newconf,v 1.23 1995/03/10 02:31:35 gwr Exp $ +# $NetBSD: files.sun3.newconf,v 1.24 1995/03/24 17:27:12 gwr Exp $ # # sun3-specific configuration info @@ -29,15 +29,20 @@ file arch/m68k/fpe/fpu_emulate.c fpu_emulate file arch/m68k/m68k/copy.s file dev/cons.c -# +# Declare our "catch-all" root node. +device mainbus at root {} +# Misc. mainbus things (catch-all) +# Control space hack +device obctl at mainbus {addr = -1, [level = -1]} +# Floating Point Unit +device fpu at mainbus {} +file arch/sun3/sun3/fpu.c fpu + # Bus types # # The implementation of the bus_* functions in autoconfig.c # requires these all to agree with struct bus_loc -# -device mainbus at root {} -# Control space hack -device obctl at mainbus {addr = -1, [level = -1]} + # On-board MEMory space device obmem at mainbus {addr = -1, [level = -1]} # On-board I/O space diff --git a/sys/arch/sun3/conf/std.sun3 b/sys/arch/sun3/conf/std.sun3 index 2017f39e9f9f..081ec9a5bf3b 100644 --- a/sys/arch/sun3/conf/std.sun3 +++ b/sys/arch/sun3/conf/std.sun3 @@ -1,12 +1,15 @@ -# $NetBSD: std.sun3,v 1.11 1995/02/11 21:01:21 gwr Exp $ +# $NetBSD: std.sun3,v 1.12 1995/03/24 17:27:15 gwr Exp $ # Standard information for sun3's. machine sun3 m68k # The root node: mainbus0 at root + # control space hack... obctl0 at mainbus? +fpu0 at mainbus? + # main memory obmem0 at mainbus? # device space diff --git a/sys/arch/sun3/sun3/fpu.c b/sys/arch/sun3/sun3/fpu.c new file mode 100644 index 000000000000..b18564e4fe02 --- /dev/null +++ b/sys/arch/sun3/sun3/fpu.c @@ -0,0 +1,135 @@ +/* $NetBSD: fpu.c,v 1.1 1995/03/24 17:27:37 gwr Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * All rights reserved. + * + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon Ross + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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) + * Probe for the FPU at autoconfig time. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "interreg.h" + +extern int fpu_type; +extern int *nofault; + +int fpu_match __P((struct device *, void *vcf, void *args)); +void fpu_attach __P((struct device *, struct device *, void *)); +int fpu_probe(); + +struct cfdriver fpucd = { + NULL, "fpu", fpu_match, fpu_attach, + DV_DULL, sizeof(struct device), 0 }; + +int fpu_match(parent, vcf, args) + struct device *parent; + void *vcf, *args; +{ + struct cfdata *cf = vcf; + struct confargs *ca = args; + + /* This driver only supports one unit. */ + if (cf->cf_unit != 0) + return (0); + + return (1); +} + +static char *fpu_descr[] = { +#ifdef FPU_EMULATE + "emulator", /* 0 */ +#else + "no math support", /* 0 */ +#endif + "mc68881", /* 1 */ + "mc68882", /* 2 */ + "?" }; + +void fpu_attach(parent, self, args) + struct device *parent; + struct device *self; + void *args; +{ + struct confargs *ca = args; + char *descr; + int enab_reg; + + /* Set the FPU bit in the "system enable register" */ + enab_reg = get_control_byte((char *) SYSTEM_ENAB); + enab_reg |= SYSTEM_ENAB_FPP; + set_control_byte((char *) SYSTEM_ENAB, enab_reg); + + fpu_type = fpu_probe(); + if ((0 <= fpu_type) && (fpu_type <= 2)) + descr = fpu_descr[fpu_type]; + else + descr = "unknown type"; + + printf(" (%s)\n", descr); + + if (fpu_type == 0) { + /* Might as well turn the enable bit back off. */ + enab_reg = get_control_byte((char *) SYSTEM_ENAB); + enab_reg &= ~SYSTEM_ENAB_FPP; + set_control_byte((char *) SYSTEM_ENAB, enab_reg); + } +} + +int fpu_probe() +{ + jmp_buf faultbuf; + int null_fpframe[2]; + + nofault = (int *) &faultbuf; + if (setjmp(nofault)) { + nofault = (int *) 0; + return(0); + } + null_fpframe[0] = 0; + null_fpframe[1] = 0; + m68881_restore(null_fpframe); + nofault = (int *) 0; + return(1); +} diff --git a/sys/arch/sun3/sun3/locore2.c b/sys/arch/sun3/sun3/locore2.c index 5205bb417cd2..a87a08bd3ca7 100644 --- a/sys/arch/sun3/sun3/locore2.c +++ b/sys/arch/sun3/sun3/locore2.c @@ -1,4 +1,4 @@ -/* $NetBSD: locore2.c,v 1.34 1995/02/13 22:24:26 gwr Exp $ */ +/* $NetBSD: locore2.c,v 1.35 1995/03/24 17:27:44 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -77,13 +77,6 @@ unsigned char cpu_machine_id = 0; char *cpu_string = NULL; int cpu_has_vme = 0; -/* XXX - Need real code to do this at startup. */ -#ifdef FPCOPROC -int fpu_type = 1; /* XXX */ -#else -int fpu_type = 0; /* XXX */ -#endif - vm_offset_t high_segment_free_start = 0; vm_offset_t high_segment_free_end = 0; @@ -760,18 +753,6 @@ void internal_configure() clock_init(); } -/* XXX - Move this into a real device driver. */ -void fpu_init() -{ - int enab_reg; - - if (fpu_type) { - enab_reg = get_control_byte((char *) SYSTEM_ENAB); - enab_reg |= SYSTEM_ENAB_FPP; - set_control_byte((char *) SYSTEM_ENAB, enab_reg); - } -} - /* * This is called from locore.s just after the kernel is remapped * to its proper address, but before the call to main(). @@ -804,7 +785,4 @@ sun3_bootstrap() * it will not cause "spurrious level 7" complaints. */ initialize_vector_table(); - - /* XXX - Move this into a real device driver. */ - fpu_init(); } diff --git a/sys/arch/sun3/sun3/machdep.c b/sys/arch/sun3/sun3/machdep.c index 1deaadaf748c..c928ac82eb81 100644 --- a/sys/arch/sun3/sun3/machdep.c +++ b/sys/arch/sun3/sun3/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.47 1995/03/10 02:24:42 gwr Exp $ */ +/* $NetBSD: machdep.c,v 1.48 1995/03/24 17:27:41 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -99,10 +99,11 @@ #include extern char *cpu_string; -extern int fpu_type; int physmem; int cold; +int fpu_type; + /* * safepri is a safe priority for sleep to set for a spin-wait * during autoconfiguration or after a panic. diff --git a/sys/arch/sun3/sun3/sun3_startup.c b/sys/arch/sun3/sun3/sun3_startup.c index d4924d3c3960..52e13cd1456e 100644 --- a/sys/arch/sun3/sun3/sun3_startup.c +++ b/sys/arch/sun3/sun3/sun3_startup.c @@ -1,4 +1,4 @@ -/* $NetBSD: sun3_startup.c,v 1.34 1995/02/13 22:24:26 gwr Exp $ */ +/* $NetBSD: sun3_startup.c,v 1.35 1995/03/24 17:27:44 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -77,13 +77,6 @@ unsigned char cpu_machine_id = 0; char *cpu_string = NULL; int cpu_has_vme = 0; -/* XXX - Need real code to do this at startup. */ -#ifdef FPCOPROC -int fpu_type = 1; /* XXX */ -#else -int fpu_type = 0; /* XXX */ -#endif - vm_offset_t high_segment_free_start = 0; vm_offset_t high_segment_free_end = 0; @@ -760,18 +753,6 @@ void internal_configure() clock_init(); } -/* XXX - Move this into a real device driver. */ -void fpu_init() -{ - int enab_reg; - - if (fpu_type) { - enab_reg = get_control_byte((char *) SYSTEM_ENAB); - enab_reg |= SYSTEM_ENAB_FPP; - set_control_byte((char *) SYSTEM_ENAB, enab_reg); - } -} - /* * This is called from locore.s just after the kernel is remapped * to its proper address, but before the call to main(). @@ -804,7 +785,4 @@ sun3_bootstrap() * it will not cause "spurrious level 7" complaints. */ initialize_vector_table(); - - /* XXX - Move this into a real device driver. */ - fpu_init(); }