]>
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_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (C) 1998 Apple Computer
36 * Mach Operating System
37 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
38 * All Rights Reserved.
40 * Permission to use, copy, modify and distribute this software and its
41 * documentation is hereby granted, provided that both the copyright
42 * notice and this permission notice appear in all copies of the
43 * software, derivative works or modified versions, and any portions
44 * thereof, and that both notices appear in supporting documentation.
46 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
47 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
48 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
50 * Carnegie Mellon requests users of this software to return to
52 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
53 * School of Computer Science
54 * Carnegie Mellon University
55 * Pittsburgh PA 15213-3890
57 * any improvements or extensions that they make and grant Carnegie Mellon
58 * the rights to redistribute these changes.
61 * File: kern/simple_lock.h (derived from kern/lock.h)
62 * Author: Avadis Tevanian, Jr., Michael Wayne Young
65 * Atomic primitives and Simple Locking primitives definitions
70 #ifndef _KERN_SIMPLE_LOCK_H_
71 #define _KERN_SIMPLE_LOCK_H_
73 #include <sys/cdefs.h>
74 #include <mach/boolean.h>
75 #include <kern/kern_types.h>
76 #include <machine/simple_lock.h>
78 #ifdef MACH_KERNEL_PRIVATE
79 #include <mach_ldebug.h>
81 extern void hw_lock_init(
84 extern void hw_lock_lock(
87 extern void hw_lock_unlock(
90 extern unsigned int hw_lock_to(
94 extern unsigned int hw_lock_try(
97 extern unsigned int hw_lock_held(
100 #endif /* MACH_KERNEL_PRIVATE */
104 extern uint32_t hw_atomic_add(
105 volatile uint32_t *dest
,
108 extern uint32_t hw_atomic_sub(
109 volatile uint32_t *dest
,
112 extern uint32_t hw_atomic_or(
113 volatile uint32_t *dest
,
116 extern uint32_t hw_atomic_and(
117 volatile uint32_t *dest
,
121 * Variant of hw_atomic_or which doesn't return a value; potentially
122 * more efficient on some platforms.
124 extern void hw_atomic_or_noret(
125 volatile uint32_t *dest
,
128 * Variant of hw_atomic_and which doesn't return a value; potentially
129 * more efficient on some platforms.
132 extern void hw_atomic_and_noret(
133 volatile uint32_t *dest
,
136 extern uint32_t hw_compare_and_store(
139 volatile uint32_t *dest
);
141 extern void hw_queue_atomic(
142 unsigned int *anchor
,
146 extern void hw_queue_atomic_list(
147 unsigned int *anchor
,
152 extern unsigned int *hw_dequeue_atomic(
153 unsigned int *anchor
,
156 extern void usimple_lock_init(
160 extern void usimple_lock(
163 extern void usimple_unlock(
166 extern unsigned int usimple_lock_try(
171 #define ETAP_NO_TRACE 0
172 #define ETAP_IO_AHA 0
175 * If we got to here and we still don't have simple_lock_init
176 * defined, then we must either be outside the osfmk component,
177 * running on a true SMP, or need debug.
179 #if !defined(simple_lock_init)
180 #define simple_lock_init(l,t) usimple_lock_init(l,t)
181 #define simple_lock(l) usimple_lock(l)
182 #define simple_unlock(l) usimple_unlock(l)
183 #define simple_lock_try(l) usimple_lock_try(l)
184 #define simple_lock_addr(l) (&(l))
185 #endif /* !defined(simple_lock_init) */
187 #endif /*!_KERN_SIMPLE_LOCK_H_*/
189 #endif /* KERNEL_PRIVATE */