Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for atomic operations to NetBSD port to lm32

  • Loading branch information...
commit 21b5975f4c9b97e5d0d517ed30540163a2b0cf9c 1 parent 75703dc
Yann Sionneau authored April 21, 2013
17  common/lib/libc/arch/lm32/atomic/Makefile.inc
... ...
@@ -0,0 +1,17 @@
  1
+#	$NetBSD: Makefile.inc,v 1.5 2009/01/04 17:54:29 pooka Exp $
  2
+
  3
+.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
  4
+	|| ${LIB} == "rump")
  5
+
  6
+SRCS+=	atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
  7
+	atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
  8
+	atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
  9
+	atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
  10
+
  11
+.endif
  12
+
  13
+.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
  14
+
  15
+SRCS+=	atomic_init_testset.c
  16
+
  17
+.endif
1  sys/arch/lm32/conf/files.lm32
@@ -2,3 +2,4 @@ include "arch/lm32/conf/majors.lm32"
2 2
 
3 3
 file 	arch/lm32/lm32/pmap.c
4 4
 file 	arch/lm32/lm32/copy.c
  5
+file    arch/lm32/lm32/lock_stubs.S
43  sys/arch/lm32/lm32/lock_stubs.S
... ...
@@ -0,0 +1,43 @@
  1
+/*
  2
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
  3
+ */
  4
+
  5
+#include <lm32/asm.h>
  6
+
  7
+/*
  8
+ * int _atomic_cas_32(volatile uint32_t *val, uint32_t old, uint32_t new);
  9
+ *
  10
+ * The lm32 softcore does not have a cas instruction, so we implement this as
  11
+ * a restartable atomic sequence.  For an example of how this is used,
  12
+ * see sun68k/sun68k/isr.c or vax/vax/trap.c
  13
+ */
  14
+ENTRY(_atomic_cas_32)
  15
+
  16
+	.globl _C_LABEL(_atomic_cas_ras_start)
  17
+_C_LABEL(_atomic_cas_ras_start):
  18
+	lw	r4, (r1+0) /* load *val into r4 */
  19
+	bne	r4, r2, 1f /* compare r4 (*val) and old (r2) */
  20
+	sw	(r1+0), r3
  21
+	.globl	_C_LABEL(_atomic_cas_ras_end)
  22
+_C_LABEL(_atomic_cas_ras_end):
  23
+
  24
+1:
  25
+	mv	r1, r4	/* return (*val) */
  26
+	ret
  27
+
  28
+STRONG_ALIAS(atomic_cas_ptr,_atomic_cas_32)
  29
+STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
  30
+STRONG_ALIAS(atomic_cas_uint,_atomic_cas_32)
  31
+STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
  32
+STRONG_ALIAS(atomic_cas_ulong,_atomic_cas_32)
  33
+STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
  34
+STRONG_ALIAS(atomic_cas_32,_atomic_cas_32)
  35
+
  36
+STRONG_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
  37
+STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
  38
+STRONG_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
  39
+STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
  40
+STRONG_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
  41
+STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
  42
+STRONG_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
  43
+STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)

0 notes on commit 21b5975

Please sign in to comment.
Something went wrong with that request. Please try again.