]>
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_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 * mach/i386/flipc_dep.h
36 * This file will have all of the FLIPC implementation machine dependent
37 * defines that need to be visible to both kernel and AIL (eg. bus locks
38 * and bus synchronization primitives).
41 #ifndef _MACH_FLIPC_DEP_H_
42 #define _MACH_FLIPC_DEP_H_
44 /* For the 386, we don't need to wrap synchronization variable writes
46 #define SYNCVAR_WRITE(statement) statement
48 /* And similarly (I believe; check on this), for the 386 there isn't any
49 requirement for write fences. */
53 * Flipc simple lock defines. These are almost completely for the use
54 * of the AIL; the reason they are in this file is that they need to
55 * be initialized properly in the communications buffer initialization
56 * routine. Sigh. Note in particular that the kernel has no defined
57 * "simple_lock_yield_function", so it had better never expand the
58 * macro simple_lock_acquire.
60 * These locks may be declared by "flipc_simple_lock lock;". If they
61 * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they
62 * may be used without initialization.
65 #define SIMPLE_LOCK_INITIALIZER 0
66 #define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
67 class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
70 * Lower case because they may be macros or functions.
71 * I'll include the function prototypes just for examples here.
74 #define flipc_simple_lock_init(lock) \
76 *(lock) = SIMPLE_LOCK_INITIALIZER; \
80 * Defines of the actual routines, for gcc.
83 #define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
86 extern __inline__
int flipc_simple_lock_try(flipc_simple_lock
*lock
)
89 __asm__
volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r
), "=m" (*lock
));
93 /* I don't know why this requires an ASM, but I'll follow the leader. */
94 extern __inline__
void flipc_simple_lock_release(flipc_simple_lock
*lock
)
98 __asm__
volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t
), "=m" (*lock
));
101 /* If we aren't compiling with gcc, the above need to be functions. */
102 #endif /* __GNUC__ */
104 #endif /* _MACH_FLIPC_DEP_H_ */