From d56c613b7dadd2966fed2900acd8b4b5e69bbf70 Mon Sep 17 00:00:00 2001 From: Ouss4 Date: Thu, 7 May 2020 00:45:42 +0100 Subject: [PATCH] arch/avr,renesas,risc-v: The *_getsp function was moved to a header file, remove it from the different source files that used to implement it to avoid redefinitions. --- arch/avr/src/avr/up_dumpstate.c | 23 +---------------------- arch/avr/src/avr32/up_dumpstate.c | 19 +------------------ arch/avr/src/common/up_assert.c | 2 +- arch/renesas/src/common/up_assert.c | 2 +- arch/renesas/src/m16c/m16c_dumpstate.c | 20 +------------------- arch/renesas/src/rx65n/rx65n_dumpstate.c | 15 +-------------- arch/renesas/src/sh1/sh1_dumpstate.c | 20 +------------------- arch/risc-v/src/rv32im/riscv_assert.c | 19 ++----------------- arch/risc-v/src/rv64gc/riscv_assert.c | 19 ++----------------- 9 files changed, 11 insertions(+), 128 deletions(-) diff --git a/arch/avr/src/avr/up_dumpstate.c b/arch/avr/src/avr/up_dumpstate.c index f94d1bfe81..0dc4c69c2d 100644 --- a/arch/avr/src/avr/up_dumpstate.c +++ b/arch/avr/src/avr/up_dumpstate.c @@ -58,27 +58,6 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -/* There may be a built-in to do this, but I don't know if it is enabled */ - -static inline uint16_t up_getsp(void) -{ - uint8_t spl; - uint8_t sph; - - __asm__ __volatile__ - ( - "in %0, __SP_L__\n\t" - "in %1, __SP_H__\n" - : "=r" (spl), "=r" (sph) - : - ); - return (uint16_t)sph << 8 | spl; -} - /**************************************************************************** * Name: up_stackdump ****************************************************************************/ @@ -161,7 +140,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint16_t sp = up_getsp(); + uint16_t sp = avr_getsp(); uint16_t ustackbase; uint16_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 0 diff --git a/arch/avr/src/avr32/up_dumpstate.c b/arch/avr/src/avr32/up_dumpstate.c index 41837db4a2..f818041db0 100644 --- a/arch/avr/src/avr32/up_dumpstate.c +++ b/arch/avr/src/avr32/up_dumpstate.c @@ -58,23 +58,6 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -/* I don't know if the builtin to get SP is enabled */ - -static inline uint32_t up_getsp(void) -{ - uint32_t retval; - __asm__ __volatile__ ( - "mov\t%0,sp\n\t" - : "=r" (retval) - : - ); - return retval; -} - /**************************************************************************** * Name: up_stackdump ****************************************************************************/ @@ -127,7 +110,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint32_t sp = up_getsp(); + uint32_t sp = avr_getsp(); uint32_t ustackbase; uint32_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 3 diff --git a/arch/avr/src/common/up_assert.c b/arch/avr/src/common/up_assert.c index 2bba6afa40..c5c21eaab6 100644 --- a/arch/avr/src/common/up_assert.c +++ b/arch/avr/src/common/up_assert.c @@ -172,7 +172,7 @@ void up_assert(const uint8_t *filename, int lineno) syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), running_task(), filename, lineno); + board_crashdump(avr_getsp(), running_task(), filename, lineno); #endif #ifdef CONFIG_ARCH_USBDUMP diff --git a/arch/renesas/src/common/up_assert.c b/arch/renesas/src/common/up_assert.c index 6d9ad53908..131782e353 100644 --- a/arch/renesas/src/common/up_assert.c +++ b/arch/renesas/src/common/up_assert.c @@ -178,7 +178,7 @@ void up_assert(const uint8_t *filename, int lineno) syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), running_task(), filename, lineno); + board_crashdump(renesas_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/renesas/src/m16c/m16c_dumpstate.c b/arch/renesas/src/m16c/m16c_dumpstate.c index 09c7ce4b0c..95186e0a6b 100644 --- a/arch/renesas/src/m16c/m16c_dumpstate.c +++ b/arch/renesas/src/m16c/m16c_dumpstate.c @@ -62,24 +62,6 @@ static uint8_t s_last_regs[XCPTCONTEXT_REGS]; * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: m16c_getsp - ****************************************************************************/ - -static inline uint16_t m16c_getsp(void) -{ - uint16_t sp; - - __asm__ __volatile__ - ( - "\tstc sp, %0\n\t" - : "=r" (sp) - : - : "memory" - ); - return sp; -} - /**************************************************************************** * Name: m16c_getusersp ****************************************************************************/ @@ -152,7 +134,7 @@ static inline void m16c_registerdump(void) void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint16_t sp = m16c_getsp(); + uint16_t sp = renesas_getsp(); uint16_t ustackbase; uint16_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 3 diff --git a/arch/renesas/src/rx65n/rx65n_dumpstate.c b/arch/renesas/src/rx65n/rx65n_dumpstate.c index e72cdd4dd6..225131f909 100644 --- a/arch/renesas/src/rx65n/rx65n_dumpstate.c +++ b/arch/renesas/src/rx65n/rx65n_dumpstate.c @@ -48,19 +48,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS]; * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -uint16_t up_getsp(void) -{ - uint16_t sp; - - __asm__ __volatile__("\tmvfc usp, %0\n\t": "=r" (sp):: "memory"); /* check */ - - return sp; -} - /**************************************************************************** * Name: rx65n_getusersp ****************************************************************************/ @@ -141,7 +128,7 @@ static inline void rx65n_registerdump(void) void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint32_t sp = up_getsp(); + uint32_t sp = renesas_getsp(); uint32_t ustackbase; uint32_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 3 diff --git a/arch/renesas/src/sh1/sh1_dumpstate.c b/arch/renesas/src/sh1/sh1_dumpstate.c index 7a1b6a240a..973a987fbd 100644 --- a/arch/renesas/src/sh1/sh1_dumpstate.c +++ b/arch/renesas/src/sh1/sh1_dumpstate.c @@ -61,24 +61,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS]; * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: sh1_getsp - ****************************************************************************/ - -static inline uint32_t sh1_getsp(void) -{ - uint32_t sp; - - __asm__ __volatile__ - ( - "mov r15, %0\n\t" - : "=&z" (sp) - : - : "memory" - ); - return sp; -} - /**************************************************************************** * Name: sh1_stackdump ****************************************************************************/ @@ -142,7 +124,7 @@ static inline void sh1_registerdump(void) void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint32_t sp = sh1_getsp(); + uint32_t sp = renesas_getsp(); uint32_t ustackbase; uint32_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 3 diff --git a/arch/risc-v/src/rv32im/riscv_assert.c b/arch/risc-v/src/rv32im/riscv_assert.c index 7711ad8a3e..f0688ed98b 100644 --- a/arch/risc-v/src/rv32im/riscv_assert.c +++ b/arch/risc-v/src/rv32im/riscv_assert.c @@ -80,21 +80,6 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -static inline uint32_t up_getsp(void) -{ - register uint32_t sp; - __asm__ - ( - "\tadd %0, x0, x2\n" - : "=r"(sp) - ); - return sp; -} - /**************************************************************************** * Name: up_stackdump ****************************************************************************/ @@ -200,7 +185,7 @@ static inline void up_registerdump(void) static void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint32_t sp = up_getsp(); + uint32_t sp = riscv_getsp(); uint32_t ustackbase; uint32_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 3 @@ -396,7 +381,7 @@ void up_assert(const uint8_t *filename, int lineno) syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), running_task(), filename, lineno); + board_crashdump(riscv_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/risc-v/src/rv64gc/riscv_assert.c b/arch/risc-v/src/rv64gc/riscv_assert.c index 42d3cbd11f..cae90de17f 100644 --- a/arch/risc-v/src/rv64gc/riscv_assert.c +++ b/arch/risc-v/src/rv64gc/riscv_assert.c @@ -82,21 +82,6 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -static inline uint64_t up_getsp(void) -{ - register uint64_t sp; - __asm__ - ( - "\tadd %0, x0, x2\n" - : "=r"(sp) - ); - return sp; -} - /**************************************************************************** * Name: up_stackdump ****************************************************************************/ @@ -211,7 +196,7 @@ static inline void up_registerdump(void) static void up_dumpstate(void) { struct tcb_s *rtcb = running_task(); - uint64_t sp = up_getsp(); + uint64_t sp = riscv_getsp(); uintptr_t ustackbase; uintptr_t ustacksize; #if CONFIG_ARCH_INTERRUPTSTACK > 7 @@ -427,7 +412,7 @@ void up_assert(const uint8_t *filename, int lineno) syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), running_task(), filename, lineno); + board_crashdump(riscv_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE);