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

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

commit ffc9846a02312561271287085d6ed2bba944a553
Author: zhangyu117 <[email protected]>
AuthorDate: Mon Aug 10 20:05:18 2026 +0800

    arch/tricore: add tricore_mtcr and tricore_mfcr macros
    
    Add tricore_mtcr()/tricore_mfcr() inline-assembly wrappers for the
    MTCR/MFCR (move to/from Core Special Function Register) instructions.
    These let arch/tricore code access CSRs directly without relying on the
    Infineon iLLD intrinsics, and are used by the following iLLD-removal
    change in the performance-counter path.
    
    Signed-off-by: zhangyu117 <[email protected]>
---
 arch/tricore/include/arch.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/tricore/include/arch.h b/arch/tricore/include/arch.h
index 8d022db9565..811d843e7bc 100644
--- a/arch/tricore/include/arch.h
+++ b/arch/tricore/include/arch.h
@@ -42,6 +42,20 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
+/* MTCR and MFCR - move to / from Core Special Function Register */
+
+#define tricore_mtcr(reg, val)                                         \
+  ({                                                                   \
+    __asm__ volatile ("mtcr %0,%1\n\t"::"i"(reg),"d"(val):"memory");   \
+  })
+
+#define tricore_mfcr(reg)                                              \
+  ({                                                                   \
+    uint32_t __val;                                                    \
+    __asm__ volatile ("mfcr %0,%1": "=d" (__val) :"i"(reg): "memory"); \
+    __val;                                                             \
+  })
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/

Reply via email to