Chinaunix首页 | 论坛 | 博客
  • 博客访问: 76020
  • 博文数量: 54
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 600
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-16 16:44
文章分类

全部博文(54)

文章存档

2011年(2)

2009年(28)

2008年(24)

我的朋友

分类: LINUX

2011-05-25 16:27:09


#include
/* Defines the license for this LKM */
MODULE_LICENSE("GPL");
/* Init function called on module entry */
int my_module_init( void )
{
 printk(KERN_INFO "my_module_init called. Module is now loaded.\n");
  return 0;
}
/* Cleanup function called on module exit */
void my_module_cleanup( void )
{
  printk(KERN_INFO "my_module_cleanup called. Module is now unloaded.\n");
  return;
}
/* Declare entry and exit functions */
module_init( my_module_init );
module_exit( my_module_cleanup );


编写Makefile1:

obj-m : = test.o

KERNELDIR := /lib/modules/$(shell uname -r)/build

default:

(tab键)make -C $(KERNELDIR) M=$(shell pwd) modules

install:

      insmod test.ko

uninstall:

       rmmod test.ko

clean:

       make -C $(KERNELDIR) M=$(shell pwd) clean





阅读(114) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~