boot/zephyr: add option to relocate interrupts to application
If CONFIG_BOOT_INTR_VEC_RELOC is set, the mcuboot will
relocate the interrupt vector to the booted application.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index 1bea3bb..2b246ce 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -98,6 +98,18 @@
void os_heap_init(void);
#if defined(CONFIG_ARM)
+
+#ifdef CONFIG_BOOT_INTR_VEC_RELOC
+
+#ifdef CONFIG_SW_VECTOR_RELAY
+extern void *_vector_table_pointer;
+#define VTOR _vector_table_pointer
+#elif CONFIG_CPU_CORTEX_M_HAS_VTOR
+#define VTOR SCB->VTOR
+#endif
+
+#endif /* CONFIG_BOOT_INTR_VEC_RELOC */
+
struct arm_vector_table {
uint32_t msp;
uint32_t reset;
@@ -133,6 +145,11 @@
#if CONFIG_MCUBOOT_CLEANUP_ARM_CORE
cleanup_arm_nvic(); /* cleanup NVIC registers */
#endif
+
+#ifdef CONFIG_BOOT_INTR_VEC_RELOC
+ VTOR = vt;
+#endif
+
__set_MSP(vt->msp);
#if CONFIG_MCUBOOT_CLEANUP_ARM_CORE
__set_CONTROL(0x00); /* application will configures core on its own */