]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
29 * Revision 1.1.1.1 1998/09/22 21:05:31 wsanchez
30 * Import of Mac OS X kernel (~semeria)
32 * Revision 1.1.1.1 1998/03/07 02:25:47 wsanchez
33 * Import of OSF Mach kernel (~mburg)
35 * Revision 1.1.5.1 1995/06/13 18:20:42 sjs
36 * Merge from flipc_shared.
39 * Revision 1.1.3.3 1995/02/21 17:23:16 randys
40 * Re-indented code to four space indentation
41 * [1995/02/21 16:26:50 randys]
43 * Revision 1.1.3.2 1994/12/20 19:02:12 randys
44 * Moved definition of flipc_simple_lock to flipc_cb.h
45 * [1994/12/20 17:35:15 randys]
47 * Moved the machine independent macros into mach/flipc_locks.h
48 * [1994/12/20 16:44:14 randys]
50 * Added filename in comment at top of file
51 * [1994/12/19 20:29:36 randys]
53 * Fixed incorrect return of lock_try
54 * [1994/12/13 00:36:46 randys]
56 * Revision 1.1.3.1 1994/12/12 17:46:29 randys
57 * Putting initial flipc implementation under flipc_shared
58 * [1994/12/12 16:27:51 randys]
60 * Revision 1.1.1.2 1994/12/11 23:08:36 randys
61 * Initial flipc code checkin.
67 * mach/i386/flipc_dep.h
69 * This file will have all of the FLIPC implementation machine dependent
70 * defines that need to be visible to both kernel and AIL (eg. bus locks
71 * and bus synchronization primitives).
74 #ifndef _MACH_FLIPC_DEP_H_
75 #define _MACH_FLIPC_DEP_H_
77 /* For the 386, we don't need to wrap synchronization variable writes
79 #define SYNCVAR_WRITE(statement) statement
81 /* And similarly (I believe; check on this), for the 386 there isn't any
82 requirement for write fences. */
86 * Flipc simple lock defines. These are almost completely for the use
87 * of the AIL; the reason they are in this file is that they need to
88 * be initialized properly in the communications buffer initialization
89 * routine. Sigh. Note in particular that the kernel has no defined
90 * "simple_lock_yield_function", so it had better never expand the
91 * macro simple_lock_acquire.
93 * These locks may be declared by "flipc_simple_lock lock;". If they
94 * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they
95 * may be used without initialization.
98 #define SIMPLE_LOCK_INITIALIZER 0
99 #define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
100 class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
103 * Lower case because they may be macros or functions.
104 * I'll include the function prototypes just for examples here.
107 #define flipc_simple_lock_init(lock) \
109 *(lock) = SIMPLE_LOCK_INITIALIZER; \
113 * Defines of the actual routines, for gcc.
116 #define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
119 extern __inline__
int flipc_simple_lock_try(flipc_simple_lock
*lock
)
122 __asm__
volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r
), "=m" (*lock
));
126 /* I don't know why this requires an ASM, but I'll follow the leader. */
127 extern __inline__
void flipc_simple_lock_release(flipc_simple_lock
*lock
)
131 __asm__
volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t
), "=m" (*lock
));
134 /* If we aren't compiling with gcc, the above need to be functions. */
135 #endif /* __GNUC__ */
137 #endif /* _MACH_FLIPC_DEP_H_ */