summaryrefslogtreecommitdiff
path: root/sys/arch/hppa/include/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hppa/include/atomic.h')
-rw-r--r--sys/arch/hppa/include/atomic.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/arch/hppa/include/atomic.h b/sys/arch/hppa/include/atomic.h
index 16514db9153..ca98933c21d 100644
--- a/sys/arch/hppa/include/atomic.h
+++ b/sys/arch/hppa/include/atomic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomic.h,v 1.3 2007/04/26 20:52:48 miod Exp $ */
+/* $OpenBSD: atomic.h,v 1.4 2010/06/27 00:04:44 jsing Exp $ */
/* Public Domain */
@@ -7,6 +7,17 @@
#if defined(_KERNEL)
+#include <sys/mutex.h>
+
+#ifdef MULTIPROCESSOR
+extern struct mutex mtx_atomic;
+#define ATOMIC_LOCK mtx_enter(&mtx_atomic)
+#define ATOMIC_UNLOCK mtx_leave(&mtx_atomic)
+#else
+#define ATOMIC_LOCK
+#define ATOMIC_UNLOCK
+#endif
+
static __inline void
atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
{
@@ -14,7 +25,9 @@ atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
+ ATOMIC_LOCK;
*uip |= v;
+ ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
@@ -25,7 +38,9 @@ atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
+ ATOMIC_LOCK;
*uip &= ~v;
+ ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
@@ -36,7 +51,9 @@ atomic_setbits_long(__volatile unsigned long *uip, unsigned long v)
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
+ ATOMIC_LOCK;
*uip |= v;
+ ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
@@ -47,7 +64,9 @@ atomic_clearbits_long(__volatile unsigned long *uip, unsigned long v)
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
+ ATOMIC_LOCK;
*uip &= ~v;
+ ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}