Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 1 | #ifndef __ASM_SH_CMPXCHG_LLSC_H |
| 2 | #define __ASM_SH_CMPXCHG_LLSC_H |
| 3 | |
| 4 | static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) |
| 5 | { |
| 6 | unsigned long retval; |
| 7 | unsigned long tmp; |
| 8 | |
| 9 | __asm__ __volatile__ ( |
| 10 | "1: \n\t" |
Matt Fleming | 4299070 | 2009-01-20 21:14:37 +0000 | [diff] [blame] | 11 | "movli.l @%2, %0 ! xchg_u32 \n\t" |
| 12 | "mov %0, %1 \n\t" |
| 13 | "mov %3, %0 \n\t" |
| 14 | "movco.l %0, @%2 \n\t" |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 15 | "bf 1b \n\t" |
| 16 | "synco \n\t" |
Matt Fleming | 4299070 | 2009-01-20 21:14:37 +0000 | [diff] [blame] | 17 | : "=&z"(tmp), "=&r" (retval) |
| 18 | : "r" (m), "r" (val) |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 19 | : "t", "memory" |
| 20 | ); |
| 21 | |
| 22 | return retval; |
| 23 | } |
| 24 | |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 25 | static inline unsigned long |
Michael S. Tsirkin | 3226aad | 2016-01-07 17:54:54 +0200 | [diff] [blame] | 26 | __cmpxchg_u32(volatile u32 *m, unsigned long old, unsigned long new) |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 27 | { |
| 28 | unsigned long retval; |
| 29 | unsigned long tmp; |
| 30 | |
| 31 | __asm__ __volatile__ ( |
| 32 | "1: \n\t" |
Matt Fleming | 4299070 | 2009-01-20 21:14:37 +0000 | [diff] [blame] | 33 | "movli.l @%2, %0 ! __cmpxchg_u32 \n\t" |
| 34 | "mov %0, %1 \n\t" |
| 35 | "cmp/eq %1, %3 \n\t" |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 36 | "bf 2f \n\t" |
Aoi Shinkai | 4c7c997 | 2009-06-10 16:15:42 +0000 | [diff] [blame] | 37 | "mov %4, %0 \n\t" |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 38 | "2: \n\t" |
Matt Fleming | 4299070 | 2009-01-20 21:14:37 +0000 | [diff] [blame] | 39 | "movco.l %0, @%2 \n\t" |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 40 | "bf 1b \n\t" |
| 41 | "synco \n\t" |
Matt Fleming | 4299070 | 2009-01-20 21:14:37 +0000 | [diff] [blame] | 42 | : "=&z" (tmp), "=&r" (retval) |
| 43 | : "r" (m), "r" (old), "r" (new) |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 44 | : "t", "memory" |
| 45 | ); |
| 46 | |
| 47 | return retval; |
| 48 | } |
| 49 | |
Michael S. Tsirkin | 9e3f84c | 2016-01-08 09:23:58 +0200 | [diff] [blame] | 50 | #include <asm/cmpxchg-xchg.h> |
Michael S. Tsirkin | 3226aad | 2016-01-07 17:54:54 +0200 | [diff] [blame] | 51 | |
Paul Mundt | ee43a84 | 2008-08-07 18:01:43 +0900 | [diff] [blame] | 52 | #endif /* __ASM_SH_CMPXCHG_LLSC_H */ |