]> git.saurik.com Git - apple/xnu.git/blame_incremental - osfmk/mach/i386/flipc_dep.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / mach / i386 / flipc_dep.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 *
28 */
29/*
30 * HISTORY
31 *
32 * Revision 1.1.1.1 1998/09/22 21:05:31 wsanchez
33 * Import of Mac OS X kernel (~semeria)
34 *
35 * Revision 1.1.1.1 1998/03/07 02:25:47 wsanchez
36 * Import of OSF Mach kernel (~mburg)
37 *
38 * Revision 1.1.5.1 1995/06/13 18:20:42 sjs
39 * Merge from flipc_shared.
40 * [95/06/07 sjs]
41 *
42 * Revision 1.1.3.3 1995/02/21 17:23:16 randys
43 * Re-indented code to four space indentation
44 * [1995/02/21 16:26:50 randys]
45 *
46 * Revision 1.1.3.2 1994/12/20 19:02:12 randys
47 * Moved definition of flipc_simple_lock to flipc_cb.h
48 * [1994/12/20 17:35:15 randys]
49 *
50 * Moved the machine independent macros into mach/flipc_locks.h
51 * [1994/12/20 16:44:14 randys]
52 *
53 * Added filename in comment at top of file
54 * [1994/12/19 20:29:36 randys]
55 *
56 * Fixed incorrect return of lock_try
57 * [1994/12/13 00:36:46 randys]
58 *
59 * Revision 1.1.3.1 1994/12/12 17:46:29 randys
60 * Putting initial flipc implementation under flipc_shared
61 * [1994/12/12 16:27:51 randys]
62 *
63 * Revision 1.1.1.2 1994/12/11 23:08:36 randys
64 * Initial flipc code checkin.
65 *
66 * $EndLog$
67 */
68
69/*
70 * mach/i386/flipc_dep.h
71 *
72 * This file will have all of the FLIPC implementation machine dependent
73 * defines that need to be visible to both kernel and AIL (eg. bus locks
74 * and bus synchronization primitives).
75 */
76
77#ifndef _MACH_FLIPC_DEP_H_
78#define _MACH_FLIPC_DEP_H_
79
80/* For the 386, we don't need to wrap synchronization variable writes
81 at all. */
82#define SYNCVAR_WRITE(statement) statement
83
84/* And similarly (I believe; check on this), for the 386 there isn't any
85 requirement for write fences. */
86#define WRITE_FENCE()
87
88/*
89 * Flipc simple lock defines. These are almost completely for the use
90 * of the AIL; the reason they are in this file is that they need to
91 * be initialized properly in the communications buffer initialization
92 * routine. Sigh. Note in particular that the kernel has no defined
93 * "simple_lock_yield_function", so it had better never expand the
94 * macro simple_lock_acquire.
95 *
96 * These locks may be declared by "flipc_simple_lock lock;". If they
97 * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they
98 * may be used without initialization.
99 */
100
101#define SIMPLE_LOCK_INITIALIZER 0
102#define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
103class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
104
105/*
106 * Lower case because they may be macros or functions.
107 * I'll include the function prototypes just for examples here.
108 */
109
110#define flipc_simple_lock_init(lock) \
111do { \
112 *(lock) = SIMPLE_LOCK_INITIALIZER; \
113} while (0)
114
115/*
116 * Defines of the actual routines, for gcc.
117 */
118
119#define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
120
121#ifdef __GNUC__
122 extern __inline__ int flipc_simple_lock_try(flipc_simple_lock *lock)
123{
124 int r;
125 __asm__ volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r), "=m" (*lock));
126 return !r;
127}
128
129/* I don't know why this requires an ASM, but I'll follow the leader. */
130extern __inline__ void flipc_simple_lock_release(flipc_simple_lock *lock)
131{
132 register int t;
133
134 __asm__ volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t), "=m" (*lock));
135}
136#else /* __GNUC__ */
137/* If we aren't compiling with gcc, the above need to be functions. */
138#endif /* __GNUC__ */
139
140#endif /* _MACH_FLIPC_DEP_H_ */