From cea8197c7dfaf7a62d1b667c7b3bf8a8c905c48b Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 5 Apr 2007 17:35:12 +0000 Subject: Disable interrupts around bit operations for propert atomicity against them. --- sys/arch/sh/include/atomic.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sys/arch') diff --git a/sys/arch/sh/include/atomic.h b/sys/arch/sh/include/atomic.h index 736b0e5b87a..9ba0a329bdf 100644 --- a/sys/arch/sh/include/atomic.h +++ b/sys/arch/sh/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.2 2007/02/19 17:18:43 deraadt Exp $ */ +/* $OpenBSD: atomic.h,v 1.3 2007/04/05 17:35:11 miod Exp $ */ /* Public Domain */ @@ -7,16 +7,28 @@ #if defined(_KERNEL) +#include + static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { + unsigned int sr; + + __asm__ __volatile__ ("stc sr, %0" : "=r"(sr)); + __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr | PSL_IMASK)); *uip |= v; + __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr)); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { + unsigned int sr; + + __asm__ __volatile__ ("stc sr, %0" : "=r"(sr)); + __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr | PSL_IMASK)); *uip &= ~v; + __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr)); } #endif /* defined(_KERNEL) */ -- cgit v1.2.3