]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/locks.h
xnu-1504.3.12.tar.gz
[apple/xnu.git] / osfmk / ppc / locks.h
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef _PPC_LOCKS_H_
30 #define _PPC_LOCKS_H_
31
32 #include <kern/kern_types.h>
33 #ifdef MACH_KERNEL_PRIVATE
34 #include <ppc/hw_lock_types.h>
35 #endif
36
37
38 #ifdef MACH_KERNEL_PRIVATE
39
40 extern unsigned int LcksOpts;
41
42 #define enaLkDeb 0x00000001 /* Request debug in default attribute */
43 #define enaLkStat 0x00000002 /* Request statistic in default attribute */
44
45 #define disLkType 0x80000000 /* Disable type checking */
46 #define disLktypeb 0
47 #define disLkThread 0x40000000 /* Disable ownership checking */
48 #define disLkThreadb 1
49 #define enaLkExtStck 0x20000000 /* Enable extended backtrace */
50 #define enaLkExtStckb 2
51 #define disLkMyLck 0x10000000 /* Disable recursive lock dectection */
52 #define disLkMyLckb 3
53
54 #endif
55
56 #ifdef MACH_KERNEL_PRIVATE
57 typedef struct {
58 unsigned int interlock;
59 unsigned int lck_spin_pad4[2];
60 } lck_spin_t;
61
62 #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
63
64 #else
65 #ifdef KERNEL_PRIVATE
66 typedef struct {
67 unsigned int opaque[3];
68 } lck_spin_t;
69 #else
70 typedef struct __lck_spin_t__ lck_spin_t;
71 #endif
72 #endif
73
74 #ifdef MACH_KERNEL_PRIVATE
75 typedef struct _lck_mtx_ {
76 union {
77 struct {
78 unsigned int lck_mtxd_data;
79 unsigned short lck_mtxd_waiters;
80 unsigned short lck_mtxd_pri;
81 unsigned int lck_mtxd_pad8;
82 } lck_mtxd;
83 struct {
84 unsigned int lck_mtxi_tag;
85 struct _lck_mtx_ext_ *lck_mtxi_ptr;
86 unsigned int lck_mtxi_pad8;
87 } lck_mtxi;
88 } lck_mtx_sw;
89 } lck_mtx_t;
90
91 #define lck_mtx_data lck_mtx_sw.lck_mtxd.lck_mtxd_data
92 #define lck_mtx_waiters lck_mtx_sw.lck_mtxd.lck_mtxd_waiters
93 #define lck_mtx_pri lck_mtx_sw.lck_mtxd.lck_mtxd_pri
94
95 #define lck_mtx_tag lck_mtx_sw.lck_mtxi.lck_mtxi_tag
96 #define lck_mtx_ptr lck_mtx_sw.lck_mtxi.lck_mtxi_ptr
97
98 #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */
99 #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
100
101 #define LCK_FRAMES_MAX 8
102
103 typedef struct {
104 unsigned int type;
105 vm_offset_t stack[LCK_FRAMES_MAX];
106 vm_offset_t thread;
107 } lck_mtx_deb_t;
108
109 #define MUTEX_TAG 0x4d4d
110
111 typedef struct {
112 unsigned int lck_mtx_stat_data;
113 } lck_mtx_stat_t;
114
115 typedef struct _lck_mtx_ext_ {
116 lck_mtx_t lck_mtx;
117 struct _lck_grp_ *lck_mtx_grp;
118 unsigned int lck_mtx_attr;
119 lck_mtx_deb_t lck_mtx_deb;
120 /* Unused on PowerPC */
121 lck_mtx_stat_t lck_mtx_stat;
122 } lck_mtx_ext_t;
123
124 #define LCK_MTX_ATTR_DEBUG 0x1
125 #define LCK_MTX_ATTR_DEBUGb 31
126 #define LCK_MTX_ATTR_STAT 0x2
127 #define LCK_MTX_ATTR_STATb 30
128
129 #else
130 #ifdef KERNEL_PRIVATE
131 typedef struct {
132 unsigned int opaque[3];
133 } lck_mtx_t;
134
135 typedef struct {
136 unsigned int opaque[16];
137 } lck_mtx_ext_t;
138 #else
139 typedef struct __lck_mtx_t__ lck_mtx_t;
140 typedef struct __lck_mtx_ext_t__ lck_mtx_ext_t;
141 #endif
142 #endif
143
144 #ifdef MACH_KERNEL_PRIVATE
145 typedef struct {
146 union {
147 struct {
148 unsigned int lck_rwd_shared_cnt:16, /* No. of shared granted request */
149 lck_rwd_priv_excl:1, /* priority for Writer */
150 lck_rwd_pad17:11, /* padding */
151 lck_rwd_want_excl:1, /* Writer is waiting, or locked for write */
152 lck_rwd_want_upgrade:1, /* Read-to-write upgrade waiting */
153 lck_rwd_waiting:1, /* Someone is sleeping on lock */
154 lck_rwd_interlock:1; /* Read-to-write upgrade waiting */
155 unsigned int lck_rwd_pad4;
156 unsigned int lck_rwd_pad8;
157 } lck_rwd;
158 struct {
159 unsigned int lck_rwi_tag;
160 struct _lck_rw_ext_ *lck_rwi_ptr;
161 unsigned int lck_rwi_pad8;
162 } lck_rwi;
163 } lck_rw_sw;
164 } lck_rw_t;
165
166 #define lck_rw_interlock lck_rw_sw.lck_rwd.lck_rwd_interlock
167 #define lck_rw_want_upgrade lck_rw_sw.lck_rwd.lck_rwd_want_upgrade
168 #define lck_rw_want_excl lck_rw_sw.lck_rwd.lck_rwd_want_excl
169 #define lck_rw_waiting lck_rw_sw.lck_rwd.lck_rwd_waiting
170 #define lck_rw_priv_excl lck_rw_sw.lck_rwd.lck_rwd_priv_excl
171 #define lck_rw_shared_cnt lck_rw_sw.lck_rwd.lck_rwd_shared_cnt
172
173 #define lck_rw_tag lck_rw_sw.lck_rwi.lck_rwi_tag
174 #define lck_rw_ptr lck_rw_sw.lck_rwi.lck_rwi_ptr
175
176 typedef struct {
177 unsigned int type;
178 vm_offset_t stack[LCK_FRAMES_MAX];
179 thread_t thread;
180 void (*pc_excl)(void);
181 void (*pc_done)(void);
182 } lck_rw_deb_t;
183
184 #define RW_TAG 0x5d5d
185
186 typedef struct {
187 unsigned int lck_rw_stat_data;
188 } lck_rw_stat_t;
189
190 typedef struct _lck_rw_ext_ {
191 lck_rw_t lck_rw;
192 struct _lck_grp_ *lck_rw_grp;
193 unsigned int lck_rw_attr;
194 lck_rw_deb_t lck_rw_deb;
195 lck_rw_stat_t lck_rw_stat;
196 } lck_rw_ext_t;
197
198 #define LCK_RW_ATTR_DEBUG 0x1
199 #define LCK_RW_ATTR_DEBUGb 31
200 #define LCK_RW_ATTR_STAT 0x2
201 #define LCK_RW_ATTR_STATb 30
202 #define LCK_RW_ATTR_DIS_THREAD 0x40000000
203 #define LCK_RW_ATTR_DIS_THREADb 1
204 #define LCK_RW_ATTR_DIS_MYLOCK 0x10000000
205 #define LCK_RW_ATTR_DIS_MYLOCKb 3
206
207 #define LCK_RW_TAG_INDIRECT 0x00001107 /* lock marked as Indirect */
208 #define LCK_RW_TAG_DESTROYED 0x00002107 /* lock marked as Destroyed */
209
210 #else
211 #ifdef KERNEL_PRIVATE
212 typedef struct {
213 unsigned int opaque[3];
214 } lck_rw_t;
215 #else
216 typedef struct __lck_rw_t__ lck_rw_t;
217 #endif
218 #endif
219
220 #endif /* _PPC_LOCKS_H_ */