]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOSharedLock.h
xnu-517.7.7.tar.gz
[apple/xnu.git] / iokit / IOKit / IOSharedLock.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
A
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.
1c79356b 11 *
e5568f75
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
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.
1c79356b
A
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
51extern "C" {
52#endif
53
54// should be 32 bytes on PPC
55typedef volatile int IOSharedLockData;
56typedef IOSharedLockData * IOSharedLock;
57
55e303ae 58#define IOSpinLockInit(l) (*(l) = (IOSharedLockData)0)
1c79356b 59
55e303ae 60#ifndef KERNEL
1c79356b 61extern void IOSpinLock(IOSharedLock l);
55e303ae
A
62#endif
63
1c79356b
A
64extern void IOSpinUnlock(IOSharedLock l);
65extern boolean_t IOTrySpinLock(IOSharedLock l);
66
67/* exact same stuff & implementation */
68
69typedef IOSharedLockData ev_lock_data_t;
70typedef 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
55e303ae 76#ifndef KERNEL
1c79356b 77extern void ev_lock(ev_lock_t l); // Spin lock!
55e303ae
A
78#endif
79
1c79356b
A
80extern void ev_unlock(ev_lock_t l);
81extern boolean_t ev_try_lock(ev_lock_t l);
82
83#ifdef __cplusplus
84}
85#endif
86#endif /* ! _IOKIT_IOSHAREDLOCK_H */