The Interrupt service routine handles an interrupt in the Linux Kernel. The interrupt service routine for the Interrupt is registered using the “request_irq” API. The IRQ can be released using the “free_irq” API.
- The “handler” function pointer parameter in the request_irq API is the handler of the interrupt,
- The “irq” parameter is the interrupt request line that the driver is requesting
- The “flags” parameter indicate the different options that the interrupt request line should be provided
- The “dev_name” is the name of the the interrupt line will show in /proc/interrupts.
- The “dev_id” is a unique identifier for the interrupt and is relevant specifically when interrupt lines are shared, in order to figure out a specific interrupt generated in the CPU belongs to which specific driver. it is also a parameter that is used when the irq line is freed.
A few different “flag” options are provided below:
- IRQF_DISABLED – handlers run with all interrupts disabled on the local processor
- IRQF_SHARED – The flag indicates that the “irq line” is shared with other handlers
- IRQF_SAMPLE_RANDOM – This flag specifies that interrupts generated by this device should contribute to the kernel entropy pool
- IRQF_TIMER – if set the irq handler processes interrupts for Linux timer
There are other “irq APIs” and the below link provides an excellent link for the same
https://www.kernel.org/doc/html/latest/core-api/genericirq.html
we will look at an ISR program written to handle keyboard interrupt in the next article
- References
- https://www.oreilly.com/library/view/linux-device-drivers/0596000081/ch09s03.html
- https://www.kernel.org/doc/html/latest/core-api/genericirq.html
- http://books.gigatux.nl/mirror/kerneldevelopment/0672327201/ch06lev1sec3.html
- https://docs.huihoo.com/linux/kernel/2.6.26/genericirq/re09.html
Interrupt Services Routine (ISR) – Keyboard Interrupt Example
Pingback: Looking at /proc/interrupts | Hitch Hiker's Guide to Learning