static int sn_nubus_match(struct device *parent, void *cf, void *aux) { struct nubus_attach_args *na = (struct nubus_attach_args *) aux; bus_space_handle_t bsh; int rv; if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) return (0); rv = 0; if (na->category == NUBUS_CATEGORY_NETWORK && na->type == NUBUS_TYPE_ETHERNET) { switch (sn_nb_card_vendor(na->na_tag, bsh, na)) { default: break; case SN_VENDOR_APPLE: case SN_VENDOR_APPLE16: case SN_VENDOR_ASANTELC: case SN_VENDOR_DAYNA: rv = 1; break; } } bus_space_unmap(na->na_tag, bsh, NBMEMSIZE); return (rv); }
void cpi_nubus_attach(device_t parent, device_t self, void *aux) { struct cpi_softc *sc; struct nubus_attach_args *na; int err, ii; sc = device_private(self); sc->sc_options = (device_cfdata(self)->cf_flags & CPI_OPTIONS_MASK); na = aux; sc->sc_bst = na->na_tag; memcpy(&sc->sc_slot, na->fmt, sizeof(nubus_slot)); sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot); /* * The CIO sits eight bit wide on the top byte lane of * Nubus, so map 16 byte. */ if (TRACE_CONFIG) { printf("\n"); printf("\tcpi_nubus_attach() mapping 8536 CIO at 0x%lx.\n", sc->sc_basepa + CIO_BASE_OFFSET); } err = bus_space_map(sc->sc_bst, sc->sc_basepa + CIO_BASE_OFFSET, (Z8536_IOSIZE << 4), 0, &sc->sc_bsh); if (err) { aprint_normal(": failed to map memory space.\n"); return; } sc->sc_lpstate = LP_INITIAL; sc->sc_intcount = 0; sc->sc_bytestoport = 0; if (TRACE_CONFIG) printf("\tcpi_nubus_attach() about to set up 8536 CIO.\n"); for (ii = 0; ii < sizeof(cio_reset); ii += 2) z8536_reg_set(sc->sc_bst, sc->sc_bsh, cio_reset[ii], cio_reset[ii + 1]); delay(1000); /* Give the CIO time to set itself up */ for (ii = 0; ii < sizeof(cio_init); ii += 2) { z8536_reg_set(sc->sc_bst, sc->sc_bsh, cio_init[ii], cio_init[ii + 1]); } if (TRACE_CONFIG) printf("\tcpi_nubus_attach() done with 8536 CIO setup.\n"); /* XXX Get information strings from the card ROM */ aprint_normal(": CSI Hurdler II Centronics\n"); /* Attach CIO timers 1+2 as timecounter */ if (sc->sc_options & CPI_CTC12_IS_TIMECOUNTER) { cpi_tc_initclock(sc); } callout_init(&sc->sc_wakeupchan, 0); /* XXX */ /* make sure interrupts are vectored to us */ add_nubus_intr(na->slot, cpi_nubus_intr, sc); }
/* * Install interface into kernel networking data structures */ static void sn_nubus_attach(struct device *parent, struct device *self, void *aux) { struct sn_softc *sc = (void *)self; struct nubus_attach_args *na = (struct nubus_attach_args *)aux; int i, success, offset; bus_space_tag_t bst; bus_space_handle_t bsh, tmp_bsh; u_int8_t myaddr[ETHER_ADDR_LEN]; char cardtype[INTERFACE_NAME_LEN]; /* type string */ (void)(&offset); /* Work around lame gcc initialization bug */ bst = na->na_tag; if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) { printf(": can't map mem space\n"); return; } sc->sc_regt = bst; strncpy(cardtype, nubus_get_card_name(bst, bsh, na->fmt), INTERFACE_NAME_LEN); success = 0; sc->slotno = na->slot; switch (sn_nb_card_vendor(bst, bsh, na)) { case SN_VENDOR_DAYNA: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 1; /* 32 bit card */ if (bus_space_subregion(bst, bsh, 0x00180000, SN_REGSIZE, &sc->sc_regh)) { printf(": can't map register space\n"); break; } if (bus_space_subregion(bst, bsh, 0x00ffe004, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": can't map ROM space\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 2; success = 1; break; case SN_VENDOR_APPLE: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 1; /* 32 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; case SN_VENDOR_APPLE16: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_EXBUS | DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 0; /* 16 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; case SN_VENDOR_ASANTELC: /* Macintosh LC Ethernet Adapter */ sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 0; /* 16 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x400000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; default: /* * You can't actually get this default, the snmatch * will fail for unknown hardware. If you're adding support * for a new card, the following defaults are a * good starting point. */ sc->snr_dcr = DCR_SYNC | DCR_WAIT0 | DCR_DW32 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; success = 0; printf(": unknown card: attachment incomplete.\n"); } if (!success) { bus_space_unmap(bst, bsh, NBMEMSIZE); return; } /* Regs are addressed as words, big endian. */ for (i = 0; i < SN_NREGS; i++) { sc->sc_reg_map[i] = (bus_size_t)((i * 4) + offset); } printf(": %s, ", cardtype); /* snsetup returns 1 if something fails */ if (snsetup(sc, myaddr)) { bus_space_unmap(bst, bsh, NBMEMSIZE); return; } add_nubus_intr(sc->slotno, IPL_NET, snintr, sc, sc->sc_dev.dv_xname); }