]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/simple_lock.h
37fe67747e26bcf4e7ee1a917d185071836b3729
2 * Copyright (c) 2000-2005 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@
31 * Copyright (C) 1998 Apple Computer
38 * Mach Operating System
39 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
40 * All Rights Reserved.
42 * Permission to use, copy, modify and distribute this software and its
43 * documentation is hereby granted, provided that both the copyright
44 * notice and this permission notice appear in all copies of the
45 * software, derivative works or modified versions, and any portions
46 * thereof, and that both notices appear in supporting documentation.
48 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
49 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
50 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
52 * Carnegie Mellon requests users of this software to return to
54 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
55 * School of Computer Science
56 * Carnegie Mellon University
57 * Pittsburgh PA 15213-3890
59 * any improvements or extensions that they make and grant Carnegie Mellon
60 * the rights to redistribute these changes.
63 * File: kern/simple_lock.h (derived from kern/lock.h)
64 * Author: Avadis Tevanian, Jr., Michael Wayne Young
67 * Atomic primitives and Simple Locking primitives definitions
72 #ifndef _KERN_SIMPLE_LOCK_H_
73 #define _KERN_SIMPLE_LOCK_H_
75 #include <sys/cdefs.h>
76 #include <mach/boolean.h>
77 #include <kern/kern_types.h>
78 #include <machine/simple_lock.h>
80 #ifdef MACH_KERNEL_PRIVATE
81 #include <mach_ldebug.h>
83 extern void hw_lock_init(
86 extern void hw_lock_lock(
89 extern void hw_lock_unlock(
92 extern unsigned int hw_lock_to(
96 extern unsigned int hw_lock_try(
99 extern unsigned int hw_lock_held(
102 #endif /* MACH_KERNEL_PRIVATE */
106 extern uint32_t hw_atomic_add(
110 extern uint32_t hw_atomic_sub(
114 extern uint32_t hw_atomic_or(
118 extern uint32_t hw_atomic_and(
122 extern uint32_t hw_compare_and_store(
127 extern void hw_queue_atomic(
128 unsigned int *anchor
,
132 extern void hw_queue_atomic_list(
133 unsigned int *anchor
,
138 extern unsigned int *hw_dequeue_atomic(
139 unsigned int *anchor
,
142 extern void usimple_lock_init(
146 extern void usimple_lock(
149 extern void usimple_unlock(
152 extern unsigned int usimple_lock_try(
157 #define ETAP_NO_TRACE 0
158 #define ETAP_IO_AHA 0
161 * If we got to here and we still don't have simple_lock_init
162 * defined, then we must either be outside the osfmk component,
163 * running on a true SMP, or need debug.
165 #if !defined(simple_lock_init)
166 #define simple_lock_init(l,t) usimple_lock_init(l,t)
167 #define simple_lock(l) usimple_lock(l)
168 #define simple_unlock(l) usimple_unlock(l)
169 #define simple_lock_try(l) usimple_lock_try(l)
170 #define simple_lock_addr(l) (&(l))
171 #define thread_sleep_simple_lock(l, e, i) \
172 thread_sleep_usimple_lock((l), (e), (i))
173 #endif /* !defined(simple_lock_init) */
175 #endif /*!_KERN_SIMPLE_LOCK_H_*/
177 #endif /* KERNEL_PRIVATE */