Port-mips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ucas for MIPS



Some time ago rmind@ asked me to write this.  Can anyone review?

(Not tested at all. :)

Masao

Index: sys/arch/mips/mips/copy.S
===================================================================
RCS file: /src/netbsd/cvsroot/src/sys/arch/mips/mips/copy.S,v
retrieving revision 1.5
diff -u -r1.5 copy.S
--- sys/arch/mips/mips/copy.S   17 Oct 2007 19:55:37 -0000      1.5
+++ sys/arch/mips/mips/copy.S   22 Feb 2009 15:25:11 -0000
@@ -411,6 +411,40 @@
 END(subyte)
 
 /*
+ * int ucasword(volatile void *uptr, void *old, void *new, void *ret);
+ * Compare-and-swap the pointer in the user-space.
+ */
+LEAF(ucas_uint)
+       lw      v1, L_ADDR(MIPS_CURLWP)
+       la      v0, _C_LABEL(baderr)
+       blt     a0, zero, _C_LABEL(baderr)
+       sw      v0, U_PCB_ONFAULT(v1)
+
+       lw      a1, (a1)
+       lw      a2, (a2)
+
+1:     /* Perform the CAS. */
+       ll      t0, (a0)
+       bne     t0, a1, 2f
+        addu   t1, zero, a2
+       sc      t1, (a0)
+       beq     t1, zero, 1b
+        nop
+
+       /* Succeeded. */
+       sw      zero, U_PCB_ONFAULT(v1)
+       sw      a1, (a3)
+       j       ra
+        move   v0, zero
+
+2:     /* Failure case. */
+       sw      zero, U_PCB_ONFAULT(v1)
+       sw      t0, (a3)
+       j       ra
+        move   v0, -1
+END(ucas_uint)
+
+/*
  * int badaddr(void addr, int len)
  * See if access to addr with a len type instruction causes a machine check.
  * len is length of access (1=byte, 2=short, 4=long)


Home | Main Index | Thread Index | Old Index