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
@@ -86,23 +86,13 @@ EXTERN volatile xcpt_reg_t *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 */
/* Name: up_irq_save, up_irq_restore, and friends.
*
@@ -124,12 +114,20 @@ void up_irq_enable(void);
static inline_function xcpt_reg_t *up_current_regs(void)
{
#ifdef CONFIG_SMP
return (xcpt_reg_t *)g_current_regs[up_cpu_index()];
#else
return (xcpt_reg_t *)g_current_regs[0];
#endif
}
static inline_function void up_set_current_regs(xcpt_reg_t *regs)
{
#ifdef CONFIG_SMP
g_current_regs[up_cpu_index()] = regs;
#else
g_current_regs[0] = regs;
#endif
}
/* Return the current value of the stack pointer */