Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Mar 2015 10:04:14 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279483 - head/sys/cddl/dev/dtrace/arm
Message-ID:  <201503011004.t21A4EkE058398@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sun Mar  1 10:04:14 2015
New Revision: 279483
URL: https://svnweb.freebsd.org/changeset/base/279483

Log:
  Fix the dtrace ARM atomic compare-and-set functions. These functions are
  expected to return the data in the memory location pointed at by target
  after the operation. The FreeBSD atomic functions previously used return
  either 0 or 1 to indicate if the comparison succeeded or not respectively.
  
  With this change these functions only support ARMv6 and later are supported
  by these functions.
  
  Sponsored by:	ABT Systems Ltd

Modified:
  head/sys/cddl/dev/dtrace/arm/dtrace_asm.S
  head/sys/cddl/dev/dtrace/arm/dtrace_isa.c

Modified: head/sys/cddl/dev/dtrace/arm/dtrace_asm.S
==============================================================================
--- head/sys/cddl/dev/dtrace/arm/dtrace_asm.S	Sun Mar  1 09:29:59 2015	(r279482)
+++ head/sys/cddl/dev/dtrace/arm/dtrace_asm.S	Sun Mar  1 10:04:14 2015	(r279483)
@@ -195,3 +195,25 @@ ENTRY(dtrace_caller)
 	mov	r0, #-1
 	RET
 END(dtrace_caller)
+
+/*
+uint32_t
+dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
+
+void *
+dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
+*/
+ENTRY(dtrace_cas32)
+EENTRY(dtrace_casptr)
+1:	ldrex	r3, [r0]	/* Load target */
+	cmp	r3, r1		/* Check if *target == cmp */
+	bne	2f		/* No, return */
+	strex	r3, r2, [r0]	/* Store new to target */
+	cmp	r3, #0		/* Did the store succeed? */
+	bne	1b		/* No, try again */
+	mov	r0, r2		/* Return the new value of the store */
+2:	movne	r0, r3		/* The first compare failed, return */
+				/* the value loaded from memory */
+	RET
+EEND(dtrace_casptr)
+END(dtrace_cas32)

Modified: head/sys/cddl/dev/dtrace/arm/dtrace_isa.c
==============================================================================
--- head/sys/cddl/dev/dtrace/arm/dtrace_isa.c	Sun Mar  1 09:29:59 2015	(r279482)
+++ head/sys/cddl/dev/dtrace/arm/dtrace_isa.c	Sun Mar  1 10:04:14 2015	(r279483)
@@ -262,34 +262,3 @@ dtrace_fuword64(void *uaddr)
 	}
 	return (dtrace_fuword64_nocheck(uaddr));
 }
-
-#define __with_interrupts_disabled(expr) \
-	do {						\
-		u_int cpsr_save, tmp;			\
-							\
-		__asm __volatile(			\
-			"mrs  %0, cpsr;"		\
-			"orr  %1, %0, %2;"		\
-			"msr  cpsr_fsxc, %1;"		\
-			: "=r" (cpsr_save), "=r" (tmp)	\
-			: "I" (PSR_I | PSR_F)		    \
-			: "cc" );		\
-		(expr);				\
-		 __asm __volatile(		\
-			"msr  cpsr_fsxc, %0"	\
-			: /* no output */	\
-			: "r" (cpsr_save)	\
-			: "cc" );		\
-	} while(0)
-
-uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
-{
-	return atomic_cmpset_32((uint32_t*)target, (uint32_t)cmp, (uint32_t)new);
-
-}
-
-void * dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
-{
-        return (void*)dtrace_cas32((uint32_t*)target, (uint32_t)cmp, (uint32_t)new);
-}
-



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503011004.t21A4EkE058398>