I'm new to Cortex A5 and I'm trying to figure out how the interrupts work.
From my understanding, the Cortex A5 starts in secure mode and I don't change it. Now I set up the "secure interrupt controller" (of course only accessible in secure mode) and let it fire an FIQ interrupt. Now, from within the interrupt, should I be able to talk to the "secure interrupt controller", or does that require changing the SCR first, so the FIQ gets me to "monitor mode" instead? Is there any way to access secure peripherals from within FIQs?
Actually it's an Atmel SAMA5D2, having a non secure interrupt controller on IRQ and a secure one on FIQ.
What does it depend on if interrupts are coming in in secure or non-secure state? I guess changing the state of the application doesn't automatically change the state of the IRQs and FIQs?
This is a diagram we use in training to explain this idea:
Consider a couple of scenarios. First the two easy ones:
1) You are in Non-secure state and receive a Non-secure interrupt (IRQ). We want to enter IRQ mode, and handle the interrupt normally. So while in Non-secure state we want SCR.IRQ==0.
2) You are in Secure state and receive a Secure interrupt (FIQ). We want to enter FIQ mode, and handle the interrupt normally. So while in Secure state we want SCR.FIQ==0.
Now for a trickier one:
3) You are in Non-secure state and receive a Secure interrupt (FIQ). We want to enter _Secure_ FIQ mode in order to deal with the interrupt. But in order to do this, we first need to enter Monitor mode in order to do the world switch. To achieve this we set SCR.FIQ==1 while in Non-secure state.