diff --git a/arch/arm/include/armv6-m/irq.h b/arch/arm/include/armv6-m/irq.h index 13921fa503..6d75ccf466 100644 --- a/arch/arm/include/armv6-m/irq.h +++ b/arch/arm/include/armv6-m/irq.h @@ -362,6 +362,12 @@ static always_inline_function uint32_t up_getsp(void) return sp; } +static always_inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + static always_inline_function bool up_interrupt_context(void) { return getipsr() != 0; diff --git a/arch/arm/include/armv7-a/irq.h b/arch/arm/include/armv7-a/irq.h index 98d13aaa99..e086bc1817 100644 --- a/arch/arm/include/armv7-a/irq.h +++ b/arch/arm/include/armv7-a/irq.h @@ -473,6 +473,12 @@ static inline_function uint32_t up_getsp(void) return sp; } +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + noinstrument_function static inline_function void up_set_interrupt_context(bool flag) { diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index 207dbfc3c1..8c1cf80368 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -512,6 +512,12 @@ static always_inline_function uint32_t up_getsp(void) return sp; } +static always_inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + static always_inline_function bool up_interrupt_context(void) { return getipsr() != 0; diff --git a/arch/arm/include/armv7-r/irq.h b/arch/arm/include/armv7-r/irq.h index f82e07803c..5f06261f7c 100644 --- a/arch/arm/include/armv7-r/irq.h +++ b/arch/arm/include/armv7-r/irq.h @@ -468,6 +468,12 @@ static inline_function uint32_t up_getsp(void) return sp; } +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + noinstrument_function static inline_function void up_set_interrupt_context(bool flag) { diff --git a/arch/arm/include/armv8-m/irq.h b/arch/arm/include/armv8-m/irq.h index 66a51f274c..a9fb63b9c8 100644 --- a/arch/arm/include/armv8-m/irq.h +++ b/arch/arm/include/armv8-m/irq.h @@ -487,6 +487,12 @@ static always_inline_function uint32_t up_getsp(void) return sp; } +static always_inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + static always_inline_function bool up_interrupt_context(void) { return getipsr() != 0; diff --git a/arch/arm/include/armv8-r/irq.h b/arch/arm/include/armv8-r/irq.h index 643a697cb5..8c2deef162 100644 --- a/arch/arm/include/armv8-r/irq.h +++ b/arch/arm/include/armv8-r/irq.h @@ -468,6 +468,12 @@ static inline_function uint32_t up_getsp(void) return sp; } +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + noinstrument_function static inline_function void up_set_interrupt_context(bool flag) { diff --git a/arch/arm/include/tlsr82/irq.h b/arch/arm/include/tlsr82/irq.h index fc3d3fb051..7a89ac77a7 100644 --- a/arch/arm/include/tlsr82/irq.h +++ b/arch/arm/include/tlsr82/irq.h @@ -262,6 +262,12 @@ static inline_function uint32_t up_getsp(void) return sp; } +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint32_t *ptr = (uint32_t *)regs; + return ptr[REG_SP]; +} + noinstrument_function static inline_function bool up_interrupt_context(void) { diff --git a/arch/arm/src/common/arm_registerdump.c b/arch/arm/src/common/arm_registerdump.c index f8171844e9..baacabfb10 100644 --- a/arch/arm/src/common/arm_registerdump.c +++ b/arch/arm/src/common/arm_registerdump.c @@ -43,16 +43,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/arm64/include/irq.h b/arch/arm64/include/irq.h index 2f3e1c88c8..d3e1ece7f8 100644 --- a/arch/arm64/include/irq.h +++ b/arch/arm64/include/irq.h @@ -462,6 +462,14 @@ static inline_function void up_irq_restore(irqstate_t flags) #define up_getusrpc(regs) \ (((uintptr_t *)((regs) ? (regs) : running_regs()))[REG_ELR]) +#ifndef CONFIG_BUILD_KERNEL +# define up_getusrsp(regs) \ + ((uintptr_t)((uint64_t *)(regs))[REG_SP_ELX]) +#else +# define up_getusrsp(regs) \ + ((uintptr_t)((uint64_t *)(regs))[REG_SP_EL0]) +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/arm64/src/common/arm64_registerdump.c b/arch/arm64/src/common/arm64_registerdump.c index 4d609128f6..8b016d82a0 100644 --- a/arch/arm64/src/common/arm64_registerdump.c +++ b/arch/arm64/src/common/arm64_registerdump.c @@ -46,19 +46,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ -#ifndef CONFIG_BUILD_KERNEL - return ((uint64_t *)regs)[REG_SP_ELX]; -#else - return ((uint64_t *)regs)[REG_SP_EL0]; -#endif -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/avr/include/irq.h b/arch/avr/include/irq.h index 3f35c40925..cf4dbde368 100644 --- a/arch/avr/include/irq.h +++ b/arch/avr/include/irq.h @@ -126,6 +126,13 @@ static inline_function void up_set_current_regs(FAR uint8_t *regs) #define up_interrupt_context() (up_current_regs() != NULL) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint8_t *)(regs))[REG_R13]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/avr/src/avr/avr_registerdump.c b/arch/avr/src/avr/avr_registerdump.c index 460f9e37ad..b7297eedb5 100644 --- a/arch/avr/src/avr/avr_registerdump.c +++ b/arch/avr/src/avr/avr_registerdump.c @@ -40,16 +40,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint8_t *ptr = regs; - return ptr[REG_R13]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/avr/src/avr32/avr_registerdump.c b/arch/avr/src/avr32/avr_registerdump.c index ba0700da8c..c89383bc4f 100644 --- a/arch/avr/src/avr32/avr_registerdump.c +++ b/arch/avr/src/avr32/avr_registerdump.c @@ -40,16 +40,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint8_t *ptr = regs; - return ptr[REG_R13]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/ceva/include/irq.h b/arch/ceva/include/irq.h index 5d2584ed6e..0952d126b1 100644 --- a/arch/ceva/include/irq.h +++ b/arch/ceva/include/irq.h @@ -175,6 +175,13 @@ static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t*)(regs))[REG_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/ceva/src/common/ceva_registerdump.c b/arch/ceva/src/common/ceva_registerdump.c index 3d0b7b1459..e9213f4767 100644 --- a/arch/ceva/src/common/ceva_registerdump.c +++ b/arch/ceva/src/common/ceva_registerdump.c @@ -37,16 +37,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/hc/include/irq.h b/arch/hc/include/irq.h index b277b90e80..f00c78c0e3 100644 --- a/arch/hc/include/irq.h +++ b/arch/hc/include/irq.h @@ -127,6 +127,16 @@ static inline_function void up_set_current_regs(FAR uint8_t *regs) #define up_interrupt_context() (up_current_regs() != NULL) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint8_t *ptr = regs; + return (uintptr_t)(ptr[REG_SPH] << 8 | ptr[REG_SPL]); +} + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/hc/src/m9s12/m9s12_registerdump.c b/arch/hc/src/m9s12/m9s12_registerdump.c index dde8fed1c5..96dec69b05 100644 --- a/arch/hc/src/m9s12/m9s12_registerdump.c +++ b/arch/hc/src/m9s12/m9s12_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint8_t *ptr = regs; - return (uintptr_t)(ptr[REG_SPH] << 8 | ptr[REG_SPL]); -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/mips/include/irq.h b/arch/mips/include/irq.h index 3cdc19d01d..907c982698 100644 --- a/arch/mips/include/irq.h +++ b/arch/mips/include/irq.h @@ -138,6 +138,13 @@ static inline_function void up_set_current_regs(uint32_t *regs) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EPC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t*)(regs))[REG_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/mips/src/mips32/mips_registerdump.c b/arch/mips/src/mips32/mips_registerdump.c index 0fcc550f10..3834f8c677 100644 --- a/arch/mips/src/mips32/mips_registerdump.c +++ b/arch/mips/src/mips32/mips_registerdump.c @@ -40,16 +40,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/misoc/include/lm32/irq.h b/arch/misoc/include/lm32/irq.h index 2a3af49356..ee7c687438 100644 --- a/arch/misoc/include/lm32/irq.h +++ b/arch/misoc/include/lm32/irq.h @@ -227,5 +227,12 @@ struct xcptcontext #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EPC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_SP]) + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_MISOC_INCLUDE_LM32_IRQ_H */ diff --git a/arch/misoc/include/minerva/irq.h b/arch/misoc/include/minerva/irq.h index 19e17dbb13..414a781c0a 100644 --- a/arch/misoc/include/minerva/irq.h +++ b/arch/misoc/include/minerva/irq.h @@ -308,5 +308,12 @@ struct xcptcontext #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_CSR_MEPC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_X2]) + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_MISOC_INCLUDE_MINERVA_IRQ_H */ diff --git a/arch/misoc/src/lm32/lm32_registerdump.c b/arch/misoc/src/lm32/lm32_registerdump.c index da69efb27d..df1d759092 100644 --- a/arch/misoc/src/lm32/lm32_registerdump.c +++ b/arch/misoc/src/lm32/lm32_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/misoc/src/minerva/minerva_registerdump.c b/arch/misoc/src/minerva/minerva_registerdump.c index 0b5da071ed..d3174cb262 100644 --- a/arch/misoc/src/minerva/minerva_registerdump.c +++ b/arch/misoc/src/minerva/minerva_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_X2]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/or1k/include/irq.h b/arch/or1k/include/irq.h index b73d6e7c4c..0491446fe5 100644 --- a/arch/or1k/include/irq.h +++ b/arch/or1k/include/irq.h @@ -157,6 +157,13 @@ static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_R13]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/or1k/src/common/or1k_registerdump.c b/arch/or1k/src/common/or1k_registerdump.c index ef1e0ad47a..34414ff3a9 100644 --- a/arch/or1k/src/common/or1k_registerdump.c +++ b/arch/or1k/src/common/or1k_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_R13]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/renesas/include/m16c/irq.h b/arch/renesas/include/m16c/irq.h index 04ed3d17c2..dffdef85a7 100644 --- a/arch/renesas/include/m16c/irq.h +++ b/arch/renesas/include/m16c/irq.h @@ -350,6 +350,16 @@ static inline_function irqstate_t up_irq_enable(void) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uint8_t *ptr = regs; + return (uintptr_t)(ptr[REG_SP] << 8 | ptr[REG_SP + 1]); +} + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/renesas/include/rx65n/irq.h b/arch/renesas/include/rx65n/irq.h index 61f930d990..67f80336a0 100644 --- a/arch/renesas/include/rx65n/irq.h +++ b/arch/renesas/include/rx65n/irq.h @@ -1088,6 +1088,13 @@ static inline_function void up_irq_restore(irqstate_t flags) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_SP]) + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_RENESAS_INCLUDE_RX65N_IRQ_H */ diff --git a/arch/renesas/include/sh1/irq.h b/arch/renesas/include/sh1/irq.h index 70e0d9c2ae..1d83ea476b 100644 --- a/arch/renesas/include/sh1/irq.h +++ b/arch/renesas/include/sh1/irq.h @@ -571,6 +571,13 @@ static inline_function void up_irq_restore(irqstate_t flags) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/renesas/src/m16c/m16c_registerdump.c b/arch/renesas/src/m16c/m16c_registerdump.c index 37d8db1746..92f5ffa5ad 100644 --- a/arch/renesas/src/m16c/m16c_registerdump.c +++ b/arch/renesas/src/m16c/m16c_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint8_t *ptr = regs; - return (uintptr_t)(ptr[REG_SP] << 8 | ptr[REG_SP + 1]); -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/renesas/src/rx65n/rx65n_registerdump.c b/arch/renesas/src/rx65n/rx65n_registerdump.c index 980c76523e..51a3ed99c8 100644 --- a/arch/renesas/src/rx65n/rx65n_registerdump.c +++ b/arch/renesas/src/rx65n/rx65n_registerdump.c @@ -41,16 +41,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/renesas/src/sh1/sh1_registerdump.c b/arch/renesas/src/sh1/sh1_registerdump.c index 0fc3382574..73bac21938 100644 --- a/arch/renesas/src/sh1/sh1_registerdump.c +++ b/arch/renesas/src/sh1/sh1_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/risc-v/include/irq.h b/arch/risc-v/include/irq.h index 6542b10760..7d21cdce5c 100644 --- a/arch/risc-v/include/irq.h +++ b/arch/risc-v/include/irq.h @@ -830,6 +830,13 @@ noinstrument_function static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((uintptr_t *)((regs) ? (regs) : running_regs()))[REG_EPC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + (((uintptr_t*)(regs))[REG_SP]) + #undef EXTERN #if defined(__cplusplus) } diff --git a/arch/risc-v/src/common/riscv_registerdump.c b/arch/risc-v/src/common/riscv_registerdump.c index 6df8d967f9..f0306eadce 100644 --- a/arch/risc-v/src/common/riscv_registerdump.c +++ b/arch/risc-v/src/common/riscv_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uintptr_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/sim/include/irq.h b/arch/sim/include/irq.h index 11c6272aa5..61195440e7 100644 --- a/arch/sim/include/irq.h +++ b/arch/sim/include/irq.h @@ -183,6 +183,13 @@ static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((xcpt_reg_t *)((regs) ? (regs) : up_current_regs()))[JB_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((xcpt_reg_t *)(regs))[JB_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/sim/src/sim/sim_registerdump.c b/arch/sim/src/sim/sim_registerdump.c index 7ce7de1d52..ac344f4997 100644 --- a/arch/sim/src/sim/sim_registerdump.c +++ b/arch/sim/src/sim/sim_registerdump.c @@ -34,16 +34,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - xcpt_reg_t *ptr = regs; - return ptr[JB_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/sparc/include/irq.h b/arch/sparc/include/irq.h index e4627f3676..67aeb9197d 100644 --- a/arch/sparc/include/irq.h +++ b/arch/sparc/include/irq.h @@ -175,6 +175,13 @@ static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_I6]) + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/sparc/src/sparc_v8/sparc_v8_registerdump.c b/arch/sparc/src/sparc_v8/sparc_v8_registerdump.c index a3c8756b9d..aee2659899 100644 --- a/arch/sparc/src/sparc_v8/sparc_v8_registerdump.c +++ b/arch/sparc/src/sparc_v8/sparc_v8_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_I6]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/tricore/include/irq.h b/arch/tricore/include/irq.h index d33e67184b..fb8b330b8e 100644 --- a/arch/tricore/include/irq.h +++ b/arch/tricore/include/irq.h @@ -186,6 +186,26 @@ static inline_function bool up_interrupt_context(void) return ret; } + +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +static inline_function uintptr_t up_getusrsp(void *regs) +{ + uintptr_t *csa = regs; + + while (((uintptr_t)csa & PCXI_UL) == 0) + { + csa = tricore_csa2addr((uintptr_t)csa); + csa = (uintptr_t *)csa[0]; + } + + csa = tricore_csa2addr((uintptr_t)csa); + + return csa[REG_SP]; +} + #endif /* __ASSEMBLY__ */ #undef EXTERN diff --git a/arch/tricore/src/common/tricore_registerdump.c b/arch/tricore/src/common/tricore_registerdump.c index 6130a0a679..bc29358ca1 100644 --- a/arch/tricore/src/common/tricore_registerdump.c +++ b/arch/tricore/src/common/tricore_registerdump.c @@ -39,25 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uintptr_t *csa = regs; - - while (((uintptr_t)csa & PCXI_UL) == 0) - { - csa = tricore_csa2addr((uintptr_t)csa); - csa = (uintptr_t *)csa[0]; - } - - csa = tricore_csa2addr((uintptr_t)csa); - - return csa[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/x86/include/irq.h b/arch/x86/include/irq.h index ca0dedf697..14117ecff1 100644 --- a/arch/x86/include/irq.h +++ b/arch/x86/include/irq.h @@ -120,6 +120,13 @@ static inline_function void up_set_current_regs(uint32_t *regs) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EIP]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint32_t *)(regs))[REG_ESP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/x86/src/i486/i486_regdump.c b/arch/x86/src/i486/i486_regdump.c index bb62e1a3e2..41986c86f7 100644 --- a/arch/x86/src/i486/i486_regdump.c +++ b/arch/x86/src/i486/i486_regdump.c @@ -35,16 +35,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint32_t *ptr = regs; - return ptr[REG_ESP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/x86_64/include/irq.h b/arch/x86_64/include/irq.h index 0d82aafbd9..8a1db30b81 100644 --- a/arch/x86_64/include/irq.h +++ b/arch/x86_64/include/irq.h @@ -182,6 +182,13 @@ static inline_function void up_set_interrupt_context(bool flag) #define up_getusrpc(regs) \ (((uint64_t *)((regs) ? (regs) : running_regs()))[REG_RIP]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((uint64_t *)(regs))[REG_RSP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/x86_64/src/intel64/intel64_regdump.c b/arch/x86_64/src/intel64/intel64_regdump.c index 646e1b32f8..667f253e93 100644 --- a/arch/x86_64/src/intel64/intel64_regdump.c +++ b/arch/x86_64/src/intel64/intel64_regdump.c @@ -37,16 +37,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uint64_t *ptr = regs; - return ptr[REG_RSP]; -} - /**************************************************************************** * Name: x86_64_registerdump ****************************************************************************/ diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index 973799f1d6..8e45fa8d89 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -468,6 +468,13 @@ noinstrument_function static inline_function bool up_interrupt_context(void) #define up_getusrpc(regs) \ (((uint32_t *)((regs) ? (regs) : running_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + (((uintptr_t*)(regs))[REG_A1]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/xtensa/src/common/xtensa_registerdump.c b/arch/xtensa/src/common/xtensa_registerdump.c index c770277c3a..ff3ba70b62 100644 --- a/arch/xtensa/src/common/xtensa_registerdump.c +++ b/arch/xtensa/src/common/xtensa_registerdump.c @@ -39,16 +39,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(void *regs) -{ - uintptr_t *ptr = regs; - return ptr[REG_A1]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/z16/include/irq.h b/arch/z16/include/irq.h index 18c8f52037..162bbd2de6 100644 --- a/arch/z16/include/irq.h +++ b/arch/z16/include/irq.h @@ -112,6 +112,13 @@ static inline_function void up_set_current_regs(FAR chipreg_t *regs) #define up_getusrpc(regs) \ (((FAR chipreg_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((FAR uint32_t*)(regs))[REG_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/z16/src/common/z16_registerdump.c b/arch/z16/src/common/z16_registerdump.c index 13361a9f86..2a3874f3ae 100644 --- a/arch/z16/src/common/z16_registerdump.c +++ b/arch/z16/src/common/z16_registerdump.c @@ -35,16 +35,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(FAR void *regs) -{ - FAR uint32_t *ptr = regs; - return ptr[REG_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/z80/include/irq.h b/arch/z80/include/irq.h index 28d6bfbff3..c27006ebe3 100644 --- a/arch/z80/include/irq.h +++ b/arch/z80/include/irq.h @@ -57,6 +57,13 @@ uintptr_t up_getsp(void); #define up_getusrpc(regs) \ (((FAR chipreg_t *)((regs) ? (regs) : up_current_regs()))[XCPT_PC]) +/**************************************************************************** + * Name: up_getusrsp + ****************************************************************************/ + +#define up_getusrsp(regs) \ + ((uintptr_t)((FAR chipreg_t*)(regs))[XCPT_SP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/z80/src/ez80/ez80_registerdump.c b/arch/z80/src/ez80/ez80_registerdump.c index 02016fb785..05425cbcf9 100644 --- a/arch/z80/src/ez80/ez80_registerdump.c +++ b/arch/z80/src/ez80/ez80_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(FAR void *regs) -{ - FAR chipreg_t *ptr = regs; - return ptr[XCPT_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/z80/src/z180/z180_registerdump.c b/arch/z80/src/z180/z180_registerdump.c index 07f2fa0e4f..e4ed83d91f 100644 --- a/arch/z80/src/z180/z180_registerdump.c +++ b/arch/z80/src/z180/z180_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(FAR void *regs) -{ - FAR chipreg_t *ptr = regs; - return ptr[XCPT_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/z80/src/z8/z8_registerdump.c b/arch/z80/src/z8/z8_registerdump.c index 1d6e9d2b55..ef3cc26a46 100644 --- a/arch/z80/src/z8/z8_registerdump.c +++ b/arch/z80/src/z8/z8_registerdump.c @@ -57,16 +57,6 @@ static inline void z8_dumpstate(chipreg_t sp, chipreg_t pc, uint8_t irqctl, * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(FAR void *regs) -{ - FAR chipreg_t *ptr = regs; - return ptr[XCPT_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/arch/z80/src/z80/z80_registerdump.c b/arch/z80/src/z80/z80_registerdump.c index 41659e4880..4199f4e1aa 100644 --- a/arch/z80/src/z80/z80_registerdump.c +++ b/arch/z80/src/z80/z80_registerdump.c @@ -38,16 +38,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getusrsp - ****************************************************************************/ - -uintptr_t up_getusrsp(FAR void *regs) -{ - FAR chipreg_t *ptr = regs; - return ptr[XCPT_SP]; -} - /**************************************************************************** * Name: up_dump_register ****************************************************************************/ diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index a9a5820b7f..53b6f73728 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -2112,7 +2112,9 @@ int up_timer_tick_start(clock_t ticks); * ****************************************************************************/ -uintptr_t up_getusrsp(FAR void *regs); +/* static inline_function uintptr_t up_getusrsp(void *regs); + * The actual implementation should be provided in irq.h per arch. + */ /**************************************************************************** * TLS support