/* * Probe for device. If found, try to raise an interrupt. */ int tsmatch(device_t parent, cfdata_t match, void *aux) { struct device tsdev; struct ts_softc ssc; struct ts_softc *sc = &ssc; struct uba_attach_args *ua = aux; int i; sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_mapped = 0; sc->sc_dev = &tsdev; sc->sc_uh = device_private(parent); strcpy(sc->sc_dev->dv_xname, "ts"); /* Try to reset the device */ for (i = 0; i < 3; i++) { if (tsreset(sc)) break; } if (i == 3) return 0; tsinit(sc); tswchar(sc); /* write charact. to enable interrupts */ /* completion of this will raise the intr. */ DELAY(1000000); /* Wait for interrupt */ ubmemfree(sc->sc_uh, &sc->sc_ui); return 1; }
/* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. We get the ethernet address here. */ void deattach(struct device *parent, struct device *self, void *aux) { struct uba_attach_args *ua = aux; struct de_softc *sc = (struct de_softc *)self; struct ifnet *ifp = &sc->sc_if; u_int8_t myaddr[ETHER_ADDR_LEN]; int csr1, error; char *c; sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; /* * What kind of a board is this? * The error bits 4-6 in pcsr1 are a device id as long as * the high byte is zero. */ csr1 = DE_RCSR(DE_PCSR1); if (csr1 & 0xff60) c = "broken"; else if (csr1 & 0x10) c = "delua"; else c = "deuna"; /* * Reset the board and temporarily map * the pcbb buffer onto the Unibus. */ DE_WCSR(DE_PCSR0, 0); /* reset INTE */ DELAY(100); DE_WCSR(DE_PCSR0, PCSR0_RSET); dewait(sc, "reset"); sc->sc_ui.ui_size = sizeof(struct de_cdata); if ((error = ubmemalloc((struct uba_softc *)parent, &sc->sc_ui, 0))) return printf(": failed ubmemalloc(), error = %d\n", error); sc->sc_dedata = (struct de_cdata *)sc->sc_ui.ui_vaddr; /* * Tell the DEUNA about our PCB */ DE_WCSR(DE_PCSR2, LOWORD(sc->sc_ui.ui_baddr)); DE_WCSR(DE_PCSR3, HIWORD(sc->sc_ui.ui_baddr)); DE_WLOW(CMD_GETPCBB); dewait(sc, "pcbb"); sc->sc_dedata->dc_pcbb.pcbb0 = FC_RDPHYAD; DE_WLOW(CMD_GETCMD); dewait(sc, "read addr "); bcopy((caddr_t)&sc->sc_dedata->dc_pcbb.pcbb2, myaddr, sizeof (myaddr)); printf(": %s, address %s\n", c, ether_sprintf(myaddr)); uba_intr_establish(ua->ua_icookie, ua->ua_cvec, deintr, sc, &sc->sc_intrcnt); uba_reset_establish(dereset, &sc->sc_dev); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, sc->sc_dev.dv_xname, "intr"); strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof ifp->if_xname); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI; ifp->if_ioctl = deioctl; ifp->if_start = destart; ifp->if_init = deinit; ifp->if_stop = destop; IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); ether_ifattach(ifp, myaddr); ubmemfree((struct uba_softc *)parent, &sc->sc_ui); sc->sc_sh = shutdownhook_establish(deshutdown, sc); }