Deleted Added
sdiff udiff text old ( 15363 ) new ( 15813 )
full compact
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $Id: if_ed.c,v 1.96 1996/04/08 01:25:22 davidg Exp $
28 */
29
30/*
31 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
32 * adapters. By David Greenman, 29-April-1993
33 *
34 * Currently supports the Western Digital/SMC 8003 and 8013 series,
35 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,

--- 89 unchanged lines hidden (view full) ---

125 u_char rec_page_start; /* first page of RX ring-buffer */
126 u_char rec_page_stop; /* last page of RX ring-buffer */
127 u_char next_packet; /* pointer to next unread RX packet */
128 struct kern_devconf kdc; /* kernel configuration database info */
129};
130
131static struct ed_softc ed_softc[NED];
132
133static int ed_attach __P((struct isa_device *));
134static void ed_init __P((struct ifnet *));
135static int ed_ioctl __P((struct ifnet *, int, caddr_t));
136static int ed_probe __P((struct isa_device *));
137static void ed_start __P((struct ifnet *));
138static void ed_reset __P((struct ifnet *));
139static void ed_watchdog __P((struct ifnet *));
140
141static void ed_stop __P((struct ed_softc *));
142static int ed_probe_generic8390 __P((struct ed_softc *));
143static int ed_probe_WD80x3 __P((struct isa_device *));
144static int ed_probe_3Com __P((struct isa_device *));
145static int ed_probe_Novell __P((struct isa_device *));
146static int ed_probe_pccard __P((struct isa_device *, u_char *));
147
148static void ds_getmcaf __P((struct ed_softc *, u_long *));
149
150static void ed_get_packet(struct ed_softc *, char *, /* u_short */ int, int);
151
152static void ed_rint __P((struct ed_softc *));
153static void ed_xmit __P((struct ed_softc *));
154static char * ed_ring_copy __P((struct ed_softc *, char *, char *,

--- 4 unchanged lines hidden (view full) ---

159static void ed_pio_writemem __P((struct ed_softc *, char *,
160 /* u_short */ int, /* u_short */ int));
161static u_short ed_pio_write_mbufs __P((struct ed_softc *, struct mbuf *,
162 int));
163
164static void ed_setrcr(struct ed_softc *);
165static u_long ds_crc(u_char *ep);
166
167#include "crd.h"
168#if NCRD > 0
169#include <sys/select.h>
170#include <pccard/card.h>
171#include <pccard/driver.h>
172#include <pccard/slot.h>
173
174/*
175 * PC-Card (PCMCIA) specific code.

--- 44 unchanged lines hidden (view full) ---

220 return(ENODEV);
221 /*
222 * Probe the device. If a value is returned, the
223 * device was found at the location.
224 */
225 sc->gone = 0;
226 if (ed_probe_pccard(&dp->isahd,dp->misc)==0)
227 return(ENXIO);
228 if (ed_attach(&dp->isahd)==0)
229 return(ENXIO);
230 }
231 /*
232 * XXX TODO:
233 * If it was initialized before, the device structure
234 * should also be initialized. We should
235 * reset (and possibly restart) the hardware, but
236 * I am not sure of the best way to do this...

--- 29 unchanged lines hidden (view full) ---

266
267/*
268 * card_intr - Shared interrupt called from
269 * front end of PC-Card handler.
270 */
271static int
272card_intr(struct pccard_dev *dp)
273{
274 edintr(dp->isahd.id_unit);
275 return(1);
276}
277#endif /* NCRD > 0 */
278
279struct isa_driver eddriver = {
280 ed_probe,
281 ed_attach,
282 "ed",
283 1 /* We are ultra sensitive */
284};
285
286/*
287 * Interrupt conversion table for WD/SMC ASIC/83C584
288 * (IRQ* are defined in icu.h)
289 */

--- 788 unchanged lines hidden (view full) ---

1078 isa_dev->id_msize = memsize;
1079 return (ED_3COM_IO_PORTS);
1080}
1081
1082/*
1083 * Probe and vendor-specific initialization routine for NE1000/2000 boards
1084 */
1085static int
1086ed_probe_Novell(isa_dev)
1087 struct isa_device *isa_dev;
1088{
1089 struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
1090 u_int memsize, n;
1091 u_char romdata[16], tmp;
1092 static char test_pattern[32] = "THIS is A memory TEST pattern";
1093 char test_buffer[32];
1094
1095 sc->asic_addr = isa_dev->id_iobase + ED_NOVELL_ASIC_OFFSET;
1096 sc->nic_addr = isa_dev->id_iobase + ED_NOVELL_NIC_OFFSET;
1097
1098 /* XXX - do Novell-specific probe here */
1099
1100 /* Reset the board */
1101#ifdef GWETHER
1102 outb(sc->asic_addr + ED_NOVELL_RESET, 0);
1103 DELAY(200);
1104#endif /* GWETHER */

--- 22 unchanged lines hidden (view full) ---

1127
1128 /* Make sure that we really have an 8390 based board */
1129 if (!ed_probe_generic8390(sc))
1130 return (0);
1131
1132 sc->vendor = ED_VENDOR_NOVELL;
1133 sc->mem_shared = 0;
1134 sc->cr_proto = ED_CR_RD2;
1135 isa_dev->id_maddr = 0;
1136
1137 /*
1138 * Test the ability to read and write to the NIC memory. This has the
1139 * side affect of determining if this is an NE1000 or an NE2000.
1140 */
1141
1142 /*
1143 * This prevents packets from being stored in the NIC memory when the

--- 86 unchanged lines hidden (view full) ---

1230 mstart = x * ED_PAGE_SIZE;
1231 msize = ED_PAGE_SIZE;
1232 break;
1233 }
1234 }
1235 }
1236
1237 if (mstart == 0) {
1238 printf("ed%d: Cannot find start of RAM.\n", isa_dev->id_unit);
1239 return 0;
1240 }
1241 /* Search for the start of RAM. */
1242 for (x = (mstart / ED_PAGE_SIZE) + 1; x < 256; x++) {
1243 ed_pio_readmem(sc, x * 256, tbuf, ED_PAGE_SIZE);
1244 if (bcmp(pbuf0, tbuf, ED_PAGE_SIZE) == 0) {
1245 for (i = 0; i < ED_PAGE_SIZE; i++)
1246 pbuf[i] = 255 - x;

--- 5 unchanged lines hidden (view full) ---

1252 break;
1253 }
1254 } else {
1255 break;
1256 }
1257 }
1258
1259 if (msize == 0) {
1260 printf("ed%d: Cannot find any RAM, start : %d, x = %d.\n", isa_dev->id_unit, mstart, x);
1261 return 0;
1262 }
1263 printf("ed%d: RAM start at %d, size : %d.\n", isa_dev->id_unit, mstart, msize);
1264
1265 sc->mem_size = msize;
1266 sc->mem_start = (char *) mstart;
1267 sc->mem_end = (char *) (msize + mstart);
1268 sc->tx_page_start = mstart / ED_PAGE_SIZE;
1269 }
1270#endif /* GWETHER */
1271
1272 /*
1273 * Use one xmit buffer if < 16k, two buffers otherwise (if not told
1274 * otherwise).
1275 */
1276 if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING))
1277 sc->txb_cnt = 1;
1278 else
1279 sc->txb_cnt = 2;
1280
1281 sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
1282 sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE;
1283
1284 sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;

--- 10 unchanged lines hidden (view full) ---

1295#endif /* GWETHER */
1296
1297 /* clear any pending interrupts that might have occurred above */
1298 outb(sc->nic_addr + ED_P0_ISR, 0xff);
1299
1300 return (ED_NOVELL_IO_PORTS);
1301}
1302
1303
1304/*
1305 * Probe and vendor-specific initialization routine for PCCARDs
1306 */
1307static int
1308ed_probe_pccard(isa_dev, ether)
1309 struct isa_device *isa_dev;
1310 u_char *ether;
1311{

--- 92 unchanged lines hidden (view full) ---

1404 }
1405
1406 /* clear any pending interupts that we may have caused */
1407 outb(sc->nic_addr + ED_P0_ISR, 0xff);
1408
1409 return (ED_PC_IO_PORTS);
1410}
1411
1412/*
1413 * Install interface into kernel networking data structures
1414 */
1415static int
1416ed_attach(isa_dev)
1417 struct isa_device *isa_dev;
1418{
1419 struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
1420 struct ifnet *ifp = &sc->arpcom.ac_if;
1421
1422 /*
1423 * Set interface to stopped condition (reset)
1424 */
1425 ed_stop(sc);
1426
1427 if (!ifp->if_name) {
1428 /*
1429 * Initialize ifnet structure
1430 */
1431 ifp->if_softc = sc;
1432 ifp->if_unit = isa_dev->id_unit;
1433 ifp->if_name = "ed";
1434 ifp->if_output = ether_output;
1435 ifp->if_start = ed_start;
1436 ifp->if_ioctl = ed_ioctl;
1437 ifp->if_watchdog = ed_watchdog;
1438 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
1439
1440 /*
1441 * Set default state for ALTPHYS flag (used to disable the
1442 * tranceiver for AUI operation), based on compile-time
1443 * config option.
1444 */
1445 if (isa_dev->id_flags & ED_FLAGS_DISABLE_TRANCEIVER)
1446 ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
1447 IFF_MULTICAST | IFF_ALTPHYS);
1448 else
1449 ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
1450 IFF_MULTICAST);
1451
1452 /*
1453 * Attach the interface
1454 */
1455 if_attach(ifp);
1456 ether_ifattach(ifp);
1457 }
1458 /* device attach does transition from UNCONFIGURED to IDLE state */
1459 sc->kdc.kdc_state = DC_IDLE;
1460
1461 /*
1462 * Print additional info when attached
1463 */
1464 printf("ed%d: address %6D, ", isa_dev->id_unit,
1465 sc->arpcom.ac_enaddr, ":");
1466
1467 if (sc->type_str && (*sc->type_str != 0))
1468 printf("type %s ", sc->type_str);
1469 else
1470 printf("type unknown (0x%x) ", sc->type);
1471
1472 printf("%s ", sc->isa16bit ? "(16 bit)" : "(8 bit)");

--- 5 unchanged lines hidden (view full) ---

1478 * If BPF is in the kernel, call the attach for it
1479 */
1480#if NBPFILTER > 0
1481 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
1482#endif
1483 return 1;
1484}
1485
1486/*
1487 * Reset interface.
1488 */
1489static void
1490ed_reset(ifp)
1491 struct ifnet *ifp;
1492{
1493 struct ed_softc *sc = ifp->if_softc;

--- 541 unchanged lines hidden (view full) ---

2035 outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
2036 }
2037}
2038
2039/*
2040 * Ethernet interface interrupt processor
2041 */
2042void
2043edintr(unit)
2044 int unit;
2045{
2046 struct ed_softc *sc = &ed_softc[unit];
2047 struct ifnet *ifp = (struct ifnet *)sc;
2048 u_char isr;
2049
2050 if (sc->gone)
2051 return;
2052 /*
2053 * Set NIC to page 0 registers
2054 */

--- 189 unchanged lines hidden (view full) ---

2244 if (isr & ED_ISR_CNT) {
2245 (void) inb(sc->nic_addr + ED_P0_CNTR0);
2246 (void) inb(sc->nic_addr + ED_P0_CNTR1);
2247 (void) inb(sc->nic_addr + ED_P0_CNTR2);
2248 }
2249 }
2250}
2251
2252/*
2253 * Process an ioctl request. This code needs some work - it looks
2254 * pretty ugly.
2255 */
2256static int
2257ed_ioctl(ifp, command, data)
2258 register struct ifnet *ifp;
2259 int command;

--- 618 unchanged lines hidden ---