You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/05/07 03:56:51 UTC
[incubator-nuttx] 03/04: 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.
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit d56c613b7dadd2966fed2900acd8b4b5e69bbf70
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Thu May 7 00:45:42 2020 +0100
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 f94d1bf..0dc4c69 100644
--- a/arch/avr/src/avr/up_dumpstate.c
+++ b/arch/avr/src/avr/up_dumpstate.c
@@ -59,27 +59,6 @@
****************************************************************************/
/****************************************************************************
- * 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 41837db..f818041 100644
--- a/arch/avr/src/avr32/up_dumpstate.c
+++ b/arch/avr/src/avr32/up_dumpstate.c
@@ -59,23 +59,6 @@
****************************************************************************/
/****************************************************************************
- * 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 2bba6af..c5c21ea 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 6d9ad53..131782e 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 09c7ce4..95186e0 100644
--- a/arch/renesas/src/m16c/m16c_dumpstate.c
+++ b/arch/renesas/src/m16c/m16c_dumpstate.c
@@ -63,24 +63,6 @@ static uint8_t s_last_regs[XCPTCONTEXT_REGS];
****************************************************************************/
/****************************************************************************
- * 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 e72cdd4..225131f 100644
--- a/arch/renesas/src/rx65n/rx65n_dumpstate.c
+++ b/arch/renesas/src/rx65n/rx65n_dumpstate.c
@@ -49,19 +49,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS];
****************************************************************************/
/****************************************************************************
- * 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 7a1b6a2..973a987 100644
--- a/arch/renesas/src/sh1/sh1_dumpstate.c
+++ b/arch/renesas/src/sh1/sh1_dumpstate.c
@@ -62,24 +62,6 @@ static uint32_t s_last_regs[XCPTCONTEXT_REGS];
****************************************************************************/
/****************************************************************************
- * 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 7711ad8..f0688ed 100644
--- a/arch/risc-v/src/rv32im/riscv_assert.c
+++ b/arch/risc-v/src/rv32im/riscv_assert.c
@@ -81,21 +81,6 @@
****************************************************************************/
/****************************************************************************
- * 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 42d3cbd..cae90de 100644
--- a/arch/risc-v/src/rv64gc/riscv_assert.c
+++ b/arch/risc-v/src/rv64gc/riscv_assert.c
@@ -83,21 +83,6 @@
****************************************************************************/
/****************************************************************************
- * 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);