1 #ifndef __ASM_METAG_ATOMIC_LNKGET_H
2 #define __ASM_METAG_ATOMIC_LNKGET_H
4 #define ATOMIC_INIT(i) { (i) }
6 #define atomic_set(v, i) WRITE_ONCE((v)->counter, (i))
8 #include <linux/compiler.h>
10 #include <asm/barrier.h>
13 * None of these asm statements clobber memory as LNKSET writes around
14 * the cache so the memory it modifies cannot safely be read by any means
15 * other than these accessors.
18 static inline int atomic_read(const atomic_t *v)
25 : "da" (&v->counter));
30 #define ATOMIC_OP(op) \
31 static inline void atomic_##op(int i, atomic_t *v) \
36 "1: LNKGETD %0, [%1]\n" \
37 " " #op " %0, %0, %2\n" \
38 " LNKSETD [%1], %0\n" \
39 " DEFR %0, TXSTAT\n" \
40 " ANDT %0, %0, #HI(0x3f000000)\n" \
41 " CMPT %0, #HI(0x02000000)\n" \
44 : "da" (&v->counter), "bd" (i) \
48 #define ATOMIC_OP_RETURN(op) \
49 static inline int atomic_##op##_return(int i, atomic_t *v) \
56 "1: LNKGETD %1, [%2]\n" \
57 " " #op " %1, %1, %3\n" \
58 " LNKSETD [%2], %1\n" \
59 " DEFR %0, TXSTAT\n" \
60 " ANDT %0, %0, #HI(0x3f000000)\n" \
61 " CMPT %0, #HI(0x02000000)\n" \
63 : "=&d" (temp), "=&da" (result) \
64 : "da" (&v->counter), "bd" (i) \
72 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
82 #undef ATOMIC_OP_RETURN
85 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
92 "1: LNKGETD %1, [%2]\n"
94 " LNKSETDEQ [%2], %4\n"
97 " ANDT %0, %0, #HI(0x3f000000)\n"
98 " CMPT %0, #HI(0x02000000)\n"
101 : "=&d" (temp), "=&d" (result)
102 : "da" (&v->counter), "bd" (old), "da" (new)
110 static inline int atomic_xchg(atomic_t *v, int new)
115 "1: LNKGETD %1, [%2]\n"
116 " LNKSETD [%2], %3\n"
118 " ANDT %0, %0, #HI(0x3f000000)\n"
119 " CMPT %0, #HI(0x02000000)\n"
121 : "=&d" (temp), "=&d" (old)
122 : "da" (&v->counter), "da" (new)
128 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
135 "1: LNKGETD %1, [%2]\n"
138 " LNKSETDNE [%2], %0\n"
141 " ANDT %0, %0, #HI(0x3f000000)\n"
142 " CMPT %0, #HI(0x02000000)\n"
145 : "=&d" (temp), "=&d" (result)
146 : "da" (&v->counter), "bd" (u), "bd" (a)
154 static inline int atomic_sub_if_positive(int i, atomic_t *v)
159 "1: LNKGETD %1, [%2]\n"
161 " LNKSETDGE [%2], %1\n"
164 " ANDT %0, %0, #HI(0x3f000000)\n"
165 " CMPT %0, #HI(0x02000000)\n"
168 : "=&d" (temp), "=&da" (result)
169 : "da" (&v->counter), "bd" (i)
175 #endif /* __ASM_METAG_ATOMIC_LNKGET_H */