summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmel <mmel@FreeBSD.org>2015-11-28 12:12:28 +0000
committermmel <mmel@FreeBSD.org>2015-11-28 12:12:28 +0000
commit9a64fd96daaad4fc470c9e8e4b6c3c8f14352f92 (patch)
tree3216c2b3156c11765344c37e0cd45dff6cc3beef
parentb20ba0eb138bf51227dd95a85fcbf435cf5ea248 (diff)
downloadFreeBSD-src-9a64fd96daaad4fc470c9e8e4b6c3c8f14352f92.zip
FreeBSD-src-9a64fd96daaad4fc470c9e8e4b6c3c8f14352f92.tar.gz
ARM: Implement atomic_swap_int(9). It's used in DRM2 code.
Approved by: kib (mentor)
-rw-r--r--sys/arm/include/atomic-v4.h7
-rw-r--r--sys/arm/include/atomic-v6.h19
-rw-r--r--sys/arm/include/atomic.h1
3 files changed, 27 insertions, 0 deletions
diff --git a/sys/arm/include/atomic-v4.h b/sys/arm/include/atomic-v4.h
index e8f6fb2..0c0b377 100644
--- a/sys/arm/include/atomic-v4.h
+++ b/sys/arm/include/atomic-v4.h
@@ -363,6 +363,13 @@ atomic_readandclear_32(volatile u_int32_t *p)
return (__swp(0, p));
}
+static __inline uint32_t
+atomic_swap_32(volatile u_int32_t *p, u_int32_t v)
+{
+
+ return (__swp(v, p));
+}
+
#define atomic_cmpset_rel_32 atomic_cmpset_32
#define atomic_cmpset_acq_32 atomic_cmpset_32
#define atomic_set_rel_32 atomic_set_32
diff --git a/sys/arm/include/atomic-v6.h b/sys/arm/include/atomic-v6.h
index aa1780f..06cb507 100644
--- a/sys/arm/include/atomic-v6.h
+++ b/sys/arm/include/atomic-v6.h
@@ -641,6 +641,25 @@ atomic_testandset_64(volatile uint64_t *p, u_int v)
return (atomic_testandset_32(p32, v));
}
+static __inline uint32_t
+atomic_swap_32(volatile uint32_t *p, uint32_t v)
+{
+ uint32_t ret, exflag;
+
+ __asm __volatile(
+ "1: ldrex %[ret], [%[ptr]] \n"
+ " strex %[exf], %[val], [%[ptr]] \n"
+ " teq %[exf], #0 \n"
+ " it ne \n"
+ " bne 1b \n"
+ : [ret] "=r" (ret),
+ [exf] "=&r" (exflag)
+ : [val] "r" (v),
+ [ptr] "r" (p)
+ : "cc", "memory");
+ return (ret);
+}
+
#undef ATOMIC_ACQ_REL
#undef ATOMIC_ACQ_REL_LONG
diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h
index 039af34..ee89f06 100644
--- a/sys/arm/include/atomic.h
+++ b/sys/arm/include/atomic.h
@@ -109,5 +109,6 @@ atomic_store_long(volatile u_long *dst, u_long src)
#define atomic_readandclear_int atomic_readandclear_32
#define atomic_load_acq_int atomic_load_acq_32
#define atomic_store_rel_int atomic_store_rel_32
+#define atomic_swap_int atomic_swap_32
#endif /* _MACHINE_ATOMIC_H_ */
OpenPOWER on IntegriCloud