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