Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


void *handler_data;
void *chip_data;
struct irqaction *action; /* IRQ action list */
unsigned int status; /* IRQ status */

unsigned int depth; /* nested irq disables */
unsigned int irq_count; /* For detecting broken IRQs */
unsigned int irqs_unhandled;
...
const char *name;
} ____cacheline_internodealigned_in_smp;

In the view of the high-level code in the kernel, eachIRQ is fully described by this structure. The three
abstraction layers introduced above are represented in the structure as follows:


❑ The flow-level ISR is provided byhandle_irq.handler_datamay point to some arbitrary, IRQ,
and handler function-specific data.handle_irqis called by the architecture-specific code when-
ever an interrupt occurs. The function is then responsible to use the controller-specific methods
provided inchipto perform the necessary low-level actions required to process the interrupt.
Default functions for various interrupt types are provided by the kernel. Examples for such han-
dler functions are discussed in Section 14.1.5.
❑ actionprovides a chain of actions that need to be executed when the interrupt occurs. This is
the place where device drivers for devices that are notified by the interrupt can place their spe-
cific handler functions. A special data structure is used to represent these actions, discussed in
Section 14.1.4.
❑ Flow handling and chip-specific operations are encapsulated inchip. A special data structure is
introduced for this purpose, covered in a moment.chip_datapoints to arbitrary data that may
be associated withchip.
❑ namespecifies a name for the flow handler that is displayed in/proc/interrupts. This line is
usually either ‘‘edge’’ for edge-, or ‘‘level’’ for level-triggered interrupts.

There are some more elements in the structure that need to be described.depthhas two tasks. It can be
used to determine whether an IRQ line is enabled or disabled. A positive value indicates that the latter
is true, whereas 0 indicates an enabled line. Why are positive values used fordisabledIRQs? Because
this allows the kernel to differentiate between enabled and disabled lines and also to repeatedly disable
one and the same interrupt. Each time code from the remaining part of the kernel disables an interrupt,
the counter is incremented by 1; each time the interrupt is enabled again, the counter is decremented
accordingly. Only whendepthhas returned to 0 may the IRQ be freed again by the hardware. This
approach supports the correct handling of nested disabling of interrupts.


An IRQ can change its status not only during handler installation but also at run time:statusdescribes
the current status. The<irq.h>file defines various constants that describe the current IRQ line status.
Each constant stands for a set bit in a bit string, and several values can be set at the same time, providing
that they do not contradict each other.


❑ IRQ_DISABLEDis used for an IRQ line disabled by a device driver. It instructs the kernel not to
enter the handler.
❑ During execution of an IRQ handler the state is set toIRQ_INPROGRESS.AswithIRQ_DISABLED,
this prohibits the remaining kernel code from executing the handler.
Free download pdf