From 8179ecca63a8f06c6d66c322f6c56e551bee66e2 Mon Sep 17 00:00:00 2001 From: thorpej Date: Tue, 16 Jan 2024 03:44:43 +0000 Subject: [PATCH] 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). --- sys/arch/hp300/conf/files.hp300 | 5 +- sys/arch/hp300/dev/dio.c | 20 +-- sys/arch/hp300/dev/frodo.c | 26 ++-- sys/arch/hp300/hp300/genassym.cf | 6 +- sys/arch/hp300/hp300/intr.c | 225 ------------------------------- sys/arch/hp300/hp300/locore.s | 33 +---- sys/arch/hp300/include/cpu.h | 17 +-- sys/arch/hp300/include/intr.h | 141 ++++++------------- sys/arch/hp300/include/vectors.h | 14 +- 9 files changed, 96 insertions(+), 391 deletions(-) delete mode 100644 sys/arch/hp300/hp300/intr.c diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300 index 23ed96c9cbc2..c562b54d9105 100644 --- a/sys/arch/hp300/conf/files.hp300 +++ b/sys/arch/hp300/conf/files.hp300 @@ -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 diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c index 9730f50f7d0e..97f7671d9865 100644 --- a/sys/arch/hp300/dev/dio.c +++ b/sys/arch/hp300/dev/dio.c @@ -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 -__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 #include @@ -283,13 +283,14 @@ dio_devinfo(struct dio_attach_args *da, char *buf, size_t buflen) * 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 *arg, int ipl, int priority) 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(); } diff --git a/sys/arch/hp300/dev/frodo.c b/sys/arch/hp300/dev/frodo.c index 230944432cbe..3be616218540 100644 --- a/sys/arch/hp300/dev/frodo.c +++ b/sys/arch/hp300/dev/frodo.c @@ -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 -__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 #include @@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.35 2022/11/25 13:12:02 tsutsui Exp $"); 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 (*func)(void *), void *arg, /* 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, int line) /* 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); } diff --git a/sys/arch/hp300/hp300/genassym.cf b/sys/arch/hp300/hp300/genassym.cf index cec3d68ce63c..8b573363d1ae 100644 --- a/sys/arch/hp300/hp300/genassym.cf +++ b/sys/arch/hp300/hp300/genassym.cf @@ -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, p_raslist) 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) diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c deleted file mode 100644 index 0cb1fa774a19..000000000000 --- a/sys/arch/hp300/hp300/intr.c +++ /dev/null @@ -1,225 +0,0 @@ -/* $NetBSD: intr.c,v 1.44 2020/11/18 02:22:16 thorpej Exp $ */ - -/*- - * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass, Gordon W. Ross, and 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. - */ - -/* - * Link and dispatch interrupts. - */ - -#include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.44 2020/11/18 02:22:16 thorpej Exp $"); - -#define _HP300_INTR_H_PRIVATE - -#include -#include -#include -#include -#include -#include - -#include "audio.h" - -/* - * The location and size of the autovectored interrupt portion - * of the vector table. - */ -#define ISRLOC 0x18 -#define NISR 8 - -struct hp300_intr hp300_intr_list[NISR]; -static const char *hp300_intr_names[NISR] = { - "spurious", - "lev1", - "lev2", - "lev3", - "lev4", - "lev5", - "clock", - "nmi", -}; - -const uint16_t ipl2psl_table[NIPL] = { - [IPL_NONE] = 0, - [IPL_SOFTCLOCK] = PSL_S|PSL_IPL1, - [IPL_SOFTNET] = PSL_S|PSL_IPL1, - [IPL_SOFTSERIAL] = PSL_S|PSL_IPL1, - [IPL_SOFTBIO] = PSL_S|PSL_IPL1, - [IPL_VM] = PSL_S|PSL_IPL5, - [IPL_SCHED] = PSL_S|PSL_IPL6, - [IPL_HIGH] = PSL_S|PSL_IPL7, -}; -int idepth; - -void netintr(void); - -void -intr_init(void) -{ - struct hp300_intr *hi; - int i; - - /* Initialize the ISR lists. */ - for (i = 0; i < NISR; ++i) { - hi = &hp300_intr_list[i]; - LIST_INIT(&hi->hi_q); - evcnt_attach_dynamic(&hi->hi_evcnt, EVCNT_TYPE_INTR, - NULL, hp300_intr_names[i], "intr"); - } - -} - -/* - * Establish an interrupt handler. - * Called by driver attach functions. - */ -void * -intr_establish(int (*func)(void *), void *arg, int ipl, int priority) -{ - struct hp300_intrhand *newih, *curih; - - if ((ipl < 0) || (ipl >= NISR)) - panic("intr_establish: bad ipl %d", ipl); - - newih = kmem_alloc(sizeof(*newih), KM_SLEEP); - newih->ih_fn = func; - newih->ih_arg = arg; - newih->ih_ipl = ipl; - newih->ih_priority = priority; - - /* - * Some devices are particularly sensitive to interrupt - * handling latency. The DCA, for example, can lose many - * characters if its interrupt isn't handled with reasonable - * speed. For this reason, we sort ISRs by IPL_* priority, - * inserting higher priority interrupts before lower priority - * interrupts. - */ - - /* - * Get the appropriate ISR list. If the list is empty, no - * additional work is necessary; we simply insert ourselves - * at the head of the list. - */ - - if (LIST_FIRST(&hp300_intr_list[ipl].hi_q) == NULL) { - LIST_INSERT_HEAD(&hp300_intr_list[ipl].hi_q, newih, ih_q); - goto done; - } - - /* - * A little extra work is required. We traverse the list - * and place ourselves after any ISRs with our current (or - * higher) priority. - */ - - for (curih = LIST_FIRST(&hp300_intr_list[ipl].hi_q); - LIST_NEXT(curih,ih_q) != NULL; - curih = LIST_NEXT(curih,ih_q)) { - if (newih->ih_priority > curih->ih_priority) { - LIST_INSERT_BEFORE(curih, newih, ih_q); - goto done; - } - } - - /* - * We're the least important entry, it seems. We just go - * on the end. - */ - LIST_INSERT_AFTER(curih, newih, ih_q); - - done: - return newih; -} - -/* - * Disestablish an interrupt handler. - */ -void -intr_disestablish(void *arg) -{ - struct hp300_intrhand *ih = arg; - - LIST_REMOVE(ih, ih_q); - kmem_free(ih, sizeof(*ih)); -} - -/* - * This is the dispatcher called by the low-level - * assembly language interrupt routine. - */ -void -intr_dispatch(int evec /* format | vector offset */) -{ - struct hp300_intrhand *ih; - struct hp300_intr *list; - int handled, ipl, vec; - static int straycount, unexpected; - - vec = (evec & 0xfff) >> 2; -#ifdef DIAGNOSTIC - if ((vec < ISRLOC) || (vec >= (ISRLOC + NISR))) - panic("intr_dispatch: bad vec 0x%x", vec); -#endif - ipl = vec - ISRLOC; - - hp300_intr_list[ipl].hi_evcnt.ev_count++; - curcpu()->ci_data.cpu_nintr++; - - list = &hp300_intr_list[ipl]; - if (LIST_FIRST(&list->hi_q) == NULL) { - if (ipl != 6) { - printf("intr_dispatch: ipl %d unexpected\n", ipl); - if (++unexpected > 10) - panic("intr_dispatch:" - " too many unexpected interrupts"); - } - return; - } - - handled = 0; - /* Give all the handlers a chance. */ - for (ih = LIST_FIRST(&list->hi_q) ; ih != NULL; - ih = LIST_NEXT(ih, ih_q)) - handled |= (*ih->ih_fn)(ih->ih_arg); - -#if NAUDIO > 0 - /* hardclock() on ipl 6 is already handled in locore.s */ - if (ipl == 6) - return; -#endif - - if (handled) - straycount = 0; - else if (++straycount > 50) - panic("intr_dispatch: too many stray interrupts"); - else - printf("intr_dispatch: stray level %d interrupt\n", ipl); -} diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index d5bb42dd1329..707fe9c88ded 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -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 diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h index 3a5414e85832..85344fb4547f 100644 --- a/sys/arch/hp300/include/cpu.h +++ b/sys/arch/hp300/include/cpu.h @@ -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) diff --git a/sys/arch/hp300/include/intr.h b/sys/arch/hp300/include/intr.h index 864973a711cb..69113f3600c6 100644 --- a/sys/arch/hp300/include/intr.h +++ b/sys/arch/hp300/include/intr.h @@ -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 +#include -#include -#include -#include +#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 -#include +#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 +#define MACHINE_AUTOVEC_IGNORE_STRAY(x) ((x) == 6) +#endif +#endif -/* - * 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; - -static inline bool -cpu_intr_p(void) -{ - - return idepth != 0; -} - -extern const uint16_t ipl2psl_table[NIPL]; - -typedef int ipl_t; -typedef struct { - uint16_t _psl; -} ipl_cookie_t; - -#ifdef _KERNEL - -static inline ipl_cookie_t -makeiplcookie(ipl_t ipl) -{ - - return (ipl_cookie_t){._psl = ipl2psl_table[ipl]}; -} - -static inline int -splraiseipl(ipl_cookie_t icookie) -{ - - return _splraise(icookie._psl); -} - -static inline void -splx(int sr) -{ - - __asm volatile("movew %0,%%sr" : : "di" (sr)); -} +#include /* 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() +/* + * Interface wrappers. + */ -#define splsoftbio() splraise1() -#define splsoftclock() splraise1() -#define splsoftnet() splraise1() -#define splsoftserial() splraise1() -#define splvm() splraise5() -#define splsched() spl6() -#define splhigh() spl7() +static inline void +intr_init(void) +{ + m68k_intr_init(NULL); +} -struct hp300_intrhand { - LIST_ENTRY(hp300_intrhand) ih_q; - int (*ih_fn)(void *); - void *ih_arg; - int ih_ipl; - int ih_priority; -}; +static inline void * +intr_establish(int (*func)(void *), void *arg, int ipl, int isrpri) +{ + return m68k_intr_establish(func, arg, (void *)0, 0, ipl, isrpri, 0); +} -struct hp300_intr { - LIST_HEAD(, hp300_intrhand) hi_q; - struct evcnt hi_evcnt; -}; +static inline void +intr_disestablish(void *ih) +{ + m68k_intr_disestablish(ih); +} -/* 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 */ diff --git a/sys/arch/hp300/include/vectors.h b/sys/arch/hp300/include/vectors.h index fe8a4d92b730..dc0aa6aa02b2 100644 --- a/sys/arch/hp300/include/vectors.h +++ b/sys/arch/hp300/include/vectors.h @@ -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 -#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