📄 linux下8019驱动程序.txt
字号:
438
439 printk("\n%s: %s found at %#x, using IRQ %d.\n",
440 dev->name, name, ioaddr, dev->irq);
441
442 ei_status.name = name;
443 ei_status.tx_start_page = start_page;
444 ei_status.stop_page = stop_page;
445 ei_status.word16 = (wordlength == 2);
446
447 ei_status.rx_start_page = start_page + TX_PAGES;
448 #ifdef PACKETBUF_MEMSIZE
449 /* Allow the packet buffer size to be overridden by know-it-alls. */
450 ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
451 #endif
452
453 ei_status.reset_8390 = &ne_reset_8390;
454 ei_status.block_input = &ne_block_input;
455 ei_status.block_output = &ne_block_output;
456 ei_status.get_8390_hdr = &ne_get_8390_hdr;
457 ei_status.priv = 0;
458 dev->open = &ne_open;
459 dev->stop = &ne_close;
460 NS8390_init(dev, 0);
461 return 0;
462
463 err_out_kfree:
464 kfree(dev->priv);
465 dev->priv = NULL;
466 err_out:
467 release_region(ioaddr, NE_IO_EXTENT);
468 return ret;
469 }
470
471 static int ne_open(struct net_device *dev)
472 {
473 ei_open(dev);
474 return 0;
475 }
476
477 static int ne_close(struct net_device *dev)
478 {
479 if (ei_debug > 1)
480 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
481 ei_close(dev);
482 return 0;
483 }
484
485 /* Hard reset the card. This used to pause for the same period that a
486 8390 reset command required, but that shouldn't be necessary. */
487
488 static void ne_reset_8390(struct net_device *dev)
489 {
490 unsigned long reset_start_time = jiffies;
491
492 if (ei_debug > 1)
493 printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies);
494
495 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
496 outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
497
498 ei_status.txing = 0;
499 ei_status.dmaing = 0;
500
501 /* This check _should_not_ be necessary, omit eventually. */
502 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
503 if (jiffies - reset_start_time > 2*HZ/100) {
504 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name);
505 break;
506 }
507 outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
508 }
509
510 /* Grab the 8390 specific header. Similar to the block_input routine, but
511 we don't need to be concerned with ring wrap as the header will be at
512 the start of a page, so we optimize accordingly. */
513
514 static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
515 {
516 int nic_base = dev->base_addr;
517
518 /* This *shouldn't* happen. If it does, it's the last thing you'll see */
519
520 if (ei_status.dmaing)
521 {
522 printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr "
523 "[DMAstat:%d][irqlock:%d].\n",
524 dev->name, ei_status.dmaing, ei_status.irqlock);
525 return;
526 }
527
528 ei_status.dmaing |= 0x01;
529 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
530 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
531 outb_p(0, nic_base + EN0_RCNTHI);
532 outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
533 outb_p(ring_page, nic_base + EN0_RSARHI);
534 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
535
536 if (ei_status.word16)
537 insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
538 else
539 insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
540
541 outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
542 ei_status.dmaing &= ~0x01;
543
544 le16_to_cpus(&hdr->count);
545 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -