irq attempt

This commit is contained in:
Ciro Santilli
2017-06-15 10:29:13 +01:00
parent 2284109290
commit 3556eef2fc
2 changed files with 20 additions and 11 deletions

View File

@@ -9,6 +9,10 @@ TODO: get handler running multiple times on some existing interrupt from /proc/i
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int irq = 0;
module_param_named(i, irq, int, S_IRUSR);
MODULE_PARM_DESC(i, "irq line number");
/** /**
* Return value from kernel docs:* * Return value from kernel docs:*
* *
@@ -17,28 +21,32 @@ MODULE_LICENSE("GPL");
* @IRQ_HANDLED interrupt was handled by this device * @IRQ_HANDLED interrupt was handled by this device
* @IRQ_WAKE_THREAD handler requests to wake the handler thread * @IRQ_WAKE_THREAD handler requests to wake the handler thread
*/ */
static irqreturn_t handler(int i, void *v) static irqreturn_t handler(int irq, void *v)
{ {
pr_info("handler %llu\n", (unsigned long long)jiffies); pr_info("handler irq = %d jiffies = %llx\n", irq, (unsigned long long)jiffies);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int myinit(void) static int myinit(void)
{ {
irqreturn_t r; int ret;
r = request_irq(
1, for (int i = 0; i < 128; ++i) {
handler, ret = request_irq(
IRQF_SHARED, i,
"myirqhandler0", handler,
0 IRQF_SHARED,
); "myirqhandler0",
pr_info("request_irq %llu\n", (unsigned long long)r); NULL
);
pr_info("request_irq irq = %d ret = %d\n", i, ret);
}
return 0; return 0;
} }
static void myexit(void) static void myexit(void)
{ {
free_irq(irq, NULL);
} }
module_init(myinit) module_init(myinit)

View File

@@ -55,6 +55,7 @@ case "$arch" in
-net nic,model=virtio \ -net nic,model=virtio \
-net user \ -net user \
-smp 1 \ -smp 1 \
-device edu \
$extra_flags $extra_flags
" "
;; ;;