]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/lock.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / ppc / lock.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (C) 1998 Apple Computer
27 * All Rights Reserved
28 */
29 /*
30 * @OSF_COPYRIGHT@
31 */
32
33 /*
34 * Mach Operating System
35 * Copyright (c) 1991,1990 Carnegie Mellon University
36 * All Rights Reserved.
37 *
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
43 *
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58
59 #ifndef _PPC_LOCK_H_
60 #define _PPC_LOCK_H_
61
62 #include <sys/appleapiopts.h>
63
64 #ifdef __APPLE_API_PRIVATE
65
66 #include <kern/macro_help.h>
67 #include <kern/assert.h>
68 #include <mach/etap_events.h>
69 #include <mach/etap.h>
70
71 extern unsigned int LockTimeOut; /* Number of hardware ticks of a lock timeout */
72
73 #if defined(MACH_KERNEL_PRIVATE)
74
75 #include <cpus.h>
76
77 #if !(NCPUS == 1 || ETAP_LOCK_TRACE || USLOCK_DEBUG)
78
79 #include <ppc/hw_lock_types.h>
80
81 #define __slock_held_func__(l) hw_lock_held(l)
82
83 extern void ppc_usimple_lock_init(simple_lock_t,etap_event_t);
84 extern void ppc_usimple_lock(simple_lock_t);
85 extern void ppc_usimple_unlock_rwmb(simple_lock_t);
86 extern void ppc_usimple_unlock_rwcmb(simple_lock_t);
87 extern unsigned int ppc_usimple_lock_try(simple_lock_t);
88
89 #define MACHINE_SIMPLE_LOCK
90
91 #define simple_lock_init(l,t) ppc_usimple_lock_init(l,t)
92 #define simple_lock(l) ppc_usimple_lock(l)
93 #define simple_unlock(l) ppc_usimple_unlock_rwcmb(l)
94 #define simple_unlock_rwmb(l) ppc_usimple_unlock_rwmb(l)
95 #define simple_lock_try(l) ppc_usimple_lock_try(l)
96 #define simple_lock_addr(l) (&(l))
97 #define thread_sleep_simple_lock(l, e, i) \
98 thread_sleep_fast_usimple_lock((l), (e), (i))
99
100 #define mutex_unlock(l) mutex_unlock_rwcmb(l)
101
102 #endif /* !(NCPUS == 1 || ETAP_LOCK_TRACE || USLOCK_DEBUG) */
103
104 #endif /* MACH_KERNEL_PRIVATE */
105
106 #endif /* __APPLE_API_PRIVATE */
107
108 #endif /* _PPC_LOCK_H_ */