This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6c4992aca84 arch/tricore: use __asm__/__volatile__ for tasking
tc3xx/tc4xx
6c4992aca84 is described below
commit 6c4992aca84dca52018e54f23bb35ca751624645
Author: zhangyu117 <[email protected]>
AuthorDate: Tue Feb 24 16:27:41 2026 +0800
arch/tricore: use __asm__/__volatile__ for tasking tc3xx/tc4xx
TASKING manual documents __asm; __asm__ and bare volatile in asm
statements are not accepted under tc3xx. include/nuttx/compiler.h
already maps __asm__/__volatile__ for TASKING, so use
__asm__ __volatile__ consistently in arch/tricore.
Signed-off-by: zhangyu117 <[email protected]>
---
arch/tricore/include/arch.h | 22 ++++++++++--------
arch/tricore/include/barriers.h | 10 ++++----
arch/tricore/include/irq.h | 7 +++---
arch/tricore/include/syscall.h | 28 +++++++++++------------
arch/tricore/src/common/tricore_idle.c | 4 ++--
arch/tricore/src/common/tricore_irq.c | 2 +-
arch/tricore/src/common/tricore_saveusercontext.c | 4 ++--
arch/tricore/src/common/tricore_trapcall.c | 16 ++++++-------
8 files changed, 48 insertions(+), 45 deletions(-)
diff --git a/arch/tricore/include/arch.h b/arch/tricore/include/arch.h
index 7076edb0ff2..a1c2f269319 100644
--- a/arch/tricore/include/arch.h
+++ b/arch/tricore/include/arch.h
@@ -47,16 +47,16 @@
/* 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_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; \
+#define tricore_mfcr(reg) \
+ ({ \
+ uint32_t __val; \
+ __asm__ __volatile__ ("mfcr %0,%1": "=d" (__val) :"i"(reg): "memory"); \
+ __val; \
})
/* Return from a handler that the trap or interrupt vector entered with
@@ -64,9 +64,11 @@
*/
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
-# define tricore_jump_backto_link() __asm__ volatile ("ji a11" : : : "a11")
+# define tricore_jump_backto_link() \
+ __asm__ __volatile__ ("ji a11" : : : "a11")
#else
-# define tricore_jump_backto_link() __asm__ volatile ("ji %a11")
+# define tricore_jump_backto_link() \
+ __asm__ __volatile__ ("ji %a11")
#endif
/****************************************************************************
diff --git a/arch/tricore/include/barriers.h b/arch/tricore/include/barriers.h
index 8d5fbfbfa13..146e1a79d01 100644
--- a/arch/tricore/include/barriers.h
+++ b/arch/tricore/include/barriers.h
@@ -21,11 +21,11 @@
#ifndef __ARCH_TRICORE_INCLUDE_BARRIERS_H
#define __ARCH_TRICORE_INCLUDE_BARRIERS_H
-#define UP_DSB() __asm__ volatile ("dsync" : : : "memory")
-#define UP_DMB() asm volatile ("" : : : "memory")
-#define UP_RMB() asm volatile ("" : : : "memory")
-#define UP_WMB() asm volatile ("" : : : "memory")
-#define UP_ISB() __asm__ volatile ("isync" : : : "memory")
+#define UP_DSB() __asm__ __volatile__ ("dsync" : : : "memory")
+#define UP_DMB() __asm__ __volatile__ ("" : : : "memory")
+#define UP_RMB() __asm__ __volatile__ ("" : : : "memory")
+#define UP_WMB() __asm__ __volatile__ ("" : : : "memory")
+#define UP_ISB() __asm__ __volatile__ ("isync" : : : "memory")
#endif /* __ARCH_TRICORE_INCLUDE_BARRIERS_H */
diff --git a/arch/tricore/include/irq.h b/arch/tricore/include/irq.h
index 9e23a22a2cc..a119d9fdcf8 100644
--- a/arch/tricore/include/irq.h
+++ b/arch/tricore/include/irq.h
@@ -231,7 +231,8 @@ noinstrument_function static inline_function uintptr_t
up_getpc(void)
return (uintptr_t)__mfcr(TRICORE_CPU_PC);
#else
uintptr_t pc;
- __asm__ volatile ("mfcr %0,%1": "=d" (pc) :"i"(TRICORE_CPU_PC): "memory");
+ __asm__ __volatile__ ("mfcr %0,%1": "=d" (pc) :"i"(TRICORE_CPU_PC):
+ "memory");
return pc;
#endif
}
@@ -283,7 +284,7 @@ noinstrument_function static inline_function irqstate_t
up_irq_save(void)
#else
irqstate_t flags;
- __asm__ volatile ("disable %0" : "=d"(flags) : : "memory");
+ __asm__ __volatile__ ("disable %0" : "=d"(flags) : : "memory");
return flags;
#endif
}
@@ -313,7 +314,7 @@ void up_irq_restore(irqstate_t flags)
UP_ISB();
}
#else
- __asm__ volatile ("restore %0" : : "d"(flags) : "memory");
+ __asm__ __volatile__ ("restore %0" : : "d"(flags) : "memory");
#endif
}
diff --git a/arch/tricore/include/syscall.h b/arch/tricore/include/syscall.h
index b0e10cd7a52..e86eb592e45 100644
--- a/arch/tricore/include/syscall.h
+++ b/arch/tricore/include/syscall.h
@@ -135,14 +135,14 @@ static inline uintptr_t sys_call0(unsigned int nbr)
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
:
: "d"(nbr)
: "d8"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -171,7 +171,7 @@ static inline uintptr_t sys_call1(unsigned int nbr,
uintptr_t parm1)
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -179,7 +179,7 @@ static inline uintptr_t sys_call1(unsigned int nbr,
uintptr_t parm1)
: "d"(nbr), "d"(parm1)
: "d8", "d9"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -210,7 +210,7 @@ static inline uintptr_t sys_call2(unsigned int nbr,
uintptr_t parm1,
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -219,7 +219,7 @@ static inline uintptr_t sys_call2(unsigned int nbr,
uintptr_t parm1,
: "d"(nbr), "d"(parm1), "d"(parm2)
: "d8", "d9", "d10"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -251,7 +251,7 @@ static inline uintptr_t sys_call3(unsigned int nbr,
uintptr_t parm1,
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -261,7 +261,7 @@ static inline uintptr_t sys_call3(unsigned int nbr,
uintptr_t parm1,
: "d"(nbr), "d"(parm1), "d"(parm2), "d"(parm3)
: "d8", "d9", "d10", "d11"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -295,7 +295,7 @@ static inline uintptr_t sys_call4(unsigned int nbr,
uintptr_t parm1,
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -306,7 +306,7 @@ static inline uintptr_t sys_call4(unsigned int nbr,
uintptr_t parm1,
: "d"(nbr), "d"(parm1), "d"(parm2), "d"(parm3), "d"(parm4)
: "d8", "d9", "d10", "d11", "d12"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -342,7 +342,7 @@ static inline uintptr_t sys_call5(unsigned int nbr,
uintptr_t parm1,
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -354,7 +354,7 @@ static inline uintptr_t sys_call5(unsigned int nbr,
uintptr_t parm1,
: "d"(nbr), "d"(parm1), "d"(parm2), "d"(parm3), "d"(parm4), "d"(parm5)
: "d8", "d9", "d10", "d11", "d12", "d13"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
@@ -392,7 +392,7 @@ static inline uintptr_t sys_call6(unsigned int nbr,
uintptr_t parm1,
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
register long reg0;
- __asm volatile
+ __asm__ __volatile__
(
"mov d8, %0 \n\t"
"mov d9, %1 \n\t"
@@ -406,7 +406,7 @@ static inline uintptr_t sys_call6(unsigned int nbr,
uintptr_t parm1,
"d"(parm3), "d"(parm4), "d"(parm5), "d"(parm6)
: "d8", "d9", "d10", "d11", "d12", "d13", "d14"
);
- __asm volatile
+ __asm__ __volatile__
(
"syscall %1"
: "=d"(reg0)
diff --git a/arch/tricore/src/common/tricore_idle.c
b/arch/tricore/src/common/tricore_idle.c
index 402f8d04cf6..3f271e633ed 100644
--- a/arch/tricore/src/common/tricore_idle.c
+++ b/arch/tricore/src/common/tricore_idle.c
@@ -37,9 +37,9 @@
****************************************************************************/
#if defined(__TASKING__)
-# define tricore_idle_loop() __asm__ volatile ("1: loopu 1p")
+# define tricore_idle_loop() __asm__ __volatile__ ("1: loopu 1p")
#else
-# define tricore_idle_loop() __asm__ volatile ("1: loopu 1b")
+# define tricore_idle_loop() __asm__ __volatile__ ("1: loopu 1b")
#endif
/****************************************************************************
diff --git a/arch/tricore/src/common/tricore_irq.c
b/arch/tricore/src/common/tricore_irq.c
index 7902a1c742e..4176c35906a 100644
--- a/arch/tricore/src/common/tricore_irq.c
+++ b/arch/tricore/src/common/tricore_irq.c
@@ -154,7 +154,7 @@ void up_irq_enable(void)
UP_ISB();
#endif
- __asm__ volatile ("enable" : : : "memory");
+ __asm__ __volatile__ ("enable" : : : "memory");
}
/****************************************************************************
diff --git a/arch/tricore/src/common/tricore_saveusercontext.c
b/arch/tricore/src/common/tricore_saveusercontext.c
index bb5f3c69bed..343e30e1163 100644
--- a/arch/tricore/src/common/tricore_saveusercontext.c
+++ b/arch/tricore/src/common/tricore_saveusercontext.c
@@ -60,7 +60,7 @@ int up_saveusercontext(void *saveregs)
/* to unify the trap processing, extra save lowcsa */
- __asm("svlcx");
+ __asm__("svlcx");
regs = tricore_csa2addr(tricore_mfcr(TRICORE_CPU_PCXI));
memcpy(saveregs, regs, csa_size);
@@ -73,7 +73,7 @@ int up_saveusercontext(void *saveregs)
((uintptr_t *)saveregs)[REG_LPCXI] = pcxi & (~PCXI_UL);
- __asm("rslcx");
+ __asm__("rslcx");
return 0;
}
diff --git a/arch/tricore/src/common/tricore_trapcall.c
b/arch/tricore/src/common/tricore_trapcall.c
index f2e77a147ce..953c82cce6a 100644
--- a/arch/tricore/src/common/tricore_trapcall.c
+++ b/arch/tricore/src/common/tricore_trapcall.c
@@ -412,15 +412,15 @@ noinstrument_function void tricore_fcu_recover(void)
/* A11 is the trap return address, from the saved upper context */
#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING
- __asm__ volatile ("ld.a a11, [%0]12\n\t"
- "mov d15, #4\n\t"
- "mov d5, #3\n\t"
- "j tricore_trap_entry\n\t" : : "a"(csa));
+ __asm__ __volatile__ ("ld.a a11, [%0]12\n\t"
+ "mov d15, #4\n\t"
+ "mov d5, #3\n\t"
+ "j tricore_trap_entry\n\t" : : "a"(csa));
#else
- __asm__ volatile ("ld.a %%a11, [%0]12\n\t"
- "mov %%d15, 4\n\t"
- "mov %%d5, 3\n\t"
- "j tricore_trap_entry\n\t" : : "a"(csa));
+ __asm__ __volatile__ ("ld.a %%a11, [%0]12\n\t"
+ "mov %%d15, 4\n\t"
+ "mov %%d5, 3\n\t"
+ "j tricore_trap_entry\n\t" : : "a"(csa));
#endif
for (; ; );