]> git.saurik.com Git - apple/xnu.git/blame_incremental - osfmk/kern/simple_lock.h
xnu-792.10.96.tar.gz
[apple/xnu.git] / osfmk / kern / simple_lock.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000-2005 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
24 * All Rights Reserved
25 */
26/*
27 * @OSF_COPYRIGHT@
28 */
29/*
30 * Mach Operating System
31 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
32 * All Rights Reserved.
33 *
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.
39 *
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.
43 *
44 * Carnegie Mellon requests users of this software to return to
45 *
46 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
47 * School of Computer Science
48 * Carnegie Mellon University
49 * Pittsburgh PA 15213-3890
50 *
51 * any improvements or extensions that they make and grant Carnegie Mellon
52 * the rights to redistribute these changes.
53 */
54/*
55 * File: kern/simple_lock.h (derived from kern/lock.h)
56 * Author: Avadis Tevanian, Jr., Michael Wayne Young
57 * Date: 1985
58 *
59 * Atomic primitives and Simple Locking primitives definitions
60 */
61
62#ifdef KERNEL_PRIVATE
63
64#ifndef _KERN_SIMPLE_LOCK_H_
65#define _KERN_SIMPLE_LOCK_H_
66
67#include <sys/cdefs.h>
68#include <mach/boolean.h>
69#include <kern/kern_types.h>
70#include <machine/simple_lock.h>
71
72#ifdef MACH_KERNEL_PRIVATE
73#include <mach_ldebug.h>
74
75extern void hw_lock_init(
76 hw_lock_t);
77
78extern void hw_lock_lock(
79 hw_lock_t);
80
81extern void hw_lock_unlock(
82 hw_lock_t);
83
84extern unsigned int hw_lock_to(
85 hw_lock_t,
86 unsigned int);
87
88extern unsigned int hw_lock_try(
89 hw_lock_t);
90
91extern unsigned int hw_lock_held(
92 hw_lock_t);
93
94#endif /* MACH_KERNEL_PRIVATE */
95
96__BEGIN_DECLS
97
98extern uint32_t hw_atomic_add(
99 uint32_t *dest,
100 uint32_t delt);
101
102extern uint32_t hw_atomic_sub(
103 uint32_t *dest,
104 uint32_t delt);
105
106extern uint32_t hw_atomic_or(
107 uint32_t *dest,
108 uint32_t mask);
109
110extern uint32_t hw_atomic_and(
111 uint32_t *dest,
112 uint32_t mask);
113
114extern uint32_t hw_compare_and_store(
115 uint32_t oldval,
116 uint32_t newval,
117 uint32_t *dest);
118
119extern void hw_queue_atomic(
120 unsigned int *anchor,
121 unsigned int *elem,
122 unsigned int disp);
123
124extern void hw_queue_atomic_list(
125 unsigned int *anchor,
126 unsigned int *first,
127 unsigned int *last,
128 unsigned int disp);
129
130extern unsigned int *hw_dequeue_atomic(
131 unsigned int *anchor,
132 unsigned int disp);
133
134extern void usimple_lock_init(
135 usimple_lock_t,
136 unsigned short);
137
138extern void usimple_lock(
139 usimple_lock_t);
140
141extern void usimple_unlock(
142 usimple_lock_t);
143
144extern unsigned int usimple_lock_try(
145 usimple_lock_t);
146
147__END_DECLS
148
149#define ETAP_NO_TRACE 0
150#define ETAP_IO_AHA 0
151
152/*
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.
156 */
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) */
166
167#endif /*!_KERN_SIMPLE_LOCK_H_*/
168
169#endif /* KERNEL_PRIVATE */