From 272534eb725f2486b7a32b39d998202a101bd36e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 18 Dec 2020 10:11:51 +0100 Subject: bsps/arm: Set VBAR in start.S Set the VBAR to the vector table in the start section before bsp_start_hook_0() is called to earlier handle exceptions in RTEMS. Set the VBAR to the normal vector table in start.S for the main processor. Secondary processors set it in bsp_start_hook_0(). Update #4202. --- bsps/arm/shared/start/start.S | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'bsps/arm/shared/start/start.S') diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S index 93590c1c36..9ebc2818e5 100644 --- a/bsps/arm/shared/start/start.S +++ b/bsps/arm/shared/start/start.S @@ -377,6 +377,20 @@ _start: #endif /* ARM_MULTILIB_VFP */ +#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A') || __ARM_ARCH >= 8 + /* + * Set VBAR to the vector table in the start section and make sure + * SCTLR[V] is cleared. Afterwards, exceptions are handled by RTEMS. + */ + ldr r0, =bsp_start_vector_table_begin + dsb + mcr p15, 0, r0, c12, c0, 0 + mrc p15, 0, r0, c1, c0, 0 + bic r1, r0, #0x2000 + mcr p15, 0, r1, c1, c0, 0 + isb +#endif + /* * Invoke the start hook 0. * @@ -414,7 +428,7 @@ bsp_start_hook_0_done: stmdb sp!, {r4, r5, r6} ldr r0, =bsp_vector_table_begin - adr r1, bsp_start_vector_table_begin + ldr r1, =bsp_start_vector_table_begin cmp r0, r1 beq .Lvector_table_copy_done ldmia r1!, {r2-r9} @@ -424,6 +438,18 @@ bsp_start_hook_0_done: .Lvector_table_copy_done: +#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A') || __ARM_ARCH >= 8 + /* + * This code path is only executed by the primary processor. Set the + * VBAR to the normal vector table. For secondary processors, this is + * done by bsp_start_hook_0(). + */ + ldr r0, =bsp_vector_table_begin + dsb + mcr p15, 0, r0, c12, c0, 0 + isb +#endif + ldmia sp!, {r0, r1, r2} SWITCH_FROM_ARM_TO_THUMB r3 -- cgit v1.2.3