From 8f326e829027c4ade9cf508f8740f1408560a237 Mon Sep 17 00:00:00 2001 From: thorpej Date: Mon, 12 Mar 2007 02:51:03 +0000 Subject: [PATCH] - Define LOCK_CAS_CHECK() in m68k/frame.h (there because it operates on a clockframe). - Call LOCK_CAS_CHECK() in clock_intr() (noted by Izumi Tsutsui). --- sys/arch/m68k/include/frame.h | 22 +++++++++++++++++++++- sys/arch/sun2/sun2/clock.c | 7 +++++-- sys/arch/sun68k/sun68k/isr.c | 19 ++----------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/sys/arch/m68k/include/frame.h b/sys/arch/m68k/include/frame.h index 5cc60b5b7fe9..29d776d01bba 100644 --- a/sys/arch/m68k/include/frame.h +++ b/sys/arch/m68k/include/frame.h @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.26 2005/12/11 12:17:53 christos Exp $ */ +/* $NetBSD: frame.h,v 1.27 2007/03/12 02:51:03 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -256,6 +256,26 @@ void buildcontext(struct lwp *, void *, void *); void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); #endif +#if defined(__mc68010__) +/* + * Restartable atomic sequence-cased compare-and-swap for 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; + +#define LOCK_CAS_CHECK(cfp) \ +do { \ + if ((cfp)->cf_pc < (u_long)&_lock_cas_ras_end && \ + (cfp)->cf_pc > (u_long)&_lock_cas_ras_start) { \ + (cfp)->cf_pc = (u_long)&_lock_cas_ras_start; \ + } \ +} while (/*CONSTCOND*/0) +#else +#define LOCK_CAS_CHECK(cfp) /* nothing */ +#endif /* __mc68010__ */ + #endif /* _KERNEL */ #endif /* _M68K_FRAME_H_ */ diff --git a/sys/arch/sun2/sun2/clock.c b/sys/arch/sun2/sun2/clock.c index ab045d06831a..1c93f9873ce8 100644 --- a/sys/arch/sun2/sun2/clock.c +++ b/sys/arch/sun2/sun2/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.11 2006/09/03 21:43:56 gdamore Exp $ */ +/* $NetBSD: clock.c,v 1.12 2007/03/12 02:51:03 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2006/09/03 21:43:56 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12 2007/03/12 02:51:03 thorpej Exp $"); #include #include @@ -95,6 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2006/09/03 21:43:56 gdamore Exp $"); #include #include +#include #include #include @@ -307,4 +308,6 @@ clock_intr(struct clockframe cf) /* Call common clock interrupt handler. */ hardclock(&cf); + + LOCK_CAS_CHECK(&cf); } diff --git a/sys/arch/sun68k/sun68k/isr.c b/sys/arch/sun68k/sun68k/isr.c index 751e39422de0..3cc55a4b7329 100644 --- a/sys/arch/sun68k/sun68k/isr.c +++ b/sys/arch/sun68k/sun68k/isr.c @@ -1,4 +1,4 @@ -/* $NetBSD: isr.c,v 1.13 2007/03/11 05:22:26 thorpej Exp $ */ +/* $NetBSD: isr.c,v 1.14 2007/03/12 02:51:03 thorpej Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.13 2007/03/11 05:22:26 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.14 2007/03/12 02:51:03 thorpej Exp $"); #include #include @@ -92,21 +92,6 @@ void *get_vector_entry(int); void isr_autovec (struct clockframe); void isr_vectored(struct clockframe); -#if defined(__mc68010__) -extern char _lock_cas_ras_start; -extern char _lock_cas_ras_end; - -#define LOCK_CAS_CHECK(cfp) \ -do { \ - if ((cfp)->cf_pc < (u_long)&_lock_cas_ras_end && \ - (cfp)->cf_pc > (u_long)&_lock_cas_ras_start) { \ - (cfp)->cf_pc = (u_long)&_lock_cas_ras_start; \ - } \ -} while (/*CONSTCOND*/0) -#else /* ! __mc68010__ */ -#define LOCK_CAS_CHECK(cfp) /* nothing */ -#endif /* __mc68010__ */ - void isr_add_custom(int level, void *handler) {