A
Aleksandar Kuktin
Guest
Hi all.
Some time ago, I designed a small and simple CPU to go into a project I
am sort-of working on (when can I steal the time to do so). Now, I added
an interrupt mechanism to it and encountered a problem when I tried to
turn the one-interrupt interrupt into a multiple-interrupt interrupt -
the kind all other CPUs have these days.
Here's my gripe: suppose the CPU enters interrupt 1. While it is
interrupted, IRQ2 comes in. And then IRQ3 comes in, followed by IRQ4. WTF
am I supposed to do now? I want all IRQ-s to be handled. So, no ignoring.
My first idea was to make a stack and push the interrupt contexts onto
the stack as new IRQs come in and pop them as the software interrupt
handlers return. But this is far too elaborate to be implemented in
reasonably little resources.
My second idea was to have every IRQ assert a bit in a special reqister
before asserting the unified IRQ signal. Then I would mandate that the
software interrupt handler iterates over the register and handles IRQs
that it finds asserted. And when it is done, the interrupt handler would
reiterate over the register to catch any interrupts that came in during
the handling of the previous ones. I currently plan to use a variant of
this method.
While writing this I also came up with the option of deffering IRQs until
the previous one's handling returns. Probably with some sort of a stack.
If done correctly, it should take little resources.
What to other CPUs usualy do in these situations?
Some time ago, I designed a small and simple CPU to go into a project I
am sort-of working on (when can I steal the time to do so). Now, I added
an interrupt mechanism to it and encountered a problem when I tried to
turn the one-interrupt interrupt into a multiple-interrupt interrupt -
the kind all other CPUs have these days.
Here's my gripe: suppose the CPU enters interrupt 1. While it is
interrupted, IRQ2 comes in. And then IRQ3 comes in, followed by IRQ4. WTF
am I supposed to do now? I want all IRQ-s to be handled. So, no ignoring.
My first idea was to make a stack and push the interrupt contexts onto
the stack as new IRQs come in and pop them as the software interrupt
handlers return. But this is far too elaborate to be implemented in
reasonably little resources.
My second idea was to have every IRQ assert a bit in a special reqister
before asserting the unified IRQ signal. Then I would mandate that the
software interrupt handler iterates over the register and handles IRQs
that it finds asserted. And when it is done, the interrupt handler would
reiterate over the register to catch any interrupts that came in during
the handling of the previous ones. I currently plan to use a variant of
this method.
While writing this I also came up with the option of deffering IRQs until
the previous one's handling returns. Probably with some sort of a stack.
If done correctly, it should take little resources.
What to other CPUs usualy do in these situations?