diff options
| author | tsutsui <tsutsui@NetBSD.org> | 2008-04-05 22:47:52 +0000 |
|---|---|---|
| committer | tsutsui <tsutsui@NetBSD.org> | 2008-04-05 22:47:52 +0000 |
| commit | c3b129605ad16c8ade2f89eef82bcc61e4fb40e2 (patch) | |
| tree | f5bd33f3435e65b243f602686765d9ec51585516 | |
| parent | 7dfcdee2a2b64502c4ea98556c5631760d76b865 (diff) | |
Use generic atomic_cas_uint() for mutex(9) and rwlock(9), and
remodel old RAS based _lock_cas() implementation for m68010
into genereic atomic_cas_32().
Now sun2 kernel compiles and even works on multiuser. (hehe)
Tested on tme (emulationg 2/120 and 3/150) and (real) 3/80.
| -rw-r--r-- | sys/arch/m68k/include/frame.h | 20 | ||||
| -rw-r--r-- | sys/arch/m68k/include/mutex.h | 6 | ||||
| -rw-r--r-- | sys/arch/m68k/include/rwlock.h | 6 | ||||
| -rw-r--r-- | sys/arch/m68k/m68k/lock_stubs.s | 55 | ||||
| -rw-r--r-- | sys/arch/sun2/sun2/clock.c | 6 | ||||
| -rw-r--r-- | sys/arch/sun68k/sun68k/isr.c | 8 |
6 files changed, 50 insertions, 51 deletions
diff --git a/sys/arch/m68k/include/frame.h b/sys/arch/m68k/include/frame.h index 113cd777669..5665720165b 100644 --- a/sys/arch/m68k/include/frame.h +++ b/sys/arch/m68k/include/frame.h @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.28 2007/03/13 17:17:28 thorpej Exp $ */ +/* $NetBSD: frame.h,v 1.29 2008/04/05 22:47:52 tsutsui Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -258,23 +258,23 @@ void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); #if defined(__mc68010__) /* - * Restartable atomic sequence-cased compare-and-swap for locking - * primitives. We defined this here because it manipulates a + * Restartable atomic sequence-cased compare-and-swap for atomic_cas ops + * and locking primitives. We defined this here because it manipulates a * "clockframe" as prepared by interrupt handlers. */ -extern char _lock_cas_ras_start; -extern char _lock_cas_ras_end; +extern char _atomic_cas_ras_start; +extern char _atomic_cas_ras_end; -#define LOCK_CAS_CHECK(cfp) \ +#define ATOMIC_CAS_CHECK(cfp) \ do { \ if (! CLKF_USERMODE(cfp) && \ - (CLKF_PC(cfp) < (u_long)&_lock_cas_ras_end && \ - CLKF_PC(cfp) > (u_long)&_lock_cas_ras_start)) { \ - (cfp)->cf_pc = (u_long)&_lock_cas_ras_start; \ + (CLKF_PC(cfp) < (u_long)&_atomic_cas_ras_end && \ + CLKF_PC(cfp) > (u_long)&_atomic_cas_ras_start)) { \ + (cfp)->cf_pc = (u_long)&_atomic_cas_ras_start; \ } \ } while (/*CONSTCOND*/0) #else -#define LOCK_CAS_CHECK(cfp) /* nothing */ +#define ATOMIC_CAS_CHECK(cfp) /* nothing */ #endif /* __mc68010__ */ #endif /* _KERNEL */ diff --git a/sys/arch/m68k/include/mutex.h b/sys/arch/m68k/include/mutex.h index a069274587d..79bee2aa555 100644 --- a/sys/arch/m68k/include/mutex.h +++ b/sys/arch/m68k/include/mutex.h @@ -1,4 +1,4 @@ -/* $NetBSD: mutex.h,v 1.5 2007/11/21 10:19:07 yamt Exp $ */ +/* $NetBSD: mutex.h,v 1.6 2008/04/05 22:47:53 tsutsui Exp $ */ /*- * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. @@ -72,9 +72,7 @@ struct kmutex { #define MUTEX_RECEIVE(mtx) mb_read() #define MUTEX_GIVE(mtx) mb_memory() -#define MUTEX_CAS(p, o, n) _lock_cas((p), (o), (n)) - -int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); +#define MUTEX_CAS(p, o, n) (atomic_cas_uint((p), (o), (n)) == (o)) #endif /* __MUTEX_PRIVATE */ diff --git a/sys/arch/m68k/include/rwlock.h b/sys/arch/m68k/include/rwlock.h index 0c5160039fe..e3b071e602f 100644 --- a/sys/arch/m68k/include/rwlock.h +++ b/sys/arch/m68k/include/rwlock.h @@ -1,4 +1,4 @@ -/* $NetBSD: rwlock.h,v 1.3 2007/11/21 10:19:07 yamt Exp $ */ +/* $NetBSD: rwlock.h,v 1.4 2008/04/05 22:47:53 tsutsui Exp $ */ /*- * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. @@ -50,9 +50,7 @@ struct krwlock { #define RW_RECEIVE(rw) /* nothing */ #define RW_GIVE(rw) /* nothing */ -#define RW_CAS(p, o, n) _lock_cas((p), (o), (n)) - -int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); +#define RW_CAS(p, o, n) (atomic_cas_uint((p), (o), (n)) == (o)) #endif /* __RWLOCK_PRIVATE */ diff --git a/sys/arch/m68k/m68k/lock_stubs.s b/sys/arch/m68k/m68k/lock_stubs.s index 0094e44df30..c3b4d2c24e7 100644 --- a/sys/arch/m68k/m68k/lock_stubs.s +++ b/sys/arch/m68k/m68k/lock_stubs.s @@ -1,4 +1,4 @@ -/* $NetBSD: lock_stubs.s,v 1.4 2007/12/02 19:28:32 ad Exp $ */ +/* $NetBSD: lock_stubs.s,v 1.5 2008/04/05 22:47:53 tsutsui Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -45,46 +45,49 @@ .file "lock_stubs.s" .text -#if !defined(__mc68010__) -/* - * int _lock_cas(uintptr_t *val, uintptr_t old, uintptr_t new); - */ -ENTRY(_lock_cas) - movl %sp@(4),%a0 | a0 = val address - movl %sp@(8),%d0 | d0 = old value - movl %sp@(12),%d1 | d1 = new value - casl %d0,%d1,%a0@ | compare old, set new - beqb 1f | matched and set - movq #0,%d0 - rts -1: movq #1,%d0 - rts -#else /* __mc68010__ */ +#if defined(__mc68010__) /* - * int _lock_cas(uintptr_t *val, uintptr_t old, uintptr_t new); + * int _atomic_cas_32(volatile uint32_t *val, uint32_t old, uint32_t new); * * The 68010 does not have a cas instruction, so we implement this as * a restartable atomic sequence. For an example of how this is used, * see sun68k/sun68k/isr.c */ -ENTRY_NOPROFILE(_lock_cas) +ENTRY_NOPROFILE(_atomic_cas_32) movl %sp@(4),%a0 - .globl _C_LABEL(_lock_cas_ras_start) -_C_LABEL(_lock_cas_ras_start): + .globl _C_LABEL(_atomic_cas_ras_start) +_C_LABEL(_atomic_cas_ras_start): movl %a0@,%d0 cmpl %sp@(8),%d0 jne 1f movl %sp@(12),%a0@ - .globl _C_LABEL(_lock_cas_ras_end) -_C_LABEL(_lock_cas_ras_end): + .globl _C_LABEL(_atomic_cas_ras_end) +_C_LABEL(_atomic_cas_ras_end): - movq #1,%d0 - rts 1: - clrl %d0 + movl %d0, %a0 /* pointers return also in %a0 */ rts -#endif /* ! __mc68010__ */ + +STRONG_ALIAS(atomic_cas_ptr,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) +STRONG_ALIAS(atomic_cas_uint,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) +STRONG_ALIAS(atomic_cas_ulong,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) +STRONG_ALIAS(atomic_cas_32,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_32,_atomic_cas_32) + +STRONG_ALIAS(atomic_cas_32_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) + +STRONG_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32) +STRONG_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) +STRONG_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32) +STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32) +#endif /* __mc68010__ */ #if !defined(LOCKDEBUG) diff --git a/sys/arch/sun2/sun2/clock.c b/sys/arch/sun2/sun2/clock.c index aa66b4d3dcd..a0b5eadd1cb 100644 --- a/sys/arch/sun2/sun2/clock.c +++ b/sys/arch/sun2/sun2/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.13 2008/01/26 14:02:54 tsutsui Exp $ */ +/* $NetBSD: clock.c,v 1.14 2008/04/05 22:47:53 tsutsui Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -85,7 +85,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2008/01/26 14:02:54 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.14 2008/04/05 22:47:53 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -313,5 +313,5 @@ clock_intr(struct clockframe cf) idepth--; - LOCK_CAS_CHECK(&cf); + ATOMIC_CAS_CHECK(&cf); } diff --git a/sys/arch/sun68k/sun68k/isr.c b/sys/arch/sun68k/sun68k/isr.c index cbccec20531..265a6b46fae 100644 --- a/sys/arch/sun68k/sun68k/isr.c +++ b/sys/arch/sun68k/sun68k/isr.c @@ -1,4 +1,4 @@ -/* $NetBSD: isr.c,v 1.19 2008/01/11 10:21:26 tsutsui Exp $ */ +/* $NetBSD: isr.c,v 1.20 2008/04/05 22:47:53 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.19 2008/01/11 10:21:26 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.20 2008/04/05 22:47:53 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -140,7 +140,7 @@ isr_autovec(struct clockframe cf) out: idepth--; - LOCK_CAS_CHECK(&cf); + ATOMIC_CAS_CHECK(&cf); } /* @@ -209,7 +209,7 @@ isr_vectored(struct clockframe cf) out: idepth--; - LOCK_CAS_CHECK(&cf); + ATOMIC_CAS_CHECK(&cf); } /* |
