diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-26 21:21:29 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-26 21:21:29 +0000 |
commit | 5382705f9a2199c8dd490a0ac41b017d64b3743f (patch) | |
tree | 9517faaf4c7ba66f21314d16609b29cce6675d3d | |
parent | 4157921535281a74d8ad3b91b803cdead55d4792 (diff) |
More interrupt system cleaning and homogenization:
- switch all interrupt functions to an int (*)(void *) prototype.
- do not register dummy functions for all unhandled interrupts, instead
let the dispatchers cope with NULL.
- add evcount interrupt counters.
-rw-r--r-- | sys/arch/mac68k/dev/adb_direct.c | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/esp.c | 10 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_mv.c | 68 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_ae.c | 13 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_ae_nubus.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_aevar.h | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn.c | 15 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_nubus.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_obio.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_snvar.h | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/ite.c | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/mac68k5380.c | 27 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/zs.c | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/include/intr.h | 20 | ||||
-rw-r--r-- | sys/arch/mac68k/include/viareg.h | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/clock.c | 13 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/intr.c | 108 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/locore.s | 23 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/macrom.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/macrom.h | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/psc.c | 10 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/via.c | 390 |
22 files changed, 392 insertions, 361 deletions
diff --git a/sys/arch/mac68k/dev/adb_direct.c b/sys/arch/mac68k/dev/adb_direct.c index 73214a76ef9..f6f747ca974 100644 --- a/sys/arch/mac68k/dev/adb_direct.c +++ b/sys/arch/mac68k/dev/adb_direct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adb_direct.c,v 1.14 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: adb_direct.c,v 1.15 2004/11/26 21:21:23 miod Exp $ */ /* $NetBSD: adb_direct.c,v 1.5 1997/04/21 18:04:28 scottr Exp $ */ /* From: adb_direct.c 2.02 4/18/97 jpw */ @@ -2152,14 +2152,14 @@ set_adb_info(ADBSetInfoBlock * info, int adbAddr) } #ifndef MRG_ADB -long +int mrg_adbintr(void) { adb_intr(); return 1; /* mimic mrg_adbintr in macrom.h just in case */ } -long +int mrg_pmintr(void) /* we don't do this yet */ { pm_intr(); diff --git a/sys/arch/mac68k/dev/esp.c b/sys/arch/mac68k/dev/esp.c index 5eaf797fe59..927f0a20d38 100644 --- a/sys/arch/mac68k/dev/esp.c +++ b/sys/arch/mac68k/dev/esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esp.c,v 1.17 2003/06/05 12:27:02 deraadt Exp $ */ +/* $OpenBSD: esp.c,v 1.18 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: esp.c,v 1.59 1996/10/13 02:59:48 christos Exp $ */ /* @@ -186,8 +186,8 @@ espattach(parent, self, aux) unsigned long reg_offset; esc->sc_reg = (volatile u_char *) SCSIBase; - via2_register_irq(VIA2_SCSIIRQ, - (void (*)(void *))ncr53c9x_intr, esc); + via2_register_irq(VIA2_SCSIIRQ, ncr53c9x_intr, esc, + self->dv_xname); esc->irq_mask = V2IF_SCSIIRQ; reg_offset = SCSIBase - IOBase; if (reg_offset == 0x10000) { @@ -197,8 +197,8 @@ espattach(parent, self, aux) } } else { esc->sc_reg = (volatile u_char *) SCSIBase + 0x402; - via2_register_irq(VIA2_SCSIDRQ, - (void (*)(void *))ncr53c9x_intr, esc); + via2_register_irq(VIA2_SCSIDRQ, ncr53c9x_intr, esc, + self->dv_xname); esc->irq_mask = V2IF_SCSIDRQ; /* V2IF_T1? */ sc->sc_freq = 25000000; } diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c index 9d9d3dc3098..f68647c0e5d 100644 --- a/sys/arch/mac68k/dev/grf_mv.c +++ b/sys/arch/mac68k/dev/grf_mv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grf_mv.c,v 1.19 2004/01/09 22:55:19 jmc Exp $ */ +/* $OpenBSD: grf_mv.c,v 1.20 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: grf_mv.c,v 1.24 1997/05/03 02:29:54 briggs Exp $ */ /* @@ -53,11 +53,11 @@ static void load_image_data(caddr_t data, struct image_data *image); -static void grfmv_intr_generic(void *vsc, int slot); -static void grfmv_intr_radius(void *vsc, int slot); -static void grfmv_intr_cti(void *vsc, int slot); -static void grfmv_intr_cb264(void *vsc, int slot); -static void grfmv_intr_cb364(void *vsc, int slot); +static int grfmv_intr_generic(void *vsc); +static int grfmv_intr_radius(void *vsc); +static int grfmv_intr_cti(void *vsc); +static int grfmv_intr_cb264(void *vsc); +static int grfmv_intr_cb364(void *vsc); static int grfmv_mode(struct grf_softc *gp, int cmd, void *arg); static caddr_t grfmv_phys(struct grf_softc *gp, vm_offset_t addr); @@ -219,30 +219,37 @@ grfmv_attach(parent, self, aux) case NUBUS_DRHW_TFB: sc->cli_offset = 0xa0000; sc->cli_value = 0; - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_WVC: sc->cli_offset = 0xa00000; sc->cli_value = 0; - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_RPC8XJ: - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_radius, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_radius, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_FIILX: case NUBUS_DRHW_FIISXDSP: sc->cli_offset = 0xF05000; sc->cli_value = 0x80; - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_generic, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_SAM768: - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cti, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cti, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_CB264: - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cb264, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cb264, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_CB364: - add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cb364, sc); + add_nubus_intr(sc->sc_slot.slot, grfmv_intr_cb364, sc, + sc->sc_dev.dv_xname); break; case NUBUS_DRHW_SE30: /* Do nothing--SE/30 interrupts are disabled */ @@ -296,10 +303,8 @@ grfmv_phys(gp, addr) * cards. */ /*ARGSUSED*/ -static void -grfmv_intr_generic(vsc, slot) - void *vsc; - int slot; +static int +grfmv_intr_generic(void *vsc) { struct grfbus_softc *sc; volatile char *slotbase; @@ -307,6 +312,7 @@ grfmv_intr_generic(vsc, slot) sc = (struct grfbus_softc *)vsc; slotbase = (volatile char *)sc->sc_slot.virtual_base; slotbase[sc->cli_offset] = sc->cli_value; + return (1); } /* @@ -315,10 +321,8 @@ grfmv_intr_generic(vsc, slot) * cards. */ /*ARGSUSED*/ -static void -grfmv_intr_radius(vsc, slot) - void *vsc; - int slot; +static int +grfmv_intr_radius(void *vsc) { unsigned char c; struct grfbus_softc *sc; @@ -338,6 +342,7 @@ grfmv_intr_radius(vsc, slot) slotbase[0xD00403] = c; c &= 0x7F; slotbase[0xD00403] = c; + return (1); } /* @@ -350,10 +355,8 @@ grfmv_intr_radius(vsc, slot) * Information for this provided by Brad Salai <bsalai@servtech.com> */ /*ARGSUSED*/ -static void -grfmv_intr_cti(vsc, slot) - void *vsc; - int slot; +static int +grfmv_intr_cti(void *vsc) { struct grfbus_softc *sc; volatile char *slotbase; @@ -362,13 +365,12 @@ grfmv_intr_cti(vsc, slot) slotbase = ((volatile char *)sc->sc_slot.virtual_base) + 0x00080000; *slotbase = (*slotbase | 0x02); *slotbase = (*slotbase & 0xFD); + return (1); } /*ARGSUSED*/ -static void -grfmv_intr_cb264(vsc, slot) - void *vsc; - int slot; +static int +grfmv_intr_cb264(void *vsc) { struct grfbus_softc *sc; volatile char *slotbase; @@ -412,6 +414,7 @@ grfmv_intr_cb264(vsc, slot) _mv_intr_fin: movl #0x1,a0@(0xff6014)" : : "g" (slotbase) : "a0","d0","d1"); + return (1); } /* @@ -420,10 +423,8 @@ grfmv_intr_cb264(vsc, slot) * significantly simplified. Contributions welcome... :-) */ /*ARGSUSED*/ -static void -grfmv_intr_cb364(vsc, slot) - void *vsc; - int slot; +static int +grfmv_intr_cb364(void *vsc) { struct grfbus_softc *sc; volatile char *slotbase; @@ -503,4 +504,5 @@ grfmv_intr_cb364(vsc, slot) movl #0x1,a0@(0xfe6014) _cb364_intr_quit: " : : "g" (slotbase) : "a0","d0","d1","d2"); + return (1); } diff --git a/sys/arch/mac68k/dev/if_ae.c b/sys/arch/mac68k/dev/if_ae.c index 105205d0d95..ea7e5c93169 100644 --- a/sys/arch/mac68k/dev/if_ae.c +++ b/sys/arch/mac68k/dev/if_ae.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ae.c,v 1.23 2004/08/03 12:10:47 todd Exp $ */ +/* $OpenBSD: if_ae.c,v 1.24 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_ae.c,v 1.62 1997/04/24 16:52:05 scottr Exp $ */ /* @@ -585,10 +585,8 @@ loop: } /* Ethernet interface interrupt processor. */ -void -aeintr(arg, slot) - void *arg; - int slot; +int +aeintr(void *arg) { struct ae_softc *sc = (struct ae_softc *)arg; struct ifnet *ifp = &sc->sc_arpcom.ac_if; @@ -599,7 +597,7 @@ aeintr(arg, slot) isr = NIC_GET(sc, ED_P0_ISR); if (!isr) - return; + return (0); /* Loop until there are no more new interrupts. */ for (;;) { @@ -749,8 +747,9 @@ aeintr(arg, slot) isr = NIC_GET(sc, ED_P0_ISR); if (!isr) - return; + break; } + return (1); } /* diff --git a/sys/arch/mac68k/dev/if_ae_nubus.c b/sys/arch/mac68k/dev/if_ae_nubus.c index 2df9ecb1c63..c536a454295 100644 --- a/sys/arch/mac68k/dev/if_ae_nubus.c +++ b/sys/arch/mac68k/dev/if_ae_nubus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ae_nubus.c,v 1.9 2004/04/02 21:01:44 xsa Exp $ */ +/* $OpenBSD: if_ae_nubus.c,v 1.10 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_ae_nubus.c,v 1.17 1997/05/01 18:17:16 briggs Exp $ */ /* @@ -340,7 +340,7 @@ ae_nubus_attach(parent, self, aux) } /* make sure interrupts are vectored to us */ - add_nubus_intr(na->slot, aeintr, sc); + add_nubus_intr(na->slot, aeintr, sc, sc->sc_dev.dv_xname); } static int diff --git a/sys/arch/mac68k/dev/if_aevar.h b/sys/arch/mac68k/dev/if_aevar.h index 83a8ac81328..77311fb7d11 100644 --- a/sys/arch/mac68k/dev/if_aevar.h +++ b/sys/arch/mac68k/dev/if_aevar.h @@ -1,5 +1,5 @@ /* $NetBSD: if_aevar.h,v 1.7 1997/03/19 08:04:40 scottr Exp $ */ -/* $OpenBSD: if_aevar.h,v 1.3 2002/03/14 01:26:35 millert Exp $ */ +/* $OpenBSD: if_aevar.h,v 1.4 2004/11/26 21:21:24 miod Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -59,7 +59,7 @@ int ae_size_card_memory( bus_space_tag_t, bus_space_handle_t, int); int aesetup(struct ae_softc *); -void aeintr(void *, int); +int aeintr(void *); int aeioctl(struct ifnet *, u_long, caddr_t); void aestart(struct ifnet *); void aewatchdog(struct ifnet *); diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index d4a1f2ef0b6..fac81bbba87 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn.c,v 1.33 2003/01/19 17:25:42 henning Exp $ */ +/* $OpenBSD: if_sn.c,v 1.34 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_sn.c,v 1.13 1997/04/25 03:40:10 briggs Exp $ */ /* @@ -854,15 +854,15 @@ initialise_rra(sc) wbflush(); } -void -snintr(arg, slot) - void *arg; - int slot; +int +snintr(void *arg) { struct sn_softc *sc = (struct sn_softc *)arg; - int isr; + int isr; + int rv = 0; while ((isr = (NIC_GET(sc, SNR_ISR) & ISR_ALL)) != 0) { + rv = 1; /* scrub the interrupts that we are going to service */ NIC_PUT(sc, SNR_ISR, isr); wbflush(); @@ -913,7 +913,8 @@ snintr(arg, slot) } snstart(&sc->sc_if); } - return; + + return (rv); } /* diff --git a/sys/arch/mac68k/dev/if_sn_nubus.c b/sys/arch/mac68k/dev/if_sn_nubus.c index c05b8de97e3..e8732920cfd 100644 --- a/sys/arch/mac68k/dev/if_sn_nubus.c +++ b/sys/arch/mac68k/dev/if_sn_nubus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn_nubus.c,v 1.15 2002/04/22 20:15:55 miod Exp $ */ +/* $OpenBSD: if_sn_nubus.c,v 1.16 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_sn_nubus.c,v 1.13 1997/05/11 19:11:34 scottr Exp $ */ /* * Copyright (C) 1997 Allen Briggs @@ -262,7 +262,7 @@ sn_nubus_attach(parent, self, aux) return; } - add_nubus_intr(sc->slotno, snintr, (void *)sc); + add_nubus_intr(sc->slotno, snintr, sc, sc->sc_dev.dv_xname); } static int diff --git a/sys/arch/mac68k/dev/if_sn_obio.c b/sys/arch/mac68k/dev/if_sn_obio.c index 2ec0f5981a2..f57d4dd6dc4 100644 --- a/sys/arch/mac68k/dev/if_sn_obio.c +++ b/sys/arch/mac68k/dev/if_sn_obio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn_obio.c,v 1.19 2002/04/22 20:15:55 miod Exp $ */ +/* $OpenBSD: if_sn_obio.c,v 1.20 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_sn_obio.c,v 1.9 1997/04/22 20:56:15 scottr Exp $ */ /* @@ -181,7 +181,7 @@ sn_obio_attach(parent, self, aux) return; } - add_nubus_intr(sc->slotno, snintr, (void *)sc); + add_nubus_intr(sc->slotno, snintr, sc, sc->sc_dev.dv_xname); } static int diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h index 7e8b43eb24b..5e8ab1395cb 100644 --- a/sys/arch/mac68k/dev/if_snvar.h +++ b/sys/arch/mac68k/dev/if_snvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_snvar.h,v 1.11 2002/04/22 20:15:55 miod Exp $ */ +/* $OpenBSD: if_snvar.h,v 1.12 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: if_snvar.h,v 1.8 1997/04/25 03:40:09 briggs Exp $ */ /* @@ -216,6 +216,6 @@ typedef struct sn_softc { #define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2)) int snsetup(struct sn_softc *sc, u_int8_t *); -void snintr(void *, int); +int snintr(void *); void sn_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, vm_offset_t o, u_char *dst); diff --git a/sys/arch/mac68k/dev/ite.c b/sys/arch/mac68k/dev/ite.c index bfdd6285158..7990e5f6ef4 100644 --- a/sys/arch/mac68k/dev/ite.c +++ b/sys/arch/mac68k/dev/ite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ite.c,v 1.23 2003/10/03 16:44:49 miod Exp $ */ +/* $OpenBSD: ite.c,v 1.24 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: ite.c,v 1.32 1997/02/20 00:23:25 scottr Exp $ */ /* @@ -894,11 +894,11 @@ ite_pollforchar() intbits = via_reg(VIA1, vIFR); if (intbits & V1IF_ADBRDY) { - mrg_adbintr(); + (void)mrg_adbintr(); via_reg(VIA1, vIFR) = V1IF_ADBRDY; } if (intbits & 0x10) { - mrg_pmintr(); + (void)mrg_pmintr(); via_reg(VIA1, vIFR) = 0x10; } } diff --git a/sys/arch/mac68k/dev/mac68k5380.c b/sys/arch/mac68k/dev/mac68k5380.c index e6c07b743d8..5a409ef50d7 100644 --- a/sys/arch/mac68k/dev/mac68k5380.c +++ b/sys/arch/mac68k/dev/mac68k5380.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mac68k5380.c,v 1.18 2004/08/03 12:10:47 todd Exp $ */ +/* $OpenBSD: mac68k5380.c,v 1.19 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: mac68k5380.c,v 1.29 1997/02/28 15:50:50 scottr Exp $ */ /* @@ -128,8 +128,8 @@ static volatile u_char *ncr_5380_without_drq = (volatile u_char *) 0x12000; #define GET_5380_REG(rnum) SCSI_5380->scsi_5380[((rnum)<<4)] #define SET_5380_REG(rnum,val) (SCSI_5380->scsi_5380[((rnum)<<4)] = (val)) -static void ncr5380_irq_intr(void *); -static void ncr5380_drq_intr(void *); +static int ncr5380_irq_intr(void *); +static int ncr5380_drq_intr(void *); static void do_ncr5380_drq_intr(void *); static __inline__ void scsi_clr_ipend(void); @@ -174,8 +174,10 @@ scsi_mach_init(sc) scsi_flag = Via1Base + VIA2 * 0x2000 + rIFR; } - via2_register_irq(VIA2_SCSIIRQ, ncr5380_irq_intr, sc); - via2_register_irq(VIA2_SCSIDRQ, ncr5380_drq_intr, sc); + via2_register_irq(VIA2_SCSIIRQ, ncr5380_irq_intr, sc, + sc->sc_dev.dv_xname); + via2_register_irq(VIA2_SCSIDRQ, ncr5380_drq_intr, sc, + sc->sc_dev.dv_xname); } static int @@ -320,7 +322,7 @@ extern u_char ncr5380_no_parchk; return 0; } -static void +static int ncr5380_irq_intr(p) void *p; { @@ -328,11 +330,12 @@ ncr5380_irq_intr(p) #if USE_PDMA if (pdma_ready()) { - return; + return (1); } #endif scsi_idisable(); ncr_ctrl_intr(cur_softc); + return (1); } /* @@ -517,20 +520,22 @@ extern int *nofault, m68k_fault_addr; nofault = (int *) 0; PID("end drq"); - return; -#else - return; #endif /* if USE_PDMA */ } -static void +static int ncr5380_drq_intr(p) void *p; { + int rv = 0; + while (GET_5380_REG(NCR5380_DMSTAT) & SC_DMA_REQ) { do_ncr5380_drq_intr(p); scsi_clear_drq(); + rv = 1; } + + return (rv); } #if USE_PDMA diff --git a/sys/arch/mac68k/dev/zs.c b/sys/arch/mac68k/dev/zs.c index e8f6f83416b..7584da404b3 100644 --- a/sys/arch/mac68k/dev/zs.c +++ b/sys/arch/mac68k/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.16 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: zs.c,v 1.17 2004/11/26 21:21:24 miod Exp $ */ /* $NetBSD: zs.c,v 1.19 1998/01/12 19:22:18 thorpej Exp $ */ /* @@ -257,7 +257,7 @@ zsc_attach(parent, self, aux) struct device *self; void *aux; { - struct zsc_softc *zsc = (void *) self; + struct zsc_softc *zsc = (void *)self; struct zsc_attach_args zsc_args; volatile struct zschan *zc; struct xzs_chanstate *xcs; @@ -418,7 +418,7 @@ zsc_attach(parent, self, aux) add_psc_lev4_intr(2, zshard, zsc); add_psc_lev4_intr(3, zshard, zsc); } else { - intr_establish(zshard, zsc, ZSHARD_PRI); + intr_establish(zshard, zsc, ZSHARD_PRI, self->dv_xname); } /* XXX - Now safe to install interrupt handlers. */ diff --git a/sys/arch/mac68k/include/intr.h b/sys/arch/mac68k/include/intr.h index 37ee5df76b7..e043d428349 100644 --- a/sys/arch/mac68k/include/intr.h +++ b/sys/arch/mac68k/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.9 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.10 2004/11/26 21:21:27 miod Exp $ */ /* $NetBSD: intr.h,v 1.9 1998/08/12 06:58:42 scottr Exp $ */ /* @@ -157,12 +157,24 @@ extern volatile u_int8_t ssir; #define setsoftadb() siron(SIR_ADB) /* intr.c */ -void intr_establish (int (*)(void *), void *, int); -void intr_disestablish (int); -void intr_dispatch (int); +void intr_establish(int (*)(void *), void *, int, const char *); +void intr_disestablish(int); +void intr_dispatch(int); /* locore.s */ int spl0(void); + +/* + * Interrupt handler. + * There is no support for shared interrupts at the moment. + */ +#include <sys/evcount.h> +struct intrhand { + int (*ih_fn)(void *); + void *ih_arg; + int ih_ipl; + struct evcount ih_count; +}; #endif /* _KERNEL */ #endif /* _MAC68K_INTR_H_ */ diff --git a/sys/arch/mac68k/include/viareg.h b/sys/arch/mac68k/include/viareg.h index 4dfd890c8d4..d82bd1fbb4e 100644 --- a/sys/arch/mac68k/include/viareg.h +++ b/sys/arch/mac68k/include/viareg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: viareg.h,v 1.10 2002/03/14 03:15:55 millert Exp $ */ +/* $OpenBSD: viareg.h,v 1.11 2004/11/26 21:21:27 miod Exp $ */ /* $NetBSD: viareg.h,v 1.6 1997/02/28 07:41:41 scottr Exp $ */ /*- @@ -194,10 +194,10 @@ void via_init(void); int rbv_vidstatus(void); void via_shutdown(void); void via_set_modem(int); -int add_nubus_intr(int, void (*)(void *, int), void *); +void add_nubus_intr(int, int (*)(void *), void *, const char *); void enable_nubus_intr(void); -void via1_register_irq(int, void (*)(void *), void *); -void via2_register_irq(int, void (*)(void *), void *); +void via1_register_irq(int, int (*)(void *), void *, const char *); +void via2_register_irq(int, int (*)(void *), void *, const char *); extern void (*via1itab[7])(void *); extern void (*via2itab[7])(void *); diff --git a/sys/arch/mac68k/mac68k/clock.c b/sys/arch/mac68k/mac68k/clock.c index c2280ca6821..b8e7eeefeb8 100644 --- a/sys/arch/mac68k/mac68k/clock.c +++ b/sys/arch/mac68k/mac68k/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.16 2004/08/03 12:10:47 todd Exp $ */ +/* $OpenBSD: clock.c,v 1.17 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: clock.c,v 1.36 1997/10/07 03:04:55 scottr Exp $ */ /* @@ -96,7 +96,7 @@ int clock_debug = 0; #endif -void rtclock_intr(void); +int rtclock_intr(void *); #define DIFF19041970 2082844800 #define DIFF19701990 630720000 @@ -464,13 +464,14 @@ dummy_delay(usec) return ((delay_factor >> 7) - cycles); } -static void delay_timer1_irq(void *); +static int delay_timer1_irq(void *); -static void +static int delay_timer1_irq(dummy) void *dummy; { delay_flag = 0; + return 1; } /* @@ -484,7 +485,7 @@ mac68k_calibrate_delay() /* Disable VIA1 timer 1 interrupts and set up service routine */ via_reg(VIA1, vIER) = V1IF_T1; - via1_register_irq(VIA1_T1, delay_timer1_irq, NULL); + via1_register_irq(VIA1_T1, delay_timer1_irq, NULL, NULL); /* Set the timer for one-shot mode, then clear and enable interrupts */ via_reg(VIA1, vACR) &= ~ACR_T1LATCH; @@ -505,7 +506,7 @@ mac68k_calibrate_delay() /* Disable timer interrupts and reset service routine */ via_reg(VIA1, vIER) = V1IF_T1; - via1_register_irq(VIA1_T1, (void (*)(void *))rtclock_intr, NULL); + via1_register_irq(VIA1_T1, rtclock_intr, NULL, NULL); /* * If this weren't integer math, the following would look diff --git a/sys/arch/mac68k/mac68k/intr.c b/sys/arch/mac68k/mac68k/intr.c index e1f5641620e..028a7b82b16 100644 --- a/sys/arch/mac68k/mac68k/intr.c +++ b/sys/arch/mac68k/mac68k/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.1 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.2 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: intr.c,v 1.2 1998/08/25 04:03:56 scottr Exp $ */ /*- @@ -45,6 +45,7 @@ #include <sys/systm.h> #include <sys/malloc.h> #include <sys/vmmeter.h> +#include <sys/evcount.h> #include <uvm/uvm_extern.h> @@ -56,34 +57,14 @@ #define NISR 8 #define ISRLOC 0x18 -static int intr_noint (void *); -void netintr (void); - -static int ((*intr_func[NISR]) (void *)) = { - intr_noint, - intr_noint, - intr_noint, - intr_noint, - intr_noint, - intr_noint, - intr_noint, - intr_noint -}; -static void *intr_arg[NISR] = { - (void *)0, - (void *)1, - (void *)2, - (void *)3, - (void *)4, - (void *)5, - (void *)6, - (void *)7 -}; +void intr_init(void); +void netintr(void); #ifdef DEBUG int intr_debug = 0; #endif +struct intrhand intrs[NISR]; extern int intrcnt[]; /* from locore.s */ /* @@ -96,35 +77,50 @@ extern int intrcnt[]; /* from locore.s */ * ensue! (sar 19980806) */ void -intr_establish(func, arg, ipl) - int (*func) (void *); - void *arg; - int ipl; +intr_establish(int (*func)(void *), void *arg, int ipl, const char *name) { - if ((ipl < 0) || (ipl >= NISR)) + struct intrhand *ih; + +#ifdef DIAGNOSTIC + if (ipl < 0 || ipl >= NISR) panic("intr_establish: bad ipl %d", ipl); +#endif + + ih = &intrs[ipl]; #ifdef DIAGNOSTIC - if (intr_func[ipl] != intr_noint) - printf("intr_establish: attempt to share ipl %d\n", ipl); + if (ih->ih_fn != NULL) + panic("intr_establish: attempt to share ipl %d", ipl); #endif - intr_func[ipl] = func; - intr_arg[ipl] = arg; + ih->ih_fn = func; + ih->ih_arg = arg; + ih->ih_ipl = ipl; + evcount_attach(&ih->ih_count, name, (void *)&ih->ih_ipl, &evcount_intr); } /* * Disestablish an interrupt handler. */ void -intr_disestablish(ipl) - int ipl; +intr_disestablish(int ipl) { - if ((ipl < 0) || (ipl >= NISR)) + struct intrhand *ih; + +#ifdef DIAGNOSTIC + if (ipl < 0 || ipl >= NISR) panic("intr_disestablish: bad ipl %d", ipl); +#endif + + ih = &intrs[ipl]; + +#ifdef DIAGNOSTIC + if (ih->ih_fn == NULL) + panic("intr_disestablish: no vector on ipl %d", ipl); +#endif - intr_func[ipl] = intr_noint; - intr_arg[ipl] = (void *)ipl; + ih->ih_fn = NULL; + evcount_detach(&ih->ih_count); } /* @@ -134,36 +130,28 @@ intr_disestablish(ipl) * XXX Note: see the warning in intr_establish() */ void -intr_dispatch(evec) - int evec; /* format | vector offset */ +intr_dispatch(int evec) /* format | vector offset */ { + struct intrhand *ih; int ipl, vec; - vec = (evec & 0xfff) >> 2; + vec = (evec & 0x0fff) >> 2; + ipl = vec - ISRLOC; #ifdef DIAGNOSTIC - if ((vec < ISRLOC) || (vec >= (ISRLOC + NISR))) - panic("intr_dispatch: bad vec 0x%x\n", vec); + if (ipl < 0 || ipl >= NISR) + panic("intr_dispatch: bad vec 0x%x", vec); #endif - ipl = vec - ISRLOC; - intrcnt[ipl]++; uvmexp.intrs++; - - (void)(*intr_func[ipl])(intr_arg[ipl]); -} - -/* - * Default interrupt handler: do nothing. - */ -static int -intr_noint(arg) - void *arg; -{ -#ifdef DEBUG - if (intr_debug) - printf("intr_noint: ipl %d\n", (int)arg); + ih = &intrs[ipl]; + if (ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) + ih->ih_count.ec_count++; + } else { +#if 0 + printf("spurious interrupt, ipl %d\n", ipl); #endif - return 0; + } } int netisr; diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s index 3a0a11cfe22..dc33ea70d93 100644 --- a/sys/arch/mac68k/mac68k/locore.s +++ b/sys/arch/mac68k/mac68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.36 2004/11/25 18:32:10 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.37 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: locore.s,v 1.103 1998/07/09 06:02:50 scottr Exp $ */ /* @@ -829,12 +829,10 @@ Lbrkpt3: #define INTERRUPT_RESTOREREG moveml sp@+,#0x0303 ENTRY_NOPROFILE(spurintr) - addql #1,_C_LABEL(intrcnt)+0 addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS jra _ASM_LABEL(rei) ENTRY_NOPROFILE(lev1intr) - addql #1,_C_LABEL(intrcnt)+4 clrl sp@- moveml #0xFFFF,sp@- movl sp, sp@- @@ -846,7 +844,6 @@ ENTRY_NOPROFILE(lev1intr) jra _ASM_LABEL(rei) ENTRY_NOPROFILE(lev2intr) - addql #1,_C_LABEL(intrcnt)+8 clrl sp@- moveml #0xFFFF,sp@- movl sp, sp@- @@ -868,7 +865,6 @@ ENTRY_NOPROFILE(intrhand) /* levels 3 through 6 */ jra _ASM_LABEL(rei) | all done ENTRY_NOPROFILE(lev7intr) - addql #1,_C_LABEL(intrcnt)+16 clrl sp@- | pad SR to longword moveml #0xFFFF,sp@- | save registers movl usp,a0 | and save @@ -897,8 +893,6 @@ ENTRY_NOPROFILE(rtclock_intr) jbsr _C_LABEL(hardclock) | call generic clock int routine lea sp@(12),sp | pop params jbsr _C_LABEL(mrg_VBLQueue) | give programs in the VBLqueue a chance - addql #1,_C_LABEL(intrcnt)+20 - addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS movw d2,sr | restore SPL movl sp@+,d2 | restore d2 movl #1,d0 | clock taken care of @@ -1886,21 +1880,8 @@ ASGLOBAL(fullcflush) .long 0 #endif -/* interrupt counters */ - +/* old interrupt counters */ GLOBAL(intrnames) - .asciz "spur" - .asciz "via1" - .asciz "via2" - .asciz "scc" - .asciz "nmi" - .asciz "clock" - .asciz "unused1" - .asciz "unused2" - .asciz "unused3" GLOBAL(eintrnames) - .even - GLOBAL(intrcnt) - .long 0,0,0,0,0,0,0,0,0 GLOBAL(eintrcnt) diff --git a/sys/arch/mac68k/mac68k/macrom.c b/sys/arch/mac68k/mac68k/macrom.c index 3b74a91b59b..fd299e0b70e 100644 --- a/sys/arch/mac68k/mac68k/macrom.c +++ b/sys/arch/mac68k/mac68k/macrom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: macrom.c,v 1.25 2004/01/09 22:55:19 jmc Exp $ */ +/* $OpenBSD: macrom.c,v 1.26 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: macrom.c,v 1.31 1997/03/01 17:20:34 scottr Exp $ */ /*- @@ -395,7 +395,7 @@ mrg_jkybdtaskpanic() /* JKybdTask stopper */ * here if we are using the MRG_ADB method to * access the ADB/PRAM/RTC. They are * defined in adb_direct.c */ -long +int mrg_adbintr() /* Call ROM ADB Interrupt */ { if(mrg_romadbintr != NULL) diff --git a/sys/arch/mac68k/mac68k/macrom.h b/sys/arch/mac68k/mac68k/macrom.h index 987517c302f..dd8eec3d9ad 100644 --- a/sys/arch/mac68k/mac68k/macrom.h +++ b/sys/arch/mac68k/mac68k/macrom.h @@ -1,4 +1,4 @@ -/* $OpenBSD: macrom.h,v 1.10 2002/03/15 01:20:04 millert Exp $ */ +/* $OpenBSD: macrom.h,v 1.11 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: macrom.h,v 1.9 1996/05/25 14:45:35 briggs Exp $ */ /*- @@ -231,8 +231,8 @@ void mrg_setvectors(romvec_t *rom_vectors); int mrg_romready(void); caddr_t *Get_Ind_Resource(u_int32_t, u_int16_t); void mrg_initadbintr(void); -long mrg_adbintr(void); -long mrg_pmintr(void); +int mrg_adbintr(void); +int mrg_pmintr(void); void mrg_fixupROMBase(caddr_t, caddr_t); int mrg_Delay(void); void mrg_VBLQueue(void); diff --git a/sys/arch/mac68k/mac68k/psc.c b/sys/arch/mac68k/mac68k/psc.c index 4f4f3bce156..af1ba3a6b00 100644 --- a/sys/arch/mac68k/mac68k/psc.c +++ b/sys/arch/mac68k/mac68k/psc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psc.c,v 1.3 2004/11/25 18:32:11 miod Exp $ */ +/* $OpenBSD: psc.c,v 1.4 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: psc.c,v 1.5 1998/08/12 05:42:46 scottr Exp $ */ @@ -92,10 +92,10 @@ psc_init() * Only Quadra AVs have a PSC. */ if (current_mac_model->class == MACH_CLASSAV) { - intr_establish(psc_lev3_intr, NULL, 3); - intr_establish(psc_lev4_intr, NULL, 4); - intr_establish(psc_lev5_intr, NULL, 5); - intr_establish(psc_lev6_intr, NULL, 6); + intr_establish(psc_lev3_intr, NULL, 3, "psc"); + intr_establish(psc_lev4_intr, NULL, 4, "psc"); + intr_establish(psc_lev5_intr, NULL, 5, "psc"); + intr_establish(psc_lev6_intr, NULL, 6, "psc"); psc_reg1(PSC_LEV3_IER) = 0x01; /* disable level 3 interrupts */ psc_reg1(PSC_LEV4_IER) = 0x09; /* disable level 4 interrupts */ psc_reg1(PSC_LEV4_IER) = 0x86; /* except for SCC */ diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c index 10445242ff5..911027722e5 100644 --- a/sys/arch/mac68k/mac68k/via.c +++ b/sys/arch/mac68k/mac68k/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.18 2004/11/25 18:32:11 miod Exp $ */ +/* $OpenBSD: via.c,v 1.19 2004/11/26 21:21:28 miod Exp $ */ /* $NetBSD: via.c,v 1.62 1997/09/10 04:38:48 scottr Exp $ */ /*- @@ -43,53 +43,32 @@ #include <sys/kernel.h> #include <sys/syslog.h> #include <sys/systm.h> +#include <sys/evcount.h> + #include <machine/cpu.h> #include <machine/frame.h> +#include <machine/intr.h> #include <machine/viareg.h> -static void via1_noint(void *); -static void via2_noint(void *); -static void slot_ignore(void *, int); -static void slot_noint(void *, int); -void mrg_adbintr(void *); -void mrg_pmintr(void *); -void rtclock_intr(void *); +int mrg_adbintr(void *); +int mrg_pmintr(void *); void profclock(void *); +int rbv_nubus_intr(void *); +static int rbv_slot_ignore(void *); +int rtclock_intr(void *); void via1_intr(struct frame *); -void via2_nubus_intr(void *); -void rbv_nubus_intr(void *); +int via2_nubus_intr(void *); + int VIA2 = 1; /* default for II, IIx, IIcx, SE/30. */ -void (*via1itab[7])(void *)={ - via1_noint, - via1_noint, - mrg_adbintr, - via1_noint, - mrg_pmintr, - via1_noint, - rtclock_intr, -}; /* VIA1 interrupt handler table */ - -void (*via2itab[7])(void *)={ - via2_noint, - via2_nubus_intr, - via2_noint, - via2_noint, - via2_noint, /* snd_intr */ - via2_noint, /* via2t2_intr */ - via2_noint, -}; /* VIA2 interrupt handler table */ - -void *via2iarg[7] = { - (void *) 0, (void *) 1, (void *) 2, (void *) 3, - (void *) 4, (void *) 5, (void *) 6 -}; /* Arg array for VIA2 interrupts. */ - -void via2_intr(struct frame *); -void rbv_intr(struct frame *); -void oss_intr(struct frame *); - -void (*real_via2_intr)(struct frame *); +struct intrhand via1intrs[7]; +struct intrhand via2intrs[7]; + +void oss_intr(struct frame *); +void rbv_intr(struct frame *); +void via2_intr(struct frame *); + +void (*real_via2_intr)(struct frame *); /* * Nubus slot interrupt routines and parameters for slots 9-15. Note @@ -97,20 +76,7 @@ void (*real_via2_intr)(struct frame *); * as a slot 15 interrupt; this slot is quite fictitious in real-world * Macs. See also GMFH, pp. 165-167, and "Monster, Loch Ness." */ -void (*slotitab[7])(void *, int) = { - slot_noint, - slot_noint, - slot_noint, - slot_noint, - slot_noint, - slot_noint, - slot_noint /* int_video_intr */ -}; - -void *slotptab[7] = { - (void *) 0, (void *) 1, (void *) 2, (void *) 3, - (void *) 4, (void *) 5, (void *) 6 -}; +struct intrhand slotintrs[7]; void via_init() @@ -127,6 +93,11 @@ via_init() /* turn off timer latch */ via_reg(VIA1, vACR) &= 0x3f; + /* register default VIA1 interrupts */ + via1_register_irq(2, mrg_adbintr, NULL, "adb"); + via1_register_irq(4, mrg_pmintr, NULL, "pm"); + via1_register_irq(VIA1_T1, rtclock_intr, NULL, "clock"); + if (VIA2 == VIA2OFF) { /* Initialize VIA2 */ via2_reg(vT1L) = 0; @@ -139,6 +110,10 @@ via_init() /* turn off timer latch */ via2_reg(vACR) &= 0x3f; + /* register default VIA2 interrupts */ + via2_register_irq(1, via2_nubus_intr, NULL, NULL); + /* 4 snd_intr, 5 via2t2_intr */ + /* * Turn off SE/30 video interrupts. */ @@ -169,7 +144,6 @@ via_init() } real_via2_intr = via2_intr; - via2itab[1] = via2_nubus_intr; } else if (current_mac_model->class == MACH_CLASSIIfx) { /* OSS */ real_via2_intr = oss_intr; } else { /* RBV */ @@ -180,8 +154,9 @@ via_init() via2_reg(rBufB) |= DB2O_CEnable; } real_via2_intr = rbv_intr; - via2itab[1] = rbv_nubus_intr; - add_nubus_intr(0, slot_ignore, NULL); + via2_register_irq(1, rbv_nubus_intr, NULL, NULL); + /* XXX necessary? */ + add_nubus_intr(0, rbv_slot_ignore, NULL, "dummy"); } } @@ -189,8 +164,7 @@ via_init() * Set the state of the modem serial port's clock source. */ void -via_set_modem(onoff) - int onoff; +via_set_modem(int onoff) { via_reg(VIA1, vDirA) |= DA1O_vSync; if (onoff) @@ -200,11 +174,11 @@ via_set_modem(onoff) } void -via1_intr(fp) - struct frame *fp; +via1_intr(struct frame *fp) { - u_int8_t intbits, bitnum; - u_int mask; + struct intrhand *ih; + u_int8_t intbits, bitnum; + u_int mask; intbits = via_reg(VIA1, vIFR) & via_reg(VIA1, vIER); @@ -219,21 +193,27 @@ via1_intr(fp) intbits &= 0x7f; mask = 1; - bitnum = 0; - do { - if (intbits & mask) { - via1itab[bitnum]((void *)((int) bitnum)); + for (bitnum = 0, ih = via1intrs; ; bitnum++, ih++) { + if ((intbits & mask) != 0 && ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) + ih->ih_count.ec_count++; + } else { +#if 0 + printf("spurious VIA1 interrupt, source %d\n", bitnum); +#endif } mask <<= 1; - } while (intbits >= mask && ++bitnum); + if (intbits < mask) + break; + } } void -via2_intr(fp) - struct frame *fp; +via2_intr(struct frame *fp) { - u_int8_t intbits, bitnum; - u_int mask; + struct intrhand *ih; + u_int8_t intbits, bitnum; + u_int mask; intbits = via2_reg(vIFR) & via2_reg(vIER); @@ -244,18 +224,25 @@ via2_intr(fp) intbits &= 0x7f; mask = 1; - bitnum = 0; - do { - if (intbits & mask) - via2itab[bitnum](via2iarg[bitnum]); + for (bitnum = 0, ih = via2intrs; ; bitnum++, ih++) { + if ((intbits & mask) != 0 && ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) + ih->ih_count.ec_count++; + } else { +#if 0 + printf("spurious VIA2 interrupt, source %d\n", bitnum); +#endif + } mask <<= 1; - } while (intbits >= mask && ++bitnum); + if (intbits < mask) + break; + } } void -oss_intr(fp) - struct frame *fp; +oss_intr(struct frame *fp) { + struct intrhand *ih; u_int8_t intbits, bitnum; u_int mask; @@ -266,22 +253,29 @@ oss_intr(fp) intbits &= 0x7f; mask =1 ; - bitnum = 0; - do { + for (bitnum = 0, ih = slotintrs; ; bitnum++, ih++) { if (intbits & mask) { - (*slotitab[bitnum])(slotptab[bitnum], bitnum+9); + if (ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) + ih->ih_count.ec_count++; + } else { + printf("spurious nubus interrupt, slot %d\n", + bitnum); + } via2_reg(rIFR) = mask; } mask <<= 1; - } while (intbits >= mask && ++bitnum); + if (intbits < mask) + break; + } } void -rbv_intr(fp) - struct frame *fp; +rbv_intr(struct frame *fp) { - u_int8_t intbits, bitnum; - u_int mask; + struct intrhand *ih; + u_int8_t intbits, bitnum; + u_int mask; intbits = (via2_reg(vIFR + rIFR) & via2_reg(vIER + rIER)); @@ -292,37 +286,29 @@ rbv_intr(fp) intbits &= 0x7f; mask = 1; - bitnum = 0; - do { - if (intbits & mask) - via2itab[bitnum](via2iarg[bitnum]); + for (bitnum = 0, ih = via2intrs; ; bitnum++, ih++) { + if ((intbits & mask) != 0 && ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) + ih->ih_count.ec_count++; + } else { +#if 0 + printf("spurious VIA2 interrupt, source %d\n", bitnum); +#endif + } mask <<= 1; - } while (intbits >= mask && ++bitnum); -} - -static void -via1_noint(bitnum) - void *bitnum; -{ - printf("via1_noint(%d)\n", (int) bitnum); -} - -static void -via2_noint(bitnum) - void *bitnum; -{ - printf("via2_noint(%d)\n", (int)bitnum); + if (intbits < mask) + break; + } } -static int nubus_intr_mask = 0; +static int nubus_intr_mask = 0; -int -add_nubus_intr(slot, func, client_data) - int slot; - void (*func)(void *, int); - void *client_data; +void +add_nubus_intr(int slot, int (*func)(void *), void *client_data, + const char *name) { - int s; + struct intrhand *ih; + int s; /* * Map Nubus slot 0 to "slot" 15; see note on Nubus slot @@ -330,19 +316,29 @@ add_nubus_intr(slot, func, client_data) */ if (slot == 0) slot = 15; - if (slot < 9 || slot > 15) - return 0; + slot -= 9; +#ifdef DIAGNOSTIC + if (slot < 0 || slot > 7) + panic("add_nubus_intr: wrong slot %d", slot + 9); +#endif s = splhigh(); - slotitab[slot-9] = func; - slotptab[slot-9] = client_data; + ih = &slotintrs[slot]; - nubus_intr_mask |= (1 << (slot-9)); +#ifdef DIAGNOSTIC + if (ih->ih_fn != NULL) + panic("add_nubus_intr: attempt to share slot %d", slot + 9); +#endif - splx(s); + ih->ih_fn = func; + ih->ih_arg = client_data; + ih->ih_ipl = slot + 9; + evcount_attach(&ih->ih_count, name, (void *)&ih->ih_ipl, &evcount_intr); - return 1; + nubus_intr_mask |= (1 << slot); + + splx(s); } void @@ -358,53 +354,72 @@ enable_nubus_intr() } /*ARGSUSED*/ -void -via2_nubus_intr(bitarg) - void *bitarg; +int +via2_nubus_intr(void *bitarg) { - u_int8_t i, intbits, mask; + struct intrhand *ih; + u_int8_t i, intbits, mask; + int rv = 0; via2_reg(vIFR) = 0x80 | V2IF_SLOTINT; while ((intbits = (~via2_reg(vBufA)) & nubus_intr_mask)) { - i = 6; - mask = (1 << i); - do { - if (intbits & mask) - (*slotitab[i])(slotptab[i], i+9); - i--; - mask >>= 1; - } while (mask); + for (i = 6, ih = &slotintrs[i], mask = 1 << i; mask != 0; + i--, ih--, mask >>= 1) { + if (intbits & mask) { + if (ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) { + ih->ih_count.ec_count++; + rv = 1; + } + } else { +#if 0 + printf("spurious nubus interrupt, slot %d\n", + i); +#endif + } + } + } via2_reg(vIFR) = V2IF_SLOTINT; } + return (rv); } /*ARGSUSED*/ -void -rbv_nubus_intr(bitarg) - void *bitarg; +int +rbv_nubus_intr(void *bitarg) { + struct intrhand *ih; u_int8_t i, intbits, mask; + int rv = 0; via2_reg(rIFR) = 0x80 | V2IF_SLOTINT; while ((intbits = (~via2_reg(rBufA)) & via2_reg(rSlotInt))) { - i = 6; - mask = (1 << i); - do { - if (intbits & mask) - (*slotitab[i])(slotptab[i], i+9); - i--; - mask >>= 1; - } while (mask); + for (i = 6, ih = &slotintrs[i], mask = 1 << i; mask != 0; + i--, ih--, mask >>= 1) { + if (intbits & mask) { + if (ih->ih_fn != NULL) { + if ((*ih->ih_fn)(ih->ih_arg) != 0) { + ih->ih_count.ec_count++; + rv = 1; + } + } else { +#if 0 + printf("spurious nubus interrupt, slot %d\n", + i); +#endif + } + } + } via2_reg(rIFR) = 0x80 | V2IF_SLOTINT; } + return (rv); } -static void -slot_ignore(client_data, slot) - void *client_data; - int slot; +static int +rbv_slot_ignore(void *client_data) { - register int mask = (1 << (slot-9)); + int slot = 0 + 9; + int mask = (1 << (slot - 9)); if (VIA2 == VIA2OFF) { via2_reg(vDirA) |= mask; @@ -412,14 +427,8 @@ slot_ignore(client_data, slot) via2_reg(vDirA) &= ~mask; } else via2_reg(rBufA) = mask; -} -static void -slot_noint(client_data, slot) - void *client_data; - int slot; -{ - printf("slot_noint() slot %x\n", slot); + return (1); } void @@ -446,28 +455,61 @@ rbv_vidstatus() } void -via1_register_irq(irq, irq_func, client_data) - int irq; - void (*irq_func)(void *); - void *client_data; +via1_register_irq(int irq, int (*irq_func)(void *), void *client_data, + const char *name) { - if (irq_func) - via1itab[irq] = irq_func; - else - via1itab[irq] = via1_noint; + struct intrhand *ih; + +#ifdef DIAGNOSTIC + if (irq < 0 || irq > 7) + panic("via1_register_irq: bad irq %d", irq); +#endif + + ih = &via1intrs[irq]; + + /* + * VIA1_T1 is special, since we need to temporary replace + * the callback during bootstrap, to compute the delay + * values. + * To avoid a loop in evcount lists, only invoke + * evcount_attach() if name is non-NULL, and have the two + * replacements calls in clock.c pass a NULL pointer. + */ +#ifdef DIAGNOSTIC + if (ih->ih_fn != NULL && irq != VIA1_T1) + panic("via1_register_irq: attempt to share irq %d", irq); +#endif + + ih->ih_fn = irq_func; + ih->ih_arg = client_data; + ih->ih_ipl = irq; + if (name != NULL || irq != VIA1_T1) + evcount_attach(&ih->ih_count, name, (void *)&ih->ih_ipl, + &evcount_intr); } void -via2_register_irq(irq, irq_func, client_data) - int irq; - void (*irq_func)(void *); - void *client_data; +via2_register_irq(int irq, int (*irq_func)(void *), void *client_data, + const char *name) { - if (irq_func) { - via2itab[irq] = irq_func; - via2iarg[irq] = client_data; - } else { - via2itab[irq] = via2_noint; - via2iarg[irq] = (void *) 0; - } + struct intrhand *ih; + +#ifdef DIAGNOSTIC + if (irq < 0 || irq > 7) + panic("via2_register_irq: bad irq %d", irq); +#endif + + ih = &via2intrs[irq]; + +#ifdef DIAGNOSTIC + if (ih->ih_fn != NULL) + panic("via2_register_irq: attempt to share irq %d", irq); +#endif + + ih->ih_fn = irq_func; + ih->ih_arg = client_data; + ih->ih_ipl = irq; + if (name != NULL) + evcount_attach(&ih->ih_count, name, (void *)&ih->ih_ipl, + &evcount_intr); } |