]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/simple_lock.h
xnu-792.25.20.tar.gz
[apple/xnu.git] / osfmk / kern / simple_lock.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
6601e61a 4 * @APPLE_LICENSE_HEADER_START@
1c79356b 5 *
6601e61a
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.
8f6c56a5 11 *
6601e61a
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
8f6c56a5
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
6601e61a
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.
8f6c56a5 19 *
6601e61a 20 * @APPLE_LICENSE_HEADER_END@
1c79356b
A
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 *
91447636 59 * Atomic primitives and Simple Locking primitives definitions
1c79356b
A
60 */
61
91447636 62#ifdef KERNEL_PRIVATE
1c79356b 63
91447636
A
64#ifndef _KERN_SIMPLE_LOCK_H_
65#define _KERN_SIMPLE_LOCK_H_
1c79356b 66
91447636 67#include <sys/cdefs.h>
1c79356b
A
68#include <mach/boolean.h>
69#include <kern/kern_types.h>
91447636 70#include <machine/simple_lock.h>
9bccf70c
A
71
72#ifdef MACH_KERNEL_PRIVATE
91447636 73#include <mach_ldebug.h>
9bccf70c 74
91447636
A
75extern void hw_lock_init(
76 hw_lock_t);
9bccf70c 77
91447636
A
78extern void hw_lock_lock(
79 hw_lock_t);
9bccf70c 80
91447636
A
81extern void hw_lock_unlock(
82 hw_lock_t);
1c79356b 83
91447636
A
84extern unsigned int hw_lock_to(
85 hw_lock_t,
86 unsigned int);
9bccf70c 87
91447636
A
88extern unsigned int hw_lock_try(
89 hw_lock_t);
9bccf70c 90
91447636
A
91extern unsigned int hw_lock_held(
92 hw_lock_t);
9bccf70c 93
91447636 94#endif /* MACH_KERNEL_PRIVATE */
9bccf70c 95
91447636 96__BEGIN_DECLS
9bccf70c 97
91447636
A
98extern uint32_t hw_atomic_add(
99 uint32_t *dest,
100 uint32_t delt);
1c79356b 101
91447636
A
102extern uint32_t hw_atomic_sub(
103 uint32_t *dest,
104 uint32_t delt);
1c79356b 105
91447636
A
106extern uint32_t hw_atomic_or(
107 uint32_t *dest,
108 uint32_t mask);
1c79356b 109
91447636
A
110extern uint32_t hw_atomic_and(
111 uint32_t *dest,
112 uint32_t mask);
1c79356b 113
91447636
A
114extern uint32_t hw_compare_and_store(
115 uint32_t oldval,
116 uint32_t newval,
117 uint32_t *dest);
1c79356b 118
91447636
A
119extern void hw_queue_atomic(
120 unsigned int *anchor,
121 unsigned int *elem,
122 unsigned int disp);
1c79356b 123
91447636
A
124extern void hw_queue_atomic_list(
125 unsigned int *anchor,
126 unsigned int *first,
127 unsigned int *last,
128 unsigned int disp);
1c79356b 129
91447636
A
130extern unsigned int *hw_dequeue_atomic(
131 unsigned int *anchor,
132 unsigned int disp);
9bccf70c 133
91447636
A
134extern void usimple_lock_init(
135 usimple_lock_t,
136 unsigned short);
9bccf70c 137
91447636
A
138extern void usimple_lock(
139 usimple_lock_t);
1c79356b 140
91447636
A
141extern void usimple_unlock(
142 usimple_lock_t);
1c79356b 143
91447636
A
144extern unsigned int usimple_lock_try(
145 usimple_lock_t);
1c79356b 146
91447636 147__END_DECLS
9bccf70c 148
91447636
A
149#define ETAP_NO_TRACE 0
150#define ETAP_IO_AHA 0
1c79356b
A
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))
9bccf70c
A
163#define thread_sleep_simple_lock(l, e, i) \
164 thread_sleep_usimple_lock((l), (e), (i))
55e303ae 165#endif /* !defined(simple_lock_init) */
1c79356b 166
91447636 167#endif /*!_KERN_SIMPLE_LOCK_H_*/
1c79356b 168
91447636 169#endif /* KERNEL_PRIVATE */