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