您的位置:首页 > 运维架构 > Linux

linux驱动学习-2th

2014-03-13 21:53 183 查看
第一个驱动程序hellodrv.

#include<linux/module.h>
#include<linux/kernel.h>

static int __init hello_drv_init(void)
{
printk("hellodrv init go to here!\n");
return 0;
}

static void __exit hello_drv_exit(void)
{
printk("hellodrv exit go to here!\n");
}

module_init(hello_drv_init);
module_exit(hello_drv_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("onejacky wanshiji@126.com");


makefile :

#KERN_DIR = /usr/src/linux-2.6.32.2/
KERN_DIR = /home/onejacky/my_work/src_code/linux-2.6.32.2
all:
make -C $(KERN_DIR) M=`pwd` modules

clean:
make -C $(KERN_DIR) M=`pwd` modules clean
rm -rf modules.order
obj-m	+= hellodrv.o
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: