Skip to content

Commit

Permalink
smp: Implement empty macro for obtaining logical CPU index
Browse files Browse the repository at this point in the history
This implements empty hooks to the arch/chip layer, which can implement
an optional translation between logical<->physical CPU/core id.

The default mapping is 1:1 i.e. logical=physical.
  • Loading branch information
pussuw committed Oct 15, 2024
1 parent f171854 commit 319f0ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ config ARCH_HAVE_MULTICPU
bool
default n

config ARCH_HAVE_CPUID_MAPPING
bool
default n
depends on ARCH_HAVE_MULTICPU

config ARCH_HAVE_FORK
bool
default n
Expand Down
13 changes: 13 additions & 0 deletions include/nuttx/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@
# define up_cpu_index() 0
#endif /* CONFIG_ARCH_HAVE_MULTICPU */

/****************************************************************************
* Name: up_this_cpu
*
* Description:
* Return the logical core number. Default implementation is 1:1 mapping,
* i.e. physical=logical.
*
****************************************************************************/

#ifndef CONFIG_ARCH_HAVE_CPUID_MAPPING
# define up_this_cpu() up_cpu_index()
#endif

/****************************************************************************
* Public Types
****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
*/

#ifdef CONFIG_SMP
# define this_cpu() up_cpu_index()
# define this_cpu() up_this_cpu()
#else
# define this_cpu() (0)
#endif
Expand Down

0 comments on commit 319f0ea

Please sign in to comment.