我编译了内核,pci_register_driver不能使用,我也大量发分~~~ 大量发分~~~
为什么编译时错误:pci_register_driver没有声明~~~!!!!
怎么挂接到他的内核上啊~~~~~
我按照下面的方法做了一遍为什么还不能编译 pci_register_driver 啊~~~
1、下载内核文件如:linux-2.6.20.tar.gz ftp://ftp.kernel.org/pub/linux/kernel/ 拷贝到/usr/src目录并解压缩。
# cd /usr/src
# tar zvxf linux-2.6.20.tar.gz
2、进入解压目录。(/usr/src/linux-2.6.20.tar.gz,视文件名而定)
ln –s linux-2.6.20 linux,因为在ipvs-1.24中的makefile文件中默认指定Kernel Source的路径为:KERNELSOURCE = /usr/src/linux
# cd /usr/src/linux-2.6.20.tar.gz
# make mrproper
# make xconfig
# make menuconfig(如果需要 Virtual Server Configuration,则需要执行此项)执行make menuconfig时,我们将进入一个图形化的界面,在其中可以对Linux Kernel进行详细设置。与LVS相关的kernel选项都在“Networking options”中,进入“Networking options”,可以查看到“IP: Virtual Server Configuration”选项,将其它所有的子选项都选上。
3、进行选译,自己设定个性化的内核。完后点“save and exit”
4、进行编译。
# make dep
# make clean
# make bzImage (I要大写哟)
5、编译模块。
# make modules
# make modules_install
# depmod -a
6、编译完成,开始替换文件。
# cd /boot
# rm System.map
# rm vmlinuz
# mv /usr/src/linux-2.6.20/System.map System.map
# mv /usr/src/linux-2.6.20/arch/i386/boot/bzImage vmlinux
7.修改开机设定。
GRUB是 /boot/grub/grub.conf文件
lilo是/etc/lilo.conf文件
可以用命令
# mkinitrd /boot/initrd-2.6.20.img 2.6.20来生成initrd文件。如果用命令,则会自动生成System.map vmlinux 还会修改grub.conf文件,最后之后检查一下,看是否正确。
用GRUB来举例子说。(红色部分)
------解决方案--------------------http://dukeandbyl.bokee.com/1479853.html
------解决方案--------------------少量接分
------解决方案--------------------#include <linux/mm.h>
#include <linux/kernel.h>
#include <linux/pci.h>
int main()
{
pci_enable_device(0,0);
return 0;
}
这段代码概念错误,无论是mm.h, kernel.h, pci.h都是内核态的头文件,你可以在模块中include他们,但你的这段main代码明显是用户态的,怎么可以包含内核头文件,模块的编译也不是g++ -c 那么简单的。
建议参考Linux Device Driver 3rd中关于模块的介绍