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:
hujun5
2024-10-08 12:56:11 +08:00
committed by Xiang Xiao
parent 092bdec20b
commit e249dd2672
56 changed files with 266 additions and 504 deletions
+12 -14
View File
@@ -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
}
/****************************************************************************