函数如下:


static int ne_probe1(struct device *dev, int ioaddr)
{
.....................//合法性检查
/* Fixup for users that don't know that IRQ 2 is really IRQ 9,
    or don't know which one to set. */
 dev->irq = 9;//设置中断类型号
   
    /* Snarf the interrupt now.  There's no point in waiting since we cannot
       share and the board will usually be enabled. */
    {
 int irqval = request_irq (dev->irq, ei_interrupt, 0, wordlength==2 ? "ne2000":"ne1000");//注册申请中断,中断处理函数为ei_interrupt
 if (irqval) {
     printk (" unable to get IRQ %d (irqval=%d). ", dev->irq, irqval);
     return EAGAIN;
 }
    }

    dev->base_addr = ioaddr;

    request_region(ioaddr, NE_IO_EXTENT, wordlength==2 ? "ne2000":"ne1000");//申请内存空间

    for(i = 0; i < ETHER_ADDR_LEN; i++)
 dev->dev_addr[i] = SA_prom[i];

    ethdev_init(dev);//调用函数对dev设备结构体进行初始化
    printk(" %s: %s found at %#x, using IRQ %d. ",
    dev->name, name, ioaddr, dev->irq);

    if (ei_debug > 0)
 printk(version);

    ei_status.name = name;
    ei_status.tx_start_page = start_page;
    ei_status.stop_page = stop_page;
    ei_status.word16 = (wordlength == 2);

    ei_status.rx_start_page = start_page + TX_PAGES;
#ifdef PACKETBUF_MEMSIZE
    /* Allow the packet buffer size to be overridden by know-it-alls. */
    ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
#endif

    ei_status.reset_8390 = &ne_reset_8390;
    ei_status.block_input = &ne_block_input;
    ei_status.block_output = &ne_block_output;
    NS8390_init(dev, 0);//配置网卡中的寄存器等到默认状态
    return 0;
}
 


  初始化函数ethdev_init()在文件drivers/net/8390.c中。如下:


/* Initialize the rest of the 8390 device structure. */
int ethdev_init(struct device *dev)
{
    if (ei_debug > 1)
  printk(version);
   
    if (dev->priv == NULL) {//申请私有空间存储具体网卡的结构体信息
  struct ei_device *ei_local;//8390网卡设备的结构体
 
  dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);//申请内核内存空间
  memset(dev->priv, 0, sizeof(struct ei_device));
  ei_local = (struct ei_device *)dev->priv;
#ifndef NO_PINGPONG
  ei_local->pingpong = 1;
#endif
    }
   
    /* The open call may be overridden by the card-specific code. */
    if (dev->open == NULL)
  dev->open = &ei_open;//设备的打开函数
    /* We should have a dev->stop entry also. */
    dev->hard_start_xmit = &ei_start_xmit;//设备的发送函数,定义在8390.c中
    dev->get_stats = get_stats;
#ifdef HAVE_MULTICAST
    dev->set_multicast_list = &set_multicast_list;
#endif

    ether_setup(dev);//进一步调用函数设置dev设备结构体
       
    return 0;
}