]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOSharedLock.h
xnu-344.49.tar.gz
[apple/xnu.git] / iokit / IOKit / IOSharedLock.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
27 *
28 * HISTORY
29 *
30 */
31
32 /*
33 * Multiprocessor locks used within the shared memory area between the
34 * kernel and event system. These must work in both user and kernel mode.
35 *
36 * These routines are public, for the purpose of writing frame buffer device
37 * drivers which handle their own cursors. Certain architectures define a
38 * generic display class which handles cursor drawing and is subclassed by
39 * driver writers. These drivers need not be concerned with the following
40 * types and definitions.
41 *
42 * The ev_lock(), ev_unlock(), and ev_try_lock() functions are available only
43 * to drivers built in or dynamically loaded into the kernel, and to DPS
44 * drivers built in or dynamically loaded into the Window Server. They do not
45 * exist in any shared library.
46 *
47 * --> They're now in IOKit user lib.
48 */
49
50 #ifndef _IOKIT_IOSHAREDLOCK_H
51 #define _IOKIT_IOSHAREDLOCK_H
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 // should be 32 bytes on PPC
58 typedef volatile int IOSharedLockData;
59 typedef IOSharedLockData * IOSharedLock;
60
61 #define IOSpinLockInit(l) (*(l) = (IOSpinLockData)0)
62
63 extern void IOSpinLock(IOSharedLock l);
64 extern void IOSpinUnlock(IOSharedLock l);
65 extern boolean_t IOTrySpinLock(IOSharedLock l);
66
67 /* exact same stuff & implementation */
68
69 typedef IOSharedLockData ev_lock_data_t;
70 typedef ev_lock_data_t * ev_lock_t;
71
72 #define ev_init_lock(l) (*(l) = (ev_lock_data_t)0)
73 // needs isync?
74 //#define ev_is_locked(l) (*(l) != (ev_lock_data_t)0)
75
76 extern void ev_lock(ev_lock_t l); // Spin lock!
77 extern void ev_unlock(ev_lock_t l);
78 extern boolean_t ev_try_lock(ev_lock_t l);
79
80 #ifdef __cplusplus
81 }
82 #endif
83 #endif /* ! _IOKIT_IOSHAREDLOCK_H */