Yet more interrupt cleanup -- the platform mater interrupt establish

function now just takes an "irq", which is an index into the irqmap
table for that platform.
This commit is contained in:
thorpej 2001-06-15 04:01:39 +00:00
parent 993a4807cb
commit e51a043945
9 changed files with 121 additions and 100 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: algor_p4032_intr.c,v 1.3 2001/06/10 09:13:06 thorpej Exp $ */
/* $NetBSD: algor_p4032_intr.c,v 1.4 2001/06/15 04:01:39 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -126,6 +126,15 @@ const char *p4032_intrnames[NIRQMAPS] = {
"mcclock",
};
struct p4032_irqmap {
int irqidx;
int cpuintr;
int irqreg;
int irqbit;
int xbarreg;
int xbarshift;
};
const struct p4032_irqmap p4032_irqmap[NIRQMAPS] = {
/*
* PCI INTERRUPTS
@ -153,35 +162,35 @@ const struct p4032_irqmap p4032_irqmap[NIRQMAPS] = {
/*
* 8-BIT DEVICE INTERRUPTS
*/
{ 4, 1,
{ P4032_IRQ_PCICTLR, 1,
IRQREG_8BIT, IRR0_PCICTLR,
0, 0 },
{ 5, 1,
{ P4032_IRQ_FLOPPY, 1,
IRQREG_8BIT, IRR0_FLOPPY,
0, 2 },
{ 6, 1,
{ P4032_IRQ_PCKBC, 1,
IRQREG_8BIT, IRR0_PCKBC,
0, 4 },
{ 7, 1,
{ P4032_IRQ_COM1, 1,
IRQREG_8BIT, IRR0_COM1,
0, 6 },
{ 8, 1,
{ P4032_IRQ_COM2, 1,
IRQREG_8BIT, IRR0_COM2,
1, 0 },
{ 9, 1,
{ P4032_IRQ_LPT, 1,
IRQREG_8BIT, IRR0_LPT,
1, 2 },
{ 10, 1,
{ P4032_IRQ_GPIO, 1,
IRQREG_8BIT, IRR0_GPIO,
1, 4 },
{ 11, 1,
{ P4032_IRQ_RTC, 1,
IRQREG_8BIT, IRR0_RTC,
1, 6 },
};
@ -210,12 +219,15 @@ const char *p4032_intrgroups[NINTRS] = {
"8-bit",
};
void *algor_p4032_intr_establish(int, int (*)(void *), void *);
void algor_p4032_intr_disestablish(void *);
int algor_p4032_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
const char *algor_p4032_pci_intr_string(void *, pci_intr_handle_t);
const struct evcnt *algor_p4032_pci_intr_evcnt(void *, pci_intr_handle_t);
void *algor_p4032_pci_intr_establish(void *, pci_intr_handle_t, int,
int (*)(void *), void *);
void algor_p4032_pci_intr_disestablish(void *, void *);
void algor_p4032_pci_conf_interrupt(void *, int, int, int, int, int *);
void algor_p4032_iointr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
@ -255,10 +267,12 @@ algor_p4032_intr_init(struct p4032_config *acp)
acp->ac_pc.pc_intr_string = algor_p4032_pci_intr_string;
acp->ac_pc.pc_intr_evcnt = algor_p4032_pci_intr_evcnt;
acp->ac_pc.pc_intr_establish = algor_p4032_pci_intr_establish;
acp->ac_pc.pc_intr_disestablish = algor_p4032_intr_disestablish;
acp->ac_pc.pc_intr_disestablish = algor_p4032_pci_intr_disestablish;
acp->ac_pc.pc_conf_interrupt = algor_p4032_pci_conf_interrupt;
acp->ac_pc.pc_pciide_compat_intr_establish = NULL;
algor_intr_establish = algor_p4032_intr_establish;
algor_intr_disestablish = algor_p4032_intr_disestablish;
algor_iointr = algor_p4032_iointr;
}
@ -328,12 +342,16 @@ algor_p4032_cal_timer(bus_space_tag_t st, bus_space_handle_t sh)
}
void *
algor_p4032_intr_establish(const struct p4032_irqmap *irqmap,
int (*func)(void *), void *arg)
algor_p4032_intr_establish(int irq, int (*func)(void *), void *arg)
{
const struct p4032_irqmap *irqmap;
struct algor_intrhand *ih;
int s;
irqmap = &p4032_irqmap[irq];
KASSERT(irq == irqmap->irqidx);
ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT);
if (ih == NULL)
return (NULL);
@ -366,12 +384,14 @@ algor_p4032_intr_establish(const struct p4032_irqmap *irqmap,
}
void
algor_p4032_intr_disestablish(void *v, void *cookie)
algor_p4032_intr_disestablish(void *cookie)
{
const struct p4032_irqmap *irqmap;
struct algor_intrhand *ih = v;
struct algor_intrhand *ih = cookie;
int s;
irqmap = ih->ih_irqmap;
s = splhigh();
/*
@ -544,7 +564,14 @@ algor_p4032_pci_intr_establish(void *v, pci_intr_handle_t ih, int level,
if (ih >= NPCIIRQS)
panic("algor_p4032_intr_establish: bogus IRQ %ld\n", ih);
return (algor_p4032_intr_establish(&p4032_irqmap[ih], func, arg));
return (algor_p4032_intr_establish(ih, func, arg));
}
void
algor_p4032_pci_intr_disestablish(void *v, void *cookie)
{
return (algor_p4032_intr_disestablish(cookie));
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: algor_p4032var.h,v 1.2 2001/06/10 05:26:58 thorpej Exp $ */
/* $NetBSD: algor_p4032var.h,v 1.3 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -68,21 +68,7 @@ struct p4032_config {
#define P4032_IRQ_GPIO 10
#define P4032_IRQ_RTC 11
struct p4032_irqmap {
int irqidx;
int cpuintr;
int irqreg;
int irqbit;
int xbarreg;
int xbarshift;
};
void algor_p4032_intr_disestablish(void *, void *);
void *algor_p4032_intr_establish(const struct p4032_irqmap *,
int (*)(void *), void *);
extern struct p4032_config p4032_configuration;
extern const struct p4032_irqmap p4032_irqmap[];
void algor_p4032loc_bus_io_init(bus_space_tag_t, void *);
void algor_p4032_bus_io_init(bus_space_tag_t, void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: algor_p5064_intr.c,v 1.3 2001/06/10 09:13:07 thorpej Exp $ */
/* $NetBSD: algor_p5064_intr.c,v 1.4 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -146,6 +146,15 @@ const char *p5064_intrnames[NIRQMAPS] = {
"IDE secondary",
};
struct p5064_irqmap {
int irqidx;
int cpuintr;
int irqreg;
int irqbit;
int xbarreg;
int xbarshift;
};
const struct p5064_irqmap p5064_irqmap[NIRQMAPS] = {
/*
* PCI INTERRUPTS
@ -171,17 +180,17 @@ const struct p5064_irqmap p5064_irqmap[NIRQMAPS] = {
2, 6 },
/* Ethernet */
{ 4, 1,
{ P5064_IRQ_ETHERNET, 1,
IRQREG_PCIINT, PCIINT_ETH,
4, 2 },
/* SCSI */
{ 5, 1,
{ P5064_IRQ_SCSI, 1,
IRQREG_PCIINT, PCIINT_SCSI,
4, 4 },
/* USB */
{ 6, 1,
{ P5064_IRQ_USB, 1,
IRQREG_PCIINT, PCIINT_USB,
4, 6 },
@ -189,32 +198,32 @@ const struct p5064_irqmap p5064_irqmap[NIRQMAPS] = {
* LOCAL INTERRUPTS
*/
/* keyboard */
{ 7, 2,
{ P5064_IRQ_MKBD, 2,
IRQREG_LOCINT, LOCINT_MKBD,
0, 4 },
/* COM1 */
{ 8, 2,
{ P5064_IRQ_COM1, 2,
IRQREG_LOCINT, LOCINT_COM1,
0, 6 },
/* COM2 */
{ 9, 2,
{ P5064_IRQ_COM2, 2,
IRQREG_LOCINT, LOCINT_COM2,
1, 0 },
/* floppy controller */
{ 10, 2,
{ P5064_IRQ_FLOPPY, 2,
IRQREG_LOCINT, LOCINT_FLP,
0, 2 },
/* parallel port */
{ 11, 2,
{ P5064_IRQ_CENTRONICS, 2,
IRQREG_LOCINT, LOCINT_CENT,
1, 2 },
/* RTC */
{ 12, 2,
{ P5064_IRQ_RTC, 2,
IRQREG_LOCINT, LOCINT_RTC,
1, 6 },
@ -222,17 +231,17 @@ const struct p5064_irqmap p5064_irqmap[NIRQMAPS] = {
* ISA INTERRUPTS
*/
/* ISA bridge */
{ 13, 0,
{ P5064_IRQ_ISABRIDGE, 0,
IRQREG_ISAINT, ISAINT_ISABR,
0, 4 },
/* IDE 0 */
{ 14, 0,
{ P5064_IRQ_IDE0, 0,
IRQREG_ISAINT, ISAINT_IDE0,
3, 2 },
/* IDE 1 */
{ 15, 0,
{ P5064_IRQ_IDE1, 0,
IRQREG_ISAINT, ISAINT_IDE1,
3, 4 },
};
@ -282,11 +291,15 @@ const char *p5064_intrgroups[NINTRS] = {
"local",
};
void *algor_p5064_intr_establish(int, int (*)(void *), void *);
void algor_p5064_intr_disestablish(void *);
int algor_p5064_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
const char *algor_p5064_pci_intr_string(void *, pci_intr_handle_t);
const struct evcnt *algor_p5064_pci_intr_evcnt(void *, pci_intr_handle_t);
void *algor_p5064_pci_intr_establish(void *, pci_intr_handle_t, int,
int (*)(void *), void *);
void algor_p5064_pci_intr_disestablish(void *, void *);
void *algor_p5064_pciide_compat_intr_establish(void *, struct device *,
struct pci_attach_args *, int, int (*)(void *), void *);
void algor_p5064_pci_conf_interrupt(void *, int, int, int, int, int *);
@ -294,6 +307,7 @@ void algor_p5064_pci_conf_interrupt(void *, int, int, int, int, int *);
const struct evcnt *algor_p5064_isa_intr_evcnt(void *, int);
void *algor_p5064_isa_intr_establish(void *, int, int, int,
int (*)(void *), void *);
void algor_p5064_isa_intr_disestablish(void *, void *);
int algor_p5064_isa_intr_alloc(void *, int, int, int *);
void algor_p5064_iointr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
@ -333,7 +347,7 @@ algor_p5064_intr_init(struct p5064_config *acp)
acp->ac_pc.pc_intr_string = algor_p5064_pci_intr_string;
acp->ac_pc.pc_intr_evcnt = algor_p5064_pci_intr_evcnt;
acp->ac_pc.pc_intr_establish = algor_p5064_pci_intr_establish;
acp->ac_pc.pc_intr_disestablish = algor_p5064_intr_disestablish;
acp->ac_pc.pc_intr_disestablish = algor_p5064_pci_intr_disestablish;
acp->ac_pc.pc_conf_interrupt = algor_p5064_pci_conf_interrupt;
acp->ac_pc.pc_pciide_compat_intr_establish =
algor_p5064_pciide_compat_intr_establish;
@ -341,9 +355,11 @@ algor_p5064_intr_init(struct p5064_config *acp)
acp->ac_ic.ic_v = NULL;
acp->ac_ic.ic_intr_evcnt = algor_p5064_isa_intr_evcnt;
acp->ac_ic.ic_intr_establish = algor_p5064_isa_intr_establish;
acp->ac_ic.ic_intr_disestablish = algor_p5064_intr_disestablish;
acp->ac_ic.ic_intr_disestablish = algor_p5064_isa_intr_disestablish;
acp->ac_ic.ic_intr_alloc = algor_p5064_isa_intr_alloc;
algor_intr_establish = algor_p5064_intr_establish;
algor_intr_disestablish = algor_p5064_intr_disestablish;
algor_iointr = algor_p5064_iointr;
}
@ -413,12 +429,16 @@ algor_p5064_cal_timer(bus_space_tag_t st, bus_space_handle_t sh)
}
void *
algor_p5064_intr_establish(const struct p5064_irqmap *irqmap,
int (*func)(void *), void *arg)
algor_p5064_intr_establish(int irq, int (*func)(void *), void *arg)
{
const struct p5064_irqmap *irqmap;
struct algor_intrhand *ih;
int s;
irqmap = &p5064_irqmap[irq];
KASSERT(irq == irqmap->irqidx);
ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT);
if (ih == NULL)
return (NULL);
@ -451,12 +471,14 @@ algor_p5064_intr_establish(const struct p5064_irqmap *irqmap,
}
void
algor_p5064_intr_disestablish(void *v, void *cookie)
algor_p5064_intr_disestablish(void *cookie)
{
const struct p5064_irqmap *irqmap;
struct algor_intrhand *ih = v;
struct algor_intrhand *ih = cookie;
int s;
irqmap = ih->ih_irqmap;
s = splhigh();
/*
@ -621,7 +643,14 @@ algor_p5064_pci_intr_establish(void *v, pci_intr_handle_t ih, int level,
if (ih >= NPCIIRQS)
panic("algor_p5064_intr_establish: bogus IRQ %ld\n", ih);
return (algor_p5064_intr_establish(&p5064_irqmap[ih], func, arg));
return (algor_p5064_intr_establish(ih, func, arg));
}
void
algor_p5064_pci_intr_disestablish(void *v, void *cookie)
{
return (algor_p5064_intr_disestablish(cookie));
}
void
@ -640,7 +669,6 @@ void *
algor_p5064_pciide_compat_intr_establish(void *v, struct device *dev,
struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
{
const struct p5064_irqmap *irqmap;
pci_chipset_tag_t pc = pa->pa_pc;
void *cookie;
int bus;
@ -653,14 +681,12 @@ algor_p5064_pciide_compat_intr_establish(void *v, struct device *dev,
if (bus != 0)
return (NULL);
irqmap = &p5064_irqmap[P5064_IRQ_IDE0 + chan];
cookie = algor_p5064_intr_establish(irqmap, func, arg);
cookie = algor_p5064_intr_establish(P5064_IRQ_IDE0 + chan, func, arg);
if (cookie == NULL)
return (NULL);
printf("%s: %s channel interrupting at on-board %s IRQ\n",
dev->dv_xname, PCIIDE_CHANNEL_NAME(chan),
p5064_intrnames[irqmap->irqidx]);
p5064_intrnames[P5064_IRQ_IDE0 + chan]);
return (cookie);
}
@ -688,7 +714,14 @@ algor_p5064_isa_intr_establish(void *v, int iirq, int type, int level,
if ((irqidx = p5064_isa_to_irqmap[iirq]) == -1)
return (NULL);
return (algor_p5064_intr_establish(&p5064_irqmap[irqidx], func, arg));
return (algor_p5064_intr_establish(irqidx, func, arg));
}
void
algor_p5064_isa_intr_disestablish(void *v, void *cookie)
{
algor_p5064_intr_disestablish(cookie);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: algor_p5064var.h,v 1.3 2001/06/10 09:13:07 thorpej Exp $ */
/* $NetBSD: algor_p5064var.h,v 1.4 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -72,21 +72,7 @@ struct p5064_config {
#define P5064_IRQ_IDE0 14
#define P5064_IRQ_IDE1 15
struct p5064_irqmap {
int irqidx;
int cpuintr;
int irqreg;
int irqbit;
int xbarreg;
int xbarshift;
};
void algor_p5064_intr_disestablish(void *, void *);
void *algor_p5064_intr_establish(const struct p5064_irqmap *,
int (*)(void *), void *);
extern struct p5064_config p5064_configuration;
extern const struct p5064_irqmap p5064_irqmap[];
void algor_p5064_bus_io_init(bus_space_tag_t, void *);
void algor_p5064_bus_mem_init(bus_space_tag_t, void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: interrupt.c,v 1.4 2001/06/14 19:03:43 thorpej Exp $ */
/* $NetBSD: interrupt.c,v 1.5 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -62,6 +62,9 @@
#include <algor/algor/algor_p6032var.h>
#endif
void *(*algor_intr_establish)(int, int (*)(void *), void *);
void (*algor_intr_disestablish)(void *);
void (*algor_iointr)(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
struct algor_soft_intrhand *softnet_intrhand;

View File

@ -1,4 +1,4 @@
/* $NetBSD: com_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp $ */
/* $NetBSD: com_mainbus.c,v 1.3 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.3 2001/06/15 04:01:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -64,10 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#if defined(ALGOR_P4032)
#include <algor/algor/algor_p4032var.h>
#endif
struct com_mainbus_softc {
struct com_softc sc_com; /* real "com" softc */
@ -117,11 +113,7 @@ com_mainbus_attach(struct device *parent, struct device *self, void *aux)
com_attach_subr(sc);
#if defined(ALGOR_P4032)
msc->sc_ih = algor_p4032_intr_establish(&p4032_irqmap[ma->ma_irq],
comintr, sc);
#endif
msc->sc_ih = (*algor_intr_establish)(ma->ma_irq, comintr, sc);
if (msc->sc_ih == NULL) {
printf("%s: unable to establish interrupt\n",
sc->sc_dev.dv_xname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpt_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp $ */
/* $NetBSD: lpt_mainbus.c,v 1.3 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: lpt_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: lpt_mainbus.c,v 1.3 2001/06/15 04:01:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -62,10 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: lpt_mainbus.c,v 1.2 2001/06/10 05:26:59 thorpej Exp
#include <dev/ic/lptreg.h>
#include <dev/ic/lptvar.h>
#if defined(ALGOR_P4032)
#include <algor/algor/algor_p4032var.h>
#endif
struct lpt_mainbus_softc {
struct lpt_softc sc_lpt; /* real "lpt" softc */
@ -112,11 +108,7 @@ lpt_mainbus_attach(struct device *parent, struct device *self, void *aux)
lpt_attach_subr(sc);
#if defined(ALGOR_P4032)
sc->sc_ih = algor_p4032_intr_establish(&p4032_irqmap[ma->ma_irq],
lptintr, sc);
#endif
sc->sc_ih = (*algor_intr_establish)(ma->ma_irq, lptintr, sc);
if (msc->sc_ih == NULL) {
printf("%s: unable to establish interrupt\n",
sc->sc_dev.dv_xname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.3 2001/06/10 09:13:07 thorpej Exp $ */
/* $NetBSD: intr.h,v 1.4 2001/06/15 04:01:40 thorpej Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -174,6 +174,8 @@ extern struct algor_soft_intrhand *softnet_intrhand;
extern struct evcnt mips_int5_evcnt;
void intr_init(void);
void *(*algor_intr_establish)(int, int (*)(void *), void *);
void (*algor_intr_disestablish)(void *);
#endif /* _KERNEL */
#endif /* ! _ALGOR_INTR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcib.c,v 1.4 2001/06/10 09:28:26 thorpej Exp $ */
/* $NetBSD: pcib.c,v 1.5 2001/06/15 04:01:41 thorpej Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.4 2001/06/10 09:28:26 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.5 2001/06/15 04:01:41 thorpej Exp $");
#include "opt_algor_p5064.h"
#include "opt_algor_p6032.h"
@ -270,10 +270,10 @@ pcib_attach(struct device *parent, struct device *self, void *aux)
/* Hook up our interrupt handler. */
#if defined(ALGOR_P5064)
sc->sc_ih = algor_p5064_intr_establish(&p5064_irqmap[
P5064_IRQ_ISABRIDGE], pcib_intr, sc);
sc->sc_ih = (*algor_intr_establish)(P5064_IRQ_ISABRIDGE,
pcib_intr, sc);
#elif defined(ALGOR_P6032)
sc->sc_ih = algor_p6032_intr_establish(&p6032_irqmap[XXX],
sc->sc_ih = (*algor_intr_establish)(XXX,
pcib_intr, sc);
#endif
if (sc->sc_ih == NULL)