summaryrefslogtreecommitdiff
path: root/sys/arch/i386/isa
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1998-06-29 02:13:01 +0000
committerJason Downs <downsj@cvs.openbsd.org>1998-06-29 02:13:01 +0000
commitf56abcd0d549a363bea4dbc1297fc422f10c15cd (patch)
tree1a4b4ce5bcbe9cbb543c8cc52a2612f7e1dd80c9 /sys/arch/i386/isa
parentecd2252f547ee1e4c798be74469378b7e333f8e4 (diff)
Add and use isa_intr_check().
Diffstat (limited to 'sys/arch/i386/isa')
-rw-r--r--sys/arch/i386/isa/isa_machdep.c53
-rw-r--r--sys/arch/i386/isa/isa_machdep.h1
-rw-r--r--sys/arch/i386/isa/pms.c18
3 files changed, 47 insertions, 25 deletions
diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c
index d702b62e2ab..1466de2073d 100644
--- a/sys/arch/i386/isa/isa_machdep.c
+++ b/sys/arch/i386/isa/isa_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isa_machdep.c,v 1.29 1998/06/27 22:42:22 deraadt Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.30 1998/06/29 02:12:58 downsj Exp $ */
/* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */
#define ISA_DMA_STATS
@@ -445,6 +445,33 @@ isa_intr_alloc(ic, mask, type, irq)
}
/*
+ * Just check to see if an IRQ is available/can be shared.
+ */
+int
+isa_intr_check(ic, irq, type)
+ isa_chipset_tag_t ic; /* Not used. */
+ int irq;
+ int type;
+{
+ if (!LEGAL_IRQ(irq) || type == IST_NONE)
+ return (0);
+
+ switch (intrtype[irq]) {
+ case IST_NONE:
+ break;
+ case IST_EDGE:
+ case IST_LEVEL:
+ if (type != intrtype[irq])
+ return (0);
+ break;
+ case IST_PULSE:
+ if (type != IST_NONE)
+ return (0);
+ }
+ return (1);
+}
+
+/*
* Set up an interrupt handler to start being called.
* XXX PRONE TO RACE CONDITIONS, UGLY, 'INTERESTING' INSERTION ALGORITHM.
*/
@@ -464,16 +491,12 @@ isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg, ih_what)
/* no point in sleeping unless someone can free memory. */
ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
- if (ih == NULL) {
- printf("%s: isa_intr_establish: can't malloc handler info\n",
- ih_what);
- return NULL;
- }
+ if (ih == NULL)
+ panic("isa_intr_establish: can't malloc handler info");
+
+ if (!LEGAL_IRQ(irq) || type == IST_NONE)
+ panic("intr_establish: bogus irq or type");
- if (!LEGAL_IRQ(irq) || type == IST_NONE) {
- printf("%s: intr_establish: bogus irq or type\n", ih_what);
- return NULL;
- }
switch (intrtype[irq]) {
case IST_NONE:
intrtype[irq] = type;
@@ -483,12 +506,10 @@ isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg, ih_what)
if (type == intrtype[irq])
break;
case IST_PULSE:
- if (type != IST_NONE) {
- /*printf("%s: intr_establish: can't share %s with %s, irq %d\n",
- ih_what, isa_intr_typename(intrtype[irq]),
- isa_intr_typename(type), irq);*/
- return NULL;
- }
+ if (type != IST_NONE)
+ panic("intr_establish: can't share %s with %s, irq %d",
+ isa_intr_typename(intrtype[irq]),
+ isa_intr_typename(type), irq);
break;
}
diff --git a/sys/arch/i386/isa/isa_machdep.h b/sys/arch/i386/isa/isa_machdep.h
index b86993cfbc6..e74b560af6e 100644
--- a/sys/arch/i386/isa/isa_machdep.h
+++ b/sys/arch/i386/isa/isa_machdep.h
@@ -107,6 +107,7 @@ struct isabus_attach_args; /* XXX */
void isa_attach_hook __P((struct device *, struct device *,
struct isabus_attach_args *));
int isa_intr_alloc __P((isa_chipset_tag_t, int, int, int *));
+int isa_intr_check __P((isa_chipset_tag_t, int, int));
void *isa_intr_establish __P((isa_chipset_tag_t ic, int irq, int type,
int level, int (*ih_fun)(void *), void *ih_arg, char *ih_what));
void isa_intr_disestablish __P((isa_chipset_tag_t ic, void *handler));
diff --git a/sys/arch/i386/isa/pms.c b/sys/arch/i386/isa/pms.c
index c67515fb5c3..76f80a97304 100644
--- a/sys/arch/i386/isa/pms.c
+++ b/sys/arch/i386/isa/pms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pms.c,v 1.19 1998/06/27 22:42:47 deraadt Exp $ */
+/* $OpenBSD: pms.c,v 1.20 1998/06/29 02:13:00 downsj Exp $ */
/* $NetBSD: pms.c,v 1.29 1996/05/12 23:12:42 mycroft Exp $ */
/*-
@@ -186,7 +186,6 @@ pmsprobe(parent, match, aux)
void *match, *aux;
{
struct cfdata *cf = match;
- void *ih;
u_char x;
/*
@@ -209,15 +208,16 @@ pmsprobe(parent, match, aux)
x = inb(PMS_DATA);
pms_pit_cmd(PMS_INT_DISABLE);
if (x & 0x04)
- return 0;
+ return (0);
- ih = isa_intr_establish(aux, cf->cf_loc[0],
- IST_EDGE, IPL_TTY, pmsintr, NULL, pms_cd.cd_name);
- if (ih == NULL)
- return 0;
+ /* Make sure the IRQ is available. */
+ if (!isa_intr_check((isa_chipset_tag_t)0, cf->cf_loc[0], IST_EDGE)) {
+ printf ("%s%d: irq %d already in use\n", cf->cf_driver->cd_name,
+ cf->cf_unit, cf->cf_loc[0]);
+ return (0);
+ }
- isa_intr_disestablish(aux, ih);
- return 1;
+ return (1);
}
void