Module Name:    src
Committed By:   tsutsui
Date:           Fri Aug 16 13:39:47 UTC 2013

Modified Files:
        src/sys/arch/hp300/conf: GENERIC files.hp300
        src/sys/arch/hp300/hp300: locore.s machdep.c trap.c

Log Message:
Make FPU_EMULATE work on NetBSD/hp300.  Commented out by default in GENERIC.

Tested on HP9000/362 without optional MC68882 FPU in its socket.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/arch/hp300/conf/GENERIC
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/hp300/conf/files.hp300
cvs rdiff -u -r1.165 -r1.166 src/sys/arch/hp300/hp300/locore.s
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/hp300/hp300/machdep.c
cvs rdiff -u -r1.149 -r1.150 src/sys/arch/hp300/hp300/trap.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/hp300/conf/GENERIC
diff -u src/sys/arch/hp300/conf/GENERIC:1.179 src/sys/arch/hp300/conf/GENERIC:1.180
--- src/sys/arch/hp300/conf/GENERIC:1.179	Sun Jun 30 21:38:57 2013
+++ src/sys/arch/hp300/conf/GENERIC	Fri Aug 16 13:39:47 2013
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.179 2013/06/30 21:38:57 rmind Exp $
+# $NetBSD: GENERIC,v 1.180 2013/08/16 13:39:47 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/hp300/conf/std.hp300"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.179 $"
+#ident 		"GENERIC-$Revision: 1.180 $"
 
 maxusers	32		# estimated number of users
 
@@ -43,6 +43,7 @@ options 	HP400
 options 	HP425
 options 	HP433
 options 	FPSP		# floating point interface for 68040
+#options 	FPU_EMULATE	# software fpu emulation for MC68030
 
 # Standard system options
 options 	KTRACE		# system call tracing support

Index: src/sys/arch/hp300/conf/files.hp300
diff -u src/sys/arch/hp300/conf/files.hp300:1.85 src/sys/arch/hp300/conf/files.hp300:1.86
--- src/sys/arch/hp300/conf/files.hp300:1.85	Sun Jun 12 03:35:40 2011
+++ src/sys/arch/hp300/conf/files.hp300	Fri Aug 16 13:39:47 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: files.hp300,v 1.85 2011/06/12 03:35:40 rmind Exp $
+#	$NetBSD: files.hp300,v 1.86 2013/08/16 13:39:47 tsutsui Exp $
 #
 # hp300-specific configuration info
 
@@ -208,6 +208,7 @@ file	arch/hp300/hp300/trap.c
 file	arch/hp300/hp300/disksubr.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
@@ -216,6 +217,10 @@ file	arch/m68k/m68k/vm_machdep.c
 
 file	dev/cons.c
 
+# Emulation modules
+# 6888x emulator (FPU_EMULATE)
+include "arch/m68k/fpe/files.fpe"
+
 # NetBSD m68k a.out Binary Compatibility (COMPAT_AOUT_M68K)
 include	"compat/aoutm68k/files.aoutm68k"
 

Index: src/sys/arch/hp300/hp300/locore.s
diff -u src/sys/arch/hp300/hp300/locore.s:1.165 src/sys/arch/hp300/hp300/locore.s:1.166
--- src/sys/arch/hp300/hp300/locore.s:1.165	Thu Dec 22 15:33:29 2011
+++ src/sys/arch/hp300/hp300/locore.s	Fri Aug 16 13:39:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.165 2011/12/22 15:33:29 tsutsui Exp $	*/
+/*	$NetBSD: locore.s,v 1.166 2013/08/16 13:39:47 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -576,6 +576,8 @@ Lenab1:
 	movl	#USRSTACK-4,%a2
 	movl	%a2,%usp		| init user SP
 
+	jbsr	_C_LABEL(fpu_probe)
+	movl	%d0,_C_LABEL(fputype)
 	tstl	_C_LABEL(fputype)	| Have an FPU?
 	jeq	Lenab2			| No, skip.
 	clrl	%a1@(PCB_FPCTX)		| ensure null FP context

Index: src/sys/arch/hp300/hp300/machdep.c
diff -u src/sys/arch/hp300/hp300/machdep.c:1.226 src/sys/arch/hp300/hp300/machdep.c:1.227
--- src/sys/arch/hp300/hp300/machdep.c:1.226	Fri Aug 10 12:29:59 2012
+++ src/sys/arch/hp300/hp300/machdep.c	Fri Aug 16 13:39:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.226 2012/08/10 12:29:59 tsutsui Exp $	*/
+/*	$NetBSD: machdep.c,v 1.227 2013/08/16 13:39:47 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,10 +39,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.226 2012/08/10 12:29:59 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.227 2013/08/16 13:39:47 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
+#include "opt_fpu_emulate.h"
 #include "opt_modular.h"
 #include "opt_panicbutton.h"
 
@@ -447,6 +448,13 @@ identifycpu(void)
 		len += sprintf(cpu_model + len, ", %sMHz MC68881 FPU",
 		    machineid == HP_350 ? "20" : "16.67");
 		break;
+	case FPU_NONE:
+#ifdef FPU_EMULATE
+		len += sprintf(cpu_model + len, ", emulated FPU");
+#else
+		len += sprintf(cpu_model + len, ", no FPU");
+#endif
+		break;
 	default:
 		len += sprintf(cpu_model + len, ", unknown FPU");
 	}

Index: src/sys/arch/hp300/hp300/trap.c
diff -u src/sys/arch/hp300/hp300/trap.c:1.149 src/sys/arch/hp300/hp300/trap.c:1.150
--- src/sys/arch/hp300/hp300/trap.c:1.149	Sun Feb 19 21:06:07 2012
+++ src/sys/arch/hp300/hp300/trap.c	Fri Aug 16 13:39:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.149 2012/02/19 21:06:07 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.150 2013/08/16 13:39:47 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,12 +39,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.149 2012/02/19 21:06:07 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.150 2013/08/16 13:39:47 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
 #include "opt_kgdb.h"
 #include "opt_compat_sunos.h"
+#include "opt_fpu_emulate.h"
 #include "opt_m68k_arch.h"
 
 #include <machine/hp300spu.h>	/* XXX param.h includes cpu.h */
@@ -74,6 +75,10 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.1
 
 #include <dev/cons.h>
 
+#ifdef FPU_EMULATE
+#include <m68k/fpe/fpu_emulate.h>
+#endif
+
 #ifdef COMPAT_SUNOS
 #include <compat/sunos/sunos_exec.h>
 #include <compat/sunos/sunos_syscall.h>
@@ -378,9 +383,30 @@ trap(struct frame *fp, int type, u_int c
 		ksi.ksi_code = fpsr2siginfocode(code);
 		break;
 
-#ifdef M68040
+	/*
+	 * FPU faults in supervisor mode.
+	 */
+	case T_ILLINST: /* fnop generates this, apparently. */
+	case T_FPEMULI:
+	case T_FPEMULD: {
+		extern label_t *nofault;
+
+		if (nofault)    /* If we're probing. */
+			longjmp(nofault);
+		if (type == T_ILLINST)
+			printf("Kernel Illegal Instruction trap.\n");
+		else
+			printf("Kernel FPU trap.\n");
+		goto dopanic;
+	}
+
 	case T_FPEMULI|T_USER:	/* unimplemented FP instruction */
 	case T_FPEMULD|T_USER:	/* unimplemented FP data type */
+#ifdef FPU_EMULATE
+		if (fpu_emulate(fp, &pcb->pcb_fpregs, &ksi) == 0)
+			; /* XXX - Deal with tracing? (fp->f_sr & PSL_T) */
+		break;
+#elif defined(M68040)
 		/* XXX need to FSAVE */
 		printf("pid %d(%s): unimplemented FP %s at %x (EA %x)\n",
 		       p->p_pid, p->p_comm,
@@ -390,6 +416,8 @@ trap(struct frame *fp, int type, u_int c
 		ksi.ksi_signo = SIGFPE;
 		ksi.ksi_code = FPE_FLTINV;
 		break;
+#else
+		/* FALLTHROUGH */
 #endif
 
 	case T_ILLINST|T_USER:	/* illegal instruction fault */
@@ -616,7 +644,8 @@ trap(struct frame *fp, int type, u_int c
 		break;
 	    }
 	}
-	trapsignal(l, &ksi);
+	if (ksi.ksi_signo)
+		trapsignal(l, &ksi);
 	if ((type & T_USER) == 0)
 		return;
  out:

Reply via email to