if (!(command & PCI_COMMAND_IO_ENABLE)) { printf(": failed to enable I/O ports!\n"); goto fail; }
wb_attach(parent, self, aux)	struct device *parent, *self;	void *aux;{	struct wb_softc *sc = (struct wb_softc *)self;	struct pci_attach_args *pa = aux;	pci_chipset_tag_t pc = pa->pa_pc;	pci_intr_handle_t ih;	const char *intrstr = NULL;	struct ifnet *ifp = &sc->arpcom.ac_if;	bus_size_t iosize;	int s, rseg;	pcireg_t command;	bus_dma_segment_t seg;	bus_dmamap_t dmamap;	caddr_t kva;	s = splimp();	/*	 * Handle power management nonsense.	 */	command = pci_conf_read(pc, pa->pa_tag, WB_PCI_CAPID) & 0x000000FF;	if (command == 0x01) {		command = pci_conf_read(pc, pa->pa_tag, WB_PCI_PWRMGMTCTRL);		if (command & WB_PSTATE_MASK) {			u_int32_t		io, mem, irq;			/* Save important PCI config data. */			io = pci_conf_read(pc, pa->pa_tag, WB_PCI_LOIO);			mem = pci_conf_read(pc, pa->pa_tag, WB_PCI_LOMEM);			irq = pci_conf_read(pc, pa->pa_tag, WB_PCI_INTLINE);			/* Reset the power state. */			printf("%s: chip is in D%d power mode "			    "-- setting to D0\n", sc->sc_dev.dv_xname,			    command & WB_PSTATE_MASK);			command &= 0xFFFFFFFC;			pci_conf_write(pc, pa->pa_tag, WB_PCI_PWRMGMTCTRL,			    command);			/* Restore PCI config data. */			pci_conf_write(pc, pa->pa_tag, WB_PCI_LOIO, io);			pci_conf_write(pc, pa->pa_tag, WB_PCI_LOMEM, mem);			pci_conf_write(pc, pa->pa_tag, WB_PCI_INTLINE, irq);		}	}	/*	 * Map control/status registers.	 */	command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);#ifdef WB_USEIOSPACE	if (!(command & PCI_COMMAND_IO_ENABLE)) {		printf(": failed to enable I/O ports!\n");		goto fail;	}	if (pci_mapreg_map(pa, WB_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,	    &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)) {		printf(": can't map i/o space\n");		goto fail;	}#else	if (!(command & PCI_COMMAND_MEM_ENABLE)) {		printf(": failed to enable memory mapping!\n");		goto fail;	}	if (pci_mapreg_map(pa, WB_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,	    &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)){		printf(": can't map mem space\n");		goto fail;	}#endif	/* Allocate interrupt */	if (pci_intr_map(pa, &ih)) {		printf(": couldn't map interrupt\n");		goto fail_1;	}	intrstr = pci_intr_string(pc, ih);	sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, wb_intr, sc,	    self->dv_xname);	if (sc->sc_ih == NULL) {		printf(": couldn't establish interrupt");		if (intrstr != NULL)			printf(" at %s", intrstr);		printf("\n");		goto fail_1;	}	printf(": %s", intrstr);	sc->wb_cachesize = pci_conf_read(pc, pa->pa_tag, WB_PCI_CACHELEN)&0xff;	/* Reset the adapter. */	wb_reset(sc);	/*	 * Get station address from the EEPROM.	 */	wb_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, 0, 3, 0);	printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr));	if (bus_dmamem_alloc(pa->pa_dmat, sizeof(struct wb_list_data),	    PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {		printf("%s: can't alloc list data\n", sc->sc_dev.dv_xname);		goto fail_1;	}	if (bus_dmamem_map(pa->pa_dmat, &seg, rseg,	    sizeof(struct wb_list_data), &kva, BUS_DMA_NOWAIT)) {		printf("%s: can't map list data, size %d\n",		    sc->sc_dev.dv_xname, sizeof(struct wb_list_data));		bus_dmamem_free(pa->pa_dmat, &seg, rseg);		goto fail_1;	}	if (bus_dmamap_create(pa->pa_dmat, sizeof(struct wb_list_data), 1,	    sizeof(struct wb_list_data), 0, BUS_DMA_NOWAIT, &dmamap)) {		printf("%s: can't create dma map\n", sc->sc_dev.dv_xname);		bus_dmamem_unmap(pa->pa_dmat, kva,		    sizeof(struct wb_list_data));		bus_dmamem_free(pa->pa_dmat, &seg, rseg);		goto fail_1;	}	if (bus_dmamap_load(pa->pa_dmat, dmamap, kva,	    sizeof(struct wb_list_data), NULL, BUS_DMA_NOWAIT)) {		printf("%s: can't load dma map\n", sc->sc_dev.dv_xname);		bus_dmamap_destroy(pa->pa_dmat, dmamap);		bus_dmamem_unmap(pa->pa_dmat, kva,		    sizeof(struct wb_list_data));		bus_dmamem_free(pa->pa_dmat, &seg, rseg);		goto fail_1;	}	sc->wb_ldata = (struct wb_list_data *)kva;	bzero(sc->wb_ldata, sizeof(struct wb_list_data));	ifp->if_softc = sc;	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;	ifp->if_ioctl = wb_ioctl;	ifp->if_start = wb_start;	ifp->if_watchdog = wb_watchdog;	ifp->if_baudrate = 10000000;	IFQ_SET_MAXLEN(&ifp->if_snd, WB_TX_LIST_CNT - 1);	IFQ_SET_READY(&ifp->if_snd);	bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);	/*	 * Do ifmedia setup.	 */	wb_stop(sc);	ifmedia_init(&sc->sc_mii.mii_media, 0, wb_ifmedia_upd, wb_ifmedia_sts);	sc->sc_mii.mii_ifp = ifp;	sc->sc_mii.mii_readreg = wb_miibus_readreg;	sc->sc_mii.mii_writereg = wb_miibus_writereg;	sc->sc_mii.mii_statchg = wb_miibus_statchg;	mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY,	    0);	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE,0,NULL);		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);	} else		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);	/*	 * Call MI attach routines.	 */	if_attach(ifp);	ether_ifattach(ifp);	shutdownhook_establish(wb_shutdown, sc);fail_1:	bus_space_unmap(sc->wb_btag, sc->wb_bhandle, iosize);fail:	splx(s);	return;}