From afa910a4edee0b2b76eb7fbcccde4c6185949bc6 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Sat, 14 Jun 2003 19:11:40 +0000 Subject: [PATCH] Add isa_intr_alloc() for isapnp support. --- sys/arch/arc/include/isa_machdep.h | 4 ++- sys/arch/arc/isa/isabus.c | 39 +++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/sys/arch/arc/include/isa_machdep.h b/sys/arch/arc/include/isa_machdep.h index 71137fd6c637..a5a669f5a730 100644 --- a/sys/arch/arc/include/isa_machdep.h +++ b/sys/arch/arc/include/isa_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: isa_machdep.h,v 1.7 2003/05/09 23:51:26 fvdl Exp $ */ +/* $NetBSD: isa_machdep.h,v 1.8 2003/06/14 19:11:40 tsutsui Exp $ */ /* $OpenBSD: isa_machdep.h,v 1.5 1997/04/19 17:20:00 pefo Exp $ */ /* @@ -119,6 +119,8 @@ struct arc_isa_bus { #define isa_mappage(m, o, p) \ _isa_mappage((m), (o), (p)) +int isa_intr_alloc(isa_chipset_tag_t, int, int, int *); + void sysbeepstop(void *); void sysbeep(int, int); diff --git a/sys/arch/arc/isa/isabus.c b/sys/arch/arc/isa/isabus.c index 5aa19d2486ea..7dd9090a9c2e 100644 --- a/sys/arch/arc/isa/isabus.c +++ b/sys/arch/arc/isa/isabus.c @@ -1,4 +1,4 @@ -/* $NetBSD: isabus.c,v 1.20 2003/05/25 14:00:15 tsutsui Exp $ */ +/* $NetBSD: isabus.c,v 1.21 2003/06/14 19:11:41 tsutsui Exp $ */ /* $OpenBSD: isabus.c,v 1.15 1998/03/16 09:38:46 pefo Exp $ */ /* NetBSD: isa.c,v 1.33 1995/06/28 04:30:51 cgd Exp */ @@ -488,3 +488,40 @@ sysbeep(pitch, period) beeping = last_period = period; callout_reset(&sysbeep_ch, period, sysbeepstop, NULL); } + +int +isa_intr_alloc(isa_chipset_tag_t c, int mask, int type, int *irq_p) +{ + int irq; + int maybe_irq = -1; + int shared_depth = 0; + mask &= 0x8b28; /* choose from 3, 5, 8, 9, 11, 15 XXX */ + for (irq = 0; mask != 0; mask >>= 1, irq++) { + if ((mask & 1) == 0) + continue; + if (intrtype[irq] == IST_NONE) { + *irq_p = irq; + return 0; + } + /* Level interrupts can be shared */ + if (type == IST_LEVEL && intrtype[irq] == IST_LEVEL) { + struct intrhand *ih = intrhand[irq]; + int depth; + if (maybe_irq == -1) { + maybe_irq = irq; + continue; + } + for (depth = 0; ih != NULL; ih = ih->ih_next) + depth++; + if (depth < shared_depth) { + maybe_irq = irq; + shared_depth = depth; + } + } + } + if (maybe_irq != -1) { + *irq_p = maybe_irq; + return 0; + } + return 1; +}