]>
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@
28 * mach/i386/flipc_dep.h
30 * This file will have all of the FLIPC implementation machine dependent
31 * defines that need to be visible to both kernel and AIL (eg. bus locks
32 * and bus synchronization primitives).
35 #ifndef _MACH_FLIPC_DEP_H_
36 #define _MACH_FLIPC_DEP_H_
38 /* For the 386, we don't need to wrap synchronization variable writes
40 #define SYNCVAR_WRITE(statement) statement
42 /* And similarly (I believe; check on this), for the 386 there isn't any
43 requirement for write fences. */
47 * Flipc simple lock defines. These are almost completely for the use
48 * of the AIL; the reason they are in this file is that they need to
49 * be initialized properly in the communications buffer initialization
50 * routine. Sigh. Note in particular that the kernel has no defined
51 * "simple_lock_yield_function", so it had better never expand the
52 * macro simple_lock_acquire.
54 * These locks may be declared by "flipc_simple_lock lock;". If they
55 * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they
56 * may be used without initialization.
59 #define SIMPLE_LOCK_INITIALIZER 0
60 #define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \
61 class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER
64 * Lower case because they may be macros or functions.
65 * I'll include the function prototypes just for examples here.
68 #define flipc_simple_lock_init(lock) \
70 *(lock) = SIMPLE_LOCK_INITIALIZER; \
74 * Defines of the actual routines, for gcc.
77 #define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER)
80 extern __inline__
int flipc_simple_lock_try(flipc_simple_lock
*lock
)
83 __asm__
volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r
), "=m" (*lock
));
87 /* I don't know why this requires an ASM, but I'll follow the leader. */
88 extern __inline__
void flipc_simple_lock_release(flipc_simple_lock
*lock
)
92 __asm__
volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t
), "=m" (*lock
));
95 /* If we aren't compiling with gcc, the above need to be functions. */
98 #endif /* _MACH_FLIPC_DEP_H_ */