Hello all,
I have a A53 based platform. There are multiple IRQ sources, some of which fire at the same time. To avoid recursive IRQ handler calls, I have disabled IRQs' on entry in IRQ handler and enabled them befor exit. However, at one point, there is a IRQ pending while I am in IRQ handler and as soon as I re-enable IRQ's, the IRQ handler is called again. This time core thinks that ELR should hold (PC+4) which is beyond the return statement of IRQ handler. Everything goes haywire from there. My code:
__irq void irqHandler(void){ unsigned int ID;
__disable_irq(); __isb(0xF); __dsb(0xF);
ID = readAliasedIntAck(); // Run specific handler writeAliasedEOI(ID); __enable_irq(); // <--- Second interrupt processed here, resulting in a call to irqHandler.
return;}<-------- ELR points here
1) Is there any way I can ensure that IRQs' are not serviced untill I exit the handler?2) Do I *have* to write a re-entrant IRQ handler?3) If yes, is the code available online since this is a pretty standard use-case?
Thanks a lot for helping.
You don't need to modify the interrupt mask (PSTATE.I/F or CPSR.I/F) inside the interrupt handlers - unless you want to write a re-entrant handler.
This is because taking an interrupt causes the mask bit to be set. Meaning that on entry to the handler interrupt are already masked.
The mask bits get set back to their original state when you restore the SPSR to the PSTATE/CPSR as part of the exception return.