diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-04-26 20:52:49 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-04-26 20:52:49 +0000 |
commit | 3cf94ca9907342b6f505b930f2528e3c0d82a229 (patch) | |
tree | 2b129c630b78558d789644d1c1383189e2e8c08d | |
parent | 886d7ecea76cd562224a6a1cc016383573ec9ad2 (diff) |
Proper atomic_{set,clear}bits_{int,long} implementation, and use it for
softintr(); ok mickey@
-rw-r--r-- | sys/arch/hppa/include/atomic.h | 34 | ||||
-rw-r--r-- | sys/arch/hppa/include/intr.h | 15 |
2 files changed, 37 insertions, 12 deletions
diff --git a/sys/arch/hppa/include/atomic.h b/sys/arch/hppa/include/atomic.h index ee7b4a4ab27..16514db9153 100644 --- a/sys/arch/hppa/include/atomic.h +++ b/sys/arch/hppa/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.2 2007/02/19 17:18:42 deraadt Exp $ */ +/* $OpenBSD: atomic.h,v 1.3 2007/04/26 20:52:48 miod Exp $ */ /* Public Domain */ @@ -10,13 +10,45 @@ static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { + register_t eiem; + + __asm __volatile("mfctl %%cr15, %0": "=r" (eiem)); + __asm __volatile("mtctl %r0, %cr15"); *uip |= v; + __asm __volatile("mtctl %0, %%cr15":: "r" (eiem)); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { + register_t eiem; + + __asm __volatile("mfctl %%cr15, %0": "=r" (eiem)); + __asm __volatile("mtctl %r0, %cr15"); + *uip &= ~v; + __asm __volatile("mtctl %0, %%cr15":: "r" (eiem)); +} + +static __inline void +atomic_setbits_long(__volatile unsigned long *uip, unsigned long v) +{ + register_t eiem; + + __asm __volatile("mfctl %%cr15, %0": "=r" (eiem)); + __asm __volatile("mtctl %r0, %cr15"); + *uip |= v; + __asm __volatile("mtctl %0, %%cr15":: "r" (eiem)); +} + +static __inline void +atomic_clearbits_long(__volatile unsigned long *uip, unsigned long v) +{ + register_t eiem; + + __asm __volatile("mfctl %%cr15, %0": "=r" (eiem)); + __asm __volatile("mtctl %r0, %cr15"); *uip &= ~v; + __asm __volatile("mtctl %0, %%cr15":: "r" (eiem)); } #endif /* defined(_KERNEL) */ diff --git a/sys/arch/hppa/include/intr.h b/sys/arch/hppa/include/intr.h index fd40afee537..3ed7bccee0a 100644 --- a/sys/arch/hppa/include/intr.h +++ b/sys/arch/hppa/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.20 2006/03/12 03:14:36 brad Exp $ */ +/* $OpenBSD: intr.h,v 1.21 2007/04/26 20:52:48 miod Exp $ */ /* * Copyright (c) 2002-2004 Michael Shalayeff @@ -55,6 +55,8 @@ #if !defined(_LOCORE) && defined(_KERNEL) +#include <machine/atomic.h> + extern volatile int cpl; extern volatile u_long ipending, imask[NIPL]; extern int astpending; @@ -116,16 +118,7 @@ splx(int ncpl) #define splhigh() splraise(IPL_HIGH) #define spl0() spllower(IPL_NONE) -static __inline void -softintr(u_long mask) -{ - register_t eiem; - - __asm __volatile("mfctl %%cr15, %0": "=r" (eiem)); - __asm __volatile("mtctl %r0, %cr15"); - ipending |= mask; - __asm __volatile("mtctl %0, %%cr15":: "r" (eiem)); -} +#define softintr(mask) atomic_setbits_long(&ipending, mask) #define SOFTINT_MASK ((1 << (IPL_SOFTCLOCK - 1)) | \ (1 << (IPL_SOFTNET - 1)) | (1 << (IPL_SOFTTTY - 1))) |