mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 20:44:26 +01:00
irq kind of works!!
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
TODO: get handler running multiple times on some existing interrupt from /proc/interrupts.
|
TODO: get handler running multiple times on some existing interrupt from /proc/interrupts.
|
||||||
|
|
||||||
|
Inside QEMU, try:
|
||||||
|
|
||||||
|
watch -n 1 cat /proc/interrupts
|
||||||
|
|
||||||
|
Then see how clicking the mouse and keyboard affect the interrupts. This will point you to:
|
||||||
|
|
||||||
|
- 1: keyboard
|
||||||
|
- 12: mouse click and drags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm/uaccess.h> /* copy_from_user, copy_to_user */
|
#include <asm/uaccess.h> /* copy_from_user, copy_to_user */
|
||||||
@@ -21,13 +30,13 @@ MODULE_PARM_DESC(i, "irq line number");
|
|||||||
* Return value from kernel docs:*
|
* Return value from kernel docs:*
|
||||||
*
|
*
|
||||||
* enum irqreturn
|
* enum irqreturn
|
||||||
* @IRQ_NON interrupt was not from this device or was not handled
|
* @IRQ_NONE interrupt was not from this device or was not handled
|
||||||
* @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 irq, void *v)
|
static irqreturn_t handler(int irq, void *dev)
|
||||||
{
|
{
|
||||||
pr_info("handler irq = %d\n", irq);
|
pr_info("handler irq = %d dev = %d\n", irq, *(int *)dev);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +51,7 @@ static int myinit(void)
|
|||||||
ret = request_irq(
|
ret = request_irq(
|
||||||
i,
|
i,
|
||||||
handler,
|
handler,
|
||||||
|
/* Requires an associated device. */
|
||||||
IRQF_SHARED,
|
IRQF_SHARED,
|
||||||
"myirqhandler0",
|
"myirqhandler0",
|
||||||
&major
|
&major
|
||||||
|
|||||||
Reference in New Issue
Block a user