Re: AW: Interrupt handling
Espen Skoglund <[email protected]>
| Newsgroups | gmane.comp.micro-kernel.l4.l4ka.general |
|---|---|
| Message-ID | <[email protected]> |
[Martin Christian]
> Hi Sergio!
>> after having read the byte from the serial input data port,
>> you should clear the relevant interrupt bit in the serial device
> The serial device (which is part of the bridge) has two types of
> registers:
> a) Interrupt Cause (cr)
> b) Interrupt Mask (mr)
> This is my understanding of ACK and MASK:
> 1.) ACK an interrupt means: cr <- 0
> 2.) MASK an interrupt means: mr <- 0
> My understanding of the whole interrupt handling is this:
> 1.) The kernel calls handle_irq(), which is provided by the platform
> 2.) handle_irq() calls a mask_and_ack()
> 3.) mask_and_ack does MASK and ACK (see above), which means it tells the
> device "I've seen your interrupt" and disables it untils it's handled
> 4.) handle_irq() calls the kernels handle_interrupt()
> 5.) The kernel creates an interrupt thread which sends an IPC to a
> registered interrupt handler
> 6.) Now we are in user mode! The interrupt handler receives the
> interrupt and does something meaningfull
> 7.) After handling the interrupt, the user mode handler sends back an
> IPC to the kernel interrupt thread
> 8.) The kernel interrupt thread should unmask the interrupt again and
> finish.
> Please correct me, if I'm wrong! I especially don't see a reason why a
> user mode thread should unmask the interrupt. It's all low level stuff.
The kernel does not mask or ack any interrupts on the device level
since it has no knowledge of specific devices. It only masks and acks
interrupts on the interrupt controller level.
Here's rougly the process of handling incomming interrupts, assuming
that the user-level interrupt handler thread is waiting for the
incomming interrupt. Some steps are slightly different if handler
thread is not waiting, but the concepts remain the same.
1) Interrupt is received in intctrl_t::handle_irq().
2) handle_irq() masks and acks the interrupt on the interrupt
controller. Then calls the main handle_interrupt().
3) handle_interrupt() sends the interrupt IPC to the user-level
interrupt handler on behalf of the in-kernel irq_thread().
4) handle_interrupt() then sets irq_thread() to wait for interrupt
ack IPC from the user-level interrupt handler thread.
5) User-level interrupt handler thread handles the interrupt and
possibly acks it on the device level.
6) The user-level handler replies back to the in-kernel
irq_thread() with an ack IPC.
7) Upon receiving the ack, the in-kernel irq_thread() unmasks the
corresponding interrupt on the interrupt controller.
No more interrupts will be delivered on the IRQ until step 7 is taken
and interrupt has been acked on the device itself (if applicable).
eSk