arch/sim: Change up_interrupt_context to inline function like arm
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
b6f1be8e03
commit
1905a02ddf
@ -30,6 +30,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/setjmp.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
@ -53,13 +54,6 @@ struct xcptcontext
|
||||
void *sigdeliver; /* Actual type is sig_deliver_t */
|
||||
jmp_buf regs;
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
@ -70,21 +64,25 @@ extern "C"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
/* g_current_regs[] holds a references to the current interrupt level
|
||||
* register storage structure. If is non-NULL only during interrupt
|
||||
* processing. Access to g_current_regs[] must be through the macro
|
||||
* CURRENT_REGS for portability.
|
||||
*/
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
uintptr_t regval;
|
||||
__asm mov regval, esp;
|
||||
return regval;
|
||||
#else
|
||||
return (uintptr_t)__builtin_frame_address(0);
|
||||
#endif
|
||||
}
|
||||
/* For the case of architectures with multiple CPUs, then there must be one
|
||||
* such value for each processor that can receive an interrupt.
|
||||
*/
|
||||
|
||||
EXTERN volatile void *g_current_regs[CONFIG_SMP_NCPUS];
|
||||
#define CURRENT_REGS (g_current_regs[up_cpu_index()])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_cpu_index
|
||||
@ -120,6 +118,23 @@ int up_cpu_index(void);
|
||||
irqstate_t up_irq_save(void);
|
||||
void up_irq_restore(irqstate_t flags);
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the current value of the stack pointer */
|
||||
|
||||
static inline uintptr_t up_getsp(void)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
uintptr_t regval;
|
||||
__asm mov regval, esp;
|
||||
return regval;
|
||||
#else
|
||||
return (uintptr_t)__builtin_frame_address(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
@ -129,7 +144,10 @@ void up_irq_restore(irqstate_t flags);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool up_interrupt_context(void);
|
||||
static inline bool up_interrupt_context(void)
|
||||
{
|
||||
return CURRENT_REGS != NULL;
|
||||
}
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
@ -120,19 +120,6 @@ struct i2c_master_s;
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* g_current_regs[] holds a references to the current interrupt level
|
||||
* register storage structure. If is non-NULL only during interrupt
|
||||
* processing. Access to g_current_regs[] must be through the macro
|
||||
* CURRENT_REGS for portability.
|
||||
*/
|
||||
|
||||
/* For the case of architectures with multiple CPUs, then there must be one
|
||||
* such value for each processor that can receive an interrupt.
|
||||
*/
|
||||
|
||||
extern volatile void *g_current_regs[CONFIG_SMP_NCPUS];
|
||||
#define CURRENT_REGS (g_current_regs[up_cpu_index()])
|
||||
|
||||
/* The command line arguments passed to simulator */
|
||||
|
||||
extern int g_argc;
|
||||
|
@ -33,20 +33,6 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
* Description:
|
||||
* Return true is we are currently executing in the interrupt handler
|
||||
* context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool up_interrupt_context(void)
|
||||
{
|
||||
return CURRENT_REGS != NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_doirq
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user