Linux Kernel Interrupt Controller

Linux Kernel Interrupt Controller API

Interrupt handling is an important part of the Linux kernel. Most of the kernel’s functionality, mainly in embedded system, involve interrupt handling.

This article describes the most important concepts related to the Linux kernel’s interrupt handling mechanisms. These concepts include the relevant code and data structures. Sample code from Linux kernel is also provided.

The kernel IRQ subsystem is composed of below structures:

  • Struct irq_desc;
  • struct irq_data;
  • struct irqaction;
  • struct irq_chip;
  • struct irq_domain;
  • struct irq_domain_ops;

Interrupt Descriptor: struct irq-desc
Each interrupt source available to the system has allocated to it a single struct irq_desc structure. This structure stores important information for the interrupt controller, handler and others:
struct irq_desc {
struct irq_data irq_data;
irq_flow_handler_t handle_irq;
struct irqaction * action;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry * dir;
#endif
unsigned int nr_actions;
int parent_irq;
struct module *owner;
const char *name;

};
@irq_data: per irq and chip data passed down to chip functions
@handle_irq: highlevel irq-events handler
@action: the irq action chain
@dir: /proc/irq/ procfs entry
@nr_actions: number of installed actions on this descriptor
@name: flow handler name for /proc/interrupts output

When the linux boots, the start_kernel() function calls the early_irq_init() function which probes for the number of preallocated irqs by calling arch_probe_nr_irqs() function and allocates the irq_desc structure for each irqs by calling alloc_desc() function and also initializes various fields to their default values.

This entry was posted in Technical and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *