ljk 发表于 2005-3-21 11:20:07

如何把驱动程序test.c直接编译进内核?

如题,在rh9下不行,我是这样做的:假如我的驱动程序名为test.c,将它放在/usr/src/linux/driver/char下并修改了此目录下的makefile和config.in在其中分别加入了
obj-$(CONFIG_TEST) = test.o 和bool 'My test' CONFIG_TEST.
简单的test.c如下:
#ifndef MODULE
#define MODULE
#endif
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/system.h>
#include <linux/ioport.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <asm/io.h>
#include <linux/types.h>

static int __init test_init(void)
{
printk(KERN_EMERG "HELLO test!\n");
return 0;

}

static void __exit test_cleanup(void)
{
printk(KERN_EMERG " I shut down device from kernerl mod \n");
}

module_init(test_init);
module_exit(test_cleanup);

MODULE_LICENSE("GPL");
/*EXPORT_NO_SYMBOLS;*/

我想把test.c直接编译进内核,但好像不行,不知道漏了哪些环节或是什么问题,望高手指教,谢谢!

ljk 发表于 2005-3-22 12:56:09

怎么大家一点兴趣都没有啊:-)
期待高手指点.........

wuhu 发表于 2005-4-16 08:58:58

需要用到config..in吗?写个makefile就可以啦!太复杂了!
页: [1]
查看完整版本: 如何把驱动程序test.c直接编译进内核?