Linux驱动之module--hello.ko

2014-11-24 09:50:14 · 作者: · 浏览: 1

cat hello.c


**********************************
#include
#include
#include

static int hello_init(void)
{
printk("hello");
return 0;
}

static void hello_exit(void)
{
printk("bye");
}

module_init(hello_init);
module_exit(hello_exit);
***********************************


************Makefile***********************


obj-m := hello.o
KDIR :=~~your_path_/linux-2.6

PWD := $(shell pwd)


default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
rm -rf Module.markers modules.order Module.symvers