#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/version.h>
MODULE_DESCRIPTION("Hello World !!");
MODULE_AUTHOR("jimmy");
MODULE_LICENSE("GPL");
static struct timer_list haha_timer;
static int haha = 0;
static void haha_timer_func(void){
printk(KERN_ERR"haha timer=%d jiffies=%ld\n",haha++,jiffies);
mod_timer(&haha_timer, jiffies + 1*HZ);
}
static int __init hello_init(void)
{
printk(KERN_ERR"Hello, world\n");
init_timer(&haha_timer);
haha_timer.function = haha_timer_func;
haha_timer.expires = jiffies + 1*HZ;
add_timer(&haha_timer);
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_ERR"Goodbye\n");
}
module_init(hello_init);
module_exit(hello_exit);
makefile:
PWD := $(shell pwd)
KERNEL_DIR = /home/jimmychen/work/git/ws/linux-3.10.1
MODULE_NAME = time
obj-m := $(MODULE_NAME).o
all:
make -C $(KERNEL_DIR) M=$(PWD) modules
clean:
make -C $(KERNEL_DIR) M=$(PWD) clean
沒有留言:
張貼留言