summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hp300/dev/apci.c10
-rw-r--r--sys/arch/hp300/dev/dca.c11
-rw-r--r--sys/arch/hp300/dev/dcm.c10
-rw-r--r--sys/arch/hp300/dev/dio.c28
-rw-r--r--sys/arch/hp300/dev/diovar.h6
-rw-r--r--sys/arch/hp300/dev/dma.c33
-rw-r--r--sys/arch/hp300/dev/fhpib.c12
-rw-r--r--sys/arch/hp300/dev/frodo.c108
-rw-r--r--sys/arch/hp300/dev/frodovar.h5
-rw-r--r--sys/arch/hp300/dev/if_le.c13
-rw-r--r--sys/arch/hp300/dev/if_levar.h3
-rw-r--r--sys/arch/hp300/dev/nhpib.c9
-rw-r--r--sys/arch/hp300/dev/spc.c9
-rw-r--r--sys/arch/hp300/hp300/clock.c24
-rw-r--r--sys/arch/hp300/hp300/intr.c70
-rw-r--r--sys/arch/hp300/hp300/locore.s6
-rw-r--r--sys/arch/hp300/include/intr.h18
-rw-r--r--sys/arch/hp300/include/types.h3
18 files changed, 204 insertions, 174 deletions
diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c
index 6b2b911dd1e..7d974afe397 100644
--- a/sys/arch/hp300/dev/apci.c
+++ b/sys/arch/hp300/dev/apci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apci.c,v 1.16 2004/09/19 21:34:42 mickey Exp $ */
+/* $OpenBSD: apci.c,v 1.17 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: apci.c,v 1.9 2000/11/02 00:35:05 eeh Exp $ */
/*-
@@ -123,6 +123,7 @@
struct apci_softc {
struct device sc_dev; /* generic device glue */
+ struct isr sc_isr;
struct apciregs *sc_apci; /* device registers */
struct tty *sc_tty; /* tty glue */
struct timeout sc_timeout; /* timeout */
@@ -257,8 +258,11 @@ apciattach(parent, self, aux)
sc->sc_flags |= APCI_HASFIFO;
/* Establish our interrupt handler. */
- frodo_intr_establish(parent, apciintr, sc, fa->fa_line,
- (sc->sc_flags & APCI_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF);
+ sc->sc_isr.isr_func = apciintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_priority =
+ (sc->sc_flags & APCI_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF;
+ frodo_intr_establish(parent, fa->fa_line, &sc->sc_isr, self->dv_xname);
/* Set soft carrier if requested by operator. */
if (self->dv_cfdata->cf_flags)
diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c
index 3b72eaa29ec..b0dbe036149 100644
--- a/sys/arch/hp300/dev/dca.c
+++ b/sys/arch/hp300/dev/dca.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dca.c,v 1.19 2004/09/19 21:34:42 mickey Exp $ */
+/* $OpenBSD: dca.c,v 1.20 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: dca.c,v 1.35 1997/05/05 20:58:18 thorpej Exp $ */
/*
@@ -74,6 +74,7 @@
struct dca_softc {
struct device sc_dev; /* generic device glue */
+ struct isr sc_isr;
struct dcadevice *sc_dca; /* pointer to hardware */
struct tty *sc_tty; /* our tty instance */
int sc_oflows; /* overflow counter */
@@ -233,8 +234,12 @@ dcaattach(parent, self, aux)
sc->sc_flags |= DCA_HASFIFO;
/* Establish interrupt handler. */
- (void) dio_intr_establish(dcaintr, sc, ipl,
- (sc->sc_flags & DCA_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF);
+ sc->sc_isr.isr_func = dcaintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = ipl;
+ sc->sc_isr.isr_priority =
+ (sc->sc_flags & DCA_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF;
+ dio_intr_establish(&sc->sc_isr, self->dv_xname);
sc->sc_flags |= DCA_ACTIVE;
if (self->dv_cfdata->cf_flags)
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c
index 038f321ba65..1a268611b19 100644
--- a/sys/arch/hp300/dev/dcm.c
+++ b/sys/arch/hp300/dev/dcm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dcm.c,v 1.18 2004/09/19 21:34:42 mickey Exp $ */
+/* $OpenBSD: dcm.c,v 1.19 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: dcm.c,v 1.41 1997/05/05 20:59:16 thorpej Exp $ */
/*
@@ -217,6 +217,7 @@ static char iconv[16] = {
struct dcm_softc {
struct device sc_dev; /* generic device glue */
+ struct isr sc_isr;
struct dcmdevice *sc_dcm; /* pointer to hardware */
struct tty *sc_tty[NDCMPORT]; /* our tty instances */
struct modemreg *sc_modem[NDCMPORT]; /* modem control */
@@ -352,7 +353,11 @@ dcmattach(parent, self, aux)
sc->sc_flags |= DCM_ACTIVE;
/* Establish the interrupt handler. */
- (void) dio_intr_establish(dcmintr, sc, ipl, IPL_TTY);
+ sc->sc_isr.isr_func = dcmintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = ipl;
+ sc->sc_isr.isr_priority = IPL_TTY;
+ dio_intr_establish(&sc->sc_isr, self->dv_xname);
if (dcmistype == DIS_TIMER)
dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
@@ -668,6 +673,7 @@ dcmintr(arg)
SEM_UNLOCK(dcm);
return (0);
}
+
for (i = 0; i < 4; i++) {
pcnd[i] = dcm->dcm_icrtab[i].dcm_data;
dcm->dcm_icrtab[i].dcm_data = 0;
diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c
index 551ca5e63ff..ac71a0cbd3f 100644
--- a/sys/arch/hp300/dev/dio.c
+++ b/sys/arch/hp300/dev/dio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dio.c,v 1.8 2003/05/10 21:11:12 deraadt Exp $ */
+/* $OpenBSD: dio.c,v 1.9 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: dio.c,v 1.7 1997/05/05 21:00:32 thorpej Exp $ */
/*-
@@ -319,35 +319,23 @@ dio_devinfo(da, buf, buflen)
/*
* Establish an interrupt handler for a DIO device.
*/
-void *
-dio_intr_establish(func, arg, ipl, priority)
- int (*func)(void *);
- void *arg;
- int ipl;
- int priority;
+void
+dio_intr_establish(struct isr *isr, const char *name)
{
- void *ih;
-
- ih = intr_establish(func, arg, ipl, priority);
+ intr_establish(isr, name);
- if (priority == IPL_BIO)
+ if (isr->isr_priority == IPL_BIO)
dmacomputeipl();
-
- return (ih);
}
/*
* Remove an interrupt handler for a DIO device.
*/
void
-dio_intr_disestablish(arg)
- void *arg;
+dio_intr_disestablish(struct isr *isr)
{
- struct isr *isr = arg;
- int priority = isr->isr_priority;
-
- intr_disestablish(arg);
+ intr_disestablish(isr);
- if (priority == IPL_BIO)
+ if (isr->isr_priority == IPL_BIO)
dmacomputeipl();
}
diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h
index 61c1f156170..3f6f062f7bd 100644
--- a/sys/arch/hp300/dev/diovar.h
+++ b/sys/arch/hp300/dev/diovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: diovar.h,v 1.5 2002/03/14 03:15:52 millert Exp $ */
+/* $OpenBSD: diovar.h,v 1.6 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: diovar.h,v 1.3 1997/05/05 21:01:33 thorpej Exp $ */
/*-
@@ -77,6 +77,6 @@ struct dio_devdesc {
#ifdef _KERNEL
void *dio_scodetopa(int);
-void *dio_intr_establish(int (*)(void *), void *, int, int);
-void dio_intr_disestablish(void *);
+void dio_intr_establish(struct isr *, const char *);
+void dio_intr_disestablish(struct isr *);
#endif /* _KERNEL */
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index d99d2b32681..c390c36ab95 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dma.c,v 1.13 2003/06/02 23:27:44 millert Exp $ */
+/* $OpenBSD: dma.c,v 1.14 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: dma.c,v 1.19 1997/05/05 21:02:39 thorpej Exp $ */
/*
@@ -79,14 +79,13 @@ struct dma_channel {
struct dma_softc {
struct dmareg *sc_dmareg; /* pointer to our hardware */
+ struct isr sc_isr;
struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
#ifdef DEBUG
struct timeout sc_timeout; /* DMA timeout */
#endif
TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */
char sc_type; /* A, B, or C */
- int sc_ipl; /* our interrupt level */
- void *sc_ih; /* interrupt cookie */
} dma_softc;
/* types */
@@ -183,10 +182,18 @@ dmainit()
rev, (rev == 'B') ? 16 : 32);
/*
+ * Our interrupt level must be as high as the highest
+ * device using DMA (i.e. splbio).
+ */
+ sc->sc_isr.isr_ipl = PSLTOIPL(hp300_bioipl);
+
+ /*
* Defer hooking up our interrupt until the first
* DMA-using controller has hooked up theirs.
*/
- sc->sc_ih = NULL;
+ sc->sc_isr.isr_func = NULL;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_priority = IPL_BIO;
}
/*
@@ -198,15 +205,11 @@ dmacomputeipl()
{
struct dma_softc *sc = &dma_softc;
- if (sc->sc_ih != NULL)
- intr_disestablish(sc->sc_ih);
+ if (sc->sc_isr.isr_func != NULL)
+ intr_disestablish(&sc->sc_isr);
- /*
- * Our interrupt level must be as high as the highest
- * device using DMA (i.e. splbio).
- */
- sc->sc_ipl = PSLTOIPL(hp300_bioipl);
- sc->sc_ih = intr_establish(dmaintr, sc, sc->sc_ipl, IPL_BIO);
+ sc->sc_isr.isr_func = dmaintr;
+ intr_establish(&sc->sc_isr, "dma");
}
int
@@ -336,8 +339,10 @@ dmago(unit, addr, count, flags)
char *dmaend = NULL;
int seg, tcount;
+#ifdef DIAGNOSTIC
if (count > MAXPHYS)
panic("dmago: count > MAXPHYS");
+#endif
#if defined(HP320)
if (sc->sc_type == DMA_B && (flags & DMAGO_LWORD))
@@ -408,7 +413,7 @@ dmago(unit, addr, count, flags)
/*
* Set up the command word based on flags
*/
- dc->dm_cmd = DMA_ENAB | DMA_IPL(sc->sc_ipl) | DMA_START;
+ dc->dm_cmd = DMA_ENAB | DMA_IPL(sc->sc_isr.isr_ipl) | DMA_START;
if ((flags & DMAGO_READ) == 0)
dc->dm_cmd |= DMA_WRT;
if (flags & DMAGO_LWORD)
@@ -547,7 +552,7 @@ dmaintr(arg)
printf("dma channel %d: intr when armed\n", i);
#endif
/*
- * Load the next segemnt, or finish up if we're done.
+ * Load the next segment, or finish up if we're done.
*/
dc->dm_cur++;
if (dc->dm_cur <= dc->dm_last) {
diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c
index c964ebea45f..c3dcfbf8c20 100644
--- a/sys/arch/hp300/dev/fhpib.c
+++ b/sys/arch/hp300/dev/fhpib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fhpib.c,v 1.12 2003/11/03 05:34:43 david Exp $ */
+/* $OpenBSD: fhpib.c,v 1.13 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: fhpib.c,v 1.18 1997/05/05 21:04:16 thorpej Exp $ */
/*
@@ -105,6 +105,7 @@ struct hpib_controller fhpib_controller = {
struct fhpib_softc {
struct device sc_dev; /* generic device glue */
+ struct isr sc_isr;
struct fhpibdevice *sc_regs; /* device registers */
struct timeout sc_dma_to; /* DMA done timeout */
#ifdef DEBUG
@@ -165,7 +166,11 @@ fhpibattach(parent, self, aux)
#endif
/* Establish the interrupt handler. */
- (void) dio_intr_establish(fhpibintr, sc, ipl, IPL_BIO);
+ sc->sc_isr.isr_func = fhpibintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = ipl;
+ sc->sc_isr.isr_priority = IPL_BIO;
+ dio_intr_establish(&sc->sc_isr, self->dv_xname);
ha.ha_ops = &fhpib_controller;
ha.ha_type = HPIBC; /* XXX */
@@ -191,7 +196,7 @@ fhpibreset(hs)
DELAY(100000);
/*
* See if we can do word dma.
- * If so, we should be able to write and read back the appropos bit.
+ * If so, we should be able to write and read back the apropos bit.
*/
hd->hpib_ie |= IDS_WDMA;
if (hd->hpib_ie & IDS_WDMA) {
@@ -536,6 +541,7 @@ fhpibintr(arg)
#endif
return(0);
}
+
#ifdef DEBUG
if ((fhpibdebug & FDB_DMA) && fhpibdebugunit == sc->sc_dev.dv_unit)
printf("fhpibintr: flags %x\n", hs->sc_flags);
diff --git a/sys/arch/hp300/dev/frodo.c b/sys/arch/hp300/dev/frodo.c
index 945cff1a19a..225fcb8c3aa 100644
--- a/sys/arch/hp300/dev/frodo.c
+++ b/sys/arch/hp300/dev/frodo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frodo.c,v 1.3 2002/03/14 01:26:30 millert Exp $ */
+/* $OpenBSD: frodo.c,v 1.4 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: frodo.c,v 1.5 1999/07/31 21:15:20 thorpej Exp $ */
/*-
@@ -67,8 +67,6 @@
* in HP Apollo 9000/4xx workstations.
*/
-#define _HP300_INTR_H_PRIVATE
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -84,20 +82,11 @@
#include <hp300/dev/frodoreg.h>
#include <hp300/dev/frodovar.h>
-/*
- * Description of a Frodo interrupt handler.
- */
-struct frodo_isr {
- int (*isr_func)(void *);
- void *isr_arg;
- int isr_priority;
-};
-
struct frodo_softc {
struct device sc_dev; /* generic device glue */
volatile u_int8_t *sc_regs; /* register base */
- struct frodo_isr sc_intr[FRODO_NINTR]; /* interrupt handlers */
- void *sc_ih; /* out interrupt cookie */
+ struct isr *sc_intr[FRODO_NINTR]; /* interrupt handlers */
+ struct isr sc_isr; /* main interrupt handler */
int sc_refcnt; /* number of interrupt refs */
};
@@ -178,7 +167,6 @@ frodoattach(parent, self, aux)
/* Clear all of the interrupt handlers. */
bzero(sc->sc_intr, sizeof(sc->sc_intr));
- sc->sc_refcnt = 0;
/*
* Disable all of the interrupt lines; we reenable them
@@ -200,7 +188,7 @@ frodoattach(parent, self, aux)
* We defer hooking up our interrupt handler until
* a subdevice hooks up theirs.
*/
- sc->sc_ih = NULL;
+ sc->sc_refcnt = 0;
/* ... and attach subdevices. */
for (i = 0; frodo_subdevs[i].fa_name != NULL; i++) {
@@ -246,50 +234,45 @@ frodoprint(aux, pnp)
}
void
-frodo_intr_establish(frdev, func, arg, line, priority)
- struct device *frdev;
- int (*func)(void *);
- void *arg;
- int line;
- int priority;
+frodo_intr_establish(struct device *frdev, int line, struct isr *isr,
+ const char *name)
{
struct frodo_softc *sc = (struct frodo_softc *)frdev;
- struct isr *isr = sc->sc_ih;
+ int priority = isr->isr_priority;
if (line < 0 || line >= FRODO_NINTR) {
- printf("%s: bad interrupt line %d\n",
+ panic("%s: bad interrupt line %d",
sc->sc_dev.dv_xname, line);
- goto lose;
}
- if (sc->sc_intr[line].isr_func != NULL) {
- printf("%s: interrupt line %d already used\n",
+ if (sc->sc_intr[line] != NULL) {
+ panic("%s: interrupt line %d already used",
sc->sc_dev.dv_xname, line);
- goto lose;
}
- /* Install the handler. */
- sc->sc_intr[line].isr_func = func;
- sc->sc_intr[line].isr_arg = arg;
- sc->sc_intr[line].isr_priority = priority;
-
/*
* If this is the first one, establish the frodo
* interrupt handler. If not, reestablish at a
* higher priority if necessary.
*/
- if (isr == NULL || isr->isr_priority < priority) {
- if (isr != NULL)
- intr_disestablish(isr);
- sc->sc_ih = intr_establish(frodointr, sc, 5, priority);
+ if (sc->sc_isr.isr_priority < priority) {
+ if (sc->sc_refcnt != 0)
+ intr_disestablish(&sc->sc_isr);
+ sc->sc_isr.isr_func = frodointr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = 5;
+ sc->sc_isr.isr_priority = priority;
+ intr_establish(&sc->sc_isr, sc->sc_dev.dv_xname);
}
sc->sc_refcnt++;
+ /* Install the handler. */
+ isr->isr_ipl = sc->sc_isr.isr_ipl;
+ evcount_attach(&isr->isr_count, name, &isr->isr_ipl, &evcount_intr);
+ sc->sc_intr[line] = isr;
+
/* Enable the interrupt line. */
frodo_imask(sc, (1 << line), 0);
- return;
- lose:
- panic("frodo_intr_establish");
}
void
@@ -298,33 +281,35 @@ frodo_intr_disestablish(frdev, line)
int line;
{
struct frodo_softc *sc = (struct frodo_softc *)frdev;
- struct isr *isr = sc->sc_ih;
int newpri;
- if (sc->sc_intr[line].isr_func == NULL) {
- printf("%s: no handler for line %d\n",
+ if (sc->sc_intr[line] == NULL) {
+ panic("%s: no handler for line %d",
sc->sc_dev.dv_xname, line);
- panic("frodo_intr_disestablish");
}
- sc->sc_intr[line].isr_func = NULL;
+ sc->sc_intr[line] = NULL;
frodo_imask(sc, 0, (1 << line));
/* If this was the last, unhook ourselves. */
if (sc->sc_refcnt-- == 1) {
- intr_disestablish(isr);
+ intr_disestablish(&sc->sc_isr);
return;
}
/* Lower our priority, if appropriate. */
for (newpri = 0, line = 0; line < FRODO_NINTR; line++)
- if (sc->sc_intr[line].isr_func != NULL &&
- sc->sc_intr[line].isr_priority > newpri)
- newpri = sc->sc_intr[line].isr_priority;
-
- if (newpri != isr->isr_priority) {
- intr_disestablish(isr);
- sc->sc_ih = intr_establish(frodointr, sc, 5, newpri);
+ if (sc->sc_intr[line] != NULL &&
+ sc->sc_intr[line]->isr_priority > newpri)
+ newpri = sc->sc_intr[line]->isr_priority;
+
+ if (newpri != sc->sc_isr.isr_priority) {
+ intr_disestablish(&sc->sc_isr);
+ sc->sc_isr.isr_func = frodointr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = 5;
+ sc->sc_isr.isr_priority = newpri;
+ intr_establish(&sc->sc_isr, sc->sc_dev.dv_xname);
}
}
@@ -333,7 +318,7 @@ frodointr(arg)
void *arg;
{
struct frodo_softc *sc = arg;
- struct frodo_isr *fisr;
+ struct isr *fisr;
int line, taken = 0;
/* Any interrupts pending? */
@@ -345,11 +330,18 @@ frodointr(arg)
* Get pending interrupt; this also clears it for us.
*/
line = FRODO_IPEND(sc);
- fisr = &sc->sc_intr[line];
- if (fisr->isr_func == NULL ||
- (*fisr->isr_func)(fisr->isr_arg) == 0)
- printf("%s: spurious interrupt on line %d\n",
+ fisr = sc->sc_intr[line];
+ if (fisr == NULL) {
+ printf("%s: unhandled interrupt on line %d\n",
sc->sc_dev.dv_xname, line);
+ } else {
+ if ((*fisr->isr_func)(fisr->isr_arg) != 0) {
+ fisr->isr_count.ec_count++;
+ } else {
+ printf("%s: spurious interrupt on line %d\n",
+ sc->sc_dev.dv_xname, line);
+ }
+ }
if (taken++ > 100)
panic("frodointr: looping!");
} while (FRODO_GETPEND(sc) != 0);
diff --git a/sys/arch/hp300/dev/frodovar.h b/sys/arch/hp300/dev/frodovar.h
index d05443d71bf..8685c240087 100644
--- a/sys/arch/hp300/dev/frodovar.h
+++ b/sys/arch/hp300/dev/frodovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frodovar.h,v 1.4 2003/04/03 17:01:29 millert Exp $ */
+/* $OpenBSD: frodovar.h,v 1.5 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: frodovar.h,v 1.1 1997/05/12 08:03:50 thorpej Exp $ */
/*
@@ -44,6 +44,5 @@ struct frodo_attach_args {
#define frodocf_offset cf_loc[0]
#define FRODO_UNKNOWN_OFFSET -1
-void frodo_intr_establish(struct device *, int (*func)(void *),
- void *, int, int);
+void frodo_intr_establish(struct device *, int, struct isr *, const char *);
void frodo_intr_disestablish(struct device *, int);
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index 0934fc88efc..7e78b6b42ed 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.15 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: if_le.c,v 1.16 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: if_le.c,v 1.43 1997/05/05 21:05:32 thorpej Exp $ */
/*-
@@ -196,7 +196,11 @@ leattach(parent, self, aux)
am7990_config(sc);
/* Establish the interrupt handler. */
- (void) dio_intr_establish(leintr, sc, ipl, IPL_NET);
+ lesc->sc_isr.isr_func = leintr;
+ lesc->sc_isr.isr_arg = lesc;
+ lesc->sc_isr.isr_ipl = ipl;
+ lesc->sc_isr.isr_priority = IPL_NET;
+ dio_intr_establish(&lesc->sc_isr, self->dv_xname);
ler0->ler0_status = LE_IE;
}
@@ -204,7 +208,8 @@ int
leintr(arg)
void *arg;
{
- struct am7990_softc *sc = arg;
+ struct le_softc *lesc = (struct le_softc *)arg;
+ struct am7990_softc *sc = &lesc->sc_am7990;
#ifdef USELEDS
u_int16_t isr;
@@ -220,5 +225,5 @@ leintr(arg)
ledcontrol(0, 0, LED_LANXMT);
#endif /* USELEDS */
- return (am7990_intr(sc));
+ return am7990_intr(sc);
}
diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h
index 3b18cc3d140..8fbed649e56 100644
--- a/sys/arch/hp300/dev/if_levar.h
+++ b/sys/arch/hp300/dev/if_levar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_levar.h,v 1.6 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: if_levar.h,v 1.7 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: if_levar.h,v 1.8 1997/04/14 02:30:45 thorpej Exp $ */
/*-
@@ -45,6 +45,7 @@
*/
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
+ struct isr sc_isr;
struct lereg0 *sc_r0; /* DIO registers */
struct lereg1 *sc_r1; /* LANCE registers */
diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c
index 3f6482f17de..9cd0f88c727 100644
--- a/sys/arch/hp300/dev/nhpib.c
+++ b/sys/arch/hp300/dev/nhpib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nhpib.c,v 1.12 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: nhpib.c,v 1.13 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: nhpib.c,v 1.17 1997/05/05 21:06:41 thorpej Exp $ */
/*
@@ -108,6 +108,7 @@ struct hpib_controller nhpib_controller = {
struct nhpib_softc {
struct device sc_dev; /* generic device glue */
+ struct isr sc_isr;
struct nhpibdevice *sc_regs; /* device registers */
struct hpibbus_softc *sc_hpibbus; /* XXX */
struct timeout sc_read_to; /* nhpibreadtimo timeout */
@@ -176,7 +177,11 @@ nhpibattach(parent, self, aux)
printf(" ipl %d: %s\n", ipl, desc);
/* Establish the interrupt handler. */
- (void) dio_intr_establish(nhpibintr, sc, ipl, IPL_BIO);
+ sc->sc_isr.isr_func = nhpibintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = ipl;
+ sc->sc_isr.isr_priority = IPL_BIO;
+ dio_intr_establish(&sc->sc_isr, self->dv_xname);
/* Initialize timeout structures */
timeout_set(&sc->sc_read_to, nhpibreadtimo, &sc->sc_hpibbus);
diff --git a/sys/arch/hp300/dev/spc.c b/sys/arch/hp300/dev/spc.c
index 83bfc354845..32695bb0f75 100644
--- a/sys/arch/hp300/dev/spc.c
+++ b/sys/arch/hp300/dev/spc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spc.c,v 1.8 2004/08/30 17:01:43 miod Exp $ */
+/* $OpenBSD: spc.c,v 1.9 2004/09/29 07:35:52 miod Exp $ */
/* $NetBSD: spc.c,v 1.2 2003/11/17 14:37:59 tsutsui Exp $ */
/*
@@ -67,6 +67,7 @@ void spc_dio_reset(struct spc_softc *);
struct spc_dio_softc {
struct spc_softc sc_spc; /* MI spc softc */
+ struct isr sc_isr;
volatile u_int8_t *sc_dregs; /* Complete registers */
struct dmaqueue sc_dq; /* DMA job queue */
@@ -156,7 +157,11 @@ spc_dio_attach(struct device *parent, struct device *self, void *aux)
hpspc_write(HPSCSI_CSR, 0x00);
hpspc_write(HPSCSI_HCONF, 0x00);
- dio_intr_establish(spc_dio_intr, (void *)dsc, ipl, IPL_BIO);
+ dsc->sc_isr.isr_func = spc_dio_intr;
+ dsc->sc_isr.isr_arg = dsc;
+ dsc->sc_isr.isr_ipl = ipl;
+ dsc->sc_isr.isr_priority = IPL_BIO;
+ dio_intr_establish(&dsc->sc_isr, self->dv_xname);
spc_attach(sc);
diff --git a/sys/arch/hp300/hp300/clock.c b/sys/arch/hp300/hp300/clock.c
index fdc47ebb04e..98924b79f04 100644
--- a/sys/arch/hp300/hp300/clock.c
+++ b/sys/arch/hp300/hp300/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.9 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: clock.c,v 1.10 2004/09/29 07:35:54 miod Exp $ */
/* $NetBSD: clock.c,v 1.20 1997/04/27 20:43:38 thorpej Exp $ */
/*
@@ -51,6 +51,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/tty.h>
+#include <sys/evcount.h>
#include <machine/psl.h>
#include <machine/cpu.h>
@@ -88,6 +89,7 @@ static int month_days[12] = {
u_char bbc_registers[13];
struct hil_dev *bbcaddr = NULL;
+void clockintr(struct clockframe *);
void statintr(struct clockframe *);
void hp300_calibrate_delay(void);
@@ -97,6 +99,9 @@ void read_bbc(void);
u_char read_bbc_reg(int);
u_char write_bbc_reg(int, u_int);
+struct evcount clockcnt;
+struct evcount statcnt;
+
/*
* Machine-dependent clock routines.
*
@@ -246,6 +251,9 @@ cpu_initclocks()
timer3min = statmin;
statprev = statint;
+ evcount_attach(&statcnt, "stat", NULL, &evcount_intr);
+ evcount_attach(&clockcnt, "clock", NULL, &evcount_intr);
+
/* finally, load hardware */
clk->clk_cr2 = CLK_CR1;
clk->clk_cr1 = CLK_RESET;
@@ -275,10 +283,19 @@ setstatclockrate(newhz)
}
/*
+ * Timer clock interrupt.
+ */
+void
+clockintr(fp)
+ struct clockframe *fp;
+{
+ clockcnt.ec_count++;
+ hardclock(fp);
+}
+
+/*
* Statistics/profiling clock interrupt. Compute a new interval.
* Interrupt has already been cleared.
- *
- * DO THIS INLINE IN locore.s?
*/
void
statintr(fp)
@@ -306,6 +323,7 @@ statintr(fp)
asm volatile(" movpw %0,%1@(13)" : : "d" (newint), "a" (clk));
statprev = newint;
+ statcnt.ec_count++;
statclock(fp);
}
diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c
index 0060f4e8def..68eb53836aa 100644
--- a/sys/arch/hp300/hp300/intr.c
+++ b/sys/arch/hp300/hp300/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.12 2003/11/06 21:09:34 mickey Exp $ */
+/* $OpenBSD: intr.c,v 1.13 2004/09/29 07:35:54 miod Exp $ */
/* $NetBSD: intr.c,v 1.5 1998/02/16 20:58:30 thorpej Exp $ */
/*-
@@ -41,8 +41,6 @@
* Link and dispatch interrupts.
*/
-#define _HP300_INTR_H_PRIVATE
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
@@ -59,6 +57,13 @@ void netintr(void);
#include <machine/cpu.h>
#include <machine/intr.h>
+/*
+ * The location and size of the autovectored interrupt portion
+ * of the vector table.
+ */
+#define ISRLOC 0x18
+#define NISR 8
+
typedef LIST_HEAD(, isr) isr_list_t;
isr_list_t isr_list[NISR];
@@ -159,28 +164,19 @@ intr_printlevels()
* Establish an interrupt handler.
* Called by driver attach functions.
*/
-void *
-intr_establish(func, arg, ipl, priority)
- int (*func)(void *);
- void *arg;
- int ipl;
- int priority;
+void
+intr_establish(struct isr *isr, const char *name)
{
- struct isr *newisr, *curisr;
+ struct isr *curisr;
isr_list_t *list;
- if ((ipl < 0) || (ipl >= NISR))
- panic("intr_establish: bad ipl %d", ipl);
-
- newisr = (struct isr *)malloc(sizeof(struct isr), M_DEVBUF, M_NOWAIT);
- if (newisr == NULL)
- panic("intr_establish: can't allocate space for isr");
+#ifdef DIAGNOSTIC
+ if (isr->isr_ipl < 0 || isr->isr_ipl >= NISR)
+ panic("intr_establish: bad ipl %d", isr->isr_ipl);
+#endif
- /* Fill in the new entry. */
- newisr->isr_func = func;
- newisr->isr_arg = arg;
- newisr->isr_ipl = ipl;
- newisr->isr_priority = priority;
+ evcount_attach(&isr->isr_count, name, &isr->isr_ipl,
+ &evcount_intr);
/*
* Some devices are particularly sensitive to interrupt
@@ -196,9 +192,9 @@ intr_establish(func, arg, ipl, priority)
* additional work is necessary; we simply insert ourselves
* at the head of the list.
*/
- list = &isr_list[ipl];
+ list = &isr_list[isr->isr_ipl];
if (list->lh_first == NULL) {
- LIST_INSERT_HEAD(list, newisr, isr_link);
+ LIST_INSERT_HEAD(list, isr, isr_link);
goto compute;
}
@@ -209,8 +205,8 @@ intr_establish(func, arg, ipl, priority)
*/
for (curisr = list->lh_first; curisr->isr_link.le_next != NULL;
curisr = curisr->isr_link.le_next) {
- if (newisr->isr_priority > curisr->isr_priority) {
- LIST_INSERT_BEFORE(curisr, newisr, isr_link);
+ if (isr->isr_priority > curisr->isr_priority) {
+ LIST_INSERT_BEFORE(curisr, isr, isr_link);
goto compute;
}
}
@@ -219,25 +215,21 @@ intr_establish(func, arg, ipl, priority)
* We're the least important entry, it seems. We just go
* on the end.
*/
- LIST_INSERT_AFTER(curisr, newisr, isr_link);
+ LIST_INSERT_AFTER(curisr, isr, isr_link);
compute:
/* Compute new interrupt levels. */
intr_computeipl();
- return (newisr);
}
/*
* Disestablish an interrupt handler.
*/
void
-intr_disestablish(arg)
- void *arg;
+intr_disestablish(struct isr *isr)
{
- struct isr *isr = arg;
-
+ evcount_detach(&isr->isr_count);
LIST_REMOVE(isr, isr_link);
- free(isr, M_DEVBUF);
intr_computeipl();
}
@@ -251,12 +243,14 @@ intr_dispatch(evec)
{
struct isr *isr;
isr_list_t *list;
- int handled, ipl, vec;
+ int handled, rc, ipl, vec;
static int straycount, unexpected;
vec = (evec & 0xfff) >> 2;
- if ((vec < ISRLOC) || (vec >= (ISRLOC + NISR)))
+#ifdef DIAGNOSTIC
+ if (vec < ISRLOC || vec >= (ISRLOC + NISR))
panic("isrdispatch: bad vec 0x%x", vec);
+#endif
ipl = vec - ISRLOC;
intrcnt[ipl]++;
@@ -272,8 +266,12 @@ intr_dispatch(evec)
handled = 0;
/* Give all the handlers a chance. */
- for (isr = list->lh_first ; isr != NULL; isr = isr->isr_link.le_next)
- handled |= (*isr->isr_func)(isr->isr_arg);
+ for (isr = list->lh_first ; isr != NULL; isr = isr->isr_link.le_next) {
+ rc = (*isr->isr_func)(isr->isr_arg);
+ if (rc > 0)
+ isr->isr_count.ec_count++;
+ handled |= rc;
+ }
if (handled)
straycount = 0;
diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s
index c22b49a47f3..12f2001e8e5 100644
--- a/sys/arch/hp300/hp300/locore.s
+++ b/sys/arch/hp300/hp300/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.41 2004/07/22 19:36:38 miod Exp $ */
+/* $OpenBSD: locore.s,v 1.42 2004/09/29 07:35:54 miod Exp $ */
/* $NetBSD: locore.s,v 1.91 1998/11/11 06:41:25 thorpej Exp $ */
/*
@@ -1078,13 +1078,13 @@ Lnoleds1:
movl d0,_ASM_LABEL(heartbeat)
Lnoleds0:
#endif /* USELEDS */
- jbsr _C_LABEL(hardclock) | hardclock(&frame)
+ jbsr _C_LABEL(clockintr) | clockintr(&frame)
addql #4,sp
CLKADDR(a0)
Lrecheck:
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS | chalk up another interrupt
movb a0@(CLKSR),d0 | see if anything happened
- jmi Lclkagain | while we were in hardclock/statintr
+ jmi Lclkagain | while we were in clockintr/statintr
INTERRUPT_RESTOREREG
jra _ASM_LABEL(rei) | all done
diff --git a/sys/arch/hp300/include/intr.h b/sys/arch/hp300/include/intr.h
index 39876f354b1..36afd870b1b 100644
--- a/sys/arch/hp300/include/intr.h
+++ b/sys/arch/hp300/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.11 2003/12/22 15:05:05 millert Exp $ */
+/* $OpenBSD: intr.h,v 1.12 2004/09/29 07:35:54 miod Exp $ */
/* $NetBSD: intr.h,v 1.2 1997/07/24 05:43:08 scottr Exp $ */
/*-
@@ -41,25 +41,17 @@
#define _HP300_INTR_H_
#include <machine/psl.h>
-
-#ifdef _HP300_INTR_H_PRIVATE
+#include <sys/evcount.h>
#include <sys/queue.h>
-/*
- * The location and size of the autovectored interrupt portion
- * of the vector table.
- */
-#define ISRLOC 0x18
-#define NISR 8
-
struct isr {
LIST_ENTRY(isr) isr_link;
int (*isr_func)(void *);
void *isr_arg;
int isr_ipl;
int isr_priority;
+ struct evcount isr_count;
};
-#endif /* _HP300_INTR_H_PRIVATE */
#ifdef _KERNEL
/*
@@ -175,8 +167,8 @@ int spl0(void);
/* intr.c */
void intr_init(void);
-void *intr_establish(int (*)(void *), void *, int, int);
-void intr_disestablish(void *);
+void intr_establish(struct isr *, const char *);
+void intr_disestablish(struct isr *);
void intr_dispatch(int);
void intr_printlevels(void);
#endif /* _KERNEL */
diff --git a/sys/arch/hp300/include/types.h b/sys/arch/hp300/include/types.h
index 3cab2a988d6..36b6de4792e 100644
--- a/sys/arch/hp300/include/types.h
+++ b/sys/arch/hp300/include/types.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: types.h,v 1.3 2001/09/01 05:48:18 jason Exp $ */
+/* $OpenBSD: types.h,v 1.4 2004/09/29 07:35:54 miod Exp $ */
/* $NetBSD: types.h,v 1.8 1996/12/17 08:11:50 thorpej Exp $ */
#ifndef _MACHINE_TYPES_H_
@@ -7,5 +7,6 @@
#include <m68k/types.h>
#define __HAVE_DEVICE_REGISTER
+#define __HAVE_EVCOUNT
#endif