* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / drivers / net / ne2.c
blob0a69d9004988bc3c8cbea4ab4f53b11e49e5449a
1 /* ne2.c: A NE/2 Ethernet Driver for Linux. */
2 /*
3 Based on the NE2000 driver written by Donald Becker (1992-94).
4 modified by Wim Dumon (Apr 1996)
6 This software may be used and distributed according to the terms
7 of the GNU Public License, incorporated herein by reference.
9 The author may be reached as wimpie@linux.cc.kuleuven.ac.be
11 Currently supported: NE/2
12 This patch was never tested on other MCA-ethernet adapters, but it
13 might work. Just give it a try and let me know if you have problems.
14 Also mail me if it really works, please!
16 Changelog:
17 Mon Feb 3 16:26:02 MET 1997
18 - adapted the driver to work with the 2.1.25 kernel
19 - multiple ne2 support (untested)
20 - module support (untested)
22 Fri Aug 28 00:18:36 CET 1998 (David Weinehall)
23 - fixed a few minor typos
24 - made the MODULE_PARM conditional (it only works with the v2.1.x kernels)
25 - fixed the module support (Now it's working...)
27 Mon Sep 7 19:01:44 CET 1998 (David Weinehall)
28 - added support for Arco Electronics AE/2-card (experimental)
30 Mon Sep 14 09:53:42 CET 1998 (David Weinehall)
31 - added support for Compex ENET-16MC/P (experimental)
33 Tue Sep 15 16:21:12 CET 1998 (David Weinehall, Magnus Jonsson, Tomas Ogren)
34 - Miscellaneous bugfixes
36 Tue Sep 19 16:21:12 CET 1998 (Magnus Jonsson)
37 - Cleanup
39 Wed Sep 23 14:33:34 CET 1998 (David Weinehall)
40 - Restructuring and rewriting for v2.1.x compliance
42 Wed Oct 14 17:19:21 CET 1998 (David Weinehall)
43 - Added code that unregisters irq and proc-info
44 - Version# bump
46 Mon Nov 16 15:28:23 CET 1998 (Wim Dumon)
47 - pass 'dev' as last parameter of request_irq in stead of 'NULL'
49 * WARNING
50 -------
51 This is alpha-test software. It is not guaranteed to work. As a
52 matter of fact, I'm quite sure there are *LOTS* of bugs in here. I
53 would like to hear from you if you use this driver, even if it works.
54 If it doesn't work, be sure to send me a mail with the problems !
57 static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.org>\n";
59 #include <linux/module.h>
60 #include <linux/version.h>
62 #include <linux/kernel.h>
63 #include <linux/sched.h>
64 #include <linux/types.h>
65 #include <linux/fcntl.h>
66 #include <linux/interrupt.h>
67 #include <linux/ptrace.h>
68 #include <linux/ioport.h>
69 #include <linux/in.h>
70 #include <linux/malloc.h>
71 #include <linux/string.h>
72 #include <asm/system.h>
73 #include <asm/bitops.h>
74 #include <asm/io.h>
75 #include <asm/dma.h>
76 #include <linux/errno.h>
77 #include <linux/init.h>
78 #include <linux/mca.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/skbuff.h>
83 #include "8390.h"
87 /* Some defines that people can play with if so inclined. */
89 /* Do we perform extra sanity checks on stuff ? */
90 /* #define NE_SANITY_CHECK */
92 /* Do we implement the read before write bugfix ? */
93 /* #define NE_RW_BUGFIX */
95 /* Do we have a non std. amount of memory? (in units of 256 byte pages) */
96 /* #define PACKETBUF_MEMSIZE 0x40 */
99 /* ---- No user-serviceable parts below ---- */
101 #define NE_BASE (dev->base_addr)
102 #define NE_CMD 0x00
103 #define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */
104 #define NE_RESET 0x20 /* Issue a read to reset, a write to clear. */
105 #define NE_IO_EXTENT 0x30
107 #define NE1SM_START_PG 0x20 /* First page of TX buffer */
108 #define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
109 #define NESM_START_PG 0x40 /* First page of TX buffer */
110 #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
112 /* From the .ADF file: */
113 static unsigned int addresses[7]=
114 {0x1000, 0x2020, 0x8020, 0xa0a0, 0xb0b0, 0xc0c0, 0xc3d0};
115 static int irqs[4] = {3, 4, 5, 9};
117 struct ne2_adapters_t {
118 unsigned int id;
119 char *name;
122 const struct ne2_adapters_t ne2_adapters[] = {
123 { 0x6354, "Arco Ethernet Adapter AE/2" },
124 { 0x70DE, "Compex ENET-16 MC/P" },
125 { 0x7154, "Novell Ethernet Adapter NE/2" },
126 { 0x0000, NULL }
129 extern int netcard_probe(struct net_device *dev);
131 static int ne2_probe1(struct net_device *dev, int slot);
133 static int ne_open(struct net_device *dev);
134 static int ne_close(struct net_device *dev);
136 static void ne_reset_8390(struct net_device *dev);
137 static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
138 int ring_page);
139 static void ne_block_input(struct net_device *dev, int count,
140 struct sk_buff *skb, int ring_offset);
141 static void ne_block_output(struct net_device *dev, const int count,
142 const unsigned char *buf, const int start_page);
146 * Note that at boot, this probe only picks up one card at a time.
149 int __init ne2_probe(struct net_device *dev)
151 static int current_mca_slot = -1;
152 int i;
153 int adapter_found = 0;
155 /* Do not check any supplied i/o locations.
156 POS registers usually don't fail :) */
158 /* MCA cards have POS registers.
159 Autodetecting MCA cards is extremely simple.
160 Just search for the card. */
162 for(i = 0; (ne2_adapters[i].name != NULL) && !adapter_found; i++) {
163 current_mca_slot =
164 mca_find_unused_adapter(ne2_adapters[i].id, 0);
166 if((current_mca_slot != MCA_NOTFOUND) && !adapter_found) {
167 mca_set_adapter_name(current_mca_slot,
168 ne2_adapters[i].name);
169 mca_mark_as_used(current_mca_slot);
171 return ne2_probe1(dev, current_mca_slot);
174 return ENODEV;
178 static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
180 int len=0;
182 len += sprintf(buf+len, "The NE/2 Ethernet Adapter\n" );
183 len += sprintf(buf+len, "Driver written by Wim Dumon ");
184 len += sprintf(buf+len, "<wimpie@kotnet.org>\n");
185 len += sprintf(buf+len, "Modified by ");
186 len += sprintf(buf+len, "David Weinehall <tao@acc.umu.se>\n");
187 len += sprintf(buf+len, "and by Magnus Jonsson <bigfoot@acc.umu.se>\n");
188 len += sprintf(buf+len, "Based on the original NE2000 drivers\n" );
189 len += sprintf(buf+len, "Base IO: %#x\n", (unsigned int)dev->base_addr);
190 len += sprintf(buf+len, "IRQ : %d\n", dev->irq);
192 #define HW_ADDR(i) dev->dev_addr[i]
193 len += sprintf(buf+len, "HW addr : %x:%x:%x:%x:%x:%x\n",
194 HW_ADDR(0), HW_ADDR(1), HW_ADDR(2),
195 HW_ADDR(3), HW_ADDR(4), HW_ADDR(5) );
196 #undef HW_ADDR
198 return len;
201 static int __init ne2_probe1(struct net_device *dev, int slot)
203 int i, base_addr, irq;
204 unsigned char POS;
205 unsigned char SA_prom[32];
206 const char *name = "NE/2";
207 int start_page, stop_page;
208 static unsigned version_printed = 0;
210 /* We should have a "dev" from Space.c or the static module table. */
211 if (dev == NULL) {
212 printk(KERN_ERR "ne2.c: Passed a NULL device.\n");
213 dev = init_etherdev(0, 0);
216 if (ei_debug && version_printed++ == 0)
217 printk(version);
219 printk("NE/2 ethercard found in slot %d:", slot);
221 /* Read base IO and IRQ from the POS-registers */
222 POS = mca_read_stored_pos(slot, 2);
223 if(!(POS % 2)) {
224 printk(" disabled.\n");
225 return ENODEV;
228 i = (POS & 0xE)>>1;
229 /* printk("Halleluja sdog, als er na de pijl een 1 staat is 1 - 1 == 0"
230 " en zou het moeten werken -> %d\n", i);
231 The above line was for remote testing, thanx to sdog ... */
232 base_addr = addresses[i - 1];
233 irq = irqs[(POS & 0x60)>>5];
235 #ifdef DEBUG
236 printk("POS info : pos 2 = %#x ; base = %#x ; irq = %ld\n", POS,
237 base_addr, irq);
238 #endif
240 #ifndef CRYNWR_WAY
241 /* Reset the card the way they do it in the Crynwr packet driver */
242 for (i=0; i<8; i++)
243 outb(0x0, base_addr + NE_RESET);
244 inb(base_addr + NE_RESET);
245 outb(0x21, base_addr + NE_CMD);
246 if (inb(base_addr + NE_CMD) != 0x21) {
247 printk("NE/2 adapter not responding\n");
248 return ENODEV;
251 /* In the crynwr sources they do a RAM-test here. I skip it. I suppose
252 my RAM is okay. Suppose your memory is broken. Then this test
253 should fail and you won't be able to use your card. But if I do not
254 test, you won't be able to use your card, neither. So this test
255 won't help you. */
257 #else /* _I_ never tested it this way .. Go ahead and try ...*/
258 /* Reset card. Who knows what dain-bramaged state it was left in. */
260 unsigned long reset_start_time = jiffies;
262 /* DON'T change these to inb_p/outb_p or reset will fail on
263 clones.. */
264 outb(inb(base_addr + NE_RESET), base_addr + NE_RESET);
266 while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0)
267 if (jiffies - reset_start_time > 2*HZ/100) {
268 printk(" not found (no reset ack).\n");
269 return ENODEV;
272 outb_p(0xff, base_addr + EN0_ISR); /* Ack all intr. */
274 #endif
277 /* Read the 16 bytes of station address PROM.
278 We must first initialize registers, similar to
279 NS8390_init(eifdev, 0).
280 We can't reliably read the SAPROM address without this.
281 (I learned the hard way!). */
283 struct {
284 unsigned char value, offset;
285 } program_seq[] = {
286 /* Select page 0 */
287 {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD},
288 {0x49, EN0_DCFG}, /* Set WORD-wide (0x49) access. */
289 {0x00, EN0_RCNTLO}, /* Clear the count regs. */
290 {0x00, EN0_RCNTHI},
291 {0x00, EN0_IMR}, /* Mask completion irq. */
292 {0xFF, EN0_ISR},
293 {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */
294 {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */
295 {32, EN0_RCNTLO},
296 {0x00, EN0_RCNTHI},
297 {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */
298 {0x00, EN0_RSARHI},
299 {E8390_RREAD+E8390_START, E8390_CMD},
302 for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
303 outb_p(program_seq[i].value, base_addr +
304 program_seq[i].offset);
307 for(i = 0; i < 6 /*sizeof(SA_prom)*/; i+=1) {
308 SA_prom[i] = inb(base_addr + NE_DATAPORT);
311 start_page = NESM_START_PG;
312 stop_page = NESM_STOP_PG;
314 dev->irq=irq;
316 /* Snarf the interrupt now. There's no point in waiting since we cannot
317 share and the board will usually be enabled. */
319 int irqval = request_irq(dev->irq, ei_interrupt,
320 0, name, dev);
321 if (irqval) {
322 printk (" unable to get IRQ %d (irqval=%d).\n",
323 dev->irq, +irqval);
324 return EAGAIN;
328 dev->base_addr = base_addr;
330 /* Allocate dev->priv and fill in 8390 specific dev fields. */
331 if (ethdev_init(dev)) {
332 printk (" unable to get memory for dev->priv.\n");
333 free_irq(dev->irq, dev);
334 return -ENOMEM;
337 request_region(base_addr, NE_IO_EXTENT, name);
339 for(i = 0; i < ETHER_ADDR_LEN; i++) {
340 printk(" %2.2x", SA_prom[i]);
341 dev->dev_addr[i] = SA_prom[i];
344 printk("\n%s: %s found at %#x, using IRQ %d.\n",
345 dev->name, name, base_addr, dev->irq);
347 mca_set_adapter_procfn(slot, (MCA_ProcFn) ne2_procinfo, dev);
349 ei_status.name = name;
350 ei_status.tx_start_page = start_page;
351 ei_status.stop_page = stop_page;
352 ei_status.word16 = (2 == 2);
354 ei_status.rx_start_page = start_page + TX_PAGES;
355 #ifdef PACKETBUF_MEMSIZE
356 /* Allow the packet buffer size to be overridden by know-it-alls. */
357 ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
358 #endif
360 ei_status.reset_8390 = &ne_reset_8390;
361 ei_status.block_input = &ne_block_input;
362 ei_status.block_output = &ne_block_output;
363 ei_status.get_8390_hdr = &ne_get_8390_hdr;
365 ei_status.priv = slot;
367 dev->open = &ne_open;
368 dev->stop = &ne_close;
369 NS8390_init(dev, 0);
370 return 0;
373 static int ne_open(struct net_device *dev)
375 ei_open(dev);
376 MOD_INC_USE_COUNT;
377 return 0;
380 static int ne_close(struct net_device *dev)
382 if (ei_debug > 1)
383 printk("%s: Shutting down ethercard.\n", dev->name);
384 ei_close(dev);
385 MOD_DEC_USE_COUNT;
386 return 0;
389 /* Hard reset the card. This used to pause for the same period that a
390 8390 reset command required, but that shouldn't be necessary. */
391 static void ne_reset_8390(struct net_device *dev)
393 unsigned long reset_start_time = jiffies;
395 if (ei_debug > 1)
396 printk("resetting the 8390 t=%ld...", jiffies);
398 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
399 outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
401 ei_status.txing = 0;
402 ei_status.dmaing = 0;
404 /* This check _should_not_ be necessary, omit eventually. */
405 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
406 if (jiffies - reset_start_time > 2*HZ/100) {
407 printk("%s: ne_reset_8390() did not complete.\n",
408 dev->name);
409 break;
411 outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
414 /* Grab the 8390 specific header. Similar to the block_input routine, but
415 we don't need to be concerned with ring wrap as the header will be at
416 the start of a page, so we optimize accordingly. */
418 static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
419 int ring_page)
422 int nic_base = dev->base_addr;
424 /* This *shouldn't* happen.
425 If it does, it's the last thing you'll see */
426 if (ei_status.dmaing) {
427 printk("%s: DMAing conflict in ne_get_8390_hdr "
428 "[DMAstat:%d][irqlock:%d][intr:%ld].\n",
429 dev->name, ei_status.dmaing, ei_status.irqlock,
430 dev->interrupt);
431 return;
434 ei_status.dmaing |= 0x01;
435 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
436 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
437 outb_p(0, nic_base + EN0_RCNTHI);
438 outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
439 outb_p(ring_page, nic_base + EN0_RSARHI);
440 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
442 if (ei_status.word16)
443 insw(NE_BASE + NE_DATAPORT, hdr,
444 sizeof(struct e8390_pkt_hdr)>>1);
445 else
446 insb(NE_BASE + NE_DATAPORT, hdr,
447 sizeof(struct e8390_pkt_hdr));
449 outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
450 ei_status.dmaing &= ~0x01;
453 /* Block input and output, similar to the Crynwr packet driver. If you
454 are porting to a new ethercard, look at the packet driver source for
455 hints. The NEx000 doesn't share the on-board packet memory -- you have
456 to put the packet out through the "remote DMA" dataport using outb. */
458 static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb,
459 int ring_offset)
461 #ifdef NE_SANITY_CHECK
462 int xfer_count = count;
463 #endif
464 int nic_base = dev->base_addr;
465 char *buf = skb->data;
467 /* This *shouldn't* happen.
468 If it does, it's the last thing you'll see */
469 if (ei_status.dmaing) {
470 printk("%s: DMAing conflict in ne_block_input "
471 "[DMAstat:%d][irqlock:%d][intr:%ld].\n",
472 dev->name, ei_status.dmaing, ei_status.irqlock,
473 dev->interrupt);
474 return;
476 ei_status.dmaing |= 0x01;
477 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
478 outb_p(count & 0xff, nic_base + EN0_RCNTLO);
479 outb_p(count >> 8, nic_base + EN0_RCNTHI);
480 outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
481 outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
482 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
483 if (ei_status.word16) {
484 insw(NE_BASE + NE_DATAPORT,buf,count>>1);
485 if (count & 0x01) {
486 buf[count-1] = inb(NE_BASE + NE_DATAPORT);
487 #ifdef NE_SANITY_CHECK
488 xfer_count++;
489 #endif
491 } else {
492 insb(NE_BASE + NE_DATAPORT, buf, count);
495 #ifdef NE_SANITY_CHECK
496 /* This was for the ALPHA version only, but enough people have
497 been encountering problems so it is still here. If you see
498 this message you either 1) have a slightly incompatible clone
499 or 2) have noise/speed problems with your bus. */
500 if (ei_debug > 1) { /* DMA termination address check... */
501 int addr, tries = 20;
502 do {
503 /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
504 -- it's broken for Rx on some cards! */
505 int high = inb_p(nic_base + EN0_RSARHI);
506 int low = inb_p(nic_base + EN0_RSARLO);
507 addr = (high << 8) + low;
508 if (((ring_offset + xfer_count) & 0xff) == low)
509 break;
510 } while (--tries > 0);
511 if (tries <= 0)
512 printk("%s: RX transfer address mismatch,"
513 "%#4.4x (expected) vs. %#4.4x (actual).\n",
514 dev->name, ring_offset + xfer_count, addr);
516 #endif
517 outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
518 ei_status.dmaing &= ~0x01;
521 static void ne_block_output(struct net_device *dev, int count,
522 const unsigned char *buf, const int start_page)
524 int nic_base = NE_BASE;
525 unsigned long dma_start;
526 #ifdef NE_SANITY_CHECK
527 int retries = 0;
528 #endif
530 /* Round the count up for word writes. Do we need to do this?
531 What effect will an odd byte count have on the 8390?
532 I should check someday. */
533 if (ei_status.word16 && (count & 0x01))
534 count++;
536 /* This *shouldn't* happen.
537 If it does, it's the last thing you'll see */
538 if (ei_status.dmaing) {
539 printk("%s: DMAing conflict in ne_block_output."
540 "[DMAstat:%d][irqlock:%d][intr:%ld]\n",
541 dev->name, ei_status.dmaing, ei_status.irqlock,
542 dev->interrupt);
543 return;
545 ei_status.dmaing |= 0x01;
546 /* We should already be in page 0, but to be safe... */
547 outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
549 #ifdef NE_SANITY_CHECK
550 retry:
551 #endif
553 #ifdef NE8390_RW_BUGFIX
554 /* Handle the read-before-write bug the same way as the
555 Crynwr packet driver -- the NatSemi method doesn't work.
556 Actually this doesn't always work either, but if you have
557 problems with your NEx000 this is better than nothing! */
558 outb_p(0x42, nic_base + EN0_RCNTLO);
559 outb_p(0x00, nic_base + EN0_RCNTHI);
560 outb_p(0x42, nic_base + EN0_RSARLO);
561 outb_p(0x00, nic_base + EN0_RSARHI);
562 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
563 /* Make certain that the dummy read has occurred. */
564 SLOW_DOWN_IO;
565 SLOW_DOWN_IO;
566 SLOW_DOWN_IO;
567 #endif
569 outb_p(ENISR_RDC, nic_base + EN0_ISR);
571 /* Now the normal output. */
572 outb_p(count & 0xff, nic_base + EN0_RCNTLO);
573 outb_p(count >> 8, nic_base + EN0_RCNTHI);
574 outb_p(0x00, nic_base + EN0_RSARLO);
575 outb_p(start_page, nic_base + EN0_RSARHI);
577 outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
578 if (ei_status.word16) {
579 outsw(NE_BASE + NE_DATAPORT, buf, count>>1);
580 } else {
581 outsb(NE_BASE + NE_DATAPORT, buf, count);
584 dma_start = jiffies;
586 #ifdef NE_SANITY_CHECK
587 /* This was for the ALPHA version only, but enough people have
588 been encountering problems so it is still here. */
590 if (ei_debug > 1) { /* DMA termination address check... */
591 int addr, tries = 20;
592 do {
593 int high = inb_p(nic_base + EN0_RSARHI);
594 int low = inb_p(nic_base + EN0_RSARLO);
595 addr = (high << 8) + low;
596 if ((start_page << 8) + count == addr)
597 break;
598 } while (--tries > 0);
599 if (tries <= 0) {
600 printk("%s: Tx packet transfer address mismatch,"
601 "%#4.4x (expected) vs. %#4.4x (actual).\n",
602 dev->name, (start_page << 8) + count, addr);
603 if (retries++ == 0)
604 goto retry;
607 #endif
609 while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
610 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */
611 printk("%s: timeout waiting for Tx RDC.\n", dev->name);
612 ne_reset_8390(dev);
613 NS8390_init(dev,1);
614 break;
617 outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
618 ei_status.dmaing &= ~0x01;
619 return;
623 #ifdef MODULE
624 #define MAX_NE_CARDS 4 /* Max number of NE cards per module */
625 #define NAMELEN 8 /* # of chars for storing dev->name */
626 static char namelist[NAMELEN * MAX_NE_CARDS] = { 0, };
627 static struct net_device dev_ne[MAX_NE_CARDS] = {
629 NULL, /* assign a chunk of namelist[] below */
630 0, 0, 0, 0,
631 0, 0,
632 0, 0, 0, NULL, NULL
636 static int io[MAX_NE_CARDS] = { 0, };
637 static int irq[MAX_NE_CARDS] = { 0, };
638 static int bad[MAX_NE_CARDS] = { 0, }; /* 0xbad = bad sig or no reset ack */
640 #ifdef MODULE_PARM
641 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
642 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
643 MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
644 #endif
646 /* Module code fixed by David Weinehall */
648 int init_module(void)
650 int this_dev, found = 0;
652 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
653 struct net_device *dev = &dev_ne[this_dev];
654 dev->name = namelist+(NAMELEN*this_dev);
655 dev->irq = irq[this_dev];
656 dev->mem_end = bad[this_dev];
657 dev->base_addr = io[this_dev];
658 dev->init = ne2_probe;
659 if (register_netdev(dev) != 0) {
660 if (found != 0) return 0; /* Got at least one. */
662 printk(KERN_WARNING "ne2.c: No NE/2 card found.\n");
663 return -ENXIO;
665 found++;
667 return 0;
670 void cleanup_module(void)
672 int this_dev;
674 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
675 struct net_device *dev = &dev_ne[this_dev];
676 if (dev->priv != NULL) {
677 mca_mark_as_unused(ei_status.priv);
678 mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
679 kfree(dev->priv);
680 free_irq(dev->irq, dev);
681 release_region(dev->base_addr, NE_IO_EXTENT);
682 unregister_netdev(dev);
686 #endif /* MODULE */
689 * Local variables:
690 * compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c ne2.c"
691 * version-control: t
692 * kept-new-versions: 5
693 * End: