]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/simple_lock.h
2 * Copyright (c) 2000-2005 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@
23 * Copyright (C) 1998 Apple Computer
30 * Mach Operating System
31 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
32 * All Rights Reserved.
34 * Permission to use, copy, modify and distribute this software and its
35 * documentation is hereby granted, provided that both the copyright
36 * notice and this permission notice appear in all copies of the
37 * software, derivative works or modified versions, and any portions
38 * thereof, and that both notices appear in supporting documentation.
40 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
41 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
42 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
44 * Carnegie Mellon requests users of this software to return to
46 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
47 * School of Computer Science
48 * Carnegie Mellon University
49 * Pittsburgh PA 15213-3890
51 * any improvements or extensions that they make and grant Carnegie Mellon
52 * the rights to redistribute these changes.
55 * File: kern/simple_lock.h (derived from kern/lock.h)
56 * Author: Avadis Tevanian, Jr., Michael Wayne Young
59 * Atomic primitives and Simple Locking primitives definitions
64 #ifndef _KERN_SIMPLE_LOCK_H_
65 #define _KERN_SIMPLE_LOCK_H_
67 #include <sys/cdefs.h>
68 #include <mach/boolean.h>
69 #include <kern/kern_types.h>
70 #include <machine/simple_lock.h>
72 #ifdef MACH_KERNEL_PRIVATE
73 #include <mach_ldebug.h>
75 extern void hw_lock_init(
78 extern void hw_lock_lock(
81 extern void hw_lock_unlock(
84 extern unsigned int hw_lock_to(
88 extern unsigned int hw_lock_try(
91 extern unsigned int hw_lock_held(
94 #endif /* MACH_KERNEL_PRIVATE */
98 extern uint32_t hw_atomic_add(
102 extern uint32_t hw_atomic_sub(
106 extern uint32_t hw_atomic_or(
110 extern uint32_t hw_atomic_and(
114 extern uint32_t hw_compare_and_store(
119 extern void hw_queue_atomic(
120 unsigned int *anchor
,
124 extern void hw_queue_atomic_list(
125 unsigned int *anchor
,
130 extern unsigned int *hw_dequeue_atomic(
131 unsigned int *anchor
,
134 extern void usimple_lock_init(
138 extern void usimple_lock(
141 extern void usimple_unlock(
144 extern unsigned int usimple_lock_try(
149 #define ETAP_NO_TRACE 0
150 #define ETAP_IO_AHA 0
153 * If we got to here and we still don't have simple_lock_init
154 * defined, then we must either be outside the osfmk component,
155 * running on a true SMP, or need debug.
157 #if !defined(simple_lock_init)
158 #define simple_lock_init(l,t) usimple_lock_init(l,t)
159 #define simple_lock(l) usimple_lock(l)
160 #define simple_unlock(l) usimple_unlock(l)
161 #define simple_lock_try(l) usimple_lock_try(l)
162 #define simple_lock_addr(l) (&(l))
163 #define thread_sleep_simple_lock(l, e, i) \
164 thread_sleep_usimple_lock((l), (e), (i))
165 #endif /* !defined(simple_lock_init) */
167 #endif /*!_KERN_SIMPLE_LOCK_H_*/
169 #endif /* KERNEL_PRIVATE */