From 6782c3ea236b737389dd6df1d361dfdfd6d910a2 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 18 Jan 2017 11:33:21 -0600 Subject: [PATCH] arm: cmsis: Convert relocate_vector_table to use CMSIS Replace _scs_relocate_vector_table with direct CMSIS register access and use of __ISB/__DSB routinues. We also cleanup the code a little bit to just have one implentation of relocate_vector_table() on ARMv7-M. Jira: ZEP-1568 Change-Id: I088c30e680a7ba198c1527a5822114b70f10c510 Signed-off-by: Kumar Gala --- arch/arm/core/cortex_m/prep_c.c | 15 ++++++--------- include/arch/arm/cortex_m/scs.h | 31 ------------------------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/arch/arm/core/cortex_m/prep_c.c b/arch/arm/core/cortex_m/prep_c.c index d4ed186700b..19c31d5063d 100644 --- a/arch/arm/core/cortex_m/prep_c.c +++ b/arch/arm/core/cortex_m/prep_c.c @@ -27,19 +27,16 @@ static inline void relocate_vector_table(void) { /* do nothing */ } #elif defined(CONFIG_ARMV7_M) #ifdef CONFIG_XIP -static inline void relocate_vector_table(void) -{ - /* vector table is located at the the beginning of the flash */ - _scs_relocate_vector_table((void *)(CONFIG_FLASH_BASE_ADDRESS + - CONFIG_TEXT_SECTION_OFFSET)); -} +#define VECTOR_ADDRESS (CONFIG_FLASH_BASE_ADDRESS + CONFIG_TEXT_SECTION_OFFSET) #else +#define VECTOR_ADDRESS CONFIG_SRAM_BASE_ADDRESS +#endif static inline void relocate_vector_table(void) { - /* vector table is already in SRAM, just point to it */ - _scs_relocate_vector_table((void *)CONFIG_SRAM_BASE_ADDRESS); + SCB->VTOR = VECTOR_ADDRESS & SCB_VTOR_TBLOFF_Msk; + __DSB(); + __ISB(); } -#endif #else #error Unknown ARM architecture #endif /* CONFIG_ARMv6_M */ diff --git a/include/arch/arm/cortex_m/scs.h b/include/arch/arm/cortex_m/scs.h index 0caf3b3a7df..dd0e3de0074 100644 --- a/include/arch/arm/cortex_m/scs.h +++ b/include/arch/arm/cortex_m/scs.h @@ -589,37 +589,6 @@ extern volatile struct __scs __scs; #error Unknown ARM architecture #endif /* CONFIG_ARMV6_M */ -/* API */ -#if defined(CONFIG_ARMV6_M) -#elif defined(CONFIG_ARMV7_M) -/** - * - * @brief Relocate the vector table - * - * Set the address of the vector table to the new address @a new_addr provided. - * - * It must be aligned on a 128-byte boundary. - * - * This routine must be called with interrupts locked and all sources of - * interrupts disabled. - * - * @param new_addr The new address of the vector table. - * - * @return N/A - */ - -static inline void _scs_relocate_vector_table(void *new_addr) -{ - __scs.scb.vtor.val = ((uint32_t)new_addr & 0xffffff80); - __asm__ volatile( - "dsb\n\t" - "isb\n\t" - :::); -} -#else -#error Unknown ARM architecture -#endif /* CONFIG_ARMV6_M */ - #endif /* _ASMLANGUAGE */ #ifdef __cplusplus