Skip to content

Commit

Permalink
arch: up_getusrsp change to inline and implement in irq.h
Browse files Browse the repository at this point in the history
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
  • Loading branch information
jasonbu committed Jan 5, 2025
1 parent 8ea0e4c commit f76c5fa
Show file tree
Hide file tree
Showing 52 changed files with 192 additions and 244 deletions.
6 changes: 6 additions & 0 deletions arch/arm/include/armv6-m/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/armv7-a/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/armv7-m/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/armv7-r/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/armv8-m/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/armv8-r/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/include/tlsr82/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 0 additions & 10 deletions arch/arm/src/common/arm_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
8 changes: 8 additions & 0 deletions arch/arm64/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 0 additions & 13 deletions arch/arm64/src/common/arm64_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions arch/avr/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions arch/avr/src/avr/avr_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
10 changes: 0 additions & 10 deletions arch/avr/src/avr32/avr_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions arch/ceva/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions arch/ceva/src/common/ceva_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
10 changes: 10 additions & 0 deletions arch/hc/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
10 changes: 0 additions & 10 deletions arch/hc/src/m9s12/m9s12_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions arch/mips/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions arch/mips/src/mips32/mips_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions arch/misoc/include/lm32/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
7 changes: 7 additions & 0 deletions arch/misoc/include/minerva/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
10 changes: 0 additions & 10 deletions arch/misoc/src/lm32/lm32_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
10 changes: 0 additions & 10 deletions arch/misoc/src/minerva/minerva_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions arch/or1k/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions arch/or1k/src/common/or1k_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down
10 changes: 10 additions & 0 deletions arch/renesas/include/m16c/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit f76c5fa

Please sign in to comment.