Skip to content

Commit d230a44

Browse files
committed
Revert "[nrf fromtree] arch: arm: aarch32: Always use VTOR when it is available"
This reverts commit 6b13a51. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 7282ed1 commit d230a44

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

arch/arm/core/aarch32/cortex_m/Kconfig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,12 @@ config SW_VECTOR_RELAY
276276

277277
config SW_VECTOR_RELAY_CLIENT
278278
bool "Enable Software Vector Relay (client)"
279-
default y if BOOTLOADER_MCUBOOT
280-
depends on ARMV6_M_ARMV8_M_BASELINE && !(CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP || CPU_CORTEX_M_HAS_VTOR)
279+
depends on !SW_VECTOR_RELAY
280+
default y if BOOTLOADER_MCUBOOT && !(CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP || CPU_CORTEX_M_HAS_VTOR)
281281
help
282-
Another image has enabled SW_VECTOR_RELAY, and will be forwarding
283-
exceptions and HW interrupts to this image. Enable this option to make
284-
sure the vector table pointer in RAM is set properly by the image upon
285-
initialization.
282+
Another image has enabled SW_VECTOR_RELAY, and will relay interrupts
283+
to this image. Enable this to make sure the vector table pointer in
284+
RAM is left alone.
286285

287286
endmenu
288287

arch/arm/core/aarch32/cortex_m/relay_vector_table.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030

3131
KEEP(*(.vector_relay_table))
3232
KEEP(*(".vector_relay_table.*"))
33+
KEEP(*(.vector_relay_handler))
34+
KEEP(*(".vector_relay_handler.*"))

arch/arm/core/aarch32/irq_relay.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _ASM_FILE_PROLOGUE
2929
GDATA(_vector_table_pointer)
3030
GDATA(z_main_stack)
3131

32-
SECTION_FUNC(TEXT, __vector_relay_handler)
32+
SECTION_FUNC(vector_relay_handler, __vector_relay_handler)
3333
mrs r0, ipsr;
3434
lsls r0, r0, $0x02;
3535

arch/arm/core/aarch32/prep_c.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,56 @@
3737

3838
#include <string.h>
3939

40+
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
41+
42+
#ifdef CONFIG_XIP
43+
#ifdef CONFIG_SW_VECTOR_RELAY
44+
#define VECTOR_ADDRESS ((uintptr_t)__vector_relay_table)
45+
#else
46+
#define VECTOR_ADDRESS ((uintptr_t)_vector_start)
47+
#endif
48+
#else /* CONFIG_XIP */
49+
#define VECTOR_ADDRESS CONFIG_SRAM_BASE_ADDRESS
50+
#endif /* CONFIG_XIP */
51+
52+
#else /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
53+
54+
#define VECTOR_ADDRESS 0
55+
56+
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
57+
4058
#if defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
4159
Z_GENERIC_SECTION(.vt_pointer_section) __attribute__((used))
4260
void *_vector_table_pointer;
4361
#endif
4462

45-
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
4663

47-
#ifdef CONFIG_XIP
48-
#define VECTOR_ADDRESS ((uintptr_t)_vector_start)
64+
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
65+
static inline void relocate_vector_table(void)
4966
#else
50-
#define VECTOR_ADDRESS CONFIG_SRAM_BASE_ADDRESS
67+
void __weak relocate_vector_table(void)
5168
#endif
52-
static inline void relocate_vector_table(void)
5369
{
70+
#if defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) && !defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
5471
SCB->VTOR = VECTOR_ADDRESS & SCB_VTOR_TBLOFF_Msk;
5572
__DSB();
5673
__ISB();
57-
}
58-
59-
#else
60-
61-
#define VECTOR_ADDRESS 0
62-
63-
void __weak relocate_vector_table(void)
64-
{
74+
#endif
75+
#if !defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
6576
#if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \
6677
!defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0)
6778
size_t vector_size = (size_t)_vector_end - (size_t)_vector_start;
6879
(void)memcpy(VECTOR_ADDRESS, _vector_start, vector_size);
6980
#elif defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
7081
_vector_table_pointer = _vector_start;
7182
#endif
83+
#endif /* !defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT) */
7284
}
7385

7486
#if defined(__GNUC__)
7587
#pragma GCC diagnostic pop
7688
#endif
7789

78-
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
79-
8090
#if defined(CONFIG_CPU_HAS_FPU)
8191
static inline void z_arm_floating_point_init(void)
8292
{

0 commit comments

Comments
 (0)