📄 linux下8019驱动程序.txt
字号:
214 return -ENXIO;
215 }
216 ei_status.priv = (unsigned long)idev;
217 break;
218 }
219 if (!idev)
220 continue;
221 return 0;
222 }
223
224 return -ENODEV;
225 }
226
227 static int __init ne_probe1(struct net_device *dev, int ioaddr)
228 {
229 int i;
230 unsigned char SA_prom[32];
231 int wordlength = 2;
232 const char *name = NULL;
233 int start_page, stop_page;
234 int neX000, ctron, copam, bad_card;
235 int reg0, ret;
236 static unsigned version_printed = 0;
237
238 if (!request_region(ioaddr, NE_IO_EXTENT, dev->name))
239 return -EBUSY;
240
241 reg0 = inb_p(ioaddr);
242 if (reg0 == 0xFF) {
243 ret = -ENODEV;
244 goto err_out;
245 }
246
247 /* Do a preliminary verification that we have a 8390. */
248 {
249 int regd;
250 outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
251 regd = inb_p(ioaddr + 0x0d);
252 outb_p(0xff, ioaddr + 0x0d);
253 outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);
254 inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
255 if (inb_p(ioaddr + EN0_COUNTER0) != 0) {
256 outb_p(reg0, ioaddr);
257 outb_p(regd, ioaddr + 0x0d); /* Restore the old values. */
258 ret = -ENODEV;
259 goto err_out;
260 }
261 }
262
263 if (ei_debug && version_printed++ == 0)
264 printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2);
265
266 printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr);
267
268 /* A user with a poor card that fails to ack the reset, or that
269 does not have a valid 0x57,0x57 signature can still use this
270 without having to recompile. Specifying an i/o address along
271 with an otherwise unused dev->mem_end value of "0xBAD" will
272 cause the driver to skip these parts of the probe. */
273
274 bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
275
276 /* Reset card. Who knows what dain-bramaged state it was left in. */
277
278 {
279 unsigned long reset_start_time = jiffies;
280
281 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
282 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
283
284 while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
285 if (jiffies - reset_start_time > 2*HZ/100) {
286 if (bad_card) {
287 printk(" (warning: no reset ack)");
288 break;
289 } else {
290 printk(" not found (no reset ack).\n");
291 ret = -ENODEV;
292 goto err_out;
293 }
294 }
295
296 outb_p(0xff, ioaddr + EN0_ISR); /* Ack all intr. */
297 }
298
299 /* Read the 16 bytes of station address PROM.
300 We must first initialize registers, similar to NS8390_init(eifdev, 0).
301 We can't reliably read the SAPROM address without this.
302 (I learned the hard way!). */
303 {
304 struct {unsigned char value, offset; } program_seq[] =
305 {
306 {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/
307 {0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */
308 {0x00, EN0_RCNTLO}, /* Clear the count regs. */
309 {0x00, EN0_RCNTHI},
310 {0x00, EN0_IMR}, /* Mask completion irq. */
311 {0xFF, EN0_ISR},
312 {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */
313 {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */
314 {32, EN0_RCNTLO},
315 {0x00, EN0_RCNTHI},
316 {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */
317 {0x00, EN0_RSARHI},
318 {E8390_RREAD+E8390_START, E8390_CMD},
319 };
320
321 for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
322 outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);
323
324 }
325 for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -