diff --git a/arch/arm/include/irq.h b/arch/arm/include/irq.h index b88b2159cf..6334638455 100644 --- a/arch/arm/include/irq.h +++ b/arch/arm/include/irq.h @@ -96,6 +96,13 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #endif /* __ASSEMBLY__ */ #undef EXTERN diff --git a/arch/arm64/include/irq.h b/arch/arm64/include/irq.h index 47571b2a58..64ba9a5c65 100644 --- a/arch/arm64/include/irq.h +++ b/arch/arm64/include/irq.h @@ -435,6 +435,13 @@ static inline bool up_interrupt_context(void) return up_current_regs() != NULL; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uintptr_t *)((regs) ? (regs) : up_current_regs()))[REG_ELR]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/avr/include/avr/irq.h b/arch/avr/include/avr/irq.h index df9a82dbae..54d9037c13 100644 --- a/arch/avr/include/avr/irq.h +++ b/arch/avr/include/avr/irq.h @@ -203,6 +203,28 @@ static inline void up_irq_restore(irqstate_t flags) * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#if defined(REG_PC2) +# define up_getusrpc(regs) \ + ((regs) ? \ + ((((uint8_t *)(regs))[REG_PC0] << 16) | \ + (((uint8_t *)(regs))[REG_PC1] << 8) | \ + (((uint8_t *)(regs))[REG_PC2] << 0)) : \ + (((uint8_t *)up_current_regs())[REG_PC0] << 16) | \ + (((uint8_t *)up_current_regs())[REG_PC1] << 8) | \ + (((uint8_t *)up_current_regs())[REG_PC2] << 0)) +#else +# define up_getusrpc(regs) \ + ((regs) ? \ + ((((uint8_t *)(regs))[REG_PC0] << 8) | \ + (((uint8_t *)(regs))[REG_PC1] << 0)) : \ + (((uint8_t *)up_current_regs())[REG_PC0] << 8) | \ + (((uint8_t *)up_current_regs())[REG_PC1] << 0)) +#endif + #ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" diff --git a/arch/avr/include/avr32/irq.h b/arch/avr/include/avr32/irq.h index ed8e064bc6..52f547be0d 100644 --- a/arch/avr/include/avr32/irq.h +++ b/arch/avr/include/avr32/irq.h @@ -222,6 +222,13 @@ static inline irqstate_t up_irq_enable(void) * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" diff --git a/arch/ceva/include/irq.h b/arch/ceva/include/irq.h index 8a24f6cfb8..567b9d75ba 100644 --- a/arch/ceva/include/irq.h +++ b/arch/ceva/include/irq.h @@ -168,6 +168,13 @@ static inline bool up_interrupt_context(void) return ret; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/hc/include/m9s12/irq.h b/arch/hc/include/m9s12/irq.h index 09812970bc..89334fd9fe 100644 --- a/arch/hc/include/m9s12/irq.h +++ b/arch/hc/include/m9s12/irq.h @@ -164,6 +164,14 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + ((((uint8_t *)((regs) ? (regs) : up_current_regs()))[REG_PCH] << 8) | \ + (((uint8_t *)((regs) ? (regs) : up_current_regs()))[REG_PCL] << 0)) + /**************************************************************************** * Public Functions Prototypes ****************************************************************************/ diff --git a/arch/mips/include/irq.h b/arch/mips/include/irq.h index 8568d5b472..29681e5339 100644 --- a/arch/mips/include/irq.h +++ b/arch/mips/include/irq.h @@ -147,6 +147,13 @@ static inline_function void up_set_current_regs(uint32_t *regs) #define up_interrupt_context() (up_current_regs() != NULL) +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EPC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/misoc/include/lm32/irq.h b/arch/misoc/include/lm32/irq.h index 799cba3d5d..b82c64586c 100644 --- a/arch/misoc/include/lm32/irq.h +++ b/arch/misoc/include/lm32/irq.h @@ -214,5 +214,16 @@ struct xcptcontext uint32_t regs[XCPTCONTEXT_REGS]; }; +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EPC]) + #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 c34c49861e..799c360c31 100644 --- a/arch/misoc/include/minerva/irq.h +++ b/arch/misoc/include/minerva/irq.h @@ -299,5 +299,12 @@ struct xcptcontext * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_CSR_MEPC]) + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_MISOC_INCLUDE_MINERVA_IRQ_H */ diff --git a/arch/or1k/include/irq.h b/arch/or1k/include/irq.h index ea2015b6f6..43d665d01b 100644 --- a/arch/or1k/include/irq.h +++ b/arch/or1k/include/irq.h @@ -150,6 +150,13 @@ static inline bool up_interrupt_context(void) return ret; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/renesas/include/m16c/irq.h b/arch/renesas/include/m16c/irq.h index f06aae80d8..3ec9abb8fa 100644 --- a/arch/renesas/include/m16c/irq.h +++ b/arch/renesas/include/m16c/irq.h @@ -341,6 +341,13 @@ static inline irqstate_t up_irq_enable(void) * Public Functions Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/renesas/include/rx65n/irq.h b/arch/renesas/include/rx65n/irq.h index 42c5f62dd0..1be2755239 100644 --- a/arch/renesas/include/rx65n/irq.h +++ b/arch/renesas/include/rx65n/irq.h @@ -1079,6 +1079,13 @@ static inline void up_irq_restore(irqstate_t flags) } } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #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 2f45b100bf..6d07e8b9f8 100644 --- a/arch/renesas/include/sh1/irq.h +++ b/arch/renesas/include/sh1/irq.h @@ -562,6 +562,13 @@ static inline void up_irq_restore(irqstate_t flags) * Public Functions Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/risc-v/include/irq.h b/arch/risc-v/include/irq.h index bbae16033e..a8fc09e5c9 100644 --- a/arch/risc-v/include/irq.h +++ b/arch/risc-v/include/irq.h @@ -805,6 +805,13 @@ noinstrument_function static inline bool up_interrupt_context(void) return ret; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uintptr_t *)((regs) ? (regs) : up_current_regs()))[REG_EPC]) + #undef EXTERN #if defined(__cplusplus) } diff --git a/arch/sim/include/irq.h b/arch/sim/include/irq.h index af25d57f5d..96686f99bc 100644 --- a/arch/sim/include/irq.h +++ b/arch/sim/include/irq.h @@ -169,6 +169,19 @@ static inline bool up_interrupt_context(void) return ret; } +/**************************************************************************** + * Name: up_getusrpc + * + * Description: + * Get the PC value, The interrupted context PC register cannot be + * correctly obtained in sim It will return the PC of the interrupt + * handler function, normally it will return sim_doirq + * + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((xcpt_reg_t *)((regs) ? (regs) : up_current_regs()))[JB_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/sparc/include/irq.h b/arch/sparc/include/irq.h index cabab84f77..c37ea5b245 100644 --- a/arch/sparc/include/irq.h +++ b/arch/sparc/include/irq.h @@ -168,6 +168,13 @@ static inline bool up_interrupt_context(void) return ret; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/x86/include/irq.h b/arch/x86/include/irq.h index e216a5bbbc..6de0484f2a 100644 --- a/arch/x86/include/irq.h +++ b/arch/x86/include/irq.h @@ -129,6 +129,13 @@ static inline_function void up_set_current_regs(uint32_t *regs) #define up_interrupt_context() (up_current_regs() != NULL) +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_EIP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/x86_64/include/irq.h b/arch/x86_64/include/irq.h index e45b25ea9e..834468b84a 100644 --- a/arch/x86_64/include/irq.h +++ b/arch/x86_64/include/irq.h @@ -147,6 +147,13 @@ static inline_function bool up_interrupt_context(void) return up_current_regs() != NULL; } +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint64_t *)((regs) ? (regs) : up_current_regs()))[REG_RIP]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index ef681ab581..9a8383aa29 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -460,6 +460,13 @@ noinstrument_function static inline_function bool up_interrupt_context(void) } #endif +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((uint32_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/z16/include/irq.h b/arch/z16/include/irq.h index 0028eafba4..ecc611cd69 100644 --- a/arch/z16/include/irq.h +++ b/arch/z16/include/irq.h @@ -121,6 +121,13 @@ static inline_function void up_set_current_regs(FAR chipreg_t *regs) #define up_interrupt_context() (up_current_regs() != NULL) +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((FAR chipreg_t *)((regs) ? (regs) : up_current_regs()))[REG_PC]) + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/z80/include/irq.h b/arch/z80/include/irq.h index 91b5d06d19..fffba5a615 100644 --- a/arch/z80/include/irq.h +++ b/arch/z80/include/irq.h @@ -48,6 +48,13 @@ extern "C" uintptr_t up_getsp(void); +/**************************************************************************** + * Name: up_getusrpc + ****************************************************************************/ + +#define up_getusrpc(regs) \ + (((FAR chipreg_t *)((regs) ? (regs) : up_current_regs()))[XCPT_PC]) + #undef EXTERN #ifdef __cplusplus }