arch: arm: aarch32: Always use VTOR when it is available
Zephyr applications will always use the VTOR register when it is available on the CPU and the register will always be configured to point to applications vector table during startup. SW_VECTOR_RELAY_CLIENT is meant to be used only on baseline ARM cores. SW_VECTOR_RELAY is intended to be used only by the bootloader. The bootloader may configure the VTOR to point to the relay table right before chain-loading the application. Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
This commit is contained in:
parent
4152ccf124
commit
f2b0bfda8f
4 changed files with 22 additions and 33 deletions
|
@ -276,12 +276,13 @@ config SW_VECTOR_RELAY
|
|||
|
||||
config SW_VECTOR_RELAY_CLIENT
|
||||
bool "Enable Software Vector Relay (client)"
|
||||
depends on !SW_VECTOR_RELAY
|
||||
default y if BOOTLOADER_MCUBOOT && !(CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP || CPU_CORTEX_M_HAS_VTOR)
|
||||
default y if BOOTLOADER_MCUBOOT
|
||||
depends on ARMV6_M_ARMV8_M_BASELINE && !(CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP || CPU_CORTEX_M_HAS_VTOR)
|
||||
help
|
||||
Another image has enabled SW_VECTOR_RELAY, and will relay interrupts
|
||||
to this image. Enable this to make sure the vector table pointer in
|
||||
RAM is left alone.
|
||||
Another image has enabled SW_VECTOR_RELAY, and will be forwarding
|
||||
exceptions and HW interrupts to this image. Enable this option to make
|
||||
sure the vector table pointer in RAM is set properly by the image upon
|
||||
initialization.
|
||||
|
||||
endmenu
|
||||
|
||||
|
|
|
@ -30,5 +30,3 @@
|
|||
|
||||
KEEP(*(.vector_relay_table))
|
||||
KEEP(*(".vector_relay_table.*"))
|
||||
KEEP(*(.vector_relay_handler))
|
||||
KEEP(*(".vector_relay_handler.*"))
|
||||
|
|
|
@ -29,7 +29,7 @@ _ASM_FILE_PROLOGUE
|
|||
GDATA(_vector_table_pointer)
|
||||
GDATA(z_main_stack)
|
||||
|
||||
SECTION_FUNC(vector_relay_handler, __vector_relay_handler)
|
||||
SECTION_FUNC(TEXT, __vector_relay_handler)
|
||||
mrs r0, ipsr;
|
||||
lsls r0, r0, $0x02;
|
||||
|
||||
|
|
|
@ -37,42 +37,31 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
#ifdef CONFIG_SW_VECTOR_RELAY
|
||||
#define VECTOR_ADDRESS ((uintptr_t)__vector_relay_table)
|
||||
#else
|
||||
#define VECTOR_ADDRESS ((uintptr_t)_vector_start)
|
||||
#endif
|
||||
#else /* CONFIG_XIP */
|
||||
#define VECTOR_ADDRESS CONFIG_SRAM_BASE_ADDRESS
|
||||
#endif /* CONFIG_XIP */
|
||||
|
||||
#else /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
|
||||
|
||||
#define VECTOR_ADDRESS 0
|
||||
|
||||
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
|
||||
|
||||
#if defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
|
||||
Z_GENERIC_SECTION(.vt_pointer_section) __attribute__((used))
|
||||
void *_vector_table_pointer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_CPU_CORTEX_M_HAS_VTOR
|
||||
static inline void relocate_vector_table(void)
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
#define VECTOR_ADDRESS ((uintptr_t)_vector_start)
|
||||
#else
|
||||
void __weak relocate_vector_table(void)
|
||||
#define VECTOR_ADDRESS CONFIG_SRAM_BASE_ADDRESS
|
||||
#endif
|
||||
static inline void relocate_vector_table(void)
|
||||
{
|
||||
#if defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) && !defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
|
||||
SCB->VTOR = VECTOR_ADDRESS & SCB_VTOR_TBLOFF_Msk;
|
||||
__DSB();
|
||||
__ISB();
|
||||
#endif
|
||||
#if !defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define VECTOR_ADDRESS 0
|
||||
|
||||
void __weak relocate_vector_table(void)
|
||||
{
|
||||
#if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \
|
||||
!defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0)
|
||||
size_t vector_size = (size_t)_vector_end - (size_t)_vector_start;
|
||||
|
@ -80,13 +69,14 @@ void __weak relocate_vector_table(void)
|
|||
#elif defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT)
|
||||
_vector_table_pointer = _vector_start;
|
||||
#endif
|
||||
#endif /* !defined(CONFIG_CPU_CORTEX_M_HAS_VTOR) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT) */
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
|
||||
|
||||
#if defined(CONFIG_CPU_HAS_FPU)
|
||||
static inline void z_arm_floating_point_init(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue