mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
arch: inline up_interrupt_context()
inline the up_interrupt_context() to avoid unnecessary stack pushes Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/* Include NuttX-specific IRQ definitions */
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
@@ -37,4 +42,90 @@
|
||||
|
||||
#include <arch/chip/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* 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 uint32_t *g_current_regs[CONFIG_SMP_NCPUS];
|
||||
#define CURRENT_REGS (g_current_regs[up_cpu_index()])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_cpu_index
|
||||
*
|
||||
* Description:
|
||||
* Return an index in the range of 0 through (CONFIG_SMP_NCPUS-1) that
|
||||
* corresponds to the currently executing CPU.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* An integer index in the range of 0 through (CONFIG_SMP_NCPUS-1) that
|
||||
* corresponds to the currently executing CPU.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
int up_cpu_index(void);
|
||||
#else
|
||||
# define up_cpu_index() (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
* Description:
|
||||
* Return true is we are currently executing in the interrupt
|
||||
* handler context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline bool up_interrupt_context(void)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
irqstate_t flags = up_irq_save();
|
||||
#endif
|
||||
|
||||
bool ret = CURRENT_REGS != NULL;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
up_irq_restore(flags);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_OR1K_INCLUDE_IRQ_H */
|
||||
|
||||
Reference in New Issue
Block a user