patch-2.1.36 linux/arch/sparc/lib/locks.S

Next file: linux/arch/sparc/mm/Makefile
Previous file: linux/arch/sparc/lib/irqlock.S
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.35/linux/arch/sparc/lib/locks.S linux/arch/sparc/lib/locks.S
@@ -1,4 +1,4 @@
-/* $Id: locks.S,v 1.9 1997/04/14 05:38:41 davem Exp $
+/* $Id: locks.S,v 1.12 1997/04/22 18:48:07 davem Exp $
  * locks.S: SMP low-level lock primitives on Sparc.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -7,6 +7,7 @@
 #include <asm/cprefix.h>
 #include <asm/ptrace.h>
 #include <asm/psr.h>
+#include <asm/smp.h>
 #include <asm/spinlock.h>
 
 	.text
@@ -19,8 +20,8 @@
 	 * itself in %g1, %g4 must be restored into %o7 when we return,
 	 * and the caller wants us to return to him at three instructions
 	 * previous to the call instruction which got us here.  See how
-	 * this is used in asm-sparc/smp_lock.h if what I just said
-	 * confuses you to no end.
+	 * this is used in asm/smp_lock.h and asm/spinlock.h if what I
+	 * just said confuses you to no end.
 	 */
 	.globl	___spinlock_waitfor
 ___spinlock_waitfor:
@@ -59,8 +60,8 @@
 9:	jmpl	%o7 + 0x8, %g0
 	 mov	%g4, %o7
 
-	.globl	___lock_reaquire_kernel
-___lock_reaquire_kernel:
+	.globl	___lock_reacquire_kernel
+___lock_reacquire_kernel:
 	rd	%psr, %g3
 	or	%g3, PSR_PIL, %g7
 	wr	%g7, 0x0, %psr
@@ -81,9 +82,6 @@
 	jmpl	%o7 + 0x8, %g0
 	 mov	%g4, %o7
 
-#undef NO_PROC_ID
-#define NO_PROC_ID	0xff
-
 	.globl	___unlock_kernel
 ___unlock_kernel:
 	addcc	%g2, 1, %g2
@@ -100,4 +98,65 @@
 	wr	%g3, 0x0, %psr
 	nop; nop; nop;
 1:	jmpl	%o7 + 0x8, %g0
+	 mov	%g4, %o7
+
+	/* Read/writer locks, as usual this is overly clever to make it
+	 * as fast as possible.
+	 */
+
+	/* caches... */
+___rw_read_enter_spin_on_wlock:
+	orcc	%g2, 0x0, %g0
+	be,a	___rw_read_enter
+	 ldstub	[%g1 + 3], %g2
+	b	___rw_read_enter_spin_on_wlock
+	 ldub	[%g1 + 3], %g2
+___rw_write_enter_spin_on_wlock:
+	orcc	%g2, 0x0, %g0
+	be,a	___rw_write_enter
+	 ldstub	[%g1 + 3], %g2
+	b	___rw_write_enter_spin_on_wlock
+	 ldub	[%g1 + 3], %g2
+
+	.globl	___rw_read_enter
+___rw_read_enter:
+	orcc	%g2, 0x0, %g0
+	bne,a	___rw_read_enter_spin_on_wlock
+	 ldub	[%g1 + 3], %g2
+1:
+	ldstub	[%g1 + 2], %g7
+	orcc	%g7, 0x0, %g0
+	bne	1b
+	 ldsh	[%g1], %g2
+	add	%g2, 1, %g2
+	sth	%g2, [%g1]
+	sth	%g0, [%g1 + 2]
+	retl
+	 mov	%g4, %o7
+
+	/* We must be careful here to not blow away wlock. */
+	.globl	___rw_read_exit
+___rw_read_exit_spin:
+	ldstub	[%g1 + 2], %g2
+___rw_read_exit:
+	orcc	%g2, 0x0, %g0
+	bne	___rw_read_exit_spin
+	 ldsh	[%g1], %g7
+	sub	%g7, 1, %g7
+	sth	%g7, [%g1]
+	stb	%g0, [%g1 + 2]
+	retl
+	 mov	%g4, %o7
+
+	.globl	___rw_write_enter
+___rw_write_enter:
+	orcc	%g2, 0x0, %g0
+	bne,a	___rw_write_enter_spin_on_wlock
+	 ldub	[%g1 + 3], %g2
+	ld	[%g1], %g2
+1:
+	andncc	%g2, 0xff, %g0
+	bne,a	1b
+	 ld	[%g1], %g2
+	retl
 	 mov	%g4, %o7

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov