Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


void (*end)(unsigned int irq);
void (*set_affinity)(unsigned int irq, cpumask_t dest);
...
int (*set_type)(unsigned int irq, unsigned int flow_type);
...

The structure needs to account for all peculiarities ofthe different IRQ implementations that appear in the
kernel. Thus, a particular instance of the structure usually only defines a subset of all possible methods.


nameholds a short string to identify the hardware controller. Possible values on IA-32 systems are ‘‘XT-
PIC‘‘ and ‘‘IO-APIC,’’ and the latter one is also used for most interrupts on AMD64 systems. On other
systems there is a colorful mix of values because many different controller types are available and in
widespread use.


The function pointers have the following meaning:


❑ startuprefers to a function for the first-time initialization of an IRQ. In most cases, initialization
is limited to enabling the IRQ. As a result, thestartupfunction is just a means of forwarding to
enable.
❑ enableactivates an IRQ; in other words, it performs a transition from the disabled to the enabled
state. To this end, hardware-specific numbers must be written to hardware-specific points in I/O
memory or in the I/O ports.
❑ disableis the counterpart toenableand is used to deactivate an IRQ.shutdowncompletely
closes down an interrupt source. If this is not explicitly possible, the function is an alias for
disable.
❑ ackis closely linked with the hardware of the interrupt controller. In somemodels, the arrival
of an IRQ request (and therefore of the corresponding interrupt at the processor) must be explic-
itly acknowledged so that subsequent requests can be serviced. If a chipset does not issue this
request, the pointer can be supplied with a dummy function or a null pointer.ack_and_mask
acknowledges an interrupt, but masks it in addition afterward.
❑ endis called to mark the end of interrupt processing at the flow level. If an interrupt was dis-
abled during interrupt processing, it is the responsibility of this handler to re-enable it again.
❑ Modern interrupt controllers do not need much flow control from the kernel, but manage nearly
everything themselves out of the box. A single callback to the hardware is required when inter-
rupts are processed, and this callback is provided ineoi—end of interrupt.
❑ In multiprocessor systems,set_affinitycan be used to declare the affinity of a CPU for spec-
ified IRQs. This allows IRQs to be distributed to certain CPUs (typically, IRQs on SMP systems
are spread evenly across all processors). This method has no relevance on single-processor sys-
tems and is therefore supplied with a null pointer.
❑ set_typeallows for setting the IRQ flow type. This is mostly required on ARM, PowerPC, and
SuperH machines; other systems can do without and setset_typetoNULL.
The auxiliary functionset_irq_type(irq, type)is a convenience function to set the IRQ type
forirq.ThetypesIRQ_TYPE_RISINGandIRQ_TYPE_FALLINGspecify edge-triggered interrupts
that use the rising of falling flank, whileIRQ_TYPE_EDGE_BOTHworks for both flank types. Level-
triggered interrupts are denoted byIRQ_TYPE_LEVEL_HIGHandIRQ_TYPE_LEVEL_LOW— you will
have guessed that low and high signal levels are distinguished.IRQ_TYPE_NONE, finally, sets an
unspecified type.
Free download pdf