]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOSharedLock.h
xnu-792.24.17.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 * 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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
24 *
25 * HISTORY
26 *
27 */
28
29 /*
30 * Multiprocessor locks used within the shared memory area between the
31 * kernel and event system. These must work in both user and kernel mode.
32 *
33 * These routines are public, for the purpose of writing frame buffer device
34 * drivers which handle their own cursors. Certain architectures define a
35 * generic display class which handles cursor drawing and is subclassed by
36 * driver writers. These drivers need not be concerned with the following
37 * types and definitions.
38 *
39 * The ev_lock(), ev_unlock(), and ev_try_lock() functions are available only
40 * to drivers built in or dynamically loaded into the kernel, and to DPS
41 * drivers built in or dynamically loaded into the Window Server. They do not
42 * exist in any shared library.
43 *
44 * --> They're now in IOKit user lib.
45 */
46
47 #ifndef _IOKIT_IOSHAREDLOCK_H
48 #define _IOKIT_IOSHAREDLOCK_H
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 // should be 32 bytes on PPC
55 typedef volatile int IOSharedLockData;
56 typedef IOSharedLockData * IOSharedLock;
57
58 #define IOSpinLockInit(l) (*(l) = (IOSharedLockData)0)
59
60 #ifndef KERNEL
61 extern void IOSpinLock(IOSharedLock l);
62 #endif
63
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 #ifndef KERNEL
77 extern void ev_lock(ev_lock_t l); // Spin lock!
78 #endif
79
80 extern void ev_unlock(ev_lock_t l);
81 extern boolean_t ev_try_lock(ev_lock_t l);
82
83 #ifdef __cplusplus
84 }
85 #endif
86 #endif /* ! _IOKIT_IOSHAREDLOCK_H */