Module Name: src Committed By: thorpej Date: Tue Jan 16 03:44:44 UTC 2024
Modified Files: src/sys/arch/hp300/conf: files.hp300 src/sys/arch/hp300/dev: dio.c frodo.c src/sys/arch/hp300/hp300: genassym.cf locore.s src/sys/arch/hp300/include: cpu.h intr.h vectors.h Removed Files: src/sys/arch/hp300/hp300: intr.c Log Message: Switch hp300 over to the common interrupt dispatch code. XXX There are still some things to fix up here, but it's no worse than it was before (the problems date back to when we flattened the device interrupt levels into IPL_VM). To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/sys/arch/hp300/conf/files.hp300 cvs rdiff -u -r1.41 -r1.42 src/sys/arch/hp300/dev/dio.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/hp300/dev/frodo.c cvs rdiff -u -r1.50 -r1.51 src/sys/arch/hp300/hp300/genassym.cf cvs rdiff -u -r1.44 -r0 src/sys/arch/hp300/hp300/intr.c cvs rdiff -u -r1.180 -r1.181 src/sys/arch/hp300/hp300/locore.s cvs rdiff -u -r1.75 -r1.76 src/sys/arch/hp300/include/cpu.h cvs rdiff -u -r1.36 -r1.37 src/sys/arch/hp300/include/intr.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hp300/include/vectors.h 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/files.hp300 diff -u src/sys/arch/hp300/conf/files.hp300:1.94 src/sys/arch/hp300/conf/files.hp300:1.95 --- src/sys/arch/hp300/conf/files.hp300:1.94 Sat Jan 13 19:20:26 2024 +++ src/sys/arch/hp300/conf/files.hp300 Tue Jan 16 03:44:43 2024 @@ -1,4 +1,4 @@ -# $NetBSD: files.hp300,v 1.94 2024/01/13 19:20:26 thorpej Exp $ +# $NetBSD: files.hp300,v 1.95 2024/01/16 03:44:43 thorpej Exp $ # # hp300-specific configuration info @@ -210,7 +210,6 @@ file arch/hp300/hp300/bus_space.c file arch/hp300/hp300/clock.c file arch/hp300/hp300/dkbad.c file arch/hp300/hp300/machdep.c -file arch/hp300/hp300/intr.c file arch/hp300/hp300/leds.c useleds file arch/hp300/hp300/pmap_bootstrap.c compile-with "${NOPROF_C}" file arch/hp300/hp300/trap.c @@ -219,6 +218,8 @@ file arch/m68k/m68k/cacheops.c file arch/m68k/m68k/db_memrw.c ddb | kgdb file arch/m68k/m68k/fpu.c compile-with "${M68K_KERN_FPU}" file arch/m68k/m68k/kgdb_machdep.c kgdb +file arch/m68k/m68k/m68k_intr.c +file arch/m68k/m68k/m68k_intr_stubs.s file arch/m68k/m68k/m68k_trap.c file arch/m68k/m68k/mmu_subr.s file arch/m68k/m68k/pmap_motorola.c Index: src/sys/arch/hp300/dev/dio.c diff -u src/sys/arch/hp300/dev/dio.c:1.41 src/sys/arch/hp300/dev/dio.c:1.42 --- src/sys/arch/hp300/dev/dio.c:1.41 Sat Aug 7 16:18:53 2021 +++ src/sys/arch/hp300/dev/dio.c Tue Jan 16 03:44:43 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dio.c,v 1.41 2021/08/07 16:18:53 thorpej Exp $ */ +/* $NetBSD: dio.c,v 1.42 2024/01/16 03:44:43 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -34,9 +34,9 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dio.c,v 1.41 2021/08/07 16:18:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dio.c,v 1.42 2024/01/16 03:44:43 thorpej Exp $"); -#define _HP300_INTR_H_PRIVATE +#define _M68K_INTR_PRIVATE #include <sys/param.h> #include <sys/systm.h> @@ -283,13 +283,14 @@ dio_devinfo(struct dio_attach_args *da, * Establish an interrupt handler for a DIO device. */ void * -dio_intr_establish(int (*func)(void *), void *arg, int ipl, int priority) +dio_intr_establish(int (*func)(void *), void *arg, int ipl, int isrpri) { void *ih; - ih = intr_establish(func, arg, ipl, priority); + ih = intr_establish(func, arg, ipl, isrpri); - if (priority == IPL_BIO) + /* XXX XXX XXX */ + if (isrpri == IPL_BIO) dmacomputeipl(); return ih; @@ -301,12 +302,13 @@ dio_intr_establish(int (*func)(void *), void dio_intr_disestablish(void *arg) { - struct hp300_intrhand *ih = arg; - int priority = ih->ih_priority; + struct m68k_intrhand *ih = arg; + int isrpri = ih->ih_isrpri; intr_disestablish(arg); - if (priority == IPL_BIO) + /* XXX XXX XXX */ + if (isrpri == IPL_BIO) dmacomputeipl(); } Index: src/sys/arch/hp300/dev/frodo.c diff -u src/sys/arch/hp300/dev/frodo.c:1.35 src/sys/arch/hp300/dev/frodo.c:1.36 --- src/sys/arch/hp300/dev/frodo.c:1.35 Fri Nov 25 13:12:02 2022 +++ src/sys/arch/hp300/dev/frodo.c Tue Jan 16 03:44:43 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: frodo.c,v 1.35 2022/11/25 13:12:02 tsutsui Exp $ */ +/* $NetBSD: frodo.c,v 1.36 2024/01/16 03:44:43 thorpej Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. @@ -60,9 +60,9 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.35 2022/11/25 13:12:02 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.36 2024/01/16 03:44:43 thorpej Exp $"); -#define _HP300_INTR_H_PRIVATE +#define _M68K_INTR_PRIVATE #include <sys/param.h> #include <sys/systm.h> @@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1. struct frodo_interhand { int (*ih_fn)(void *); void *ih_arg; - int ih_priority; + int ih_isrpri; }; struct frodo_softc { @@ -237,10 +237,10 @@ frodoprint(void *aux, const char *pnp) void frodo_intr_establish(device_t frdev, int (*func)(void *), void *arg, - int line, int priority) + int line, int isrpri) { struct frodo_softc *sc = device_private(frdev); - struct hp300_intrhand *ih = sc->sc_ih; + struct m68k_intrhand *ih = sc->sc_ih; if (line < 0 || line >= FRODO_NINTR) { aprint_error_dev(frdev, "bad interrupt line %d\n", line); @@ -255,17 +255,17 @@ frodo_intr_establish(device_t frdev, int /* Install the handler. */ sc->sc_intr[line].ih_fn = func; sc->sc_intr[line].ih_arg = arg; - sc->sc_intr[line].ih_priority = priority; + sc->sc_intr[line].ih_isrpri = isrpri; /* * If this is the first one, establish the frodo * interrupt handler. If not, reestablish at a * higher priority if necessary. */ - if (ih == NULL || ih->ih_priority < priority) { + if (ih == NULL || ih->ih_isrpri < isrpri) { if (ih != NULL) intr_disestablish(ih); - sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, priority); + sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, isrpri); } sc->sc_refcnt++; @@ -281,7 +281,7 @@ void frodo_intr_disestablish(device_t frdev, int line) { struct frodo_softc *sc = device_private(frdev); - struct hp300_intrhand *ih = sc->sc_ih; + struct m68k_intrhand *ih = sc->sc_ih; int newpri; if (sc->sc_intr[line].ih_fn == NULL) { @@ -302,10 +302,10 @@ frodo_intr_disestablish(device_t frdev, /* Lower our priority, if appropriate. */ for (newpri = 0, line = 0; line < FRODO_NINTR; line++) if (sc->sc_intr[line].ih_fn != NULL && - sc->sc_intr[line].ih_priority > newpri) - newpri = sc->sc_intr[line].ih_priority; + sc->sc_intr[line].ih_isrpri > newpri) + newpri = sc->sc_intr[line].ih_isrpri; - if (newpri != ih->ih_priority) { + if (newpri != ih->ih_isrpri) { intr_disestablish(ih); sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, newpri); } Index: src/sys/arch/hp300/hp300/genassym.cf diff -u src/sys/arch/hp300/hp300/genassym.cf:1.50 src/sys/arch/hp300/hp300/genassym.cf:1.51 --- src/sys/arch/hp300/hp300/genassym.cf:1.50 Wed Dec 27 17:35:34 2023 +++ src/sys/arch/hp300/hp300/genassym.cf Tue Jan 16 03:44:44 2024 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.50 2023/12/27 17:35:34 thorpej Exp $ +# $NetBSD: genassym.cf,v 1.51 2024/01/16 03:44:44 thorpej Exp $ # # Copyright (c) 1982, 1990, 1993 @@ -157,8 +157,8 @@ define P_RASLIST offsetof(struct proc, define P_VMSPACE offsetof(struct proc, p_vmspace) # interrupt event counters -define HI_EVCNT offsetof(struct hp300_intr, hi_evcnt) -define SIZEOF_HI sizeof(struct hp300_intr) +define SIZEOF_EVCNT sizeof(struct evcnt) +define EV_COUNT offsetof(struct evcnt, ev_count) # interrupt/fault metering define CI_NINTR offsetof(struct cpu_info, ci_data.cpu_nintr) Index: src/sys/arch/hp300/hp300/locore.s diff -u src/sys/arch/hp300/hp300/locore.s:1.180 src/sys/arch/hp300/hp300/locore.s:1.181 --- src/sys/arch/hp300/hp300/locore.s:1.180 Sat Jan 13 19:20:26 2024 +++ src/sys/arch/hp300/hp300/locore.s Tue Jan 16 03:44:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.180 2024/01/13 19:20:26 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.181 2024/01/16 03:44:44 thorpej Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -798,7 +798,7 @@ Lbrkpt3: /* 64-bit evcnt counter increments */ #define EVCNT_COUNTER(ipl) \ - _C_LABEL(hp300_intr_list) + (ipl)*SIZEOF_HI + HI_EVCNT + _C_LABEL(m68k_intr_evcnt) + (ipl)*SIZEOF_EVCNT + EV_COUNT #define EVCNT_INCREMENT(ipl) \ clrl %d0; \ addql #1,EVCNT_COUNTER(ipl)+4; \ @@ -806,24 +806,6 @@ Lbrkpt3: addxl %d0,%d1; \ movel %d1,EVCNT_COUNTER(ipl) -ENTRY_NOPROFILE(spurintr) /* level 0 */ - INTERRUPT_SAVEREG - EVCNT_INCREMENT(0) - CPUINFO_INCREMENT(CI_NINTR) - INTERRUPT_RESTOREREG - jra _ASM_LABEL(rei) - -ENTRY_NOPROFILE(intrhand) /* levels 1 through 5 */ - addql #1,_C_LABEL(idepth) | entering interrupt - INTERRUPT_SAVEREG - movw %sp@(22),%sp@- | push exception vector info - clrw %sp@- - jbsr _C_LABEL(intr_dispatch) | call dispatch routine - addql #4,%sp - INTERRUPT_RESTOREREG - subql #1,_C_LABEL(idepth) | exiting from interrupt - jra _ASM_LABEL(rei) | all done - ENTRY_NOPROFILE(lev6intr) /* level 6: clock */ addql #1,_C_LABEL(idepth) | entering interrupt INTERRUPT_SAVEREG @@ -839,7 +821,7 @@ Lnotim1: btst #2,%d0 | timer3 interrupt? jeq Lnotim3 | no, skip statclock movpw %a0@(CLKMSB3),%d1 | clear timer3 interrupt - lea %sp@(16),%a1 | a1 = &clockframe + lea %sp@(0),%a1 | a1 = &clockframe movl %d0,%sp@- | save status movl %a1,%sp@- jbsr _C_LABEL(statintr) | statintr(&frame) @@ -850,7 +832,7 @@ Lnotim3: btst #0,%d0 | timer1 interrupt? jeq Lrecheck | no, skip hardclock EVCNT_INCREMENT(6) - lea %sp@(16),%a1 | a1 = &clockframe + lea %sp@(0),%a1 | a1 = &clockframe movl %a1,%sp@- #ifdef USELEDS tstl _C_LABEL(ledaddr) | using LEDs? @@ -889,10 +871,9 @@ Lrecheck: movb %a0@(CLKSR),%d0 | see if anything happened jmi Lclkagain | while we were in hardclock/statintr #if NAUDIO >0 - movw %sp@(22),%sp@- | push exception vector info - clrw %sp@- - jbsr _C_LABEL(intr_dispatch) | call dispatch routine - addql #4,%sp + jbsr _C_LABEL(m68k_intr_autovec) | call dispatch routine + | in case the audio device + | generated the interrupt #endif INTERRUPT_RESTOREREG subql #1,_C_LABEL(idepth) | exiting from interrupt Index: src/sys/arch/hp300/include/cpu.h diff -u src/sys/arch/hp300/include/cpu.h:1.75 src/sys/arch/hp300/include/cpu.h:1.76 --- src/sys/arch/hp300/include/cpu.h:1.75 Sat Jan 13 19:20:26 2024 +++ src/sys/arch/hp300/include/cpu.h Tue Jan 16 03:44:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.75 2024/01/13 19:20:26 thorpej Exp $ */ +/* $NetBSD: cpu.h,v 1.76 2024/01/16 03:44:44 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -64,16 +64,17 @@ /* * Arguments to hardclock and gatherstats encapsulate the previous * machine state in an opaque clockframe. On the hp300, we use - * what the hardware pushes on an interrupt (frame format 0). + * what the locore.s glue puts on the stack before calling C-code. */ struct clockframe { - u_short sr; /* sr at time of interrupt */ - u_long pc; /* pc at time of interrupt */ - u_short vo; /* vector offset (4-word frame) */ -}; + u_int cf_regs[4]; /* d0,d1,a0,a1 */ + u_short cf_sr; /* sr at time of interrupt */ + u_long cf_pc; /* pc at time of interrupt */ + u_short cf_vo; /* vector offset (4-word frame) */ +} __attribute__((packed)); -#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) -#define CLKF_PC(framep) ((framep)->pc) +#define CLKF_USERMODE(framep) (((framep)->cf_sr & PSL_S) == 0) +#define CLKF_PC(framep) ((framep)->cf_pc) #if 0 /* We would like to do it this way... */ #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) Index: src/sys/arch/hp300/include/intr.h diff -u src/sys/arch/hp300/include/intr.h:1.36 src/sys/arch/hp300/include/intr.h:1.37 --- src/sys/arch/hp300/include/intr.h:1.36 Tue Jul 11 17:54:54 2023 +++ src/sys/arch/hp300/include/intr.h Tue Jan 16 03:44:44 2024 @@ -1,7 +1,7 @@ -/* $NetBSD: intr.h,v 1.36 2023/07/11 17:54:54 riastradh Exp $ */ +/* $NetBSD: intr.h,v 1.37 2024/01/16 03:44:44 thorpej Exp $ */ /*- - * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc. + * Copyright (c) 2024 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -30,115 +30,60 @@ */ #ifndef _HP300_INTR_H_ -#define _HP300_INTR_H_ +#define _HP300_INTR_H_ -#include <sys/types.h> - -#include <sys/evcnt.h> -#include <sys/queue.h> -#include <sys/stdbool.h> - -#include <machine/psl.h> +#include <m68k/psl.h> +#define MACHINE_PSL_IPL_SOFTCLOCK PSL_IPL1 +#define MACHINE_PSL_IPL_SOFTBIO PSL_IPL1 +#define MACHINE_PSL_IPL_SOFTNET PSL_IPL1 +#define MACHINE_PSL_IPL_SOFTSERIAL PSL_IPL1 +#define MACHINE_PSL_IPL_VM PSL_IPL5 +#define MACHINE_PSL_IPL_SCHED PSL_IPL6 + +#define MACHINE_INTREVCNT_NAMES \ + { "spurious", "lev1", "lev2", "lev3", "lev4", "lev5", "clock", "nmi" } + +#if defined(_M68K_INTR_PRIVATE) && defined(_KERNEL_OPT) +#include "audio.h" +#if NAUDIO > 0 /* - * Interrupt "levels". These are a more abstract representation - * of interrupt levels, and do not have the same meaning as m68k - * CPU interrupt levels. They serve the following purposes: - * - * - properly order ISRs in the list for that CPU ipl - * - compute CPU PSL values for the spl*() calls. - * - used to create cookie for the splraiseipl(). + * Audio interrupts also come in on level 6, and those are dispatched + * from a custom stub which handles the clock inline before calling the + * general interrupt dispatch. We want to suppress warning about stray + * level 6 interrupts in the common code in case the clock interrupted + * but audio did not. */ -#define IPL_NONE 0 -#define IPL_SOFTCLOCK 1 -#define IPL_SOFTBIO 2 -#define IPL_SOFTNET 3 -#define IPL_SOFTSERIAL 4 -#define IPL_VM 5 -#define IPL_SCHED 6 -#define IPL_HIGH 7 -#define NIPL 8 - -/* - * Convert PSL values to m68k CPU IPLs and vice-versa. - * Note: CPU IPL values are different from IPL_* used by splraiseipl(). - */ -#define PSLTOIPL(x) (((x) >> 8) & 0xf) -#define IPLTOPSL(x) ((((x) & 0xf) << 8) | PSL_S) - -extern int idepth; +#define MACHINE_AUTOVEC_IGNORE_STRAY(x) ((x) == 6) +#endif +#endif -static inline bool -cpu_intr_p(void) -{ - - return idepth != 0; -} - -extern const uint16_t ipl2psl_table[NIPL]; +#include <m68k/intr.h> -typedef int ipl_t; -typedef struct { - uint16_t _psl; -} ipl_cookie_t; +/* These spl calls are _not_ to be used by machine-independent code. */ +#define splhil() splraise1() +#define splkbd() splhil() -#ifdef _KERNEL +/* + * Interface wrappers. + */ -static inline ipl_cookie_t -makeiplcookie(ipl_t ipl) +static inline void +intr_init(void) { - - return (ipl_cookie_t){._psl = ipl2psl_table[ipl]}; + m68k_intr_init(NULL); } -static inline int -splraiseipl(ipl_cookie_t icookie) +static inline void * +intr_establish(int (*func)(void *), void *arg, int ipl, int isrpri) { - - return _splraise(icookie._psl); + return m68k_intr_establish(func, arg, (void *)0, 0, ipl, isrpri, 0); } static inline void -splx(int sr) +intr_disestablish(void *ih) { - - __asm volatile("movew %0,%%sr" : : "di" (sr)); + m68k_intr_disestablish(ih); } -/* These spl calls are _not_ to be used by machine-independent code. */ -#define splhil() splraise1() -#define splkbd() splhil() - -/* These spl calls are used by machine-independent code. */ -#define spl0() _spl0() - -#define splsoftbio() splraise1() -#define splsoftclock() splraise1() -#define splsoftnet() splraise1() -#define splsoftserial() splraise1() -#define splvm() splraise5() -#define splsched() spl6() -#define splhigh() spl7() - -struct hp300_intrhand { - LIST_ENTRY(hp300_intrhand) ih_q; - int (*ih_fn)(void *); - void *ih_arg; - int ih_ipl; - int ih_priority; -}; - -struct hp300_intr { - LIST_HEAD(, hp300_intrhand) hi_q; - struct evcnt hi_evcnt; -}; - -/* intr.c */ -void intr_init(void); -void *intr_establish(int (*)(void *), void *, int, int); -void intr_disestablish(void *); -void intr_dispatch(int); - -#endif /* _KERNEL */ - -#endif /* _HP300_INTR_H_ */ +#endif /* _HP300_INTR_H */ Index: src/sys/arch/hp300/include/vectors.h diff -u src/sys/arch/hp300/include/vectors.h:1.1 src/sys/arch/hp300/include/vectors.h:1.2 --- src/sys/arch/hp300/include/vectors.h:1.1 Sat Jan 13 19:20:26 2024 +++ src/sys/arch/hp300/include/vectors.h Tue Jan 16 03:44:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: vectors.h,v 1.1 2024/01/13 19:20:26 thorpej Exp $ */ +/* $NetBSD: vectors.h,v 1.2 2024/01/16 03:44:44 thorpej Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -36,12 +36,12 @@ #include <m68k/vectors.h> -#define MACHINE_AV0_HANDLER spurintr -#define MACHINE_AV1_HANDLER intrhand -#define MACHINE_AV2_HANDLER intrhand -#define MACHINE_AV3_HANDLER intrhand -#define MACHINE_AV4_HANDLER intrhand -#define MACHINE_AV5_HANDLER intrhand +#define MACHINE_AV0_HANDLER intrstub_autovec +#define MACHINE_AV1_HANDLER intrstub_autovec +#define MACHINE_AV2_HANDLER intrstub_autovec +#define MACHINE_AV3_HANDLER intrstub_autovec +#define MACHINE_AV4_HANDLER intrstub_autovec +#define MACHINE_AV5_HANDLER intrstub_autovec #define MACHINE_AV6_HANDLER lev6intr #define MACHINE_AV7_HANDLER lev7intr