I am writing a bootloader for an ARM Cortex-M0 CPU. I need to forward the IRQs to the target app, unfortunately the IRQ vector in this CPU is at fixed address and I cannot relocate it, so I need a bit of trickery.
I know the address where the addresses of the target app's IRQs are stored. So let's say, at address 0x5008 there's the address of void x_IRQHandler(void) (target app)
What I want to do is:
- at start up save the addresses of all x_IRQHandler() (so that it is not calculated at run-time);
- whenever an IRQ call is received by the bootloader, call the related IRQ function in the target app from its address.
This is what I have done in the bootloader, I can't find the right syntax for it.
//pointers to x_IRQHandler() functions
void(* x_IRQ_addr)(void);
x_IRQ_addr = (void(*)(void))(0x5008);
//here I should call the function pointed by x_IRQ_addr; but this syntax is not valid
void x_IRQ_Handler(void)
{
*x_IRQ_addr();
}
I have tried different approaches with no success, how can I fix that?