]>
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_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
36 * mach/i386/flipc_dep.h
38 * This file will have all of the FLIPC implementation machine dependent
39 * defines that need to be visible to both kernel and AIL (eg. bus locks
40 * and bus synchronization primitives).
43 #ifndef _MACH_FLIPC_DEP_H_
44 #define _MACH_FLIPC_DEP_H_
46 /* For the 386, we don't need to wrap synchronization variable writes
48 #define SYNCVAR_WRITE(statement) statement
50 /* And similarly (I believe; check on this), for the 386 there isn't any
51 requirement for write fences. */
55 * Flipc simple lock defines. These are almost completely for the use
56 * of the AIL; the reason they are in this file is that they need to
57 * be initialized properly in the communications buffer initialization
58 * routine. Sigh. Note in particular that the kernel has no defined
59 * "simple_lock_yield_function", so it had better never expand the
60 * macro simple_lock_acquire.
62 * These locks may be declared by "flipc_simple_lock lock;". If they
63 * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they
64 * may be used without initialization.
67 #define SIMPLE_LOCK_INITIALIZER 0
68 #define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
69 class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
72 * Lower case because they may be macros or functions.
73 * I'll include the function prototypes just for examples here.
76 #define flipc_simple_lock_init(lock) \
78 *(lock) = SIMPLE_LOCK_INITIALIZER; \
82 * Defines of the actual routines, for gcc.
85 #define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
88 extern __inline__
int flipc_simple_lock_try(flipc_simple_lock
*lock
)
91 __asm__
volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r
), "=m" (*lock
));
95 /* I don't know why this requires an ASM, but I'll follow the leader. */
96 extern __inline__
void flipc_simple_lock_release(flipc_simple_lock
*lock
)
100 __asm__
volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t
), "=m" (*lock
));
103 /* If we aren't compiling with gcc, the above need to be functions. */
104 #endif /* __GNUC__ */
106 #endif /* _MACH_FLIPC_DEP_H_ */