Module Name:    src
Committed By:   thorpej
Date:           Sat Jan 13 21:40:54 UTC 2024

Modified Files:
        src/sys/arch/next68k/conf: files.next68k
        src/sys/arch/next68k/include: cpu.h
        src/sys/arch/next68k/next68k: isr.c isr.h locore.s
Added Files:
        src/sys/arch/next68k/include: vectors.h
Removed Files:
        src/sys/arch/next68k/next68k: vectors.s

Log Message:
Switch next68k over to the common m68k vector table.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/next68k/conf/files.next68k
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/next68k/include/cpu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/next68k/include/vectors.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/next68k/next68k/isr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/next68k/next68k/isr.h
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/next68k/next68k/locore.s
cvs rdiff -u -r1.13 -r0 src/sys/arch/next68k/next68k/vectors.s

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/next68k/conf/files.next68k
diff -u src/sys/arch/next68k/conf/files.next68k:1.43 src/sys/arch/next68k/conf/files.next68k:1.44
--- src/sys/arch/next68k/conf/files.next68k:1.43	Tue Jan  9 04:16:26 2024
+++ src/sys/arch/next68k/conf/files.next68k	Sat Jan 13 21:40:53 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.next68k,v 1.43 2024/01/09 04:16:26 thorpej Exp $
+# $NetBSD: files.next68k,v 1.44 2024/01/13 21:40:53 thorpej Exp $
 
 # next68k-specific configuration info
 
@@ -40,6 +40,7 @@ file	arch/m68k/m68k/mmu_subr.s
 file	arch/m68k/m68k/pmap_motorola.c
 file	arch/m68k/m68k/procfs_machdep.c		procfs
 file	arch/m68k/m68k/sys_machdep.c
+file	arch/m68k/m68k/vectors.c
 file	arch/m68k/m68k/vm_machdep.c
 
 # include "arch/m68k/fpe/files.fpe"

Index: src/sys/arch/next68k/include/cpu.h
diff -u src/sys/arch/next68k/include/cpu.h:1.53 src/sys/arch/next68k/include/cpu.h:1.54
--- src/sys/arch/next68k/include/cpu.h:1.53	Tue Jan  9 04:16:26 2024
+++ src/sys/arch/next68k/include/cpu.h	Sat Jan 13 21:40:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.53 2024/01/09 04:16:26 thorpej Exp $	*/
+/*	$NetBSD: cpu.h,v 1.54 2024/01/13 21:40:54 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -112,8 +112,6 @@ extern volatile unsigned int interrupt_d
 
 extern	int	astpending;	/* need to trap before returning to user mode */
 
-extern	void (*vectab[])(void);
-
 /* locore.s functions */
 void	doboot(void) __attribute__((__noreturn__));
 int	nmihand(void *);

Index: src/sys/arch/next68k/next68k/isr.c
diff -u src/sys/arch/next68k/next68k/isr.c:1.33 src/sys/arch/next68k/next68k/isr.c:1.34
--- src/sys/arch/next68k/next68k/isr.c:1.33	Fri Feb  3 23:19:03 2023
+++ src/sys/arch/next68k/next68k/isr.c	Sat Jan 13 21:40:54 2024
@@ -1,11 +1,4 @@
-/*	$NetBSD: isr.c,v 1.33 2023/02/03 23:19:03 tsutsui Exp $ */
-
-/*
- * This file was taken from mvme68k/mvme68k/isr.c
- * should probably be re-synced when needed.
- * Darrin B. Jewell <jew...@mit.edu>  Tue Nov 10 05:07:16 1998
- * original cvs id: NetBSD: isr.c,v 1.12 1998/07/05 06:49:07 jonathan Exp
- */
+/*	$NetBSD: isr.c,v 1.34 2024/01/13 21:40:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -41,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.33 2023/02/03 23:19:03 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.34 2024/01/13 21:40:54 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -59,7 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.33
 
 volatile unsigned int interrupt_depth;
 isr_autovec_list_t isr_autovec[NISRAUTOVEC];
-struct	isr_vectored isr_vectored[NISRVECTORED];
 static const char irqgroupname[] = "hard irqs";
 struct	evcnt next68k_irq_evcnt[] = {
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, irqgroupname, "spur"),
@@ -77,7 +69,6 @@ int ssir;
 extern	u_int intrcnt[];	/* from locore.s. XXXSCW: will go away soon */
 extern	void (*vectab[])(void);
 extern	void badtrap(void);
-extern	void intrhand_vectored(void);
 
 #if 0
 static	int spurintr(void *);
@@ -95,10 +86,6 @@ isrinit(void)
 	/* Initialise the interrupt event counts */
 	for (i = 0; i < (sizeof(next68k_irq_evcnt) / sizeof(struct evcnt)); i++)
 		evcnt_attach_static(&next68k_irq_evcnt[i]);
-
-	/* Arrange to trap Spurious and NMI auto-vectored Interrupts */
-/* 	isrlink_autovec(spurintr, NULL, 0, 0, NULL); */
-/* 	isrlink_autovec(nmihand, NULL, 7, 0, NULL); */
 }
 
 /*
@@ -172,40 +159,6 @@ isrlink_autovec(int (*func)(void *), voi
 }
 
 /*
- * Establish a vectored interrupt handler.
- * Called by bus interrupt establish functions.
- */
-void
-isrlink_vectored(int (*func)(void *), void *arg, int ipl, int vec,
-    struct evcnt *evcnt)
-{
-	struct isr_vectored *isr;
-
-#ifdef DIAGNOSTIC
-	if ((ipl < 0) || (ipl >= NISRAUTOVEC))
-		panic("isrlink_vectored: bad ipl %d", ipl);
-	if ((vec < ISRVECTORED) || (vec >= ISRVECTORED + NISRVECTORED))
-		panic("isrlink_vectored: bad vec 0x%x", vec);
-#endif
-
-	isr = &isr_vectored[vec - ISRVECTORED];
-
-#ifdef DIAGNOSTIC
-	if ((vectab[vec] != badtrap) || (isr->isr_func != NULL))
-		panic("isrlink_vectored: vec 0x%x not available", vec);
-#endif
-
-	/* Fill in the new entry. */
-	isr->isr_func = func;
-	isr->isr_arg = arg;
-	isr->isr_ipl = ipl;
-	isr->isr_evcnt = evcnt;
-
-	/* Hook into the vector table. */
-	vectab[vec] = intrhand_vectored;
-}
-
-/*
  * Return a pointer to the evcnt structure for
  * the specified ipl.
  */
@@ -223,25 +176,6 @@ isrlink_evcnt(int ipl)
 }
 
 /*
- * Unhook a vectored interrupt.
- */
-void
-isrunlink_vectored(int vec)
-{
-
-#ifdef DIAGNOSTIC
-	if ((vec < ISRVECTORED) || (vec >= ISRVECTORED + NISRVECTORED))
-		panic("isrunlink_vectored: bad vec 0x%x", vec);
-
-	if (vectab[vec] != intrhand_vectored)
-		panic("isrunlink_vectored: not vectored interrupt");
-#endif
-
-	vectab[vec] = badtrap;
-	memset(&isr_vectored[vec - ISRVECTORED], 0, sizeof(struct isr_vectored));
-}
-
-/*
  * This is the dispatcher called by the low-level
  * assembly language autovectored interrupt routine.
  */
@@ -345,47 +279,6 @@ cpu_intr_p(void)
 	return idepth != 0;
 }
 
-/*
- * This is the dispatcher called by the low-level
- * assembly language vectored interrupt routine.
- */
-void
-isrdispatch_vectored(int ipl, struct clockframe *frame)
-{
-	struct isr_vectored *isr;
-	int vec;
-
-	vec = (frame->vec >> 2) - ISRVECTORED;
-
-#ifdef DIAGNOSTIC
-	if ((vec < 0) || (vec >= NISRVECTORED))
-		panic("isrdispatch_vectored: bad vec 0x%x", frame->vec);
-#endif
-
-	isr = &isr_vectored[vec];
-
-	intrcnt[ipl]++; /* XXXSCW: Will go away soon */
-	next68k_irq_evcnt[ipl].ev_count++;
-	curcpu()->ci_data.cpu_nintr++;
-
-	if (isr->isr_func == NULL) {
-		printf("isrdispatch_vectored: no handler for vec 0x%x\n",
-		    frame->vec);
-		vectab[vec + ISRVECTORED] = badtrap;
-		return;
-	}
-
-	/*
-	 * Handler gets exception frame if argument is NULL.
-	 */
-	if ((*isr->isr_func)(isr->isr_arg ? isr->isr_arg : frame) == 0)
-		printf("isrdispatch_vectored: vec 0x%x not claimed\n",
-		    frame->vec);
-	else
-	if (isr->isr_evcnt)
-		isr->isr_evcnt->ev_count++;
-}
-
 #if 0
 /* ARGSUSED */
 static int

Index: src/sys/arch/next68k/next68k/isr.h
diff -u src/sys/arch/next68k/next68k/isr.h:1.8 src/sys/arch/next68k/next68k/isr.h:1.9
--- src/sys/arch/next68k/next68k/isr.h:1.8	Sun Dec  5 04:54:21 2021
+++ src/sys/arch/next68k/next68k/isr.h	Sat Jan 13 21:40:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: isr.h,v 1.8 2021/12/05 04:54:21 msaitoh Exp $ */
+/*	$NetBSD: isr.h,v 1.9 2024/01/13 21:40:54 thorpej Exp $ */
 
 /*
  * This file was taken from mvme68k/mvme68k/isr.h
@@ -51,7 +51,6 @@
  * of the vector table.
  */
 #define ISRVECTORED	0x40
-#define NISRVECTORED	192
 
 /*
  * Autovectored interrupt handler cookie.
@@ -92,8 +91,5 @@ extern struct evcnt next68k_irq_evcnt[];
 void	isrinit(void);
 struct	evcnt *isrlink_evcnt(int);
 void	isrlink_autovec(int (*)(void *), void *, int, int, struct evcnt *);
-void	isrlink_vectored(int (*)(void *), void *, int, int, struct evcnt *);
-void	isrunlink_vectored(int);
 void	isrdispatch_autovec(struct clockframe *);
-void	isrdispatch_vectored(int, struct clockframe *);
 void	netintr(void);

Index: src/sys/arch/next68k/next68k/locore.s
diff -u src/sys/arch/next68k/next68k/locore.s:1.80 src/sys/arch/next68k/next68k/locore.s:1.81
--- src/sys/arch/next68k/next68k/locore.s:1.80	Fri Jan 12 23:36:29 2024
+++ src/sys/arch/next68k/next68k/locore.s	Sat Jan 13 21:40:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.80 2024/01/12 23:36:29 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.81 2024/01/13 21:40:54 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1998 Darrin B. Jewell
@@ -125,8 +125,6 @@ GLOBAL(endstack)
 GLOBAL(bgnstack)
 ASLOCAL(tmpstk)
 
-#include <next68k/next68k/vectors.s>
-
 /*
  * Macro to relocate a symbol, used before MMU is enabled.
  * On the NeXT, memory is laid out as in the mach header
@@ -258,41 +256,6 @@ Lis68020:
 	 */
 
 Lstart1:
-	/*
-	 * Now that we know what CPU we have, initialize the address error
-	 * and bus error handlers in the vector table:
-	 *
-	 *	vectab+8	bus error
-	 *	vectab+12	address error
-	 */
-	RELOC(cputype, %a0)
-#if 0
-	/* XXX assembler/linker feature/bug */
-	RELOC(vectab, %a2)
-#else
-	movl	#_C_LABEL(vectab),%a2
-	addl	%a5,%a2
-#endif
-#if defined(M68040)
-	cmpl	#CPU_68040,%a0@		| 68040?
-	jne	1f			| no, skip
-	movl	#_C_LABEL(buserr40),%a2@(8)
-	movl	#_C_LABEL(addrerr4060),%a2@(12)
-	jra	Lstart2
-1:
-#endif
-#if defined(M68020) || defined(M68030)
-	cmpl	#CPU_68040,%a0@		| 68040?
-	jeq	1f			| yes, skip
-	movl	#_C_LABEL(busaddrerr2030),%a2@(8)
-	movl	#_C_LABEL(busaddrerr2030),%a2@(12)
-	jra	Lstart2
-1:
-#endif
-	/* Config botch; no hope. */
-	PANIC("Config botch in locore")
-
-Lstart2:
 /* initialize source/destination control registers for movs */
 	moveq	#FC_USERD,%d0		| user space
 	movc	%d0,%sfc		|   as source
@@ -340,19 +303,8 @@ Lmotommu1:
 	movl	%d1,%a0@(4)		| segtable address
 	pmove	%a0@,%srp		| load the supervisor root pointer
 #endif /* M68030 */
-Lstploaddone:
-
-	/*
-	 * Set up the vector table, and race to get the MMU
-	 * enabled.
-	 */
-
-	movc    %vbr,%d0		| Keep copy of ROM VBR
-	ASRELOC(save_vbr,%a0)
-	movl    %d0,%a0@
-	movl	#_C_LABEL(vectab),%d0	| set Vector Base Register
-	movc	%d0,%vbr
 
+Lstploaddone:
 	RELOC(mmutype, %a0)
 	cmpl	#MMU_68040,%a0@		| 68040?
 	jne	Lmotommu2		| no, skip
@@ -382,6 +334,7 @@ Lturnoffttr:
 	.long	0x4e7b0005		| movc %d0,%itt1
 	.long	0x4e7b0007		| movc %d0,%dtt1
 	jmp	Lenab1
+
 Lmotommu2:
 	pflusha
 	RELOC(prototc, %a2)
@@ -393,10 +346,8 @@ Lmotommu2:
  * Should be running mapped from this point on
  */
 Lenab1:
-	lea	_ASM_LABEL(tmpstk),%sp	| temporary stack
-	bsr     Lpushpc			| Push the PC on the stack.
-Lpushpc:
-
+	lea	_ASM_LABEL(tmpstk),%sp	| re-load temporary stack
+	jbsr	_C_LABEL(vec_init)	| initialize vector table
 /* call final pmap setup */
 	jbsr	_C_LABEL(pmap_bootstrap_finalize)
 /* set kernel stack, user SP */
@@ -697,8 +648,6 @@ Lbrkpt3:
  * For vectored interrupts, we pull the pc, evec, and exception frame
  * and pass them to the vectored interrupt dispatcher.  The vectored
  * interrupt dispatcher will deal with strays.
- *
- * intrhand_vectored is the entry point for vectored interrupts.
  */
 
 ENTRY_NOPROFILE(spurintr)	/* Level 0 */
@@ -730,16 +679,6 @@ ENTRY_NOPROFILE(lev7intr)	/* level 7: pa
 	addql	#8,%sp			| pop SP and stack adjust
 	jra	_ASM_LABEL(rei)		| all done
 
-ENTRY_NOPROFILE(intrhand_vectored)
-	addql	#1,_C_LABEL(interrupt_depth)
-	INTERRUPT_SAVEREG
-	lea	%sp@(16),%a1		| get pointer to frame
-	movl	%a1,%sp@-
-	movw	%sr,%d0
-	bfextu	%d0,21,3,%d0		| Get current ipl
-	movl	%d0,%sp@-		| Push it
-	jbsr	_C_LABEL(isrdispatch_vectored)	| call dispatcher
-	addql	#8,%sp
 Lintrhand_exit:
 	INTERRUPT_RESTOREREG
 	subql	#1,_C_LABEL(interrupt_depth)
@@ -964,7 +903,7 @@ ENTRY_NOPROFILE(doboot)
 	ASRELOC(Ldoboot1, %a0)
 	jmp     %a0@			| jump into physical address space.
 Ldoboot1:
-	ASRELOC(save_vbr, %a0)
+	RELOC(saved_vbr, %a0)
 	movl    %a0@,%d0
 	movc    %d0,%vbr
 
@@ -1022,9 +961,6 @@ GLOBAL(fbbasepa)
 GLOBAL(fblimitpa)
 	.long	MONOTOP		| PA of end of framebuffer
 
-ASLOCAL(save_vbr)		| VBR from ROM
-	.long 0xdeadbeef
-
 GLOBAL(monbootflag)
 	.long 0
 

Added files:

Index: src/sys/arch/next68k/include/vectors.h
diff -u /dev/null src/sys/arch/next68k/include/vectors.h:1.1
--- /dev/null	Sat Jan 13 21:40:54 2024
+++ src/sys/arch/next68k/include/vectors.h	Sat Jan 13 21:40:54 2024
@@ -0,0 +1,50 @@
+/*	$NetBSD: vectors.h,v 1.1 2024/01/13 21:40:54 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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.
+ */
+
+#ifndef _NEXT68K_VECTORS_H_
+#define	_NEXT68K_VECTORS_H_
+
+#ifdef _KERNEL
+
+#include <m68k/vectors.h>
+
+#define	MACHINE_AV0_HANDLER	spurintr
+#define	MACHINE_AV1_HANDLER	intrhand_autovec
+#define	MACHINE_AV2_HANDLER	intrhand_autovec
+#define	MACHINE_AV3_HANDLER	intrhand_autovec
+#define	MACHINE_AV4_HANDLER	intrhand_autovec
+#define	MACHINE_AV5_HANDLER	intrhand_autovec
+#define	MACHINE_AV6_HANDLER	intrhand_autovec
+#define	MACHINE_AV7_HANDLER	lev7intr
+
+#endif /* _KERNEL */
+
+#endif /* _NEXT68K_VECTORS_H_ */

Reply via email to