static int an_attach_isa(device_t dev) { struct an_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; int flags = device_get_flags(dev); int error; an_alloc_port(dev, sc->port_rid, 1); an_alloc_irq(dev, sc->irq_rid, 0); sc->an_bhandle = rman_get_bushandle(sc->port_res); sc->an_btag = rman_get_bustag(sc->port_res); error = an_attach(sc, dev, flags); if (error) goto fail; error = bus_setup_intr(dev, sc->irq_res, INTR_MPSAFE, an_intr, sc, &sc->irq_handle, sc->arpcom.ac_if.if_serializer); if (error) { ether_ifdetach(&sc->arpcom.ac_if); ifmedia_removeall(&sc->an_ifmedia); goto fail; } ifq_set_cpuid(&ifp->if_snd, rman_get_cpuid(sc->irq_res)); return (0); fail: an_release_resources(dev); return(error); }
static int an_attach_isa(device_t dev) { struct an_softc *sc = device_get_softc(dev); int flags = device_get_flags(dev); int error; an_alloc_port(dev, sc->port_rid, 1); an_alloc_irq(dev, sc->irq_rid, 0); sc->an_dev = dev; error = an_attach(sc, flags); if (error) { an_release_resources(dev); return (error); } error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, NULL, an_intr, sc, &sc->irq_handle); if (error) { an_release_resources(dev); return (error); } return (0); }
static int an_pccard_attach(device_t dev) { struct an_softc *sc = device_get_softc(dev); int flags = device_get_flags(dev); int error; error = an_probe(dev); /* 0 is failure for now */ if (error == 0) { error = ENXIO; goto fail; } error = an_alloc_irq(dev, 0, 0); if (error != 0) goto fail; an_alloc_irq(dev, sc->irq_rid, 0); error = an_attach(sc, flags); if (error) goto fail; /* * Must setup the interrupt after the an_attach to prevent racing. */ error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, NULL, an_intr, sc, &sc->irq_handle); fail: if (error) an_release_resources(dev); return (error); }
void an_pcmcia_attach(struct device *parent, struct device *self, void *aux) { struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)self; struct an_softc *sc = (struct an_softc *)self; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; const char *intrstr; int error; psc->sc_pf = pa->pf; cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); pcmcia_function_init(pa->pf, cfe); if (pcmcia_function_enable(pa->pf)) { printf(": function enable failed\n"); return; } if (pcmcia_io_alloc(pa->pf, 0, AN_IOSIZ, AN_IOSIZ, &psc->sc_pcioh)) { printf(": can't alloc i/o space\n"); pcmcia_function_disable(pa->pf); return; } if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16, 0, AN_IOSIZ, &psc->sc_pcioh, &psc->sc_io_window)) { printf(": can't map i/o space\n"); pcmcia_io_free(pa->pf, &psc->sc_pcioh); pcmcia_function_disable(pa->pf); return; } sc->sc_iot = psc->sc_pcioh.iot; sc->sc_ioh = psc->sc_pcioh.ioh; sc->sc_enabled = 1; sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, an_intr, sc, sc->sc_dev.dv_xname); intrstr = pcmcia_intr_string(psc->sc_pf, sc->sc_ih); if (*intrstr) printf(", %s", intrstr); printf("\n"); error = an_attach(sc); if (error) { printf("%s: failed to attach controller\n", self->dv_xname); return; } sc->sc_enabled = 0; psc->sc_state = AN_PCMCIA_ATTACHED; }
void an_isapnp_attach(struct device *parent, struct device *self, void *aux) { struct an_softc *sc = (void *)self; struct isa_attach_args *ia = aux; sc->sc_iot = ia->ia_iot; sc->sc_ioh = ia->ipa_io[0].h; sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_NET, an_intr, sc, sc->sc_dev.dv_xname); an_attach(sc); }
void an_pci_attach(struct device *parent, struct device *self, void *aux) { struct an_softc *sc = (struct an_softc *)self; struct pci_attach_args *pa = aux; pci_intr_handle_t ih; bus_space_handle_t ioh; bus_space_tag_t iot = pa->pa_iot; pci_chipset_tag_t pc = pa->pa_pc; const char *intrstr; /* Map the I/O ports. */ if (pci_mapreg_map(pa, AN_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL, 0) != 0) { printf(": can't map i/o space\n"); return; } sc->sc_iot = iot; sc->sc_ioh = ioh; /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { printf("\n%s: couldn't map interrupt\n", sc->sc_dev.dv_xname); return; } intrstr = pci_intr_string(pc, ih); sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, an_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { printf("\n%s: couldn't establish interrupt", sc->sc_dev.dv_xname); if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); return; } printf(": %s", intrstr); sc->sc_enabled = 1; an_attach(sc); }
static int an_pccard_attach(device_t dev) { struct an_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; int flags = device_get_flags(dev); int error; an_alloc_port(dev, sc->port_rid, AN_IOSIZ); an_alloc_irq(dev, sc->irq_rid, 0); sc->an_bhandle = rman_get_bushandle(sc->port_res); sc->an_btag = rman_get_bustag(sc->port_res); error = an_attach(sc, dev, flags); if (error) goto fail; /* * Must setup the interrupt after the an_attach to prevent racing. */ error = bus_setup_intr(dev, sc->irq_res, INTR_MPSAFE, an_intr, sc, &sc->irq_handle, sc->arpcom.ac_if.if_serializer); if (error) { ether_ifdetach(&sc->arpcom.ac_if); ifmedia_removeall(&sc->an_ifmedia); goto fail; } ifp->if_cpuid = rman_get_cpuid(sc->irq_res); KKASSERT(ifp->if_cpuid >= 0 && ifp->if_cpuid < ncpus); return 0; fail: an_release_resources(dev); return (error); }