Skip to content

Commit 2195b47

Browse files
pussuwxiaoxiang781216
authored andcommitted
smp: Implement empty macro for obtaining logical CPU index
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.
1 parent f47c0a1 commit 2195b47

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

arch/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ config ARCH_HAVE_MULTICPU
417417
bool
418418
default n
419419

420+
config ARCH_HAVE_CPUID_MAPPING
421+
bool
422+
default n
423+
depends on ARCH_HAVE_MULTICPU
424+
420425
config ARCH_HAVE_FORK
421426
bool
422427
default n

include/nuttx/arch.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@
111111
# define up_cpu_index() 0
112112
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
113113

114+
/****************************************************************************
115+
* Name: up_this_cpu
116+
*
117+
* Description:
118+
* Return the logical core number. Default implementation is 1:1 mapping,
119+
* i.e. physical=logical.
120+
*
121+
****************************************************************************/
122+
123+
#ifndef CONFIG_ARCH_HAVE_CPUID_MAPPING
124+
# define up_this_cpu() up_cpu_index()
125+
#endif
126+
114127
/****************************************************************************
115128
* Public Types
116129
****************************************************************************/

include/nuttx/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
*/
238238

239239
#ifdef CONFIG_SMP
240-
# define this_cpu() up_cpu_index()
240+
# define this_cpu() up_this_cpu()
241241
#else
242242
# define this_cpu() (0)
243243
#endif

0 commit comments

Comments
 (0)