diff --git a/sys/dev/pdq/if_fea.c b/sys/dev/pdq/if_fea.c index e7072a119213..ca0807ca81db 100644 --- a/sys/dev/pdq/if_fea.c +++ b/sys/dev/pdq/if_fea.c @@ -1,5 +1,3 @@ -#warning "fix if_fea.c! - newbus casualty" -#if 0 /*- * Copyright (c) 1995, 1996 Matt Thomas * All rights reserved. @@ -23,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_fea.c,v 1.13 1999/01/12 00:36:27 eivind Exp $ + * $Id: if_fea.c,v 1.14 1999/05/02 20:35:42 peter Exp $ */ /* @@ -33,465 +31,237 @@ */ #include +#include #include #include -#if defined(__bsdi__) || defined(__NetBSD__) -#include -#endif #include #include -#if defined(__FreeBSD__) +#include +#include +#include +#include +#include #include #include #include -#elif defined(__bsdi__) -#include -#include -#include -#include -#include -#include -#include -#elif defined(__NetBSD__) -#include -#include -#include -#include +static void pdq_eisa_subprobe __P((pdq_bus_t, u_int32_t, u_int32_t *, u_int32_t *, u_int32_t *)); +static void pdq_eisa_devinit __P((pdq_softc_t *)); +static const char * pdq_eisa_match __P((eisa_id_t)); +static int pdq_eisa_probe __P((device_t)); +static int pdq_eisa_attach __P((device_t)); +void pdq_eisa_intr __P((void *)); +static void pdq_eisa_shutdown __P((int, void *)); -#include -#include -#include -#endif +#define DEFEA_IRQS 0x0000FBA9U -/* - * - */ - -#define DEFEA_IRQS 0x0000FBA9U - -#if defined(__FreeBSD__) -static pdq_softc_t *pdqs_eisa[16]; -#define PDQ_EISA_UNIT_TO_SOFTC(unit) (pdqs_eisa[unit]) #define DEFEA_INTRENABLE 0x8 /* level interrupt */ -#define pdq_eisa_ifwatchdog NULL #define DEFEA_DECODE_IRQ(n) ((DEFEA_IRQS >> ((n) << 2)) & 0x0f) -#elif defined(__bsdi__) -extern struct cfdriver feacd; -#define PDQ_EISA_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)feacd.cd_devs[unit]) -#define DEFEA_INTRENABLE 0x28 /* edge interrupt */ -static const int pdq_eisa_irqs[4] = { IRQ9, IRQ10, IRQ11, IRQ15 }; -#define DEFEA_DECODE_IRQ(n) (pdq_eisa_irqs[(n)]) - -#elif defined(__NetBSD__) -#define DEFEA_INTRENABLE 0x8 /* level interrupt */ -#define pdq_eisa_ifwatchdog NULL -#define DEFEA_DECODE_IRQ(n) ((DEFEA_IRQS >> ((n) << 2)) & 0x0f) - -#else -#error unknown system -#endif - -#ifndef pdq_eisa_ifwatchdog -static ifnet_ret_t -pdq_eisa_ifwatchdog( - int unit) -{ - pdq_ifwatchdog(&PDQ_EISA_UNIT_TO_SOFTC(unit)->sc_if); -} -#endif +#define EISA_DEVICE_ID_DEC_DEC3001 0x10a33001 +#define EISA_DEVICE_ID_DEC_DEC3002 0x10a33002 +#define EISA_DEVICE_ID_DEC_DEC3003 0x10a33003 +#define EISA_DEVICE_ID_DEC_DEC3004 0x10a33004 static void -pdq_eisa_subprobe( - pdq_bus_t bc, - pdq_bus_ioport_t iobase, - pdq_uint32_t *maddr, - pdq_uint32_t *msize, - pdq_uint32_t *irq) +pdq_eisa_subprobe(bc, iobase, maddr, msize, irq) + pdq_bus_t bc; + u_int32_t iobase; + u_int32_t *maddr; + u_int32_t *msize; + u_int32_t *irq; { - if (irq != NULL) - *irq = DEFEA_DECODE_IRQ(PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_IO_CONFIG_STAT_0) & 3); - *maddr = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_0) << 8) - | (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_1) << 16); - *msize = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_MASK_0) + 4) << 8; + if (irq != NULL) + *irq = DEFEA_DECODE_IRQ(PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_IO_CONFIG_STAT_0) & 3); + *maddr = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_0) << 8) + | (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_1) << 16); + *msize = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_MASK_0) + 4) << 8; + + return; } static void -pdq_eisa_devinit( - pdq_softc_t *sc) +pdq_eisa_devinit (sc) + pdq_softc_t *sc; { - pdq_uint8_t data; + pdq_uint8_t data; - /* - * Do the standard initialization for the DEFEA registers. - */ - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_FUNCTION_CTRL, 0x23); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_1_1, (sc->sc_iobase >> 8) & 0xF0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_0_1, (sc->sc_iobase >> 8) & 0xF0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_SLOT_CTRL, 0x01); - data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF); + /* + * Do the standard initialization for the DEFEA registers. + */ + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_FUNCTION_CTRL, 0x23); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_1_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_0_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_SLOT_CTRL, 0x01); + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF); #if defined(PDQ_IOMAPPED) - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data & ~1); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data & ~1); #else - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data | 1); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data | 1); #endif - data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0, data | DEFEA_INTRENABLE); + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0, data | DEFEA_INTRENABLE); + + return; } -#if defined(__FreeBSD__) -static void pdq_eisa_shutdown(int howto, void *sc); -static int pdq_eisa_probe(void); -static int pdq_eisa_attach(struct eisa_device *ed); - -static unsigned long pdq_eisa_unit; - -static struct eisa_driver pdq_eisa_driver = { - "fea", pdq_eisa_probe, pdq_eisa_attach, NULL, &pdq_eisa_unit -}; - -DATA_SET(eisadriver_set, pdq_eisa_driver); - - static const char * -pdq_eisa_match( - eisa_id_t type) +pdq_eisa_match (type) + eisa_id_t type; { - if ((type >> 8) == 0x10a330) - return ("DEC DEFEA EISA FDDI Controller"); - return NULL; -} - -static int -pdq_eisa_probe( - void) -{ - struct eisa_device *ed = NULL; - int count; - - for (count = 0; (ed = eisa_match_dev(ed, pdq_eisa_match)) != NULL; count++) { - pdq_bus_ioport_t iobase = ed->ioconf.slot * EISA_SLOT_SIZE; - pdq_uint32_t irq, maddr, msize; - - eisa_add_iospace(ed, iobase, 0x200, RESVADDR_NONE); - pdq_eisa_subprobe(PDQ_BUS_EISA, iobase, &maddr, &msize, &irq); - eisa_add_mspace(ed, maddr, msize, RESVADDR_NONE); - eisa_add_intr(ed, irq); - eisa_registerdev(ed, &pdq_eisa_driver); - } - return count; -} - -static void -pdq_eisa_interrupt( - void *arg) -{ - pdq_softc_t * const sc = (pdq_softc_t *) arg; - (void) pdq_interrupt(sc->sc_pdq); -} - -static int -pdq_eisa_attach( - struct eisa_device *ed) -{ - pdq_softc_t *sc; - resvaddr_t *iospace; - resvaddr_t *mspace; - int irq; - - if (TAILQ_FIRST(&ed->ioconf.irqs) == NULL) - return (-1); - - irq = TAILQ_FIRST(&ed->ioconf.irqs)->irq_no; - - sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); - if (sc == NULL) { - printf("fea%ld: malloc failed!\n", ed->unit); - return -1; - } - pdqs_eisa[ed->unit] = sc; - - bzero(sc, sizeof(pdq_softc_t)); /* Zero out the softc*/ - sc->sc_if.if_name = "fea"; - sc->sc_if.if_unit = ed->unit; - - if ((iospace = ed->ioconf.ioaddrs.lh_first) == NULL) { - printf("fea%d: no iospace??\n", sc->sc_if.if_unit); - return -1; - } - if ((mspace = ed->ioconf.maddrs.lh_first) == NULL) { - printf("fea%d: no memory space??\n", sc->sc_if.if_unit); - return -1; - } - - sc->sc_iobase = (pdq_bus_ioport_t) iospace->addr; - sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(mspace->addr, mspace->size); - if (sc->sc_membase == NULL) { - printf("fea%d: failed to map memory 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); - return -1; - } - - eisa_reg_start(ed); - if (eisa_reg_iospace(ed, iospace)) { - printf("fea%d: failed to register iospace 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, iospace->addr, iospace->addr + iospace->size - 1); - return -1; - } - if (eisa_reg_mspace(ed, mspace)) { - printf("fea%d: failed to register memory 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); - return -1; - } - - if (eisa_reg_intr(ed, irq, pdq_eisa_interrupt, sc, &net_imask, 1)) { - printf("fea%d: interrupt registration failed\n", sc->sc_if.if_unit); - return -1; - } - - eisa_reg_end(ed); - - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, sc->sc_membase, - sc->sc_if.if_name, sc->sc_if.if_unit, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("fea%d: initialization failed\n", sc->sc_if.if_unit); - return -1; - } - - if (eisa_enable_intr(ed, irq)) { - printf("fea%d: failed to enable interrupt\n", sc->sc_if.if_unit); - return -1; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - at_shutdown(pdq_eisa_shutdown, (void *) sc, SHUTDOWN_POST_SYNC); - - return 0; -} - -static void -pdq_eisa_shutdown( - int howto, - void *sc) -{ - pdq_hwreset(((pdq_softc_t *)sc)->sc_pdq); -} -#endif /* __FreeBSD__ */ - -#if defined(__bsdi__) -static int -pdq_eisa_probe( - struct device *parent, - struct cfdata *cf, - void *aux) -{ - struct isa_attach_args *ia = (struct isa_attach_args *) aux; - int slot; - pdq_uint32_t irq, maddr, msize; - - if (isa_bustype != BUS_EISA) - return 0; - - if ((slot = eisa_match(cf, ia)) == 0) - return 0; - ia->ia_iobase = slot << 12; - ia->ia_iosize = EISA_NPORT; - eisa_slotalloc(slot); - - pdq_eisa_subprobe(PDQ_BUS_EISA, ia->ia_iobase, &maddr, &msize, &irq); - if (ia->ia_irq != IRQUNK && irq != ia->ia_irq) { - printf("fea%d: error: desired IRQ of %d does not match device's actual IRQ (%d),\n", - cf->cf_unit, - ffs(ia->ia_irq) - 1, ffs(irq) - 1); - return 0; - } - if (ia->ia_irq == IRQUNK) { - if ((ia->ia_irq = isa_irqalloc(irq)) == 0) { - if ((ia->ia_irq = isa_irqalloc(IRQ9|IRQ10|IRQ11|IRQ15)) == 0) { - printf("fea%d: error: IRQ %d is already in use\n", cf->cf_unit, - ffs(irq) - 1); - return 0; - } - irq = PDQ_OS_IORD_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0) & ~3; - switch (ia->ia_irq) { - case IRQ9: irq |= 0; - case IRQ10: irq |= 1; - case IRQ11: irq |= 2; - case IRQ15: irq |= 3; - } - PDQ_OS_IOWR_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0, irq); + switch (type) { + case EISA_DEVICE_ID_DEC_DEC3001: + case EISA_DEVICE_ID_DEC_DEC3002: + case EISA_DEVICE_ID_DEC_DEC3003: + case EISA_DEVICE_ID_DEC_DEC3004: + return ("DEC FDDIcontroller/EISA Adapter"); + break; + default: + break; } - } - if (maddr == 0) { - printf("fea%d: error: memory not enabled! ECU reconfiguration required\n", - cf->cf_unit); - return 0; - } - - /* EISA bus masters don't use host DMA channels */ - ia->ia_drq = DRQNONE; - - ia->ia_maddr = (caddr_t) maddr; - ia->ia_msize = msize; - return 1; + return (NULL); } -static void -pdq_eisa_attach( - struct device *parent, - struct device *self, - void *aux) -{ - pdq_softc_t *sc = (pdq_softc_t *) self; - register struct isa_attach_args *ia = (struct isa_attach_args *) aux; - register struct ifnet *ifp = &sc->sc_if; - - sc->sc_if.if_unit = sc->sc_dev.dv_unit; - sc->sc_if.if_name = "fea"; - sc->sc_if.if_flags = 0; - - sc->sc_iobase = ia->ia_iobase; - - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, - (pdq_bus_memaddr_t) ISA_HOLE_VADDR(ia->ia_maddr), - sc->sc_if.if_name, sc->sc_if.if_unit, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("fea%d: initialization failed\n", sc->sc_if.if_unit); - return; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - - isa_establish(&sc->sc_id, &sc->sc_dev); - - sc->sc_ih.ih_fun = pdq_interrupt; - sc->sc_ih.ih_arg = (void *) sc->sc_pdq; - intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET); - - sc->sc_ats.func = (void (*)(void *)) pdq_hwreset; - sc->sc_ats.arg = (void *) sc->sc_pdq; - atshutdown(&sc->sc_ats, ATSH_ADD); -} - -static char *pdq_eisa_ids[] = { - "DEC3001", /* 0x0130A310 */ - "DEC3002", /* 0x0230A310 */ - "DEC3003", /* 0x0330A310 */ - "DEC3004", /* 0x0430A310 */ -}; - -struct cfdriver feacd = { - 0, "fea", pdq_eisa_probe, pdq_eisa_attach, DV_IFNET, sizeof(pdq_softc_t), - pdq_eisa_ids -}; -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) static int -pdq_eisa_match( - struct device *parent, - void *match, - void *aux) +pdq_eisa_probe (dev) + device_t dev; { - const struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; + const char *desc; + u_int32_t iobase; + u_int32_t irq; + u_int32_t maddr; + u_int32_t msize; - if (strncmp(ea->ea_idstring, "DEC300", 6) == 0) - return 1; + u_int32_t eisa_id = eisa_get_id(dev);; - return 0; + desc = pdq_eisa_match(eisa_id); + if (!desc) { + return (ENXIO); + } + + device_set_desc(dev, desc); + + iobase = eisa_get_slot(dev) * EISA_SLOT_SIZE; + pdq_eisa_subprobe(PDQ_BUS_EISA, iobase, &maddr, &msize, &irq); + + eisa_add_iospace(dev, iobase, 0x200, RESVADDR_NONE); + eisa_add_mspace(dev, maddr, msize, RESVADDR_NONE); + eisa_add_intr(dev, irq); + + return (0); +} + +void +pdq_eisa_intr(xdev) + void *xdev; +{ + device_t dev = (device_t) xdev; + pdq_softc_t *sc = device_get_softc(dev); + (void) pdq_interrupt(sc->sc_pdq); + + return; +} + +static int +pdq_eisa_attach (dev) + device_t dev; +{ + pdq_softc_t *sc = device_get_softc(dev); + struct resource *io = 0; + struct resource *irq = 0; + struct resource *mspace = 0; + int rid; + void *ih; + u_int32_t m_addr, m_size; + + rid = 0; + io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, + 0, ~0, 1, RF_ACTIVE); + + if (!io) { + device_printf(dev, "No I/O space?!\n"); + goto bad; + } + + rid = 0; + mspace = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, + 0, ~0, 1, RF_ACTIVE); + + if (!mspace) { + device_printf(dev, "No memory space?!\n"); + goto bad; + } + + rid = 0; + irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, + 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); + + if (!irq) { + device_printf(dev, "No, irq?!\n"); + goto bad; + } + + m_addr = rman_get_start(mspace); + m_size = (rman_get_end(mspace) - rman_get_start(mspace)) + 1; + + sc->sc_iobase = (pdq_bus_ioport_t) rman_get_start(io); + sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(m_addr, m_size); + sc->sc_if.if_name = "fea"; + sc->sc_if.if_unit = device_get_unit(dev); + + pdq_eisa_devinit(sc); + sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, sc->sc_membase, + sc->sc_if.if_name, sc->sc_if.if_unit, + (void *) sc, PDQ_DEFEA); + if (sc->sc_pdq == NULL) { + device_printf(dev, "initialization failed\n"); + goto bad; + } + + if (bus_setup_intr(dev, irq, INTR_TYPE_NET, pdq_eisa_intr, dev, &ih)) { + goto bad; + } + + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + pdq_ifattach(sc, NULL); + at_shutdown(pdq_eisa_shutdown, (void *) sc, SHUTDOWN_POST_SYNC); + + return (0); + +bad: + if (io) + bus_release_resource(dev, SYS_RES_IOPORT, 0, io); + if (irq) + bus_release_resource(dev, SYS_RES_IRQ, 0, irq); + if (mspace) + bus_release_resource(dev, SYS_RES_MEMORY, 0, mspace); + + return (-1); } static void -pdq_eisa_attach( - struct device *parent, - struct device *self, - void *aux) +pdq_eisa_shutdown(howto, sc) + int howto; + void *sc; { - pdq_softc_t * const sc = (pdq_softc_t *) self; - struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; - pdq_uint32_t irq, maddr, msize; - eisa_intr_handle_t ih; - const char *intrstr; - - sc->sc_bc = ea->ea_bc; - bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); - sc->sc_if.if_flags = 0; - sc->sc_if.if_softc = sc; - - if (bus_io_map(sc->sc_bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, &sc->sc_iobase)) { - printf("\n%s: failed to map I/O!\n", sc->sc_dev.dv_xname); - return; - } - - pdq_eisa_subprobe(sc->sc_bc, sc->sc_iobase, &maddr, &msize, &irq); - -#if !defined(PDQ_IOMAPPED) - if (maddr == 0 || msize == 0) { - printf("\n%s: error: memory not enabled! ECU reconfiguration required\n", - sc->sc_dev.dv_xname); - return; - } - - if (bus_mem_map(sc->sc_bc, maddr, msize, 0, &sc->sc_membase)) { - bus_io_unmap(sc->sc_bc, sc->sc_iobase, EISA_SLOT_SIZE); - printf("\n%s: failed to map memory (0x%x-0x%x)!\n", - sc->sc_dev.dv_xname, maddr, maddr + msize - 1); - return; - } -#endif - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase, - sc->sc_if.if_xname, 0, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("%s: initialization failed\n", sc->sc_dev.dv_xname); - return; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - - if (eisa_intr_map(ea->ea_ec, irq, &ih)) { - printf("%s: couldn't map interrupt (%d)\n", sc->sc_dev.dv_xname, irq); - return; - } - intrstr = eisa_intr_string(ea->ea_ec, ih); - sc->sc_ih = eisa_intr_establish(ea->ea_ec, ih, IST_LEVEL, IPL_NET, - (int (*)(void *)) pdq_interrupt, sc->sc_pdq); - if (sc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname); - if (intrstr != NULL) - printf(" at %s", intrstr); - printf("\n"); - return; - } - sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq); - if (sc->sc_ats == NULL) - printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname); -#if !defined(PDQ_IOMAPPED) - printf("%s: using iomem 0x%x-0x%x\n", sc->sc_dev.dv_xname, maddr, maddr + msize - 1); -#endif - if (intrstr != NULL) - printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); + pdq_hwreset(((pdq_softc_t *)sc)->sc_pdq); } -struct cfattach fea_ca = { - sizeof(pdq_softc_t), pdq_eisa_match, pdq_eisa_attach +static device_method_t pdq_eisa_methods[] = { + DEVMETHOD(device_probe, pdq_eisa_probe), + DEVMETHOD(device_attach, pdq_eisa_attach), + + { 0, 0 } }; -struct cfdriver fea_cd = { - 0, "fea", DV_IFNET +static driver_t pdq_eisa_driver = { + "fea", + pdq_eisa_methods, + sizeof(pdq_softc_t), }; -#endif -#endif + +static devclass_t pdq_devclass; + +DRIVER_MODULE(pdq, eisa, pdq_eisa_driver, pdq_devclass, 0, 0); diff --git a/sys/i386/eisa/if_fea.c b/sys/i386/eisa/if_fea.c index e7072a119213..ca0807ca81db 100644 --- a/sys/i386/eisa/if_fea.c +++ b/sys/i386/eisa/if_fea.c @@ -1,5 +1,3 @@ -#warning "fix if_fea.c! - newbus casualty" -#if 0 /*- * Copyright (c) 1995, 1996 Matt Thomas * All rights reserved. @@ -23,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_fea.c,v 1.13 1999/01/12 00:36:27 eivind Exp $ + * $Id: if_fea.c,v 1.14 1999/05/02 20:35:42 peter Exp $ */ /* @@ -33,465 +31,237 @@ */ #include +#include #include #include -#if defined(__bsdi__) || defined(__NetBSD__) -#include -#endif #include #include -#if defined(__FreeBSD__) +#include +#include +#include +#include +#include #include #include #include -#elif defined(__bsdi__) -#include -#include -#include -#include -#include -#include -#include -#elif defined(__NetBSD__) -#include -#include -#include -#include +static void pdq_eisa_subprobe __P((pdq_bus_t, u_int32_t, u_int32_t *, u_int32_t *, u_int32_t *)); +static void pdq_eisa_devinit __P((pdq_softc_t *)); +static const char * pdq_eisa_match __P((eisa_id_t)); +static int pdq_eisa_probe __P((device_t)); +static int pdq_eisa_attach __P((device_t)); +void pdq_eisa_intr __P((void *)); +static void pdq_eisa_shutdown __P((int, void *)); -#include -#include -#include -#endif +#define DEFEA_IRQS 0x0000FBA9U -/* - * - */ - -#define DEFEA_IRQS 0x0000FBA9U - -#if defined(__FreeBSD__) -static pdq_softc_t *pdqs_eisa[16]; -#define PDQ_EISA_UNIT_TO_SOFTC(unit) (pdqs_eisa[unit]) #define DEFEA_INTRENABLE 0x8 /* level interrupt */ -#define pdq_eisa_ifwatchdog NULL #define DEFEA_DECODE_IRQ(n) ((DEFEA_IRQS >> ((n) << 2)) & 0x0f) -#elif defined(__bsdi__) -extern struct cfdriver feacd; -#define PDQ_EISA_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)feacd.cd_devs[unit]) -#define DEFEA_INTRENABLE 0x28 /* edge interrupt */ -static const int pdq_eisa_irqs[4] = { IRQ9, IRQ10, IRQ11, IRQ15 }; -#define DEFEA_DECODE_IRQ(n) (pdq_eisa_irqs[(n)]) - -#elif defined(__NetBSD__) -#define DEFEA_INTRENABLE 0x8 /* level interrupt */ -#define pdq_eisa_ifwatchdog NULL -#define DEFEA_DECODE_IRQ(n) ((DEFEA_IRQS >> ((n) << 2)) & 0x0f) - -#else -#error unknown system -#endif - -#ifndef pdq_eisa_ifwatchdog -static ifnet_ret_t -pdq_eisa_ifwatchdog( - int unit) -{ - pdq_ifwatchdog(&PDQ_EISA_UNIT_TO_SOFTC(unit)->sc_if); -} -#endif +#define EISA_DEVICE_ID_DEC_DEC3001 0x10a33001 +#define EISA_DEVICE_ID_DEC_DEC3002 0x10a33002 +#define EISA_DEVICE_ID_DEC_DEC3003 0x10a33003 +#define EISA_DEVICE_ID_DEC_DEC3004 0x10a33004 static void -pdq_eisa_subprobe( - pdq_bus_t bc, - pdq_bus_ioport_t iobase, - pdq_uint32_t *maddr, - pdq_uint32_t *msize, - pdq_uint32_t *irq) +pdq_eisa_subprobe(bc, iobase, maddr, msize, irq) + pdq_bus_t bc; + u_int32_t iobase; + u_int32_t *maddr; + u_int32_t *msize; + u_int32_t *irq; { - if (irq != NULL) - *irq = DEFEA_DECODE_IRQ(PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_IO_CONFIG_STAT_0) & 3); - *maddr = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_0) << 8) - | (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_1) << 16); - *msize = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_MASK_0) + 4) << 8; + if (irq != NULL) + *irq = DEFEA_DECODE_IRQ(PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_IO_CONFIG_STAT_0) & 3); + *maddr = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_0) << 8) + | (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_1) << 16); + *msize = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_MASK_0) + 4) << 8; + + return; } static void -pdq_eisa_devinit( - pdq_softc_t *sc) +pdq_eisa_devinit (sc) + pdq_softc_t *sc; { - pdq_uint8_t data; + pdq_uint8_t data; - /* - * Do the standard initialization for the DEFEA registers. - */ - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_FUNCTION_CTRL, 0x23); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_1_1, (sc->sc_iobase >> 8) & 0xF0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_0_1, (sc->sc_iobase >> 8) & 0xF0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_SLOT_CTRL, 0x01); - data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF); + /* + * Do the standard initialization for the DEFEA registers. + */ + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_FUNCTION_CTRL, 0x23); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_1_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_0_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_SLOT_CTRL, 0x01); + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF); #if defined(PDQ_IOMAPPED) - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data & ~1); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data & ~1); #else - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data | 1); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data | 1); #endif - data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0); - PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0, data | DEFEA_INTRENABLE); + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0, data | DEFEA_INTRENABLE); + + return; } -#if defined(__FreeBSD__) -static void pdq_eisa_shutdown(int howto, void *sc); -static int pdq_eisa_probe(void); -static int pdq_eisa_attach(struct eisa_device *ed); - -static unsigned long pdq_eisa_unit; - -static struct eisa_driver pdq_eisa_driver = { - "fea", pdq_eisa_probe, pdq_eisa_attach, NULL, &pdq_eisa_unit -}; - -DATA_SET(eisadriver_set, pdq_eisa_driver); - - static const char * -pdq_eisa_match( - eisa_id_t type) +pdq_eisa_match (type) + eisa_id_t type; { - if ((type >> 8) == 0x10a330) - return ("DEC DEFEA EISA FDDI Controller"); - return NULL; -} - -static int -pdq_eisa_probe( - void) -{ - struct eisa_device *ed = NULL; - int count; - - for (count = 0; (ed = eisa_match_dev(ed, pdq_eisa_match)) != NULL; count++) { - pdq_bus_ioport_t iobase = ed->ioconf.slot * EISA_SLOT_SIZE; - pdq_uint32_t irq, maddr, msize; - - eisa_add_iospace(ed, iobase, 0x200, RESVADDR_NONE); - pdq_eisa_subprobe(PDQ_BUS_EISA, iobase, &maddr, &msize, &irq); - eisa_add_mspace(ed, maddr, msize, RESVADDR_NONE); - eisa_add_intr(ed, irq); - eisa_registerdev(ed, &pdq_eisa_driver); - } - return count; -} - -static void -pdq_eisa_interrupt( - void *arg) -{ - pdq_softc_t * const sc = (pdq_softc_t *) arg; - (void) pdq_interrupt(sc->sc_pdq); -} - -static int -pdq_eisa_attach( - struct eisa_device *ed) -{ - pdq_softc_t *sc; - resvaddr_t *iospace; - resvaddr_t *mspace; - int irq; - - if (TAILQ_FIRST(&ed->ioconf.irqs) == NULL) - return (-1); - - irq = TAILQ_FIRST(&ed->ioconf.irqs)->irq_no; - - sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); - if (sc == NULL) { - printf("fea%ld: malloc failed!\n", ed->unit); - return -1; - } - pdqs_eisa[ed->unit] = sc; - - bzero(sc, sizeof(pdq_softc_t)); /* Zero out the softc*/ - sc->sc_if.if_name = "fea"; - sc->sc_if.if_unit = ed->unit; - - if ((iospace = ed->ioconf.ioaddrs.lh_first) == NULL) { - printf("fea%d: no iospace??\n", sc->sc_if.if_unit); - return -1; - } - if ((mspace = ed->ioconf.maddrs.lh_first) == NULL) { - printf("fea%d: no memory space??\n", sc->sc_if.if_unit); - return -1; - } - - sc->sc_iobase = (pdq_bus_ioport_t) iospace->addr; - sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(mspace->addr, mspace->size); - if (sc->sc_membase == NULL) { - printf("fea%d: failed to map memory 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); - return -1; - } - - eisa_reg_start(ed); - if (eisa_reg_iospace(ed, iospace)) { - printf("fea%d: failed to register iospace 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, iospace->addr, iospace->addr + iospace->size - 1); - return -1; - } - if (eisa_reg_mspace(ed, mspace)) { - printf("fea%d: failed to register memory 0x%lx-0x%lx!\n", - sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); - return -1; - } - - if (eisa_reg_intr(ed, irq, pdq_eisa_interrupt, sc, &net_imask, 1)) { - printf("fea%d: interrupt registration failed\n", sc->sc_if.if_unit); - return -1; - } - - eisa_reg_end(ed); - - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, sc->sc_membase, - sc->sc_if.if_name, sc->sc_if.if_unit, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("fea%d: initialization failed\n", sc->sc_if.if_unit); - return -1; - } - - if (eisa_enable_intr(ed, irq)) { - printf("fea%d: failed to enable interrupt\n", sc->sc_if.if_unit); - return -1; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - at_shutdown(pdq_eisa_shutdown, (void *) sc, SHUTDOWN_POST_SYNC); - - return 0; -} - -static void -pdq_eisa_shutdown( - int howto, - void *sc) -{ - pdq_hwreset(((pdq_softc_t *)sc)->sc_pdq); -} -#endif /* __FreeBSD__ */ - -#if defined(__bsdi__) -static int -pdq_eisa_probe( - struct device *parent, - struct cfdata *cf, - void *aux) -{ - struct isa_attach_args *ia = (struct isa_attach_args *) aux; - int slot; - pdq_uint32_t irq, maddr, msize; - - if (isa_bustype != BUS_EISA) - return 0; - - if ((slot = eisa_match(cf, ia)) == 0) - return 0; - ia->ia_iobase = slot << 12; - ia->ia_iosize = EISA_NPORT; - eisa_slotalloc(slot); - - pdq_eisa_subprobe(PDQ_BUS_EISA, ia->ia_iobase, &maddr, &msize, &irq); - if (ia->ia_irq != IRQUNK && irq != ia->ia_irq) { - printf("fea%d: error: desired IRQ of %d does not match device's actual IRQ (%d),\n", - cf->cf_unit, - ffs(ia->ia_irq) - 1, ffs(irq) - 1); - return 0; - } - if (ia->ia_irq == IRQUNK) { - if ((ia->ia_irq = isa_irqalloc(irq)) == 0) { - if ((ia->ia_irq = isa_irqalloc(IRQ9|IRQ10|IRQ11|IRQ15)) == 0) { - printf("fea%d: error: IRQ %d is already in use\n", cf->cf_unit, - ffs(irq) - 1); - return 0; - } - irq = PDQ_OS_IORD_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0) & ~3; - switch (ia->ia_irq) { - case IRQ9: irq |= 0; - case IRQ10: irq |= 1; - case IRQ11: irq |= 2; - case IRQ15: irq |= 3; - } - PDQ_OS_IOWR_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0, irq); + switch (type) { + case EISA_DEVICE_ID_DEC_DEC3001: + case EISA_DEVICE_ID_DEC_DEC3002: + case EISA_DEVICE_ID_DEC_DEC3003: + case EISA_DEVICE_ID_DEC_DEC3004: + return ("DEC FDDIcontroller/EISA Adapter"); + break; + default: + break; } - } - if (maddr == 0) { - printf("fea%d: error: memory not enabled! ECU reconfiguration required\n", - cf->cf_unit); - return 0; - } - - /* EISA bus masters don't use host DMA channels */ - ia->ia_drq = DRQNONE; - - ia->ia_maddr = (caddr_t) maddr; - ia->ia_msize = msize; - return 1; + return (NULL); } -static void -pdq_eisa_attach( - struct device *parent, - struct device *self, - void *aux) -{ - pdq_softc_t *sc = (pdq_softc_t *) self; - register struct isa_attach_args *ia = (struct isa_attach_args *) aux; - register struct ifnet *ifp = &sc->sc_if; - - sc->sc_if.if_unit = sc->sc_dev.dv_unit; - sc->sc_if.if_name = "fea"; - sc->sc_if.if_flags = 0; - - sc->sc_iobase = ia->ia_iobase; - - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, - (pdq_bus_memaddr_t) ISA_HOLE_VADDR(ia->ia_maddr), - sc->sc_if.if_name, sc->sc_if.if_unit, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("fea%d: initialization failed\n", sc->sc_if.if_unit); - return; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - - isa_establish(&sc->sc_id, &sc->sc_dev); - - sc->sc_ih.ih_fun = pdq_interrupt; - sc->sc_ih.ih_arg = (void *) sc->sc_pdq; - intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET); - - sc->sc_ats.func = (void (*)(void *)) pdq_hwreset; - sc->sc_ats.arg = (void *) sc->sc_pdq; - atshutdown(&sc->sc_ats, ATSH_ADD); -} - -static char *pdq_eisa_ids[] = { - "DEC3001", /* 0x0130A310 */ - "DEC3002", /* 0x0230A310 */ - "DEC3003", /* 0x0330A310 */ - "DEC3004", /* 0x0430A310 */ -}; - -struct cfdriver feacd = { - 0, "fea", pdq_eisa_probe, pdq_eisa_attach, DV_IFNET, sizeof(pdq_softc_t), - pdq_eisa_ids -}; -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) static int -pdq_eisa_match( - struct device *parent, - void *match, - void *aux) +pdq_eisa_probe (dev) + device_t dev; { - const struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; + const char *desc; + u_int32_t iobase; + u_int32_t irq; + u_int32_t maddr; + u_int32_t msize; - if (strncmp(ea->ea_idstring, "DEC300", 6) == 0) - return 1; + u_int32_t eisa_id = eisa_get_id(dev);; - return 0; + desc = pdq_eisa_match(eisa_id); + if (!desc) { + return (ENXIO); + } + + device_set_desc(dev, desc); + + iobase = eisa_get_slot(dev) * EISA_SLOT_SIZE; + pdq_eisa_subprobe(PDQ_BUS_EISA, iobase, &maddr, &msize, &irq); + + eisa_add_iospace(dev, iobase, 0x200, RESVADDR_NONE); + eisa_add_mspace(dev, maddr, msize, RESVADDR_NONE); + eisa_add_intr(dev, irq); + + return (0); +} + +void +pdq_eisa_intr(xdev) + void *xdev; +{ + device_t dev = (device_t) xdev; + pdq_softc_t *sc = device_get_softc(dev); + (void) pdq_interrupt(sc->sc_pdq); + + return; +} + +static int +pdq_eisa_attach (dev) + device_t dev; +{ + pdq_softc_t *sc = device_get_softc(dev); + struct resource *io = 0; + struct resource *irq = 0; + struct resource *mspace = 0; + int rid; + void *ih; + u_int32_t m_addr, m_size; + + rid = 0; + io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, + 0, ~0, 1, RF_ACTIVE); + + if (!io) { + device_printf(dev, "No I/O space?!\n"); + goto bad; + } + + rid = 0; + mspace = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, + 0, ~0, 1, RF_ACTIVE); + + if (!mspace) { + device_printf(dev, "No memory space?!\n"); + goto bad; + } + + rid = 0; + irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, + 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); + + if (!irq) { + device_printf(dev, "No, irq?!\n"); + goto bad; + } + + m_addr = rman_get_start(mspace); + m_size = (rman_get_end(mspace) - rman_get_start(mspace)) + 1; + + sc->sc_iobase = (pdq_bus_ioport_t) rman_get_start(io); + sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(m_addr, m_size); + sc->sc_if.if_name = "fea"; + sc->sc_if.if_unit = device_get_unit(dev); + + pdq_eisa_devinit(sc); + sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, sc->sc_membase, + sc->sc_if.if_name, sc->sc_if.if_unit, + (void *) sc, PDQ_DEFEA); + if (sc->sc_pdq == NULL) { + device_printf(dev, "initialization failed\n"); + goto bad; + } + + if (bus_setup_intr(dev, irq, INTR_TYPE_NET, pdq_eisa_intr, dev, &ih)) { + goto bad; + } + + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + pdq_ifattach(sc, NULL); + at_shutdown(pdq_eisa_shutdown, (void *) sc, SHUTDOWN_POST_SYNC); + + return (0); + +bad: + if (io) + bus_release_resource(dev, SYS_RES_IOPORT, 0, io); + if (irq) + bus_release_resource(dev, SYS_RES_IRQ, 0, irq); + if (mspace) + bus_release_resource(dev, SYS_RES_MEMORY, 0, mspace); + + return (-1); } static void -pdq_eisa_attach( - struct device *parent, - struct device *self, - void *aux) +pdq_eisa_shutdown(howto, sc) + int howto; + void *sc; { - pdq_softc_t * const sc = (pdq_softc_t *) self; - struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; - pdq_uint32_t irq, maddr, msize; - eisa_intr_handle_t ih; - const char *intrstr; - - sc->sc_bc = ea->ea_bc; - bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); - sc->sc_if.if_flags = 0; - sc->sc_if.if_softc = sc; - - if (bus_io_map(sc->sc_bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, &sc->sc_iobase)) { - printf("\n%s: failed to map I/O!\n", sc->sc_dev.dv_xname); - return; - } - - pdq_eisa_subprobe(sc->sc_bc, sc->sc_iobase, &maddr, &msize, &irq); - -#if !defined(PDQ_IOMAPPED) - if (maddr == 0 || msize == 0) { - printf("\n%s: error: memory not enabled! ECU reconfiguration required\n", - sc->sc_dev.dv_xname); - return; - } - - if (bus_mem_map(sc->sc_bc, maddr, msize, 0, &sc->sc_membase)) { - bus_io_unmap(sc->sc_bc, sc->sc_iobase, EISA_SLOT_SIZE); - printf("\n%s: failed to map memory (0x%x-0x%x)!\n", - sc->sc_dev.dv_xname, maddr, maddr + msize - 1); - return; - } -#endif - pdq_eisa_devinit(sc); - sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase, - sc->sc_if.if_xname, 0, - (void *) sc, PDQ_DEFEA); - if (sc->sc_pdq == NULL) { - printf("%s: initialization failed\n", sc->sc_dev.dv_xname); - return; - } - - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - - pdq_ifattach(sc, pdq_eisa_ifwatchdog); - - if (eisa_intr_map(ea->ea_ec, irq, &ih)) { - printf("%s: couldn't map interrupt (%d)\n", sc->sc_dev.dv_xname, irq); - return; - } - intrstr = eisa_intr_string(ea->ea_ec, ih); - sc->sc_ih = eisa_intr_establish(ea->ea_ec, ih, IST_LEVEL, IPL_NET, - (int (*)(void *)) pdq_interrupt, sc->sc_pdq); - if (sc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname); - if (intrstr != NULL) - printf(" at %s", intrstr); - printf("\n"); - return; - } - sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq); - if (sc->sc_ats == NULL) - printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname); -#if !defined(PDQ_IOMAPPED) - printf("%s: using iomem 0x%x-0x%x\n", sc->sc_dev.dv_xname, maddr, maddr + msize - 1); -#endif - if (intrstr != NULL) - printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); + pdq_hwreset(((pdq_softc_t *)sc)->sc_pdq); } -struct cfattach fea_ca = { - sizeof(pdq_softc_t), pdq_eisa_match, pdq_eisa_attach +static device_method_t pdq_eisa_methods[] = { + DEVMETHOD(device_probe, pdq_eisa_probe), + DEVMETHOD(device_attach, pdq_eisa_attach), + + { 0, 0 } }; -struct cfdriver fea_cd = { - 0, "fea", DV_IFNET +static driver_t pdq_eisa_driver = { + "fea", + pdq_eisa_methods, + sizeof(pdq_softc_t), }; -#endif -#endif + +static devclass_t pdq_devclass; + +DRIVER_MODULE(pdq, eisa, pdq_eisa_driver, pdq_devclass, 0, 0);