Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 Grab real locks from the sparc port. I sup...
details: https://anonhg.NetBSD.org/src/rev/fd67c5e9fdd6
branches: trunk
changeset: 473351:fd67c5e9fdd6
user: eeh <eeh%NetBSD.org@localhost>
date: Sun May 30 18:57:27 1999 +0000
description:
Grab real locks from the sparc port. I suppose we could use casa and casx
instead of ldstub, but since we aren't doing n-way locking it makes little
difference. N.B. Need to decide what to do with sparc64/sparc64/asm.h which
has name conflicts with sparc64/include/asm.h. So far most of
sparc64/sparc64/asm.h has been moved to ctlreg.h.
diffstat:
sys/arch/sparc64/include/lock.h | 104 ++++++++++++++++++++++++++++++++++++++++
sys/arch/sparc64/sparc64/asm.h | 10 +++-
2 files changed, 113 insertions(+), 1 deletions(-)
diffs (129 lines):
diff -r 049fd4dfec00 -r fd67c5e9fdd6 sys/arch/sparc64/include/lock.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc64/include/lock.h Sun May 30 18:57:27 1999 +0000
@@ -0,0 +1,104 @@
+/* $NetBSD: lock.h,v 1.1 1999/05/30 18:57:27 eeh Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/*
+ * Machine dependent spin lock operations.
+ */
+
+#if defined(_KERNEL)
+
+#include <sparc64/sparc64/asm.h>
+
+static void simple_lock_init __P((__volatile struct simplelock *));
+static void simple_lock __P((__volatile struct simplelock *));
+static int simple_lock_try __P((__volatile struct simplelock *));
+static void simple_unlock __P((__volatile struct simplelock *));
+
+static __inline__ void
+simple_lock_init (alp)
+ __volatile struct simplelock *alp;
+{
+
+ alp->lock_data = 0;
+}
+
+static __inline__ void
+simple_lock (alp)
+ __volatile struct simplelock *alp;
+{
+
+ /*
+ * If someone else holds the lock use simple
+ * reads until it is released, then retry the
+ * atomic operation. This reduces memory bus contention
+ * becaused the cache-coherency logic does not have to
+ * broadcast invalidates on the lock while we spin on it.
+ */
+ while (ldstub(&alp->lock_data) != 0) {
+ while (alp->lock_data != 0)
+ /*void*/;
+ }
+}
+
+static __inline__ int
+simple_lock_try (alp)
+ __volatile struct simplelock *alp;
+{
+
+ return (ldstub(&alp->lock_data) == 0);
+}
+
+static __inline__ void
+simple_unlock (alp)
+ __volatile struct simplelock *alp;
+{
+
+ alp->lock_data = 0;
+}
+
+#if defined(LOCKDEBUG)
+#define simple_lock_dump()
+#define simple_lock_freecheck(start, end)
+#endif /* LOCKDEBUG */
+
+#endif /* _KERNEL */
+
+#endif /* _MACHINE_LOCK_H */
diff -r 049fd4dfec00 -r fd67c5e9fdd6 sys/arch/sparc64/sparc64/asm.h
--- a/sys/arch/sparc64/sparc64/asm.h Sun May 30 18:52:51 1999 +0000
+++ b/sys/arch/sparc64/sparc64/asm.h Sun May 30 18:57:27 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: asm.h,v 1.4 1999/01/31 09:21:18 mrg Exp $ */
+/* $NetBSD: asm.h,v 1.5 1999/05/30 18:57:27 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -187,3 +187,11 @@
})
#endif
+/* atomic load/store of a byte in memory */
+#define ldstub(loc) ({ \
+ int _v; \
+ __asm __volatile("ldstub [%1],%0" : "=r" (_v) : "r" (loc) : "memory"); \
+ _v; \
+})
+
+
Home |
Main Index |
Thread Index |
Old Index