I’m try to re direct interrupts, but find that in certain situations I’m getting hard faults. I’ve essentially done the following:
#define VECTOR_MBR 0x20000000
#define VECTOR_OFFSET 16
uint32_t volatile __attribute__((section(".vector_mbr"))) vectorAddr = 0;
typedef void (*p_function)(void);
static void jump_to(int32_t irqn) {
uint32_t *index = (uint32_t *)vectorAddr + VECTOR_OFFSET;
p_function jumpFunc = (p_function)index[irqn];
jumpFunc();
}
#if configUSE_MBR_FUNCTIONS == 1 /* vPortSVCHandler */
void SVC_Handler(void) {
if (vectorAddr == 0) {
SVC_Handler_MBR();
} else {
jump_to(SVCall_IRQn);
}
}
#endif
#if configUSE_MBR_FUNCTIONS == 1 /* xPortPendSVHandler */
void PendSV_Handler(void) {
if (vectorAddr == 0) {
PendSV_Handler_MBR();
} else {
jump_to(PendSV_IRQn);
}
}
void SysTick_Handler(void) { /* xPortSysTickHandler */
if (vectorAddr == 0) {
SysTick_Handler_MBR();
} else {
jump_to(SysTick_IRQn);
}
}
#endif
and in FreeRTOS config
#if configUSE_MBR_FUNCTIONS == 1
void SysTick_Handler(void);
#define xPortSysTickHandler SysTick_Handler_MBR
#else
#define xPortSysTickHandler SysTick_Handler
#endif
#if configUSE_MBR_FUNCTIONS == 1
#define xPortPendSVHandler PendSV_Handler_MBR
#define vPortSVCHandler SVC_Handler_MBR
#define xPortSysTickHandler SysTick_Handler_MBR
#else
#define xPortPendSVHandler PendSV_Handler
#define vPortSVCHandler SVC_Handler
#define xPortSysTickHandler SysTick_Handler
#endif
Is there an obvious reason this would cause a hard fault, or do I need to look elsewhere?
In testing here, vectorAddr == 0 and I know its calling the _MBR functions.