]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
91447636 | 5 | * |
8ad349bb A |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
91447636 A |
29 | */ |
30 | ||
31 | #ifndef _PPC_LOCKS_H_ | |
32 | #define _PPC_LOCKS_H_ | |
33 | ||
34 | #include <kern/kern_types.h> | |
35 | #ifdef MACH_KERNEL_PRIVATE | |
36 | #include <ppc/hw_lock_types.h> | |
37 | #endif | |
38 | ||
39 | ||
40 | #ifdef MACH_KERNEL_PRIVATE | |
41 | ||
42 | extern unsigned int LcksOpts; | |
43 | ||
44 | #define enaLkDeb 0x00000001 /* Request debug in default attribute */ | |
45 | #define enaLkStat 0x00000002 /* Request statistic in default attribute */ | |
46 | ||
47 | #define disLkType 0x80000000 /* Disable type checking */ | |
48 | #define disLktypeb 0 | |
49 | #define disLkThread 0x40000000 /* Disable ownership checking */ | |
50 | #define disLkThreadb 1 | |
51 | #define enaLkExtStck 0x20000000 /* Enable extended backtrace */ | |
52 | #define enaLkExtStckb 2 | |
53 | #define disLkMyLck 0x10000000 /* Disable recursive lock dectection */ | |
54 | #define disLkMyLckb 3 | |
55 | ||
56 | #endif | |
57 | ||
58 | #ifdef MACH_KERNEL_PRIVATE | |
59 | typedef struct { | |
60 | unsigned int interlock; | |
61 | unsigned int lck_spin_pad4[2]; | |
62 | } lck_spin_t; | |
63 | ||
64 | #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */ | |
65 | ||
66 | #else | |
67 | #ifdef KERNEL_PRIVATE | |
68 | typedef struct { | |
69 | unsigned int opaque[3]; | |
70 | } lck_spin_t; | |
71 | #else | |
72 | typedef struct __lck_spin_t__ lck_spin_t; | |
73 | #endif | |
74 | #endif | |
75 | ||
76 | #ifdef MACH_KERNEL_PRIVATE | |
77 | typedef struct _lck_mtx_ { | |
78 | union { | |
79 | struct { | |
80 | unsigned int lck_mtxd_data; | |
81 | unsigned short lck_mtxd_waiters; | |
82 | unsigned short lck_mtxd_pri; | |
83 | unsigned int lck_mtxd_pad8; | |
84 | } lck_mtxd; | |
85 | struct { | |
86 | unsigned int lck_mtxi_tag; | |
87 | struct _lck_mtx_ext_ *lck_mtxi_ptr; | |
88 | unsigned int lck_mtxi_pad8; | |
89 | } lck_mtxi; | |
90 | } lck_mtx_sw; | |
91 | } lck_mtx_t; | |
92 | ||
93 | #define lck_mtx_data lck_mtx_sw.lck_mtxd.lck_mtxd_data | |
94 | #define lck_mtx_waiters lck_mtx_sw.lck_mtxd.lck_mtxd_waiters | |
95 | #define lck_mtx_pri lck_mtx_sw.lck_mtxd.lck_mtxd_pri | |
96 | ||
97 | #define lck_mtx_tag lck_mtx_sw.lck_mtxi.lck_mtxi_tag | |
98 | #define lck_mtx_ptr lck_mtx_sw.lck_mtxi.lck_mtxi_ptr | |
99 | ||
100 | #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */ | |
101 | #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */ | |
102 | ||
103 | #define LCK_FRAMES_MAX 8 | |
104 | ||
105 | typedef struct { | |
106 | unsigned int type; | |
107 | vm_offset_t stack[LCK_FRAMES_MAX]; | |
108 | vm_offset_t thread; | |
109 | } lck_mtx_deb_t; | |
110 | ||
111 | #define MUTEX_TAG 0x4d4d | |
112 | ||
113 | typedef struct { | |
114 | unsigned int lck_mtx_stat_data; | |
115 | } lck_mtx_stat_t; | |
116 | ||
117 | typedef struct _lck_mtx_ext_ { | |
118 | lck_mtx_t lck_mtx; | |
119 | struct _lck_grp_ *lck_mtx_grp; | |
120 | unsigned int lck_mtx_attr; | |
121 | lck_mtx_deb_t lck_mtx_deb; | |
122 | lck_mtx_stat_t lck_mtx_stat; | |
123 | } lck_mtx_ext_t; | |
124 | ||
125 | #define LCK_MTX_ATTR_DEBUG 0x1 | |
126 | #define LCK_MTX_ATTR_DEBUGb 31 | |
127 | #define LCK_MTX_ATTR_STAT 0x2 | |
128 | #define LCK_MTX_ATTR_STATb 30 | |
129 | ||
130 | #else | |
131 | #ifdef KERNEL_PRIVATE | |
132 | typedef struct { | |
133 | unsigned int opaque[3]; | |
134 | } lck_mtx_t; | |
135 | #else | |
136 | typedef struct __lck_mtx_t__ lck_mtx_t; | |
137 | #endif | |
138 | #endif | |
139 | ||
140 | #ifdef MACH_KERNEL_PRIVATE | |
141 | typedef struct { | |
142 | union { | |
143 | struct { | |
144 | unsigned int lck_rwd_shared_cnt:16, /* No. of shared granted request */ | |
8ad349bb | 145 | lck_rwd_pad16:12, /* padding */ |
91447636 A |
146 | lck_rwd_want_excl:1, /* Writer is waiting, or locked for write */ |
147 | lck_rwd_want_upgrade:1, /* Read-to-write upgrade waiting */ | |
148 | lck_rwd_waiting:1, /* Someone is sleeping on lock */ | |
149 | lck_rwd_interlock:1; /* Read-to-write upgrade waiting */ | |
150 | unsigned int lck_rwd_pad4; | |
151 | unsigned int lck_rwd_pad8; | |
152 | } lck_rwd; | |
153 | struct { | |
154 | unsigned int lck_rwi_tag; | |
155 | struct _lck_rw_ext_ *lck_rwi_ptr; | |
156 | unsigned int lck_rwi_pad8; | |
157 | } lck_rwi; | |
158 | } lck_rw_sw; | |
159 | } lck_rw_t; | |
160 | ||
161 | #define lck_rw_interlock lck_rw_sw.lck_rwd.lck_rwd_interlock | |
162 | #define lck_rw_want_upgrade lck_rw_sw.lck_rwd.lck_rwd_want_upgrade | |
163 | #define lck_rw_want_excl lck_rw_sw.lck_rwd.lck_rwd_want_excl | |
164 | #define lck_rw_waiting lck_rw_sw.lck_rwd.lck_rwd_waiting | |
165 | #define lck_rw_shared_cnt lck_rw_sw.lck_rwd.lck_rwd_shared_cnt | |
166 | ||
167 | #define lck_rw_tag lck_rw_sw.lck_rwi.lck_rwi_tag | |
168 | #define lck_rw_ptr lck_rw_sw.lck_rwi.lck_rwi_ptr | |
169 | ||
170 | typedef struct { | |
171 | unsigned int type; | |
172 | vm_offset_t stack[LCK_FRAMES_MAX]; | |
173 | thread_t thread; | |
174 | void (*pc_excl)(void); | |
175 | void (*pc_done)(void); | |
176 | } lck_rw_deb_t; | |
177 | ||
178 | #define RW_TAG 0x5d5d | |
179 | ||
180 | typedef struct { | |
181 | unsigned int lck_rw_stat_data; | |
182 | } lck_rw_stat_t; | |
183 | ||
184 | typedef struct _lck_rw_ext_ { | |
185 | lck_rw_t lck_rw; | |
186 | struct _lck_grp_ *lck_rw_grp; | |
187 | unsigned int lck_rw_attr; | |
188 | lck_rw_deb_t lck_rw_deb; | |
189 | lck_rw_stat_t lck_rw_stat; | |
190 | } lck_rw_ext_t; | |
191 | ||
192 | #define LCK_RW_ATTR_DEBUG 0x1 | |
193 | #define LCK_RW_ATTR_DEBUGb 31 | |
194 | #define LCK_RW_ATTR_STAT 0x2 | |
195 | #define LCK_RW_ATTR_STATb 30 | |
196 | #define LCK_RW_ATTR_DIS_THREAD 0x40000000 | |
197 | #define LCK_RW_ATTR_DIS_THREADb 1 | |
198 | #define LCK_RW_ATTR_DIS_MYLOCK 0x10000000 | |
199 | #define LCK_RW_ATTR_DIS_MYLOCKb 3 | |
200 | ||
201 | #define LCK_RW_TAG_INDIRECT 0x00001107 /* lock marked as Indirect */ | |
202 | #define LCK_RW_TAG_DESTROYED 0x00002107 /* lock marked as Destroyed */ | |
203 | ||
204 | #else | |
205 | #ifdef KERNEL_PRIVATE | |
206 | typedef struct { | |
207 | unsigned int opaque[3]; | |
208 | } lck_rw_t; | |
209 | #else | |
210 | typedef struct __lck_rw_t__ lck_rw_t; | |
211 | #endif | |
212 | #endif | |
213 | ||
214 | #endif /* _PPC_LOCKS_H_ */ |