diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index bcc4671d1c63..0f584aa2ce30 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -910,6 +910,120 @@ ed_probe_3Com(dev, port_rid, flags) return (0); } +/* + * Probe and vendor-specific initialization routine for SIC boards + */ +int +ed_probe_SIC(dev, port_rid, flags) + device_t dev; + int port_rid; + int flags; +{ + struct ed_softc *sc = device_get_softc(dev); + int error; + int i; + u_int memsize; + u_long conf_maddr, conf_msize; + u_char sum; + + error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS); + if (error) + return (error); + + sc->asic_offset = ED_SIC_ASIC_OFFSET; + sc->nic_offset = ED_SIC_NIC_OFFSET; + + error = bus_get_resource(dev, SYS_RES_MEMORY, 0, + &conf_maddr, &conf_msize); + if (error) + return (error); + + memsize = 16384; + if (conf_msize > 1) + memsize = conf_msize; + + error = ed_alloc_memory(dev, 0, memsize); + if (error) + return (error); + + sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res); + sc->mem_size = memsize; + + /* Reset card to force it into a known state. */ + ed_asic_outb(sc, 0, 0x00); + DELAY(100); + + /* + * Here we check the card ROM, if the checksum passes, and the + * type code and ethernet address check out, then we know we have + * an SIC card. + */ + ed_asic_outb(sc, 0, 0x81); + DELAY(100); + + sum = sc->mem_start[6]; + for (i = 0; i < ETHER_ADDR_LEN; i++) { + sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i]); + } +#ifdef ED_DEBUG + device_printf(dev, "ed_probe_sic: got address %6D\n", + sc->arpcom.ac_enaddr, ":"); +#endif + if (sum != 0) { + return (ENXIO); + } + if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] | + sc->arpcom.ac_enaddr[2]) == 0) { + return (ENXIO); + } + + sc->vendor = ED_VENDOR_SIC; + sc->type_str = "SIC"; + sc->isa16bit = 0; + sc->cr_proto = 0; + + /* + * SIC RAM page 0x0000-0x3fff(or 0x7fff) + */ + ed_asic_outb(sc, 0, 0x80); + DELAY(100); + + /* + * Now zero memory and verify that it is clear + */ + bzero(sc->mem_start, sc->mem_size); + + for (i = 0; i < sc->mem_size; i++) { + if (sc->mem_start[i]) { + device_printf(dev, "failed to clear shared memory " + "at %jx - check configuration\n", + (uintmax_t)kvtop(sc->mem_start + i)); + + return (ENXIO); + } + } + + sc->mem_shared = 1; + sc->mem_end = sc->mem_start + sc->mem_size; + + /* + * allocate one xmit buffer if < 16k, two buffers otherwise + */ + if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) { + sc->txb_cnt = 1; + } else { + sc->txb_cnt = 2; + } + sc->tx_page_start = 0; + + sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt; + sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; + + sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; + + return (0); +} + /* * Probe and vendor-specific initialization routine for NE1000/2000 boards */ diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c index 4a3c651918e3..d6c37f278e44 100644 --- a/sys/dev/ed/if_ed_cbus.c +++ b/sys/dev/ed/if_ed_cbus.c @@ -869,8 +869,8 @@ ed_probe_SIC98(dev, port_rid, flags) return (error); } - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; + sc->asic_offset = ED_SIC_ASIC_OFFSET; + sc->nic_offset = ED_SIC_NIC_OFFSET; error = ed98_alloc_memory(dev, 0); if (error) { @@ -916,7 +916,7 @@ ed_probe_SIC98(dev, port_rid, flags) return (ENXIO); } - sc->vendor = ED_VENDOR_MISC; + sc->vendor = ED_VENDOR_SIC; sc->type_str = "SIC98"; sc->isa16bit = 1; sc->cr_proto = 0; diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c index 39352b398370..bc5e39799171 100644 --- a/sys/dev/ed/if_ed_isa.c +++ b/sys/dev/ed/if_ed_isa.c @@ -97,6 +97,11 @@ ed_isa_probe(dev) goto end; ed_release_resources(dev); + error = ed_probe_SIC(dev, 0, flags); + if (error == 0) + goto end; + ed_release_resources(dev); + error = ed_probe_Novell(dev, 0, flags); if (error == 0) goto end; diff --git a/sys/dev/ed/if_edreg.h b/sys/dev/ed/if_edreg.h index 068361af0578..4b0857894ce9 100644 --- a/sys/dev/ed/if_edreg.h +++ b/sys/dev/ed/if_edreg.h @@ -578,6 +578,7 @@ struct ed_ring { #define ED_VENDOR_PCCARD 0x03 /* PCMCIA/PCCARD */ #define ED_VENDOR_HP 0x04 /* Hewlett Packard */ #define ED_VENDOR_LINKSYS 0x05 /* Linksys (Dlink) */ +#define ED_VENDOR_SIC 0x06 /* Allied-Telesis SIC */ /* * Compile-time config flags @@ -1100,6 +1101,14 @@ struct ed_ring { #define ED_TYPE_HP_PCLANPLUS 0x00 +/* + * Definitions for Allied-Telesis SIC + */ +#define ED_SIC_NIC_OFFSET 0 +#define ED_SIC_ASIC_OFFSET 0x10 /* offset to nic i/o regs */ + +#define ED_SIC_IO_PORTS 17 /* # of i/o addresses used */ + /* * Chip types. */ diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h index 3855b6dec617..3b71c8c939a6 100644 --- a/sys/dev/ed/if_edvar.h +++ b/sys/dev/ed/if_edvar.h @@ -199,6 +199,7 @@ int ed_probe_generic8390 (struct ed_softc *); int ed_probe_WD80x3 (device_t, int, int); int ed_probe_WD80x3_generic (device_t, int, unsigned short *[]); int ed_probe_3Com (device_t, int, int); +int ed_probe_SIC (device_t, int, int); int ed_probe_Novell (device_t, int, int); int ed_probe_Novell_generic (device_t, int); int ed_probe_HP_pclanp (device_t, int, int);