Module Name: src Committed By: thorpej Date: Sat Jan 13 23:59:47 UTC 2024
Modified Files: src/sys/arch/news68k/conf: files.news68k src/sys/arch/news68k/include: cpu.h src/sys/arch/news68k/news68k: isr.c isr.h locore.s Added Files: src/sys/arch/news68k/include: vectors.h Removed Files: src/sys/arch/news68k/news68k: vectors.s Log Message: Switch news68k over to the common m68k vector table. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/news68k/conf/files.news68k cvs rdiff -u -r1.48 -r1.49 src/sys/arch/news68k/include/cpu.h cvs rdiff -u -r0 -r1.1 src/sys/arch/news68k/include/vectors.h cvs rdiff -u -r1.23 -r1.24 src/sys/arch/news68k/news68k/isr.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/news68k/news68k/isr.h cvs rdiff -u -r1.78 -r1.79 src/sys/arch/news68k/news68k/locore.s cvs rdiff -u -r1.9 -r0 src/sys/arch/news68k/news68k/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/news68k/conf/files.news68k diff -u src/sys/arch/news68k/conf/files.news68k:1.37 src/sys/arch/news68k/conf/files.news68k:1.38 --- src/sys/arch/news68k/conf/files.news68k:1.37 Tue Jan 9 04:16:26 2024 +++ src/sys/arch/news68k/conf/files.news68k Sat Jan 13 23:59:47 2024 @@ -1,4 +1,4 @@ -# $NetBSD: files.news68k,v 1.37 2024/01/09 04:16:26 thorpej Exp $ +# $NetBSD: files.news68k,v 1.38 2024/01/13 23:59:47 thorpej Exp $ # NEWS68K-specific configuration info @@ -29,6 +29,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 file dev/cons.c Index: src/sys/arch/news68k/include/cpu.h diff -u src/sys/arch/news68k/include/cpu.h:1.48 src/sys/arch/news68k/include/cpu.h:1.49 --- src/sys/arch/news68k/include/cpu.h:1.48 Fri Jan 12 23:36:29 2024 +++ src/sys/arch/news68k/include/cpu.h Sat Jan 13 23:59:47 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.48 2024/01/12 23:36:29 thorpej Exp $ */ +/* $NetBSD: cpu.h,v 1.49 2024/01/13 23:59:47 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -149,15 +149,10 @@ extern u_int intiobase_phys, intiotop_ph extern u_int extiobase_phys, extiotop_phys; extern u_int intrcnt[]; -extern void (*vectab[])(void); extern void *romcallvec; struct frame; -/* locore.s functions */ -void badtrap(void); -void intrhand_vectored(void); - void doboot(int) __attribute__((__noreturn__)); void nmihand(struct frame *); Index: src/sys/arch/news68k/news68k/isr.c diff -u src/sys/arch/news68k/news68k/isr.c:1.23 src/sys/arch/news68k/news68k/isr.c:1.24 --- src/sys/arch/news68k/news68k/isr.c:1.23 Sat Nov 21 17:55:38 2020 +++ src/sys/arch/news68k/news68k/isr.c Sat Jan 13 23:59:47 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: isr.c,v 1.23 2020/11/21 17:55:38 thorpej Exp $ */ +/* $NetBSD: isr.c,v 1.24 2024/01/13 23:59:47 thorpej Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.23 2020/11/21 17:55:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.24 2024/01/13 23:59:47 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,14 +49,16 @@ __KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.23 #include <uvm/uvm_extern.h> +#include <machine/vectors.h> + #include <news68k/news68k/isr.h> -isr_autovec_list_t isr_autovec[NISRAUTOVEC]; -struct isr_vectored isr_vectored[NISRVECTORED]; +isr_autovec_list_t isr_autovec[NAUTOVECTORS]; +struct isr_vectored isr_vectored[NUSERVECTORS]; int idepth; -void set_vector_entry(int, void *); -void *get_vector_entry(int); +extern char badtrap[]; +extern char intrhand_vectored[]; void isrinit(void) @@ -64,7 +66,7 @@ isrinit(void) int i; /* Initialize the autovector lists. */ - for (i = 0; i < NISRAUTOVEC; ++i) { + for (i = 0; i < NAUTOVECTORS; ++i) { LIST_INIT(&isr_autovec[i]); } } @@ -79,7 +81,7 @@ isrlink_autovec(int (*func)(void *), voi struct isr_autovec *newisr, *curisr; isr_autovec_list_t *list; - if ((ipl < 0) || (ipl >= NISRAUTOVEC)) + if ((ipl < 0) || (ipl >= NAUTOVECTORS)) panic("isrlink_autovec: bad ipl %d", ipl); newisr = kmem_alloc(sizeof(*newisr), KM_SLEEP); @@ -144,14 +146,14 @@ isrlink_vectored(int (*func)(void *), vo { struct isr_vectored *isr; - if ((ipl < 0) || (ipl >= NISRAUTOVEC)) + if (ipl < 0 || ipl >= NAUTOVECTORS) panic("isrlink_vectored: bad ipl %d", ipl); - if ((vec < ISRVECTORED) || (vec >= ISRVECTORED + NISRVECTORED)) + if (vec < VECI_USRVEC_START || vec >= NVECTORS) panic("isrlink_vectored: bad vec 0x%x", vec); - isr = &isr_vectored[vec - ISRVECTORED]; + isr = &isr_vectored[vec - VECI_USRVEC_START]; - if ((vectab[vec] != badtrap) || (isr->isr_func != NULL)) + if (vec_get_entry(vec) != badtrap || isr->isr_func != NULL) panic("isrlink_vectored: vec 0x%x not available", vec); /* Fill in the new entry. */ @@ -160,7 +162,7 @@ isrlink_vectored(int (*func)(void *), vo isr->isr_ipl = ipl; /* Hook into the vector table. */ - vectab[vec] = intrhand_vectored; + vec_set_entry(vec, intrhand_vectored); } /* @@ -169,15 +171,14 @@ isrlink_vectored(int (*func)(void *), vo void isrunlink_vectored(int vec) { - - if ((vec < ISRVECTORED) || (vec >= ISRVECTORED + NISRVECTORED)) + if (vec < VECI_USRVEC_START || vec >= NVECTORS) panic("isrunlink_vectored: bad vec 0x%x", vec); - if (vectab[vec] != intrhand_vectored) + if (vec_get_entry(vec) != intrhand_vectored) panic("isrunlink_vectored: not vectored interrupt"); - vectab[vec] = badtrap; - memset(&isr_vectored[vec - ISRVECTORED], 0, + vec_set_entry(vec, badtrap); + memset(&isr_vectored[vec - VECI_USRVEC_START], 0, sizeof(struct isr_vectored)); } @@ -193,10 +194,9 @@ isrdispatch_autovec(int evec) int handled = 0, ipl, vec; static int straycount, unexpected; - vec = (evec & 0xfff) >> 2; - if ((vec < ISRAUTOVEC) || (vec >= (ISRAUTOVEC + NISRAUTOVEC))) - panic("isrdispatch_autovec: bad vec 0x%x", vec); - ipl = vec - ISRAUTOVEC; + vec = VECO_TO_VECI(evec & 0xfff); + KASSERT(vec >= VECI_INTRAV0 && vec <= VECI_INTRAV7); + ipl = vec - VECI_INTRAV0; intrcnt[ipl]++; curcpu()->ci_data.cpu_nintr++; @@ -232,15 +232,15 @@ isrdispatch_vectored(int pc, int evec, v struct isr_vectored *isr; int ipl, vec; - vec = (evec & 0xfff) >> 2; + vec = VECO_TO_VECI(evec & 0xfff); ipl = (getsr() >> 8) & 7; intrcnt[ipl]++; curcpu()->ci_data.cpu_nintr++; - if ((vec < ISRVECTORED) || (vec >= (ISRVECTORED + NISRVECTORED))) + if (vec < VECI_USRVEC_START || vec >= NVECTORS) panic("isrdispatch_vectored: bad vec 0x%x", vec); - isr = &isr_vectored[vec - ISRVECTORED]; + isr = &isr_vectored[vec - VECI_USRVEC_START]; if (isr->isr_func == NULL) { printf("isrdispatch_vectored: no handler for vec 0x%x\n", vec); @@ -258,29 +258,7 @@ isrdispatch_vectored(int pc, int evec, v void isrlink_custom(int level, void *handler) { - - set_vector_entry(ISRAUTOVEC + level, handler); -} - -/* - * XXX - could just kill these... [from sun3] - */ -void -set_vector_entry(int entry, void *handler) -{ - - if ((entry < 0) || (entry >= NVECTORS)) - panic("set_vector_entry: setting vector too high or low"); - vectab[entry] = handler; -} - -void * -get_vector_entry(int entry) -{ - - if ((entry < 0) || (entry >= NVECTORS)) - panic("get_vector_entry: setting vector too high or low"); - return (void *)vectab[entry]; + vec_set_entry(VECI_INTRAV0 + level, handler); } const uint16_t ipl2psl_table[NIPL] = { Index: src/sys/arch/news68k/news68k/isr.h diff -u src/sys/arch/news68k/news68k/isr.h:1.7 src/sys/arch/news68k/news68k/isr.h:1.8 --- src/sys/arch/news68k/news68k/isr.h:1.7 Mon Apr 28 20:23:30 2008 +++ src/sys/arch/news68k/news68k/isr.h Sat Jan 13 23:59:47 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: isr.h,v 1.7 2008/04/28 20:23:30 martin Exp $ */ +/* $NetBSD: isr.h,v 1.8 2024/01/13 23:59:47 thorpej Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -32,22 +32,6 @@ #include <sys/queue.h> /* - * The location and size of the autovectored interrupt portion - * of the vector table. - */ -#define ISRAUTOVEC 0x18 -#define NISRAUTOVEC 8 - -#define NVECTORS (ISRAUTOVEC + NISRAUTOVEC) - -/* - * The location and size of the vectored interrupt portion - * of the vector table. - */ -#define ISRVECTORED 0x40 -#define NISRVECTORED 192 - -/* * Autovectored interrupt handler cookie. */ struct isr_autovec { Index: src/sys/arch/news68k/news68k/locore.s diff -u src/sys/arch/news68k/news68k/locore.s:1.78 src/sys/arch/news68k/news68k/locore.s:1.79 --- src/sys/arch/news68k/news68k/locore.s:1.78 Fri Jan 12 23:36:29 2024 +++ src/sys/arch/news68k/news68k/locore.s Sat Jan 13 23:59:47 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.78 2024/01/12 23:36:29 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.79 2024/01/13 23:59:47 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -67,15 +67,9 @@ .space PAGE_SIZE ASLOCAL(tmpstk) -ASLOCAL(monitor_vbr) - .long 0 - ASLOCAL(monitor) .long 0 -#include <news68k/news68k/vectors.s> - - /* * Macro to relocate a symbol, used before MMU is enabled. */ @@ -254,11 +248,6 @@ Lnot1200: movl #CTRL_LED1700,%a0@ | CTRL_LED port for news1700 Lcom030: - RELOC(vectab,%a0) - RELOC(busaddrerr2030,%a1) - movl %a1,%a0@(8) - movl %a1,%a0@(12) - movl %d4,%d1 addl %a5,%d1 moveq #PGSHIFT,%d2 @@ -341,12 +330,6 @@ Lstart2: * Enable the MMU. * Since the kernel is mapped logical == physical, we just turn it on. */ - movc %vbr,%d0 | Preserve monitor's VBR address - movl %d0,_ASM_LABEL(monitor_vbr) - - movl #_C_LABEL(vectab),%d0 | get our VBR address - movc %d0,%vbr - RELOC(Sysseg_pa, %a0) | system segment table addr movl %a0@,%d1 | read value (a PA) RELOC(mmutype, %a0) @@ -392,7 +375,8 @@ Lmotommu2: * Should be running mapped from this point on */ Lenab1: - lea _ASM_LABEL(tmpstk),%sp | temporary stack + 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 */ @@ -925,7 +909,7 @@ Lnocache5: movl _C_LABEL(bootdev),%d6 | load bootdev movl %sp@(4),%d2 | arg movl _C_LABEL(ctrl_power),%a0| CTRL_POWER port - movl _ASM_LABEL(monitor_vbr),%d3 | Fetch original VBR value + movl _C_LABEL(saved_vbr),%d3 | Fetch original VBR value lea _ASM_LABEL(tmpstk),%sp | physical SP in case of NMI movl #0,%a7@- | value for pmove to TC (turn off MMU) pmove %a7@,%tc | disable MMU Added files: Index: src/sys/arch/news68k/include/vectors.h diff -u /dev/null src/sys/arch/news68k/include/vectors.h:1.1 --- /dev/null Sat Jan 13 23:59:47 2024 +++ src/sys/arch/news68k/include/vectors.h Sat Jan 13 23:59:47 2024 @@ -0,0 +1,50 @@ +/* $NetBSD: vectors.h,v 1.1 2024/01/13 23:59:47 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 _NEWS68K_VECTORS_H_ +#define _NEWS68K_VECTORS_H_ + +#ifdef _KERNEL + +#include <m68k/vectors.h> + +#define MACHINE_AV0_HANDLER spurintr +#define MACHINE_AV1_HANDLER lev1intr +#define MACHINE_AV2_HANDLER intrhand_autovec +#define MACHINE_AV3_HANDLER lev3intr +#define MACHINE_AV4_HANDLER lev4intr +#define MACHINE_AV5_HANDLER intrhand_autovec +#define MACHINE_AV6_HANDLER intrhand_autovec +#define MACHINE_AV7_HANDLER intrhand_autovec + +#endif /* _KERNEL */ + +#endif /* _NEWS68K_VECTORS_H_ */