1/*- 2 * Copyright (c) 2005, M. Warner Losh 3 * All rights reserved. 4 * Copyright (c) 1995, David Greenman 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h>
| 1/*- 2 * Copyright (c) 2005, M. Warner Losh 3 * All rights reserved. 4 * Copyright (c) 1995, David Greenman 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h>
|
31__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_sic.c 142133 2005-02-20 18:39:54Z imp $");
| 31__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_sic.c 147256 2005-06-10 16:49:24Z brooks $");
|
32 33#include "opt_ed.h" 34 35#ifdef ED_SIC 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/sockio.h> 39#include <sys/mbuf.h> 40#include <sys/kernel.h> 41#include <sys/socket.h> 42#include <sys/syslog.h> 43 44#include <sys/bus.h> 45 46#include <machine/bus.h> 47#include <sys/rman.h> 48#include <machine/resource.h> 49 50#include <net/ethernet.h> 51#include <net/if.h> 52#include <net/if_arp.h> 53#include <net/if_dl.h> 54#include <net/if_mib.h> 55#include <net/if_media.h> 56 57#include <net/bpf.h> 58 59#include <dev/ed/if_edreg.h> 60#include <dev/ed/if_edvar.h> 61 62/* 63 * Probe and vendor-specific initialization routine for SIC boards 64 */ 65int 66ed_probe_SIC(device_t dev, int port_rid, int flags) 67{ 68 struct ed_softc *sc = device_get_softc(dev); 69 int error; 70 int i; 71 u_int memsize; 72 u_long pmem; 73 u_char sum; 74 75 error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS); 76 if (error) 77 return (error); 78 79 sc->asic_offset = ED_SIC_ASIC_OFFSET; 80 sc->nic_offset = ED_SIC_NIC_OFFSET; 81 82 memsize = 16384; 83 /* XXX Needs to allow different msize */ 84 error = ed_alloc_memory(dev, 0, memsize); 85 if (error) 86 return (error); 87 88 sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res); 89 sc->mem_size = memsize; 90 91 pmem = rman_get_start(sc->mem_res); 92 error = ed_isa_mem_ok(dev, pmem, memsize); 93 if (error) 94 return (error); 95 96 /* Reset card to force it into a known state. */ 97 ed_asic_outb(sc, 0, 0x00); 98 DELAY(100); 99 100 /* 101 * Here we check the card ROM, if the checksum passes, and the 102 * type code and ethernet address check out, then we know we have 103 * an SIC card. 104 */ 105 ed_asic_outb(sc, 0, 0x81); 106 DELAY(100); 107 108 sum = sc->mem_start[6]; 109 for (i = 0; i < ETHER_ADDR_LEN; i++)
| 32 33#include "opt_ed.h" 34 35#ifdef ED_SIC 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/sockio.h> 39#include <sys/mbuf.h> 40#include <sys/kernel.h> 41#include <sys/socket.h> 42#include <sys/syslog.h> 43 44#include <sys/bus.h> 45 46#include <machine/bus.h> 47#include <sys/rman.h> 48#include <machine/resource.h> 49 50#include <net/ethernet.h> 51#include <net/if.h> 52#include <net/if_arp.h> 53#include <net/if_dl.h> 54#include <net/if_mib.h> 55#include <net/if_media.h> 56 57#include <net/bpf.h> 58 59#include <dev/ed/if_edreg.h> 60#include <dev/ed/if_edvar.h> 61 62/* 63 * Probe and vendor-specific initialization routine for SIC boards 64 */ 65int 66ed_probe_SIC(device_t dev, int port_rid, int flags) 67{ 68 struct ed_softc *sc = device_get_softc(dev); 69 int error; 70 int i; 71 u_int memsize; 72 u_long pmem; 73 u_char sum; 74 75 error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS); 76 if (error) 77 return (error); 78 79 sc->asic_offset = ED_SIC_ASIC_OFFSET; 80 sc->nic_offset = ED_SIC_NIC_OFFSET; 81 82 memsize = 16384; 83 /* XXX Needs to allow different msize */ 84 error = ed_alloc_memory(dev, 0, memsize); 85 if (error) 86 return (error); 87 88 sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res); 89 sc->mem_size = memsize; 90 91 pmem = rman_get_start(sc->mem_res); 92 error = ed_isa_mem_ok(dev, pmem, memsize); 93 if (error) 94 return (error); 95 96 /* Reset card to force it into a known state. */ 97 ed_asic_outb(sc, 0, 0x00); 98 DELAY(100); 99 100 /* 101 * Here we check the card ROM, if the checksum passes, and the 102 * type code and ethernet address check out, then we know we have 103 * an SIC card. 104 */ 105 ed_asic_outb(sc, 0, 0x81); 106 DELAY(100); 107 108 sum = sc->mem_start[6]; 109 for (i = 0; i < ETHER_ADDR_LEN; i++)
|
110 sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i]);
| 110 sum ^= (sc->enaddr[i] = sc->mem_start[i]);
|
111#ifdef ED_DEBUG 112 device_printf(dev, "ed_probe_sic: got address %6D\n",
| 111#ifdef ED_DEBUG 112 device_printf(dev, "ed_probe_sic: got address %6D\n",
|
113 sc->arpcom.ac_enaddr, ":");
| 113 sc->enaddr, ":");
|
114#endif 115 if (sum != 0) 116 return (ENXIO);
| 114#endif 115 if (sum != 0) 116 return (ENXIO);
|
117 if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] | 118 sc->arpcom.ac_enaddr[2]) == 0)
| 117 if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
|
119 return (ENXIO); 120 121 sc->vendor = ED_VENDOR_SIC; 122 sc->type_str = "SIC"; 123 sc->isa16bit = 0; 124 sc->cr_proto = 0; 125 126 /* 127 * SIC RAM page 0x0000-0x3fff(or 0x7fff) 128 */ 129 ed_asic_outb(sc, 0, 0x80); 130 DELAY(100); 131 132 error = ed_clear_memory(dev); 133 if (error) 134 return (error); 135 136 sc->mem_shared = 1; 137 sc->mem_end = sc->mem_start + sc->mem_size; 138 139 /* 140 * allocate one xmit buffer if < 16k, two buffers otherwise 141 */ 142 if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) 143 sc->txb_cnt = 1; 144 else 145 sc->txb_cnt = 2; 146 sc->tx_page_start = 0; 147 148 sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt; 149 sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; 150 151 sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; 152 153 return (0); 154} 155 156#endif /* ED_SIC */
| 118 return (ENXIO); 119 120 sc->vendor = ED_VENDOR_SIC; 121 sc->type_str = "SIC"; 122 sc->isa16bit = 0; 123 sc->cr_proto = 0; 124 125 /* 126 * SIC RAM page 0x0000-0x3fff(or 0x7fff) 127 */ 128 ed_asic_outb(sc, 0, 0x80); 129 DELAY(100); 130 131 error = ed_clear_memory(dev); 132 if (error) 133 return (error); 134 135 sc->mem_shared = 1; 136 sc->mem_end = sc->mem_start + sc->mem_size; 137 138 /* 139 * allocate one xmit buffer if < 16k, two buffers otherwise 140 */ 141 if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) 142 sc->txb_cnt = 1; 143 else 144 sc->txb_cnt = 2; 145 sc->tx_page_start = 0; 146 147 sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt; 148 sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; 149 150 sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; 151 152 return (0); 153} 154 155#endif /* ED_SIC */
|