This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit cb5eded74c380aee229f27f36af041a12462c92b
Author: buxiasen <[email protected]>
AuthorDate: Tue Oct 28 20:47:44 2025 +0800

    arch/tricore: add performance events user access support
    
    Build the cycle-counter accessor for user-space performance-event access 
while keeping frequency conversion and counter initialization in the kernel.
    
    Signed-off-by: buxiasen <[email protected]>
---
 arch/tricore/src/common/CMakeLists.txt |  4 ++++
 arch/tricore/src/common/Make.defs      |  4 ++++
 arch/tricore/src/common/tricore_perf.c | 12 +++++++-----
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/tricore/src/common/CMakeLists.txt 
b/arch/tricore/src/common/CMakeLists.txt
index 2342d1bdadf..5b4c8778083 100644
--- a/arch/tricore/src/common/CMakeLists.txt
+++ b/arch/tricore/src/common/CMakeLists.txt
@@ -53,6 +53,10 @@ if(CONFIG_BUILD_PROTECTED OR CONFIG_BUILD_KERNEL)
   if(CONFIG_BUILD_PROTECTED)
     target_sources(arch_interface PRIVATE tricore_signal_handler.c)
   endif()
+
+  if(CONFIG_ARCH_PERF_EVENTS_USER_ACCESS)
+    target_sources(arch_interface PRIVATE tricore_perf.c)
+  endif()
 endif()
 
 if(CONFIG_SCHED_BACKTRACE)
diff --git a/arch/tricore/src/common/Make.defs 
b/arch/tricore/src/common/Make.defs
index f3612104f4f..721cc1feace 100644
--- a/arch/tricore/src/common/Make.defs
+++ b/arch/tricore/src/common/Make.defs
@@ -74,6 +74,10 @@ ifeq ($(CONFIG_BUILD_PROTECTED)$(CONFIG_BUILD_KERNEL),y)
   ifeq ($(CONFIG_BUILD_PROTECTED),y)
     CMN_UASRCS += tricore_signal_handler.c
   endif
+
+  ifeq ($(CONFIG_ARCH_PERF_EVENTS_USER_ACCESS),y)
+    CMN_UASRCS += tricore_perf.c
+  endif
 endif
 
 ifeq ($(CONFIG_ARCH_USE_MPU),y)
diff --git a/arch/tricore/src/common/tricore_perf.c 
b/arch/tricore/src/common/tricore_perf.c
index 0f9e23708e9..666a33c38cd 100644
--- a/arch/tricore/src/common/tricore_perf.c
+++ b/arch/tricore/src/common/tricore_perf.c
@@ -44,6 +44,7 @@
 
 #ifdef CONFIG_ARCH_PERF_EVENTS
 
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -91,11 +92,6 @@ unsigned long up_perf_getfreq(void)
   return g_cpu_freq;
 }
 
-clock_t up_perf_gettime(void)
-{
-  return (clock_t)(tricore_mfcr(TRICORE_CPU_CCNT) & CCNT_VALUE_MASK);
-}
-
 void up_perf_convert(clock_t elapsed, struct timespec *ts)
 {
   clock_t left;
@@ -105,3 +101,9 @@ void up_perf_convert(clock_t elapsed, struct timespec *ts)
   ts->tv_nsec = invdiv_u64(NSEC_PER_SEC * (uint64_t)left, &g_invdiv_param);
 }
 #endif
+
+clock_t up_perf_gettime(void)
+{
+  return (clock_t)(tricore_mfcr(TRICORE_CPU_CCNT) & CCNT_VALUE_MASK);
+}
+#endif

Reply via email to