QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1432|回复: 2

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

[复制链接]
发表于 2005-3-21 11:20:07 | 显示全部楼层 |阅读模式
如题,在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直接编译进内核,但好像不行,不知道漏了哪些环节或是什么问题,望高手指教,谢谢!
 楼主| 发表于 2005-3-22 12:56:09 | 显示全部楼层
怎么大家一点兴趣都没有啊:-)
期待高手指点.........
回复

使用道具 举报

发表于 2005-4-16 08:58:58 | 显示全部楼层
需要用到config..in吗?写个makefile就可以啦!太复杂了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-9-29 05:40 , Processed in 0.124321 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表