Module Name:    src
Committed By:   chs
Date:           Wed Jul  7 01:19:10 UTC 2010

Modified Files:
        src/sys/arch/mips/include: asm.h
        src/sys/arch/mips/mips: lock_stubs.S

Log Message:
implement ucas_* for mips.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/mips/include/asm.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/mips/lock_stubs.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/include/asm.h
diff -u src/sys/arch/mips/include/asm.h:1.41 src/sys/arch/mips/include/asm.h:1.42
--- src/sys/arch/mips/include/asm.h:1.41	Mon Dec 14 00:46:04 2009
+++ src/sys/arch/mips/include/asm.h	Wed Jul  7 01:19:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: asm.h,v 1.41 2009/12/14 00:46:04 matt Exp $	*/
+/*	$NetBSD: asm.h,v 1.42 2010/07/07 01:19:09 chs Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -615,7 +615,7 @@
 #endif
 
 /* See lock_stubs.S. */
-#define	MIPS_LOCK_RAS_SIZE	128
+#define	MIPS_LOCK_RAS_SIZE	256
 
 #define	CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
 

Index: src/sys/arch/mips/mips/lock_stubs.S
diff -u src/sys/arch/mips/mips/lock_stubs.S:1.11 src/sys/arch/mips/mips/lock_stubs.S:1.12
--- src/sys/arch/mips/mips/lock_stubs.S:1.11	Sat Jan  9 11:49:16 2010
+++ src/sys/arch/mips/mips/lock_stubs.S	Wed Jul  7 01:19:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.11 2010/01/09 11:49:16 simonb Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.12 2010/07/07 01:19:09 chs Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
 #include "opt_lockdebug.h"
 #include "opt_multiprocessor.h"
 
+#include <sys/errno.h>
 #include <machine/asm.h>
 #include <machine/cpu.h>
 
@@ -137,6 +138,62 @@
 STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_uint)
 STRONG_ALIAS(atomic_cas_uint_ni,_atomic_cas_uint)
 
+/*
+ * int ucas_32(volatile int32_t *uptr, int32_t old, int32_t new, int32_t *ret);
+ */
+LEAF(ucas_32)
+	blt	a0, zero, 4f
+	 PTR_L	v1, L_PCB(MIPS_CURLWP)
+	PTR_LA	v0, 3f
+	PTR_S	v0, PCB_ONFAULT(v1)
+1:
+	ll	t0, (a0)
+	bne	t0, a1, 2f
+	 move	t1, a2
+	sc	t1, (a0)
+	beq	t1, zero, 1b
+2:
+	 INT_S	t0, (a3)
+	move	v0, zero
+3:
+	j	ra
+	 PTR_S	zero, PCB_ONFAULT(v1)
+4:
+	b	3b
+	 li	v0, EFAULT
+END(ucas_32)
+STRONG_ALIAS(ucas_int,ucas_32)
+
+/*
+ * int ucas_64(volatile int64_t *uptr, int64_t old, int64_t new, int64_t *ret);
+ */
+LEAF(ucas_64)
+	blt	a0, zero, 4f
+	 PTR_L	v1, L_PCB(MIPS_CURLWP)
+	PTR_LA	v0, 3f
+	PTR_S	v0, PCB_ONFAULT(v1)
+1:
+	lld	t0, (a0)
+	bne	t0, a1, 2f
+	 move	t1, a2
+	scd	t1, (a0)
+	beq	t1, zero, 1b
+2:
+	 INT_S	t0, (a3)
+	move	v0, zero
+3:
+	j	ra
+	 PTR_S	zero, PCB_ONFAULT(v1)
+4:
+	b	3b
+	 li	v0, EFAULT
+END(ucas_64)
+#ifdef _LP64
+STRONG_ALIAS(ucas_ptr,ucas_64)
+#else
+STRONG_ALIAS(ucas_ptr,ucas_32)
+#endif
+
 #ifndef LOCKDEBUG
 
 /*
@@ -237,11 +294,11 @@
  *   top of _lock_ras() for why).  The entry is defined here as the
  *   point after where a restart occurs if we trap within the section.
  *
- * o The entire code block is aligned on a 128 byte boundary, and is
- *   128 bytes in size.  This is to allow us to do an pessimistic check
+ * o The entire code block is aligned on a 256 byte boundary, and is
+ *   256 bytes in size.  This is to allow us to do an pessimistic check
  *   after taking a trap with:
  *
- *	if ((addr & ~127) == _lock_ras_start)
+ *	if ((addr & ~255) == _lock_ras_start)
  *		addr = _lock_ras(addr);
  *
  *   See definition of MIPS_LOCK_RAS_SIZE in asm.h.
@@ -259,7 +316,7 @@
  *     unsigned long old, unsigned long new);
  */
 	.text
-	.align	7
+	.align	8
 
 EXPORT(_lock_ras_start)
 
@@ -296,12 +353,42 @@
 STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_ulong)
 STRONG_ALIAS(atomic_cas_ptr_ni,_atomic_cas_ulong)
 
-#ifndef LOCKDEBUG
 /*
- * int mutex_enter(kmutex_t *mtx);
+ * int ucas_32(volatile int32_t *uptr, int32_t old, int32_t new, int32_t *ret);
  */
 	nop
 	nop
+LEAF_NOPROFILE(ucas_32)
+	blt	a0, zero, 4f
+	 PTR_L	v1, L_PCB(MIPS_CURLWP)
+	PTR_LA	v0, 3f
+	PTR_S	v0, PCB_ONFAULT(v1)
+	lw	t0, (a0)		/* <- critical section start */
+_ucas_32_start:
+	nop
+	bne	t0, a1, 2f
+	 nop
+	sw	a2, (a0)		/* <- critical section end */
+2:
+	sw	t0, (a3)
+	move	v0, zero
+3:
+	j	ra
+	 PTR_S	zero, PCB_ONFAULT(v1)
+4:
+	b	3b
+	 li	v0, EFAULT
+END(ucas_32)
+STRONG_ALIAS(ucas_int,ucas_32)
+#ifdef _LP64
+#else
+STRONG_ALIAS(ucas_ptr,ucas_32)
+#endif
+
+#ifndef LOCKDEBUG
+/*
+ * int mutex_enter(kmutex_t *mtx);
+ */
 	nop
 LEAF_NOPROFILE(mutex_enter)
 	PTR_L	t0, (a0)	/* <- critical section start */
@@ -335,7 +422,7 @@
 END(mutex_exit)
 	 nop
 
-	.align	7			/* Get out of the RAS block */
+	.align	8			/* Get out of the RAS block */
 
 /*
  * void	mutex_spin_enter(kmutex_t *mtx);
@@ -405,8 +492,11 @@
 	la	t0, _atomic_cas_start
 	beq	t2, t0, 1f
 	 nop
+	addiu	t0, _ucas_32_start - _atomic_cas_start
+	beq	t2, t0, 1f
+	 nop
 #ifndef LOCKDEBUG
-	addiu	t0, _mutex_enter_start - _atomic_cas_start
+	addiu	t0, _mutex_enter_start - _ucas_32_start
 	beq	t2, t0, 1f
 	 nop
 	addiu	t0, _mutex_exit_start - _mutex_enter_start

Reply via email to