[root@localhost driver]# cd hello2
[root@localhost hello2]# ls
Makefile start.c stop.c
關鍵在Makefile
##########################################################
[root@localhost hello2]# cat start.c
#include < linux/kernel.h >
#include < linux/module.h >
#include < linux/init.h >
static int __init hello_init(void){
printk("<1>Hello, World!!\n");
return 0;
}
module_init(hello_init);
[root@localhost hello2]#
##########################################################
[root@localhost hello2]# cat stop.c
#include < linux/kernel.h >
#include < linux/module.h >
#include < linux/init.h >
static void __exit hello_exit(void){
printk("<1>Bye!Bye!!\n");
}
module_exit(hello_exit);
[root@localhost hello2]#
##########################################################
[root@localhost hello2]# cat Makefile
obj-m += startstop.o
startstop-objs := start.o stop.o
all:
make -C /lib/modules/2.6.9/build M=/mnt/driver/hello2 modules
clean:
make -C /lib/modules/2.6.9/build M=/mnt/driver/hello2 clean
[root@localhost hello2]#
沒有留言:
張貼留言