I am trying to work with linux softirq. A have a simple program that uses linux system calls defined in linux/interrupt.h:
//
// Created by kivi on 24.09.16.
//
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/stat.h>
#define SHARED_IRQ 17
static int irq = SHARED_IRQ, my_dev_id, irq_counter = 0;
module_param( irq, int, S_IRUGO );
/* The interrupt handler */
static irqreturn_t xxx_interrupt( int irq, void *dev_id ) {
printk( KERN_INFO "In the top-half: counter = %d\n", irq_counter );
raise_softirq( XXX_SOFT_IRQ );
return IRQ_HANDLED;
}
/* The bottom half */
void xxx_analyze(struct softirq_action *str) {
irq_counter++;
printk( KERN_INFO "In the bottom-half: counter = %d\n", irq_counter );
}
static int __init my_init( void ) {
request_irq( irq, xxx_interrupt, 0, "xxx", NULL );
open_softirq( XXX_SOFT_IRQ, xxx_analyze);
printk( KERN_INFO "Successfully set softirq handler on IRQ %d\n", irq );
return 0;
}
static void __exit my_exit( void ) {
synchronize_irq( irq );
free_irq( irq, &my_dev_id );
printk( KERN_INFO "Successfully unloading, irq_counter = %d\n", irq_counter );
}
module_init( my_init );
module_exit( my_exit );
MODULE_LICENSE( "GPL v2" );
When I try to compile this module I get linker errors that functions open_softirq() and raise_softirq() are not defined:
kivi@kivi-pc:~/sp_labs/irq_exc/softirq$ make
make -C /lib/modules/4.7.5-custom/build M=/home/kivi/sp_labs/irq_exc/softirq modules
make[1]: Entering directory '/home/kivi/Downloads/linux-4.7.5'
Building modules, stage 2.
MODPOST 1 modules
WARNING: "open_softirq" [/home/kivi/sp_labs/irq_exc/softirq/softirq.ko] undefined!
WARNING: "raise_softirq" [/home/kivi/sp_labs/irq_exc/softirq/softirq.ko] undefined!
make[1]: Leaving directory '/home/kivi/Downloads/linux-4.7.5'
The interesting thing is that functions request_irq() e.t.c. are also defined in interrupt.h file, but they don't cause any problem.
Here is my Makefile:
obj-m += softirq.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
So can anyone help me please with my problem.
P.S. i googled my problem and found some advice that I should add KBUILD_EXTRA_SYMBOLS=*module path*/Module.symvers when compiling, but it didn't help.
#definein order to link symbols marked withEXPORT_SYMBOL_GPL()