From bb40f57a7caad930203ee3bf5e653cd8d69e1019 Mon Sep 17 00:00:00 2001 From: imp Date: Fri, 10 Aug 2001 06:07:20 +0000 Subject: Move ISA interrupt ISR and timeout routines to pcic from pcic_isa so that we can use them in the pci code when we have to fall back to ISA interrupt routing. --- sys/pccard/pcic.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ sys/pccard/pcic_isa.c | 77 ++------------------------------------------------- sys/pccard/pcicvar.h | 3 ++ 3 files changed, 73 insertions(+), 75 deletions(-) diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index bb67631e..1cd257e 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -919,3 +919,71 @@ pcic_do_stat_delta(struct pcic_slot *sp) else pccard_event(sp->slt, card_inserted); } +/* + * Wrapper function for pcicintr so that signatures match. + */ +void +pcic_isa_intr(void *arg) +{ + pcic_isa_intr1(arg); +} + +/* + * PCIC timer. If the controller doesn't have a free IRQ to use + * or if interrupt steering doesn't work, poll the controller for + * insertion/removal events. + */ +void +pcic_timeout(void *chan) +{ + struct pcic_softc *sc = (struct pcic_softc *) chan; + + if (pcic_isa_intr1(chan) != 0) { + device_printf(sc->dev, + "Static bug detected, ignoring hardware."); + sc->slot_poll = 0; + return; + } + sc->timeout_ch = timeout(sc->slot_poll, chan, hz/2); +} + +/* + * PCIC Interrupt handler. + * Check each slot in turn, and read the card status change + * register. If this is non-zero, then a change has occurred + * on this card, so send an event to the main code. + */ +int +pcic_isa_intr1(void *arg) +{ + int slot, s; + u_int8_t chg; + struct pcic_softc *sc = (struct pcic_softc *) arg; + struct pcic_slot *sp = &sc->slots[0]; + + s = splhigh(); + for (slot = 0; slot < PCIC_CARD_SLOTS; slot++, sp++) { + if (sp->slt == NULL) + continue; + if ((chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) { + /* + * if chg is 0xff, then we know that we've hit + * the famous "static bug" for some desktop + * pcmcia cards. This is caused by static + * discharge frying the poor card's mind and + * it starts return 0xff forever. We return + * an error and stop polling the card. When + * we're interrupt based, we never see this. + * The card just goes away silently. + */ + if (chg == 0xff) { + splx(s); + return (EIO); + } + if (chg & PCIC_CDTCH) + pcic_do_stat_delta(sp); + } + } + splx(s); + return (0); +} diff --git a/sys/pccard/pcic_isa.c b/sys/pccard/pcic_isa.c index 860d800..4b0072e 100644 --- a/sys/pccard/pcic_isa.c +++ b/sys/pccard/pcic_isa.c @@ -75,10 +75,6 @@ static struct { { "Intel i82365SL-DF", PCIC_DF_POWER} }; -static driver_intr_t pcicintr; -static int pcicintr1(void *); -static timeout_t pcictimeout; - /* * Look for an Intel PCIC (or compatible). * For each available slot, allocate a PC-CARD slot. @@ -317,7 +313,7 @@ pcic_isa_attach(device_t dev) irq = 0; if (r != NULL) { error = bus_setup_intr(dev, r, INTR_TYPE_MISC, - pcicintr, (void *) sc, &sc->ih); + pcic_isa_intr, (void *) sc, &sc->ih); if (error) { pcic_dealloc(dev); return (error); @@ -327,7 +323,7 @@ pcic_isa_attach(device_t dev) } sc->irq = irq; if (irq == 0) { - sc->slot_poll = pcictimeout; + sc->slot_poll = pcic_timeout; sc->timeout_ch = timeout(sc->slot_poll, (void *) sc, hz/2); device_printf(dev, "Polling mode\n"); } @@ -335,75 +331,6 @@ pcic_isa_attach(device_t dev) return (pcic_attach(dev)); } -/* - * Wrapper function for pcicintr so that signatures match. - */ -static void -pcicintr(void *arg) -{ - pcicintr1(arg); -} - -/* - * PCIC timer. If the controller doesn't have a free IRQ to use - * or if interrupt steering doesn't work, poll the controller for - * insertion/removal events. - */ -static void -pcictimeout(void *chan) -{ - struct pcic_softc *sc = (struct pcic_softc *) chan; - - if (pcicintr1(chan) != 0) { - device_printf(sc->dev, - "Static bug detected, ignoring hardware."); - sc->slot_poll = 0; - return; - } - sc->timeout_ch = timeout(sc->slot_poll, chan, hz/2); -} - -/* - * PCIC Interrupt handler. - * Check each slot in turn, and read the card status change - * register. If this is non-zero, then a change has occurred - * on this card, so send an event to the main code. - */ -static int -pcicintr1(void *arg) -{ - int slot, s; - u_int8_t chg; - struct pcic_softc *sc = (struct pcic_softc *) arg; - struct pcic_slot *sp = &sc->slots[0]; - - s = splhigh(); - for (slot = 0; slot < PCIC_CARD_SLOTS; slot++, sp++) { - if (sp->slt == NULL) - continue; - if ((chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) { - /* - * if chg is 0xff, then we know that we've hit - * the famous "static bug" for some desktop - * pcmcia cards. This is caused by static - * discharge frying the poor card's mind and - * it starts return 0xff forever. We return - * an error and stop polling the card. When - * we're interrupt based, we never see this. - * The card just goes away silently. - */ - if (chg == 0xff) { - splx(s); - return (EIO); - } - if (chg & PCIC_CDTCH) - pcic_do_stat_delta(sp); - } - } - splx(s); - return (0); -} - static device_method_t pcic_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pcic_isa_probe), diff --git a/sys/pccard/pcicvar.h b/sys/pccard/pcicvar.h index 79d65a8..bd591e7 100644 --- a/sys/pccard/pcicvar.h +++ b/sys/pccard/pcicvar.h @@ -88,6 +88,8 @@ int pcic_get_memory_offset(device_t bus, device_t child, int rid, int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid, u_long *value); unsigned char pcic_getb_io(struct pcic_slot *sp, int reg); +driver_intr_t pcic_isa_intr; +int pcic_isa_intr1(void *); void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val); int pcic_set_memory_offset(device_t bus, device_t child, int rid, u_int32_t offset, u_int32_t *deltap); @@ -98,3 +100,4 @@ int pcic_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_intr_t *intr, void *arg, void **cookiep); int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie); +timeout_t pcic_timeout; -- cgit v1.1