diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2007-03-17 23:42:07 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2007-03-17 23:42:07 +0000 |
commit | d142a65d62ed395d327a6f9a5558c75b1e9a9c40 (patch) | |
tree | c00424bdb2e23b59ea7cec400cfde027ee210473 | |
parent | 66842cdc24fa5ece692a06fc8131157de196905b (diff) |
For arm pre-v6 (ie all supported machines) it is necessary to disable
interrupts to be able to have an atomic update of a variable without a mutex.
-rw-r--r-- | sys/arch/arm/include/atomic.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/arch/arm/include/atomic.h b/sys/arch/arm/include/atomic.h index a3ac330fc85..280a48d59ca 100644 --- a/sys/arch/arm/include/atomic.h +++ b/sys/arch/arm/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.4 2007/02/19 17:18:42 deraadt Exp $ */ +/* $OpenBSD: atomic.h,v 1.5 2007/03/17 23:42:06 drahn Exp $ */ /* Public Domain */ @@ -7,16 +7,27 @@ #if defined(_KERNEL) +/* + * on pre-v6 arm processors, it is necessary to disable interrupts if + * in the kernel and atomic updates are necessary without full mutexes + */ + static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { + int oldirqstate; + oldirqstate = disable_interrupts(I32_bit|F32_bit); *uip |= v; + restore_interrupts(oldirqstate); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { + int oldirqstate; + oldirqstate = disable_interrupts(I32_bit|F32_bit); *uip &= ~v; + restore_interrupts(oldirqstate); } #endif /* defined(_KERNEL) */ |