Linux内核:从底层向上分析驱动程序层+链路层
作者:网络转载 发布时间:[ 2012/12/25 10:21:35 ] 推荐标签:
函数如下:
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;
}
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11