]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/flipc_dep.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
32 * Revision 1.1.1.1 1998/09/22 21:05:31 wsanchez
33 * Import of Mac OS X kernel (~semeria)
35 * Revision 1.1.1.1 1998/03/07 02:25:47 wsanchez
36 * Import of OSF Mach kernel (~mburg)
38 * Revision 1.1.5.1 1995/06/13 18:20:42 sjs
39 * Merge from flipc_shared.
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]
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]
50 * Moved the machine independent macros into mach/flipc_locks.h
51 * [1994/12/20 16:44:14 randys]
53 * Added filename in comment at top of file
54 * [1994/12/19 20:29:36 randys]
56 * Fixed incorrect return of lock_try
57 * [1994/12/13 00:36:46 randys]
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]
63 * Revision 1.1.1.2 1994/12/11 23:08:36 randys
64 * Initial flipc code checkin.
70 * mach/i386/flipc_dep.h
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).
77 #ifndef _MACH_FLIPC_DEP_H_
78 #define _MACH_FLIPC_DEP_H_
80 /* For the 386, we don't need to wrap synchronization variable writes
82 #define SYNCVAR_WRITE(statement) statement
84 /* And similarly (I believe; check on this), for the 386 there isn't any
85 requirement for write fences. */
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.
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.
101 #define SIMPLE_LOCK_INITIALIZER 0
102 #define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
103 class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
106 * Lower case because they may be macros or functions.
107 * I'll include the function prototypes just for examples here.
110 #define flipc_simple_lock_init(lock) \
112 *(lock) = SIMPLE_LOCK_INITIALIZER; \
116 * Defines of the actual routines, for gcc.
119 #define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
122 extern __inline__
int flipc_simple_lock_try(flipc_simple_lock
*lock
)
125 __asm__
volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r
), "=m" (*lock
));
129 /* I don't know why this requires an ASM, but I'll follow the leader. */
130 extern __inline__
void flipc_simple_lock_release(flipc_simple_lock
*lock
)
134 __asm__
volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t
), "=m" (*lock
));
137 /* If we aren't compiling with gcc, the above need to be functions. */
138 #endif /* __GNUC__ */
140 #endif /* _MACH_FLIPC_DEP_H_ */