From 93bf5f58e7721d5a768c00b89b1ea6ce385bb51a Mon Sep 17 00:00:00 2001 From: Evgeniy Paltsev Date: Fri, 7 May 2021 13:40:54 +0300 Subject: [PATCH] ARC: add TLS support for ARCv3 For ARCv3 the register is fixed to r30, so we don't need to configure it at compile-time. Signed-off-by: Eugeniy Paltsev Signed-off-by: Evgeniy Paltsev --- arch/arc/CMakeLists.txt | 9 ++++++--- arch/arc/core/thread.c | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arc/CMakeLists.txt b/arch/arc/CMakeLists.txt index 8135d072f10..66f4848e23d 100644 --- a/arch/arc/CMakeLists.txt +++ b/arch/arc/CMakeLists.txt @@ -12,8 +12,11 @@ zephyr_cc_option(-fno-delete-null-pointer-checks) zephyr_cc_option_ifdef(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS -munaligned-access) -# Instruct compiler to use register R26 as thread pointer -# for thread local storage. -zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26) +if(CONFIG_ISA_ARCV2) + # Instruct compiler to use register R26 as thread pointer + # for thread local storage. + # For ARCv3 the register is fixed to r30, so we don't need to specify it + zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26) +endif() add_subdirectory(core) diff --git a/arch/arc/core/thread.c b/arch/arc/core/thread.c index f0a0fd7ac26..be3b4052111 100644 --- a/arch/arc/core/thread.c +++ b/arch/arc/core/thread.c @@ -122,8 +122,13 @@ static inline void arch_setup_callee_saved_regs(struct k_thread *thread, ARG_UNUSED(regs); #ifdef CONFIG_THREAD_LOCAL_STORAGE - /* R26 is used for thread pointer */ +#ifdef CONFIG_ISA_ARCV2 + /* R26 is used for thread pointer for ARCv2 */ regs->r26 = thread->tls; +#else + /* R30 is used for thread pointer for ARCv3 */ + regs->r30 = thread->tls; +#endif /* CONFIG_ISA_ARCV2 */ #endif }