Bug Summary

File:obj-scan-build/../linux/src/drivers/net/ne.c
Location:line 231, column 3
Description:Function call argument is an uninitialized value

Annotated Source Code

1/* ne.c: A general non-shared-memory NS8390 ethernet driver for linux. */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU Public License, incorporated herein by reference.
10
11 The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
12 Center of Excellence in Space Data and Information Sciences
13 Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
14
15 This driver should work with many programmed-I/O 8390-based ethernet
16 boards. Currently it supports the NE1000, NE2000, many clones,
17 and some Cabletron products.
18
19 Changelog:
20
21 Paul Gortmaker : use ENISR_RDC to monitor Tx PIO uploads, made
22 sanity checks and bad clone support optional.
23 Paul Gortmaker : new reset code, reset card after probe at boot.
24 Paul Gortmaker : multiple card support for module users.
25 Paul Gortmaker : Support for PCI ne2k clones, similar to lance.c
26 Paul Gortmaker : Allow users with bad cards to avoid full probe.
27 Paul Gortmaker : PCI probe changes, more PCI cards supported.
28
29*/
30
31/* Routines for the NatSemi-based designs (NE[12]000). */
32
33static const char *version =
34 "ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
35
36
37#include <linux/module.h>
38#include <linux/config.h>
39#include <linux/kernel.h>
40#include <linux/sched.h>
41#include <linux/errno.h>
42#include <linux/pci.h>
43#include <linux/bios32.h>
44#include <asm/system.h>
45#include <asm/io.h>
46
47#include <linux/netdevice.h>
48#include <linux/etherdevice.h>
49#include "8390.h"
50
51/* Some defines that people can play with if so inclined. */
52
53/* Do we support clones that don't adhere to 14,15 of the SAprom ? */
54#define SUPPORT_NE_BAD_CLONES
55
56/* Do we perform extra sanity checks on stuff ? */
57/* #define NE_SANITY_CHECK */
58
59/* Do we implement the read before write bugfix ? */
60/* #define NE_RW_BUGFIX */
61
62/* Do we have a non std. amount of memory? (in units of 256 byte pages) */
63/* #define PACKETBUF_MEMSIZE 0x40 */
64
65#if defined(HAVE_DEVLIST) || !defined(MODULE)
66/* A zero-terminated list of I/O addresses to be probed. */
67static unsigned int netcard_portlist[] =
68{ 0x300, 0x280, 0x320, 0x340, 0x360, 0};
69#endif /* defined(HAVE_DEVLIST) || !defined(MODULE) */
70
71#ifdef CONFIG_PCI1
72/* Ack! People are making PCI ne2000 clones! Oh the horror, the horror... */
73static struct { unsigned short vendor, dev_id;}
74pci_clone_list[] = {
75 {PCI_VENDOR_ID_REALTEK0x10ec, PCI_DEVICE_ID_REALTEK_80290x8029},
76 {PCI_VENDOR_ID_WINBOND20x1050, PCI_DEVICE_ID_WINBOND2_89C9400x0940},
77 {PCI_VENDOR_ID_COMPEX0x11f6, PCI_DEVICE_ID_COMPEX_RL20000x1401},
78 {PCI_VENDOR_ID_KTI0x8e2e, PCI_DEVICE_ID_KTI_ET32P20x3000},
79 {PCI_VENDOR_ID_NETVIN0x4a14, PCI_DEVICE_ID_NETVIN_NV5000SC0x5000},
80 {PCI_VENDOR_ID_VIA0x1106, PCI_DEVICE_ID_VIA_82C9260x0926},
81 {0,}
82};
83#endif
84
85#ifdef SUPPORT_NE_BAD_CLONES
86/* A list of bad clones that we none-the-less recognize. */
87static struct { const char *name8, *name16; unsigned char SAprefix[4];}
88bad_clone_list[] = {
89 {"DE100", "DE200", {0x00, 0xDE, 0x01,}},
90 {"DE120", "DE220", {0x00, 0x80, 0xc8,}},
91 {"DFI1000", "DFI2000", {'D', 'F', 'I',}}, /* Original, eh? */
92 {"EtherNext UTP8", "EtherNext UTP16", {0x00, 0x00, 0x79}},
93 {"NE1000","NE2000-invalid", {0x00, 0x00, 0xd8}}, /* Ancient real NE1000. */
94 {"NN1000", "NN2000", {0x08, 0x03, 0x08}}, /* Outlaw no-name clone. */
95 {"4-DIM8","4-DIM16", {0x00,0x00,0x4d,}}, /* Outlaw 4-Dimension cards. */
96 {"Con-Intl_8", "Con-Intl_16", {0x00, 0x00, 0x24}}, /* Connect Int'nl */
97 {"ET-100","ET-200", {0x00, 0x45, 0x54}}, /* YANG and YA clone */
98 {"COMPEX","COMPEX16",{0x00,0x80,0x48}}, /* Broken ISA Compex cards */
99 {"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */
100 {"RealTek 8029", "RealTek 8029", {0x00, 0x3e, 0x4d}}, /* RealTek PCI cards */
101 {0,}
102};
103#endif
104
105/* ---- No user-serviceable parts below ---- */
106
107#define NE_BASE(dev->base_addr) (dev->base_addr)
108#define NE_CMD0x00 0x00
109#define NE_DATAPORT0x10 0x10 /* NatSemi-defined port window offset. */
110#define NE_RESET0x1f 0x1f /* Issue a read to reset, a write to clear. */
111#define NE_IO_EXTENT0x20 0x20
112
113#define NE1SM_START_PG0x20 0x20 /* First page of TX buffer */
114#define NE1SM_STOP_PG0x40 0x40 /* Last page +1 of RX ring */
115#define NESM_START_PG0x40 0x40 /* First page of TX buffer */
116#define NESM_STOP_PG0x80 0x80 /* Last page +1 of RX ring */
117
118/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */
119static unsigned char pci_irq_line = 0;
120
121int ne_probe(struct devicelinux_device *dev);
122#ifdef CONFIG_PCI1
123static int ne_probe_pci(struct devicelinux_device *dev);
124#endif
125static int ne_probe1(struct devicelinux_device *dev, int ioaddr);
126
127static int ne_open(struct devicelinux_device *dev);
128static int ne_close(struct devicelinux_device *dev);
129
130static void ne_reset_8390(struct devicelinux_device *dev);
131static void ne_get_8390_hdr(struct devicelinux_device *dev, struct e8390_pkt_hdr *hdr,
132 int ring_page);
133static void ne_block_input(struct devicelinux_device *dev, int count,
134 struct sk_buff *skb, int ring_offset);
135static void ne_block_output(struct devicelinux_device *dev, const int count,
136 const unsigned char *buf, const int start_page);
137
138
139/* Probe for various non-shared-memory ethercards.
140
141 NEx000-clone boards have a Station Address PROM (SAPROM) in the packet
142 buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of
143 the SAPROM, while other supposed NE2000 clones must be detected by their
144 SA prefix.
145
146 Reading the SAPROM from a word-wide card with the 8390 set in byte-wide
147 mode results in doubled values, which can be detected and compensated for.
148
149 The probe is also responsible for initializing the card and filling
150 in the 'dev' and 'ei_status' structures.
151
152 We use the minimum memory size for some ethercard product lines, iff we can't
153 distinguish models. You can increase the packet buffer size by setting
154 PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are:
155 E1010 starts at 0x100 and ends at 0x2000.
156 E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory")
157 E2010 starts at 0x100 and ends at 0x4000.
158 E2010-x starts at 0x100 and ends at 0xffff. */
159
160#ifdef HAVE_DEVLIST
161struct netdev_entry netcard_drv =
162{"ne", ne_probe1, NE_IO_EXTENT0x20, netcard_portlist};
163#else
164
165/* Note that this probe only picks up one card at a time, even for multiple
166 PCI ne2k cards. Use "ether=0,0,eth1" if you have a second PCI ne2k card.
167 This keeps things consistent regardless of the bus type of the card. */
168
169int ne_probe(struct devicelinux_device *dev)
170{
171#ifndef MODULE
172 int i;
173#endif /* MODULE */
174 int base_addr = dev ? dev->base_addr : 0;
1
Assuming 'dev' is null
2
'?' condition is false
175
176 /* First check any supplied i/o locations. User knows best. <cough> */
177 if (base_addr > 0x1ff) /* Check a single specified location. */
3
Taking false branch
178 return ne_probe1(dev, base_addr);
179 else if (base_addr != 0) /* Don't probe at all. */
4
Taking false branch
180 return ENXIO6;
181
182#ifdef CONFIG_PCI1
183 /* Then look for any installed PCI clones */
184 if (pcibios_present() && (ne_probe_pci(dev) == 0))
5
Calling 'ne_probe_pci'
185 return 0;
186#endif
187
188#ifndef MODULE
189 /* Last resort. The semi-risky ISA auto-probe. */
190 for (i = 0; netcard_portlist[i]; i++) {
191 int ioaddr = netcard_portlist[i];
192 if (check_region(ioaddr, NE_IO_EXTENT0x20))
193 continue;
194 if (ne_probe1(dev, ioaddr) == 0)
195 return 0;
196 }
197#endif
198
199 return ENODEV19;
200}
201#endif
202
203#ifdef CONFIG_PCI1
204static int ne_probe_pci(struct devicelinux_device *dev)
205{
206 int i;
207
208 for (i = 0; pci_clone_list[i].vendor != 0; i++) {
6
Loop condition is true. Entering loop body
209 unsigned char pci_bus, pci_device_fn;
210 unsigned int pci_ioaddr;
7
Variable 'pci_ioaddr' declared without an initial value
211 u16 pci_command, new_command;
212 int pci_index;
213
214 for (pci_index = 0; pci_index < 8; pci_index++) {
8
Loop condition is true. Entering loop body
215 if (pcibios_find_device (pci_clone_list[i].vendor,
9
Taking true branch
216 pci_clone_list[i].dev_id, pci_index,
217 &pci_bus, &pci_device_fn) != 0)
218 break; /* No more of these type of cards */
10
Execution continues on line 230
219 pcibios_read_config_dword(pci_bus, pci_device_fn,
220 PCI_BASE_ADDRESS_00x10, &pci_ioaddr);
221 /* Strip the I/O address out of the returned value */
222 pci_ioaddr &= PCI_BASE_ADDRESS_IO_MASK(~0x03);
223 /* Avoid already found cards from previous calls */
224 if (check_region(pci_ioaddr, NE_IO_EXTENT0x20))
225 continue;
226 pcibios_read_config_byte(pci_bus, pci_device_fn,
227 PCI_INTERRUPT_LINE0x3c, &pci_irq_line);
228 break; /* Beauty -- got a valid card. */
229 }
230 if (pci_irq_line == 0) continue; /* Try next PCI ID */
11
Assuming 'pci_irq_line' is not equal to 0
12
Taking false branch
231 printk("ne.c: PCI BIOS reports NE 2000 clone at i/o %#x, irq %d.\n",
13
Function call argument is an uninitialized value
232 pci_ioaddr, pci_irq_line);
233
234 pcibios_read_config_word(pci_bus, pci_device_fn,
235 PCI_COMMAND0x04, &pci_command);
236
237 /* Activate the card: fix for brain-damaged Win98 BIOSes. */
238 new_command = pci_command | PCI_COMMAND_IO0x1;
239 if (pci_command != new_command) {
240 printk(KERN_INFO"<6>" " The PCI BIOS has not enabled this"
241 " NE2k clone! Updating PCI command %4.4x->%4.4x.\n",
242 pci_command, new_command);
243 pcibios_write_config_word(pci_bus, pci_device_fn,
244 PCI_COMMAND0x04, new_command);
245 }
246
247 if (ne_probe1(dev, pci_ioaddr) != 0) { /* Shouldn't happen. */
248 printk(KERN_ERR"<3>" "ne.c: Probe of PCI card at %#x failed.\n", pci_ioaddr);
249 pci_irq_line = 0;
250 return -ENXIO6;
251 }
252 pci_irq_line = 0;
253 return 0;
254 }
255 return -ENODEV19;
256}
257#endif /* CONFIG_PCI */
258
259static int ne_probe1(struct devicelinux_device *dev, int ioaddr)
260{
261 int i;
262 unsigned char SA_prom[32];
263 int wordlength = 2;
264 const char *name = NULL((void *) 0);
265 int start_page, stop_page;
266 int neX000, ctron, bad_card;
267 int reg0 = inb_p(ioaddr)((__builtin_constant_p((ioaddr)) && (ioaddr) < 256
) ? __inbc_p(ioaddr) : __inb_p(ioaddr))
;
268 static unsigned version_printed = 0;
269
270 if (reg0 == 0xFF)
271 return ENODEV19;
272
273 /* Do a preliminary verification that we have a 8390. */
274 { int regd;
275 outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD)((__builtin_constant_p((ioaddr + 0x00)) && (ioaddr + 0x00
) < 256) ? __outbc_p((0x20 +0x40 +0x01),(ioaddr + 0x00)) :
__outb_p((0x20 +0x40 +0x01),(ioaddr + 0x00)))
;
276 regd = inb_p(ioaddr + 0x0d)((__builtin_constant_p((ioaddr + 0x0d)) && (ioaddr + 0x0d
) < 256) ? __inbc_p(ioaddr + 0x0d) : __inb_p(ioaddr + 0x0d
))
;
277 outb_p(0xff, ioaddr + 0x0d)((__builtin_constant_p((ioaddr + 0x0d)) && (ioaddr + 0x0d
) < 256) ? __outbc_p((0xff),(ioaddr + 0x0d)) : __outb_p((0xff
),(ioaddr + 0x0d)))
;
278 outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD)((__builtin_constant_p((ioaddr + 0x00)) && (ioaddr + 0x00
) < 256) ? __outbc_p((0x20 +0x00),(ioaddr + 0x00)) : __outb_p
((0x20 +0x00),(ioaddr + 0x00)))
;
279 inb_p(ioaddr + EN0_COUNTER0)((__builtin_constant_p((ioaddr + 0x0d)) && (ioaddr + 0x0d
) < 256) ? __inbc_p(ioaddr + 0x0d) : __inb_p(ioaddr + 0x0d
))
; /* Clear the counter by reading. */
280 if (inb_p(ioaddr + EN0_COUNTER0)((__builtin_constant_p((ioaddr + 0x0d)) && (ioaddr + 0x0d
) < 256) ? __inbc_p(ioaddr + 0x0d) : __inb_p(ioaddr + 0x0d
))
!= 0) {
281 outb_p(reg0, ioaddr)((__builtin_constant_p((ioaddr)) && (ioaddr) < 256
) ? __outbc_p((reg0),(ioaddr)) : __outb_p((reg0),(ioaddr)))
;
282 outb_p(regd, ioaddr + 0x0d)((__builtin_constant_p((ioaddr + 0x0d)) && (ioaddr + 0x0d
) < 256) ? __outbc_p((regd),(ioaddr + 0x0d)) : __outb_p((regd
),(ioaddr + 0x0d)))
; /* Restore the old values. */
283 return ENODEV19;
284 }
285 }
286
287 /* We should have a "dev" from Space.c or the static module table. */
288 if (dev == NULL((void *) 0)) {
289 printk(KERN_ERR"<3>" "ne.c: Passed a NULL device.\n");
290 dev = init_etherdev(0, 0);
291 }
292
293 if (ei_debug && version_printed++ == 0)
294 printk(version);
295
296 printk("NE*000 ethercard probe at %#3x:", ioaddr);
297
298 /* A user with a poor card that fails to ack the reset, or that
299 does not have a valid 0x57,0x57 signature can still use this
300 without having to recompile. Specifying an i/o address along
301 with an otherwise unused dev->mem_end value of "0xBAD" will
302 cause the driver to skip these parts of the probe. */
303
304 bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
305
306 /* Reset card. Who knows what dain-bramaged state it was left in. */
307 { unsigned long reset_start_time = jiffies;
308
309 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
310 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET)((__builtin_constant_p((ioaddr + 0x1f)) && (ioaddr + 0x1f
) < 256) ? __outbc((((__builtin_constant_p((ioaddr + 0x1f)
) && (ioaddr + 0x1f) < 256) ? __inbc(ioaddr + 0x1f
) : __inb(ioaddr + 0x1f))),(ioaddr + 0x1f)) : __outb((((__builtin_constant_p
((ioaddr + 0x1f)) && (ioaddr + 0x1f) < 256) ? __inbc
(ioaddr + 0x1f) : __inb(ioaddr + 0x1f))),(ioaddr + 0x1f)))
;
311
312 while ((inb_p(ioaddr + EN0_ISR)((__builtin_constant_p((ioaddr + 0x07)) && (ioaddr + 0x07
) < 256) ? __inbc_p(ioaddr + 0x07) : __inb_p(ioaddr + 0x07
))
& ENISR_RESET0x80) == 0)
313 if (jiffies - reset_start_time > 2*HZ100/100) {
314 if (bad_card) {
315 printk(" (warning: no reset ack)");
316 break;
317 } else {
318 printk(" not found (no reset ack).\n");
319 return ENODEV19;
320 }
321 }
322
323 outb_p(0xff, ioaddr + EN0_ISR)((__builtin_constant_p((ioaddr + 0x07)) && (ioaddr + 0x07
) < 256) ? __outbc_p((0xff),(ioaddr + 0x07)) : __outb_p((0xff
),(ioaddr + 0x07)))
; /* Ack all intr. */
324 }
325
326 /* Read the 16 bytes of station address PROM.
327 We must first initialize registers, similar to NS8390_init(eifdev, 0).
328 We can't reliably read the SAPROM address without this.
329 (I learned the hard way!). */
330 {
331 struct {unsigned char value, offset; } program_seq[] = {
332 {E8390_NODMA0x20+E8390_PAGE00x00+E8390_STOP0x01, E8390_CMD0x00}, /* Select page 0*/
333 {0x48, EN0_DCFG0x0e}, /* Set byte-wide (0x48) access. */
334 {0x00, EN0_RCNTLO0x0a}, /* Clear the count regs. */
335 {0x00, EN0_RCNTHI0x0b},
336 {0x00, EN0_IMR0x0f}, /* Mask completion irq. */
337 {0xFF, EN0_ISR0x07},
338 {E8390_RXOFF0x20, EN0_RXCR0x0c}, /* 0x20 Set to monitor */
339 {E8390_TXOFF0x02, EN0_TXCR0x0d}, /* 0x02 and loopback mode. */
340 {32, EN0_RCNTLO0x0a},
341 {0x00, EN0_RCNTHI0x0b},
342 {0x00, EN0_RSARLO0x08}, /* DMA starting at 0x0000. */
343 {0x00, EN0_RSARHI0x09},
344 {E8390_RREAD0x08+E8390_START0x02, E8390_CMD0x00},
345 };
346 for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
347 outb_p(program_seq[i].value, ioaddr + program_seq[i].offset)((__builtin_constant_p((ioaddr + program_seq[i].offset)) &&
(ioaddr + program_seq[i].offset) < 256) ? __outbc_p((program_seq
[i].value),(ioaddr + program_seq[i].offset)) : __outb_p((program_seq
[i].value),(ioaddr + program_seq[i].offset)))
;
348
349 }
350 for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {
351 SA_prom[i] = inb(ioaddr + NE_DATAPORT)((__builtin_constant_p((ioaddr + 0x10)) && (ioaddr + 0x10
) < 256) ? __inbc(ioaddr + 0x10) : __inb(ioaddr + 0x10))
;
352 SA_prom[i+1] = inb(ioaddr + NE_DATAPORT)((__builtin_constant_p((ioaddr + 0x10)) && (ioaddr + 0x10
) < 256) ? __inbc(ioaddr + 0x10) : __inb(ioaddr + 0x10))
;
353 if (SA_prom[i] != SA_prom[i+1])
354 wordlength = 1;
355 }
356
357 /* At this point, wordlength *only* tells us if the SA_prom is doubled
358 up or not because some broken PCI cards don't respect the byte-wide
359 request in program_seq above, and hence don't have doubled up values.
360 These broken cards would otherwise be detected as an ne1000. */
361
362 if (wordlength == 2)
363 for (i = 0; i < 16; i++)
364 SA_prom[i] = SA_prom[i+i];
365
366 if (pci_irq_line || ioaddr >= 0x400)
367 wordlength = 2; /* Catch broken PCI cards mentioned above. */
368
369 if (wordlength == 2) {
370 /* We must set the 8390 for word mode. */
371 outb_p(0x49, ioaddr + EN0_DCFG)((__builtin_constant_p((ioaddr + 0x0e)) && (ioaddr + 0x0e
) < 256) ? __outbc_p((0x49),(ioaddr + 0x0e)) : __outb_p((0x49
),(ioaddr + 0x0e)))
;
372 start_page = NESM_START_PG0x40;
373 stop_page = NESM_STOP_PG0x80;
374 } else {
375 start_page = NE1SM_START_PG0x20;
376 stop_page = NE1SM_STOP_PG0x40;
377 }
378
379 neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
380 ctron = (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);
381
382 /* Set up the rest of the parameters. */
383 if (neX000 || bad_card) {
384 name = (wordlength == 2) ? "NE2000" : "NE1000";
385 } else if (ctron) {
386 name = (wordlength == 2) ? "Ctron-8" : "Ctron-16";
387 start_page = 0x01;
388 stop_page = (wordlength == 2) ? 0x40 : 0x20;
389 } else {
390#ifdef SUPPORT_NE_BAD_CLONES
391 /* Ack! Well, there might be a *bad* NE*000 clone there.
392 Check for total bogus addresses. */
393 for (i = 0; bad_clone_list[i].name8; i++) {
394 if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&
395 SA_prom[1] == bad_clone_list[i].SAprefix[1] &&
396 SA_prom[2] == bad_clone_list[i].SAprefix[2]) {
397 if (wordlength == 2) {
398 name = bad_clone_list[i].name16;
399 } else {
400 name = bad_clone_list[i].name8;
401 }
402 break;
403 }
404 }
405 if (bad_clone_list[i].name8 == NULL((void *) 0)) {
406 printk(" not found (invalid signature %2.2x %2.2x).\n",
407 SA_prom[14], SA_prom[15]);
408 return ENXIO6;
409 }
410#else
411 printk(" not found.\n");
412 return ENXIO6;
413#endif
414
415 }
416
417 if (pci_irq_line)
418 dev->irq = pci_irq_line;
419
420 if (dev->irq < 2) {
421 autoirq_setup(0);
422 outb_p(0x50, ioaddr + EN0_IMR)((__builtin_constant_p((ioaddr + 0x0f)) && (ioaddr + 0x0f
) < 256) ? __outbc_p((0x50),(ioaddr + 0x0f)) : __outb_p((0x50
),(ioaddr + 0x0f)))
; /* Enable one interrupt. */
423 outb_p(0x00, ioaddr + EN0_RCNTLO)((__builtin_constant_p((ioaddr + 0x0a)) && (ioaddr + 0x0a
) < 256) ? __outbc_p((0x00),(ioaddr + 0x0a)) : __outb_p((0x00
),(ioaddr + 0x0a)))
;
424 outb_p(0x00, ioaddr + EN0_RCNTHI)((__builtin_constant_p((ioaddr + 0x0b)) && (ioaddr + 0x0b
) < 256) ? __outbc_p((0x00),(ioaddr + 0x0b)) : __outb_p((0x00
),(ioaddr + 0x0b)))
;
425 outb_p(E8390_RREAD+E8390_START, ioaddr)((__builtin_constant_p((ioaddr)) && (ioaddr) < 256
) ? __outbc_p((0x08 +0x02),(ioaddr)) : __outb_p((0x08 +0x02),
(ioaddr)))
; /* Trigger it... */
426 outb_p(0x00, ioaddr + EN0_IMR)((__builtin_constant_p((ioaddr + 0x0f)) && (ioaddr + 0x0f
) < 256) ? __outbc_p((0x00),(ioaddr + 0x0f)) : __outb_p((0x00
),(ioaddr + 0x0f)))
; /* Mask it again. */
427 dev->irq = autoirq_report(0);
428 if (ei_debug > 2)
429 printk(" autoirq is %d\n", dev->irq);
430 } else if (dev->irq == 2)
431 /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
432 or don't know which one to set. */
433 dev->irq = 9;
434
435 if (! dev->irq) {
436 printk(" failed to detect IRQ line.\n");
437 return EAGAIN11;
438 }
439
440 /* Snarf the interrupt now. There's no point in waiting since we cannot
441 share (with ISA cards) and the board will usually be enabled. */
442 {
443 int irqval = request_irq(dev->irq, ei_interrupt,
444 pci_irq_line ? SA_SHIRQ0x04000000 : 0, name, dev);
445 if (irqval) {
446 printk (" unable to get IRQ %d (irqval=%d).\n", dev->irq, irqval);
447 return EAGAIN11;
448 }
449 }
450
451 dev->base_addr = ioaddr;
452
453 /* Allocate dev->priv and fill in 8390 specific dev fields. */
454 if (ethdev_init(dev)) {
455 printk (" unable to get memory for dev->priv.\n");
456 free_irq(dev->irq, NULL((void *) 0));
457 return -ENOMEM12;
458 }
459
460 request_region(ioaddr, NE_IO_EXTENT0x20, name);
461
462 for(i = 0; i < ETHER_ADDR_LEN6; i++) {
463 printk(" %2.2x", SA_prom[i]);
464 dev->dev_addr[i] = SA_prom[i];
465 }
466
467 printk("\n%s: %s found at %#x, using IRQ %d.\n",
468 dev->name, name, ioaddr, dev->irq);
469
470 ei_status(*(struct ei_device *)(dev->priv)).name = name;
471 ei_status(*(struct ei_device *)(dev->priv)).tx_start_page = start_page;
472 ei_status(*(struct ei_device *)(dev->priv)).stop_page = stop_page;
473 ei_status(*(struct ei_device *)(dev->priv)).word16 = (wordlength == 2);
474
475 ei_status(*(struct ei_device *)(dev->priv)).rx_start_page = start_page + TX_PAGES12;
476#ifdef PACKETBUF_MEMSIZE
477 /* Allow the packet buffer size to be overridden by know-it-alls. */
478 ei_status(*(struct ei_device *)(dev->priv)).stop_page = ei_status(*(struct ei_device *)(dev->priv)).tx_start_page + PACKETBUF_MEMSIZE;
479#endif
480
481 ei_status(*(struct ei_device *)(dev->priv)).reset_8390 = &ne_reset_8390;
482 ei_status(*(struct ei_device *)(dev->priv)).block_input = &ne_block_input;
483 ei_status(*(struct ei_device *)(dev->priv)).block_output = &ne_block_output;
484 ei_status(*(struct ei_device *)(dev->priv)).get_8390_hdr = &ne_get_8390_hdr;
485 dev->open = &ne_open;
486 dev->stop = &ne_close;
487 NS8390_init(dev, 0);
488 return 0;
489}
490
491static int
492ne_open(struct devicelinux_device *dev)
493{
494 ei_open(dev);
495 MOD_INC_USE_COUNTdo { } while (0);
496 return 0;
497}
498
499static int
500ne_close(struct devicelinux_device *dev)
501{
502 if (ei_debug > 1)
503 printk("%s: Shutting down ethercard.\n", dev->name);
504 ei_close(dev);
505 MOD_DEC_USE_COUNTdo { } while (0);
506 return 0;
507}
508
509/* Hard reset the card. This used to pause for the same period that a
510 8390 reset command required, but that shouldn't be necessary. */
511static void
512ne_reset_8390(struct devicelinux_device *dev)
513{
514 unsigned long reset_start_time = jiffies;
515
516 if (ei_debug > 1) printk("resetting the 8390 t=%ld...", jiffies);
517
518 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
519 outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET)((__builtin_constant_p(((dev->base_addr) + 0x1f)) &&
((dev->base_addr) + 0x1f) < 256) ? __outbc((((__builtin_constant_p
(((dev->base_addr) + 0x1f)) && ((dev->base_addr
) + 0x1f) < 256) ? __inbc((dev->base_addr) + 0x1f) : __inb
((dev->base_addr) + 0x1f))),((dev->base_addr) + 0x1f)) :
__outb((((__builtin_constant_p(((dev->base_addr) + 0x1f))
&& ((dev->base_addr) + 0x1f) < 256) ? __inbc((
dev->base_addr) + 0x1f) : __inb((dev->base_addr) + 0x1f
))),((dev->base_addr) + 0x1f)))
;
520
521 ei_status(*(struct ei_device *)(dev->priv)).txing = 0;
522 ei_status(*(struct ei_device *)(dev->priv)).dmaing = 0;
523
524 /* This check _should_not_ be necessary, omit eventually. */
525 while ((inb_p(NE_BASE+EN0_ISR)((__builtin_constant_p(((dev->base_addr)+0x07)) &&
((dev->base_addr)+0x07) < 256) ? __inbc_p((dev->base_addr
)+0x07) : __inb_p((dev->base_addr)+0x07))
& ENISR_RESET0x80) == 0)
526 if (jiffies - reset_start_time > 2*HZ100/100) {
527 printk("%s: ne_reset_8390() did not complete.\n", dev->name);
528 break;
529 }
530 outb_p(ENISR_RESET, NE_BASE + EN0_ISR)((__builtin_constant_p(((dev->base_addr) + 0x07)) &&
((dev->base_addr) + 0x07) < 256) ? __outbc_p((0x80),((
dev->base_addr) + 0x07)) : __outb_p((0x80),((dev->base_addr
) + 0x07)))
; /* Ack intr. */
531}
532
533/* Grab the 8390 specific header. Similar to the block_input routine, but
534 we don't need to be concerned with ring wrap as the header will be at
535 the start of a page, so we optimize accordingly. */
536
537static void
538ne_get_8390_hdr(struct devicelinux_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
539{
540
541 int nic_base = dev->base_addr;
542
543 /* This *shouldn't* happen. If it does, it's the last thing you'll see */
544 if (ei_status(*(struct ei_device *)(dev->priv)).dmaing) {
545 printk("%s: DMAing conflict in ne_get_8390_hdr "
546 "[DMAstat:%d][irqlock:%d][intr:%d].\n",
547 dev->name, ei_status(*(struct ei_device *)(dev->priv)).dmaing, ei_status(*(struct ei_device *)(dev->priv)).irqlock,
548 dev->interrupt);
549 return;
550 }
551
552 ei_status(*(struct ei_device *)(dev->priv)).dmaing |= 0x01;
553 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD)((__builtin_constant_p((nic_base+ 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x20 +0x00 +0x02),(nic_base+ 0x00
)) : __outb_p((0x20 +0x00 +0x02),(nic_base+ 0x00)))
;
554 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO)((__builtin_constant_p((nic_base + 0x0a)) && (nic_base
+ 0x0a) < 256) ? __outbc_p((sizeof(struct e8390_pkt_hdr))
,(nic_base + 0x0a)) : __outb_p((sizeof(struct e8390_pkt_hdr))
,(nic_base + 0x0a)))
;
555 outb_p(0, nic_base + EN0_RCNTHI)((__builtin_constant_p((nic_base + 0x0b)) && (nic_base
+ 0x0b) < 256) ? __outbc_p((0),(nic_base + 0x0b)) : __outb_p
((0),(nic_base + 0x0b)))
;
556 outb_p(0, nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __outbc_p((0),(nic_base + 0x08)) : __outb_p
((0),(nic_base + 0x08)))
; /* On page boundary */
557 outb_p(ring_page, nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __outbc_p((ring_page),(nic_base + 0x09))
: __outb_p((ring_page),(nic_base + 0x09)))
;
558 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD)((__builtin_constant_p((nic_base + 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x08 +0x02),(nic_base + 0x00)
) : __outb_p((0x08 +0x02),(nic_base + 0x00)))
;
559
560 if (ei_status(*(struct ei_device *)(dev->priv)).word16)
561 insw(NE_BASE(dev->base_addr) + NE_DATAPORT0x10, hdr, sizeof(struct e8390_pkt_hdr)>>1);
562 else
563 insb(NE_BASE(dev->base_addr) + NE_DATAPORT0x10, hdr, sizeof(struct e8390_pkt_hdr));
564
565 outb_p(ENISR_RDC, nic_base + EN0_ISR)((__builtin_constant_p((nic_base + 0x07)) && (nic_base
+ 0x07) < 256) ? __outbc_p((0x40),(nic_base + 0x07)) : __outb_p
((0x40),(nic_base + 0x07)))
; /* Ack intr. */
566 ei_status(*(struct ei_device *)(dev->priv)).dmaing &= ~0x01;
567}
568
569/* Block input and output, similar to the Crynwr packet driver. If you
570 are porting to a new ethercard, look at the packet driver source for hints.
571 The NEx000 doesn't share the on-board packet memory -- you have to put
572 the packet out through the "remote DMA" dataport using outb. */
573
574static void
575ne_block_input(struct devicelinux_device *dev, int count, struct sk_buff *skb, int ring_offset)
576{
577#ifdef NE_SANITY_CHECK
578 int xfer_count = count;
579#endif
580 int nic_base = dev->base_addr;
581 char *buf = skb->data;
582
583 /* This *shouldn't* happen. If it does, it's the last thing you'll see */
584 if (ei_status(*(struct ei_device *)(dev->priv)).dmaing) {
585 printk("%s: DMAing conflict in ne_block_input "
586 "[DMAstat:%d][irqlock:%d][intr:%d].\n",
587 dev->name, ei_status(*(struct ei_device *)(dev->priv)).dmaing, ei_status(*(struct ei_device *)(dev->priv)).irqlock,
588 dev->interrupt);
589 return;
590 }
591 ei_status(*(struct ei_device *)(dev->priv)).dmaing |= 0x01;
592 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD)((__builtin_constant_p((nic_base+ 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x20 +0x00 +0x02),(nic_base+ 0x00
)) : __outb_p((0x20 +0x00 +0x02),(nic_base+ 0x00)))
;
593 outb_p(count & 0xff, nic_base + EN0_RCNTLO)((__builtin_constant_p((nic_base + 0x0a)) && (nic_base
+ 0x0a) < 256) ? __outbc_p((count & 0xff),(nic_base +
0x0a)) : __outb_p((count & 0xff),(nic_base + 0x0a)))
;
594 outb_p(count >> 8, nic_base + EN0_RCNTHI)((__builtin_constant_p((nic_base + 0x0b)) && (nic_base
+ 0x0b) < 256) ? __outbc_p((count >> 8),(nic_base +
0x0b)) : __outb_p((count >> 8),(nic_base + 0x0b)))
;
595 outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __outbc_p((ring_offset & 0xff),(nic_base
+ 0x08)) : __outb_p((ring_offset & 0xff),(nic_base + 0x08
)))
;
596 outb_p(ring_offset >> 8, nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __outbc_p((ring_offset >> 8),(nic_base
+ 0x09)) : __outb_p((ring_offset >> 8),(nic_base + 0x09
)))
;
597 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD)((__builtin_constant_p((nic_base + 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x08 +0x02),(nic_base + 0x00)
) : __outb_p((0x08 +0x02),(nic_base + 0x00)))
;
598 if (ei_status(*(struct ei_device *)(dev->priv)).word16) {
599 insw(NE_BASE(dev->base_addr) + NE_DATAPORT0x10,buf,count>>1);
600 if (count & 0x01) {
601 buf[count-1] = inb(NE_BASE + NE_DATAPORT)((__builtin_constant_p(((dev->base_addr) + 0x10)) &&
((dev->base_addr) + 0x10) < 256) ? __inbc((dev->base_addr
) + 0x10) : __inb((dev->base_addr) + 0x10))
;
602#ifdef NE_SANITY_CHECK
603 xfer_count++;
604#endif
605 }
606 } else {
607 insb(NE_BASE(dev->base_addr) + NE_DATAPORT0x10, buf, count);
608 }
609
610#ifdef NE_SANITY_CHECK
611 /* This was for the ALPHA version only, but enough people have
612 been encountering problems so it is still here. If you see
613 this message you either 1) have a slightly incompatible clone
614 or 2) have noise/speed problems with your bus. */
615 if (ei_debug > 1) { /* DMA termination address check... */
616 int addr, tries = 20;
617 do {
618 /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
619 -- it's broken for Rx on some cards! */
620 int high = inb_p(nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __inbc_p(nic_base + 0x09) : __inb_p(nic_base
+ 0x09))
;
621 int low = inb_p(nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __inbc_p(nic_base + 0x08) : __inb_p(nic_base
+ 0x08))
;
622 addr = (high << 8) + low;
623 if (((ring_offset + xfer_count) & 0xff) == low)
624 break;
625 } while (--tries > 0);
626 if (tries <= 0)
627 printk("%s: RX transfer address mismatch,"
628 "%#4.4x (expected) vs. %#4.4x (actual).\n",
629 dev->name, ring_offset + xfer_count, addr);
630 }
631#endif
632 outb_p(ENISR_RDC, nic_base + EN0_ISR)((__builtin_constant_p((nic_base + 0x07)) && (nic_base
+ 0x07) < 256) ? __outbc_p((0x40),(nic_base + 0x07)) : __outb_p
((0x40),(nic_base + 0x07)))
; /* Ack intr. */
633 ei_status(*(struct ei_device *)(dev->priv)).dmaing &= ~0x01;
634}
635
636static void
637ne_block_output(struct devicelinux_device *dev, int count,
638 const unsigned char *buf, const int start_page)
639{
640 int nic_base = NE_BASE(dev->base_addr);
641 unsigned long dma_start;
642#ifdef NE_SANITY_CHECK
643 int retries = 0;
644#endif
645
646 /* Round the count up for word writes. Do we need to do this?
647 What effect will an odd byte count have on the 8390?
648 I should check someday. */
649 if (ei_status(*(struct ei_device *)(dev->priv)).word16 && (count & 0x01))
650 count++;
651
652 /* This *shouldn't* happen. If it does, it's the last thing you'll see */
653 if (ei_status(*(struct ei_device *)(dev->priv)).dmaing) {
654 printk("%s: DMAing conflict in ne_block_output."
655 "[DMAstat:%d][irqlock:%d][intr:%d]\n",
656 dev->name, ei_status(*(struct ei_device *)(dev->priv)).dmaing, ei_status(*(struct ei_device *)(dev->priv)).irqlock,
657 dev->interrupt);
658 return;
659 }
660 ei_status(*(struct ei_device *)(dev->priv)).dmaing |= 0x01;
661 /* We should already be in page 0, but to be safe... */
662 outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD)((__builtin_constant_p((nic_base + 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x00 +0x02 +0x20),(nic_base +
0x00)) : __outb_p((0x00 +0x02 +0x20),(nic_base + 0x00)))
;
663
664#ifdef NE_SANITY_CHECK
665 retry:
666#endif
667
668#ifdef NE8390_RW_BUGFIX
669 /* Handle the read-before-write bug the same way as the
670 Crynwr packet driver -- the NatSemi method doesn't work.
671 Actually this doesn't always work either, but if you have
672 problems with your NEx000 this is better than nothing! */
673 outb_p(0x42, nic_base + EN0_RCNTLO)((__builtin_constant_p((nic_base + 0x0a)) && (nic_base
+ 0x0a) < 256) ? __outbc_p((0x42),(nic_base + 0x0a)) : __outb_p
((0x42),(nic_base + 0x0a)))
;
674 outb_p(0x00, nic_base + EN0_RCNTHI)((__builtin_constant_p((nic_base + 0x0b)) && (nic_base
+ 0x0b) < 256) ? __outbc_p((0x00),(nic_base + 0x0b)) : __outb_p
((0x00),(nic_base + 0x0b)))
;
675 outb_p(0x42, nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __outbc_p((0x42),(nic_base + 0x08)) : __outb_p
((0x42),(nic_base + 0x08)))
;
676 outb_p(0x00, nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __outbc_p((0x00),(nic_base + 0x09)) : __outb_p
((0x00),(nic_base + 0x09)))
;
677 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD)((__builtin_constant_p((nic_base + 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x08 +0x02),(nic_base + 0x00)
) : __outb_p((0x08 +0x02),(nic_base + 0x00)))
;
678 /* Make certain that the dummy read has occurred. */
679 SLOW_DOWN_IO__asm__ __volatile__("outb %al,$0x80");
680 SLOW_DOWN_IO__asm__ __volatile__("outb %al,$0x80");
681 SLOW_DOWN_IO__asm__ __volatile__("outb %al,$0x80");
682#endif
683
684 outb_p(ENISR_RDC, nic_base + EN0_ISR)((__builtin_constant_p((nic_base + 0x07)) && (nic_base
+ 0x07) < 256) ? __outbc_p((0x40),(nic_base + 0x07)) : __outb_p
((0x40),(nic_base + 0x07)))
;
685
686 /* Now the normal output. */
687 outb_p(count & 0xff, nic_base + EN0_RCNTLO)((__builtin_constant_p((nic_base + 0x0a)) && (nic_base
+ 0x0a) < 256) ? __outbc_p((count & 0xff),(nic_base +
0x0a)) : __outb_p((count & 0xff),(nic_base + 0x0a)))
;
688 outb_p(count >> 8, nic_base + EN0_RCNTHI)((__builtin_constant_p((nic_base + 0x0b)) && (nic_base
+ 0x0b) < 256) ? __outbc_p((count >> 8),(nic_base +
0x0b)) : __outb_p((count >> 8),(nic_base + 0x0b)))
;
689 outb_p(0x00, nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __outbc_p((0x00),(nic_base + 0x08)) : __outb_p
((0x00),(nic_base + 0x08)))
;
690 outb_p(start_page, nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __outbc_p((start_page),(nic_base + 0x09)
) : __outb_p((start_page),(nic_base + 0x09)))
;
691
692 outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD)((__builtin_constant_p((nic_base + 0x00)) && (nic_base
+ 0x00) < 256) ? __outbc_p((0x10 +0x02),(nic_base + 0x00)
) : __outb_p((0x10 +0x02),(nic_base + 0x00)))
;
693 if (ei_status(*(struct ei_device *)(dev->priv)).word16) {
694 outsw(NE_BASE(dev->base_addr) + NE_DATAPORT0x10, buf, count>>1);
695 } else {
696 outsb(NE_BASE(dev->base_addr) + NE_DATAPORT0x10, buf, count);
697 }
698
699 dma_start = jiffies;
700
701#ifdef NE_SANITY_CHECK
702 /* This was for the ALPHA version only, but enough people have
703 been encountering problems so it is still here. */
704 if (ei_debug > 1) { /* DMA termination address check... */
705 int addr, tries = 20;
706 do {
707 int high = inb_p(nic_base + EN0_RSARHI)((__builtin_constant_p((nic_base + 0x09)) && (nic_base
+ 0x09) < 256) ? __inbc_p(nic_base + 0x09) : __inb_p(nic_base
+ 0x09))
;
708 int low = inb_p(nic_base + EN0_RSARLO)((__builtin_constant_p((nic_base + 0x08)) && (nic_base
+ 0x08) < 256) ? __inbc_p(nic_base + 0x08) : __inb_p(nic_base
+ 0x08))
;
709 addr = (high << 8) + low;
710 if ((start_page << 8) + count == addr)
711 break;
712 } while (--tries > 0);
713 if (tries <= 0) {
714 printk("%s: Tx packet transfer address mismatch,"
715 "%#4.4x (expected) vs. %#4.4x (actual).\n",
716 dev->name, (start_page << 8) + count, addr);
717 if (retries++ == 0)
718 goto retry;
719 }
720 }
721#endif
722
723 while ((inb_p(nic_base + EN0_ISR)((__builtin_constant_p((nic_base + 0x07)) && (nic_base
+ 0x07) < 256) ? __inbc_p(nic_base + 0x07) : __inb_p(nic_base
+ 0x07))
& ENISR_RDC0x40) == 0)
724 if (jiffies - dma_start > 2*HZ100/100) { /* 20ms */
725 printk("%s: timeout waiting for Tx RDC.\n", dev->name);
726 ne_reset_8390(dev);
727 NS8390_init(dev,1);
728 break;
729 }
730
731 outb_p(ENISR_RDC, nic_base + EN0_ISR)((__builtin_constant_p((nic_base + 0x07)) && (nic_base
+ 0x07) < 256) ? __outbc_p((0x40),(nic_base + 0x07)) : __outb_p
((0x40),(nic_base + 0x07)))
; /* Ack intr. */
732 ei_status(*(struct ei_device *)(dev->priv)).dmaing &= ~0x01;
733 return;
734}
735
736
737#ifdef MODULE
738#define MAX_NE_CARDS 4 /* Max number of NE cards per module */
739#define NAMELEN 8 /* # of chars for storing dev->name */
740static char namelist[NAMELEN * MAX_NE_CARDS] = { 0, };
741static struct devicelinux_device dev_ne[MAX_NE_CARDS] = {
742 {
743 NULL((void *) 0), /* assign a chunk of namelist[] below */
744 0, 0, 0, 0,
745 0, 0,
746 0, 0, 0, NULL((void *) 0), NULL((void *) 0)
747 },
748};
749
750static int io[MAX_NE_CARDS] = { 0, };
751static int irq[MAX_NE_CARDS] = { 0, };
752static int bad[MAX_NE_CARDS] = { 0, };
753
754/* This is set up so that no autoprobe takes place. We can't guarantee
755that the ne2k probe is the last 8390 based probe to take place (as it
756is at boot) and so the probe will get confused by any other 8390 cards.
757ISA device autoprobes on a running machine are not recommended anyway. */
758
759int
760init_module(void)
761{
762 int this_dev, found = 0;
763
764 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
765 struct devicelinux_device *dev = &dev_ne[this_dev];
766 dev->name = namelist+(NAMELEN*this_dev);
767 dev->irq = irq[this_dev];
768 dev->base_addr = io[this_dev];
769 dev->init = ne_probe;
770 dev->mem_end = bad[this_dev];
771 if (register_netdev(dev) == 0) {
772 found++;
773 continue;
774 }
775 if (found != 0) /* Got at least one. */
776 return 0;
777 if (io[this_dev] != 0)
778 printk(KERN_WARNING"<4>" "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]);
779 else
780 printk(KERN_NOTICE"<5>" "ne.c: No PCI cards found. Use \"io=0xNNN\" value(s) for ISA cards.\n");
781 return -ENXIO6;
782 }
783
784 return 0;
785}
786
787void
788cleanup_module(void)
789{
790 int this_dev;
791
792 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
793 struct devicelinux_device *dev = &dev_ne[this_dev];
794 if (dev->priv != NULL((void *) 0)) {
795 kfreelinux_kfree(dev->priv);
796 dev->priv = NULL((void *) 0);
797 free_irq(dev->irq, dev);
798 irq2dev_map[dev->irq] = NULL((void *) 0);
799 release_region(dev->base_addr, NE_IO_EXTENT0x20);
800 unregister_netdev(dev);
801 }
802 }
803}
804#endif /* MODULE */
805
806/*
807 * Local variables:
808 * compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c ne.c"
809 * version-control: t
810 * kept-new-versions: 5
811 * End:
812 */