Linux kernel2.6.25 CS8900网卡驱动移植
Linuxkernel2.6.25CS8900网卡驱动移植,nbsp;一般来说,我们在编译kernel时,设备驱动的选择有两种方式:一种是直接编译到kernel里,另一种是以模块方式挂接。CS8900网卡驱动如果以模块方式挂接,函数init_module就是入口;如果是直接编译到kernel里,那么函数cs89x0_probe才是入口。在此入口函数中,将完成网..
一般来说,我们在编译kernel时,设备驱动的选择有两种方式:一种是直接编译到kernel里,另一种是以模块方式挂接。CS8900网卡驱动如果以模块方式挂接,函数init_module就是入口;如果是直接编译到kernel里,那么函数cs89x0_probe才是入口。在此入口函数中,将完成网卡驱动的各项初始化。如注册虚拟地址,设备号,中断号,以及各个相关寄存器的初始化。
cs89x0_probe函数里会去调用真正的初始化函数cs89x0_probe1。下面说一下该初始化函数里需要完成的几个重要地方:
1、 注册虚拟地址。
通过request_region函数注册虚拟地址。在kenel里面,我们所操作的寄存器的地址其实都是虚拟地址,但是每一个寄存器的虚拟地址都有唯一和其对应的物理地址,因为在kernel里面任何虚拟地址都会通过MMU转化成物理地址。所以在kernel里,定义完所要用到的寄存器后,都必须使用一个函数ioremap将我们所要用到的寄存器的物理地址转换成为在kernel里可以操作的虚拟地址,然后才能将他们用以具体的操作,否则一切都是徒劳。
ioaddr = (int)ioremap(BASE_ADDR,16);
2、填充net_device结构体。
该结构体的成员都是和网络设备有关的变量。其中比较重要的有两个:dev_addr和open。dev_addr里要存的是主机的MAC地址,一般都是从eeproom中读出来再存放到该变量中,当然也可以根据自己的需要手动赋值。
for (i=0; i < ETH_ALEN/2; i++) {
unsigned int Addr;
Addr = readreg(dev, PP_IA+i*2);
dev->dev_addr[i*2] = Addr & 0xFF;
dev->dev_addr[i*2+1] = Addr >> 8;
} |
Open是一个函数指针,需要把net_open函数赋值给他。net_open函数是一个专门用来注册网络设备中断号的函数,输入ifconfig命令时,最后就会调用到这个函数。在这个函数中要把中断号设置一下。
writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); request_irq(dev->irq, &net_interrupt, 0, dev->name, dev); |
3、 I/O端口的中断请求设置。
网卡不可能也不需要时时刻刻都处于中断状态,合理的中断触发时机是一个必要条件。根据硬件电路图的引脚可知,相对应的中断请求寄存器是GPG1和EINT9。在GPG1寄存器里面要把EINT9寄存器功能激活,而在EINT9寄存器里面则要把中断设置为上跳沿触发。
writel(readl(S 3C2410_GPGCON) | 0x8, S3C2410_GPGCON); writel(readl(S3C2410_EXTINT1) | 0x40, S3C2410_EXTINT1); |
还有一点要注意,CS8900网卡的寄存器都是16位的,所以在选择读写函数时也必须选择16位寄存器的读写函数。
static u16 readword(unsigned long base_addr, int portno)
{
return inw(base_addr + portno);
}
static void writeword(unsigned long base_addr, int portno, u16 value)
{
outw(value, base_addr + portno);
} |
以上便是Linux kernel2.6.25 CS8900网卡驱动移植所需注意的内容。Kernel里面涉及和兼容的东西非常多,去除容易产生冲突的部分,添加自己需要实现的功能,可以使得移植工作能够顺利进行。
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524487.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524486.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524485.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524484.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524483.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524482.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524481.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524480.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524479.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524478.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524477.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524476.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524475.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524474.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524473.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524472.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524471.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524470.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524469.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524468.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524467.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524466.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524465.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524464.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524463.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524462.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524461.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524460.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524459.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524458.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524449.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524457.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524456.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524455.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524454.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524453.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524452.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524451.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524450.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524448.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524447.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524446.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524445.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524444.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524443.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524442.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524441.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524416.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524440.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524439.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524438.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524437.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524436.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524435.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524434.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524433.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524432.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524431.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524430.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524429.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524428.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524427.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524426.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524425.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524424.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524423.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524422.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524421.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524420.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524419.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524418.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524417.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524415.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524414.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524413.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524412.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524411.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524410.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524409.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524408.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524407.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524406.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524405.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524404.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524403.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524402.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524401.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524400.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524399.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524398.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524397.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524396.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524395.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524394.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524393.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524392.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524391.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524390.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524389.html
- 来源:驱动中国 · 原文链接:https://www.qudong.com/article/524388.html