Interrupt Handler
1. interrupt flow
Hardware->Interrupt Controller->Processor
2.Interrupt Handler
a. Definition
The function that the kernel runs, in response to a specific interrupt.
b.Difference between other kernel function.
Kernel invoke them.
the run in a special context.
c.Interrupt handle's job
Acknowledge the kernel the interrupt receipt.
it's divided into bottom half and top half.
the top half copy data, enable interrupt and leave the left job to the bottom half.
d. the interrupt handler is registered by the driver.
3 Interrupt flag
SA_INTERRUPT , disable interruption.
int request_irq(,,void *dev_id)
the last one is the unique id if the interrupt is shared.
4.Since kernel is one thread, it's not scheduled
so it mustn't sleep in the kernel. so sleep can't be called in the interrupt handler.
5.Why the function request_irq may sleep?
register->/proc/irq/->proc_mkdir()->proc_create()->kmalloc(), and kmalloc may sleep.
notation:
initialize the device first, and then register the handler to prevent the handler to run when the device is not initialized.
6 void free_irq(unsigned int irq, void *dev_id)
difference between share and non_shared interrupt
a. request_irq() SA_SHIRQ must be set.
b.dev_id in the request_irq() must be unique.
c.handler must be capable of distinguishing whether the device actually generated the interrupt of not.
if irq shared, the kernel will call all the "Handler" sequentially, if the device didn't generate it, it must return quickly.