arch/irq: add the up_getusrpc macro to get the PC of the interrupted thread in the interrupt

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
yinshengkai 2024-03-12 18:03:39 +08:00 committed by Xiang Xiao
parent 6382b02d2b
commit f26ae83900
21 changed files with 173 additions and 0 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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"

View file

@ -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"

View file

@ -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
}

View file

@ -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
****************************************************************************/

View file

@ -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
}

View file

@ -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 */

View file

@ -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 */

View file

@ -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
}

View file

@ -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
}

View file

@ -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 */

View file

@ -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
}

View file

@ -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)
}

View file

@ -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
}

View file

@ -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
****************************************************************************/

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}