Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/m68k/include On the m68k, the most efficient type f...



details:   https://anonhg.NetBSD.org/src/rev/cb54ab2d60ed
branches:  trunk
changeset: 485610:cb54ab2d60ed
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue May 02 05:17:45 2000 +0000

description:
On the m68k, the most efficient type for __cpu_simple_lock_t is
an unsigned char, since that is what the `tas' instruction uses.

While I'm here, implement the __cpu_simple_lock family of routines.
Why?  One, because they're easy.  Two, so Steve can get master/slave
MVME systems talking across the backplane.  :-)

diffstat:

 sys/arch/m68k/include/lock.h |  54 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r 2370a6d08303 -r cb54ab2d60ed sys/arch/m68k/include/lock.h
--- a/sys/arch/m68k/include/lock.h      Tue May 02 04:52:16 2000 +0000
+++ b/sys/arch/m68k/include/lock.h      Tue May 02 05:17:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.2 2000/05/02 04:41:07 thorpej Exp $ */
+/*     $NetBSD: lock.h,v 1.3 2000/05/02 05:17:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -43,9 +43,57 @@
 #ifndef _M68K_LOCK_H_
 #define        _M68K_LOCK_H_
 
-typedef        __volatile int          __cpu_simple_lock_t;
+typedef        __volatile unsigned char __cpu_simple_lock_t;
 
-#define        __SIMPLELOCK_LOCKED     1
+#define        __SIMPLELOCK_LOCKED     0x80    /* result of `tas' insn */
 #define        __SIMPLELOCK_UNLOCKED   0
 
+static __inline void __cpu_simple_lock_init __P((__cpu_simple_lock_t *)) 
+       __attribute__((__unused__)); 
+static __inline void __cpu_simple_lock __P((__cpu_simple_lock_t *))
+       __attribute__((__unused__));
+static __inline int __cpu_simple_lock_try __P((__cpu_simple_lock_t *))
+       __attribute__((__unused__)); 
+static __inline void __cpu_simple_unlock __P((__cpu_simple_lock_t *))
+       __attribute__((__unused__));
+
+static __inline void
+__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
+{
+
+       *alp = __SIMPLELOCK_UNLOCKED;
+}
+
+static __inline void
+__cpu_simple_lock(__cpu_simple_lock_t *alp)
+{
+
+       __asm __volatile(
+               "1:     tas     %0      \n"
+               "       jne     1b      \n"
+               : "=m" (*alp));
+}
+
+static __inline int
+__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
+{
+       int __rv = 1;
+
+       __asm __volatile(
+               "       tas     %0      \n"
+               "       jeq     1f      \n"
+               "       moveq   #0, %1  \n"
+               "1:                     \n"
+               : "=m" (*alp), "=d" (__rv));
+
+       return (__rv);
+}
+
+static __inline void
+__cpu_simple_unlock(__cpu_simple_lock_t *alp)
+{
+
+       *alp = __SIMPLELOCK_UNLOCKED;
+}
+
 #endif /* _M68K_LOCK_H_ */



Home | Main Index | Thread Index | Old Index