mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
arch: support customized up_cpu_index() in AMP mode
Some app with same code runs on different cores in AMP mode, need the physical core on which the function is called. Signed-off-by: hujun5 <hujun5@xiaomi.com> Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
+12
-14
@@ -113,23 +113,13 @@ EXTERN uint32_t *volatile g_current_regs[CONFIG_SMP_NCPUS];
|
||||
* 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.
|
||||
* Return the real core number regardless CONFIG_SMP setting
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
int up_cpu_index(void);
|
||||
#else
|
||||
# define up_cpu_index() (0)
|
||||
#endif
|
||||
#ifdef CONFIG_ARCH_HAVE_MULTICPU
|
||||
int up_cpu_index(void) noinstrument_function;
|
||||
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
@@ -137,12 +127,20 @@ int up_cpu_index(void);
|
||||
|
||||
static inline_function uint32_t *up_current_regs(void)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
return (uint32_t *)g_current_regs[up_cpu_index()];
|
||||
#else
|
||||
return (uint32_t *)g_current_regs[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline_function void up_set_current_regs(uint32_t *regs)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
g_current_regs[up_cpu_index()] = regs;
|
||||
#else
|
||||
g_current_regs[0] = regs;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user