阅读:1554回复:5
那位真正的高手能给出2.4向2.6驱动源码迁移的全攻略!!!!!!!!
今天将我基于2.4编写的驱动程序,用最新的2.6的库文件编译,结果,我考,吓死我了,出来整整4大屏错误,而原来用2.4编译的时候,连个Warning都没有的,2.6怎么会跟2.4查这么多!!!
我对驱动也是初学,内核就更是菜鸟一个,勉勉强强在2.4下弄了个驱动出来,没想到在2.6下编译给我这么沉重的打击!! 那位高手能给出一个2.4向2.6迁移的全攻略出来 比如,据我看2.6的源码,我发现关于中断请求的函数 request_irq 的第二个函数参数,即函数句柄,应经从原来的 static void abc( int irq, void *data, struct pt_regs *regs) 全部改为 static irqreturn_t abc( int irq, void *data, struct pt_regs *regs) 并且如果要使中断起作用,必须return IRQ_HANDLED; 才行!! 包括main.c中也不再有 #ifdef CONFIG_MODULES init_modules(); #endif 这样的句子,搞得我现在都不知道该如何把驱动直接编译到内核里了 此外,好像新的内核也不需要驱动调用 MOD_INC_USE_COUNT; 此类函数了 但是,即便有这些改变,也不能编译的时候给我报出TMD那么多错误呀!! 求助高手,那位已经在2.6下写驱动了,请帮忙 本人QQ:3199399 msn:Forest_Leo@hotmail.com |
|
沙发#
发布于:2004-03-09 10:01
我也遇到相同问题,2.4 下的代码到了2.6以后编译就出来一大堆ERRORS
|
|
板凳#
发布于:2004-03-09 14:58
我把 2.6的源码作了一次make bzImage,错误少了很多,但是还是编译不过去,问题出在interrupt.h文件中,我必须包含这个文件,因为我用到了中断的一些函数,但是编译时候出现下列错误
In file included from /root/linux-2.6.3/include/linux/irq.h:20, from /root/linux-2.6.3/include/asm/hardirq.h:6, from /root/linux-2.6.3/include/linux/interrupt.h:11, from test.c:16: /root/linux-2.6.3/include/asm/irq.h:16:25: irq_vectors.h: No such file or directory In file included from /root/linux-2.6.3/include/asm/hardirq.h:6, from /root/linux-2.6.3/include/linux/interrupt.h:11, from test.c:16: /root/linux-2.6.3/include/linux/irq.h:70: `NR_IRQS' undeclared here (not in a function) In file included from /root/linux-2.6.3/include/linux/irq.h:72, from /root/linux-2.6.3/include/asm/hardirq.h:6, from /root/linux-2.6.3/include/linux/interrupt.h:11, from test.c:16: /root/linux-2.6.3/include/asm/hw_irq.h:28: `NR_IRQ_VECTORS' undeclared here (not in a function) /root/linux-2.6.3/include/asm/hw_irq.h:31: `NR_IRQS' undeclared here (not in a function) 我以为是我程序有问题,我就写了最简单的 hello,world程序,错误依旧,当我把interrupt.h在test.c中屏蔽后,编译就没有错误了,可是,内核自己的源码都用到了interrupt.h,而且生成内核的时候编译没有问题,所以希望哪位高人能给指点一下!!! |
|
地板#
发布于:2004-03-10 21:50
我也遇到同样的问题,我怀疑是gcc版本的问题,没有办法只有装会7.1了,现在编译中,成功了告诉大家。
|
|
地下室#
发布于:2004-03-12 10:31
新的驱动已经移植到了 2.6 下面,对于2.6的新的环境,驱动程序修改得不多,但是对于其诡异的编译方法,始终觉得不明白,最后没有办法,我把通过修改Kconfig和模仿其他驱动编写的Makefile送到了内核源码里,把握的驱动变成make menuconfig中的一个可选项,最终顺利编译通过,并且可以作为内核的一部分,或一个外挂模块都可以区别在于选择的时候是选* 还是选M,还是用lsmod insmod rmmod这些命令,不过必须下载新的程序升级他们才行,原有2.4得不能用了,升级后的insmod等命令向下兼容,可以搞定.o,也可以搞定.ko
|
|
5楼#
发布于:2004-03-17 10:14
http://lwn.net/Articles/driver-porting/
Porting device drivers to the 2.6 kernel |
|
|