From 319f0eac149bbedeae66050adf3d96a2500216e0 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 15 Oct 2024 14:01:35 +0300 Subject: [PATCH] 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. --- arch/Kconfig | 5 +++++ include/nuttx/arch.h | 13 +++++++++++++ include/nuttx/sched.h | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index f916feb5b7347..584df27d4ded8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -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 diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index a5d8b6280eeeb..88d3022ce2b52 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -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 ****************************************************************************/ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index cfca51e5fce9e..7247f1f24838b 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -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