2016年9月8日 星期四

softirq

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>

static void hello_printk(struct softirq_action *h)
{
 int i = 0;
 
 printk(KERN_ERR "softirq hello,world!!\n");
 
 while(i++ < 1000)
  printk(KERN_ERR "haha   jiffies = %lu \n" , jiffies);
}


static int hello_init(void)
{
 open_softirq(HI_SOFTIRQ, hello_printk);
 raise_softirq(HI_SOFTIRQ);
 return 0;
}

static void hello_exit(void)
{
 raise_softirq_irqoff(HI_SOFTIRQ);
 printk(KERN_ERR "softirq bye!\n");
}

module_init(hello_init);
module_exit(hello_exit);



Makefile:





#obj-m += time.o
obj-m += softirq.o
KERNEL_DIR=/home/jimmychen/work/git/ws/fs3000/trunk/linux-3.10.1/
#KERNEL_DIR=/lib/modules/2.6.32-5-amd64/build/

all:
 $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules

clean:
 $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean

在linux-3.10.1/kernel/softirq.c
加上
EXPORT_SYMBOL(raise_softirq);
EXPORT_SYMBOL(raise_softirq_irqoff);
EXPORT_SYMBOL(open_softirq);
不然會有下列錯誤
WARNING: "raise_softirq_irqoff" [/home/jimmychen/work/git/ws/trunk/time/softirq.ko] undefined!
WARNING: "raise_softirq" [/home/jimmychen/work/git/ws/trunk/time/softirq.ko] undefined!
WARNING: "open_softirq" [/home/jimmychen/work/git/ws/trunk/time/softirq.ko] undefined!

沒有留言:

張貼留言