Linux驱动之module--hello.ko


cat hello.c

**********************************
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
 
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

相关内容