]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
6d2010ae | 2 | * Copyright (c) 2000-2010 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 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 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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | /* | |
32 | * Mach Operating System | |
33 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
35 | * | |
36 | * Permission to use, copy, modify and distribute this software and its | |
37 | * documentation is hereby granted, provided that both the copyright | |
38 | * notice and this permission notice appear in all copies of the | |
39 | * software, derivative works or modified versions, and any portions | |
40 | * thereof, and that both notices appear in supporting documentation. | |
41 | * | |
42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
45 | * | |
46 | * Carnegie Mellon requests users of this software to return to | |
47 | * | |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
52 | * | |
53 | * any improvements or extensions that they make and grant Carnegie Mellon | |
54 | * the rights to redistribute these changes. | |
55 | */ | |
56 | ||
57 | #include <platforms.h> | |
1c79356b A |
58 | #include <mach_kdb.h> |
59 | #include <mach_ldebug.h> | |
60 | #include <stat_time.h> | |
61 | ||
62 | /* | |
63 | * Pass field offsets to assembly code. | |
64 | */ | |
65 | #include <kern/ast.h> | |
66 | #include <kern/thread.h> | |
67 | #include <kern/task.h> | |
68 | #include <kern/lock.h> | |
91447636 | 69 | #include <kern/locks.h> |
0c530ab8 A |
70 | #include <kern/host.h> |
71 | #include <kern/misc_protos.h> | |
1c79356b A |
72 | #include <ipc/ipc_space.h> |
73 | #include <ipc/ipc_port.h> | |
74 | #include <ipc/ipc_pset.h> | |
0c530ab8 | 75 | #include <vm/vm_map.h> |
1c79356b | 76 | #include <i386/pmap.h> |
b0d623f7 A |
77 | #include <i386/Diagnostics.h> |
78 | #include <i386/mp_desc.h> | |
79 | #include <i386/seg.h> | |
80 | #include <i386/thread.h> | |
81 | #include <i386/cpu_data.h> | |
1c79356b | 82 | #include <i386/tss.h> |
91447636 | 83 | #include <i386/cpu_capabilities.h> |
0c530ab8 | 84 | #include <i386/cpuid.h> |
0c530ab8 | 85 | #include <i386/pmCPU.h> |
0c530ab8 A |
86 | #include <mach/i386/vm_param.h> |
87 | #include <mach/i386/thread_status.h> | |
91447636 | 88 | #include <machine/commpage.h> |
91447636 | 89 | #include <pexpert/i386/boot.h> |
1c79356b | 90 | |
2d21ac55 A |
91 | #if CONFIG_DTRACE |
92 | #define NEED_DTRACE_DEFS | |
93 | #include <../bsd/sys/lockstat.h> | |
94 | #endif | |
95 | ||
1c79356b A |
96 | /* |
97 | * genassym.c is used to produce an | |
98 | * assembly file which, intermingled with unuseful assembly code, | |
99 | * has all the necessary definitions emitted. This assembly file is | |
100 | * then postprocessed with sed to extract only these definitions | |
101 | * and thus the final assyms.s is created. | |
102 | * | |
103 | * This convoluted means is necessary since the structure alignment | |
104 | * and packing may be different between the host machine and the | |
105 | * target so we are forced into using the cross compiler to generate | |
106 | * the values, but we cannot run anything on the target machine. | |
107 | */ | |
108 | ||
55e303ae | 109 | #undef offsetof |
1c79356b A |
110 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE)0)->MEMBER) |
111 | ||
112 | #if 0 | |
113 | #define DECLARE(SYM,VAL) \ | |
114 | __asm("#DEFINITION#\t.set\t" SYM ",\t%0" : : "n" ((u_int)(VAL))) | |
115 | #else | |
116 | #define DECLARE(SYM,VAL) \ | |
117 | __asm("#DEFINITION##define " SYM "\t%0" : : "n" ((u_int)(VAL))) | |
118 | #endif | |
119 | ||
120 | int main( | |
121 | int argc, | |
122 | char ** argv); | |
123 | ||
124 | int | |
125 | main( | |
126 | int argc, | |
127 | char **argv) | |
128 | { | |
129 | ||
130 | DECLARE("AST_URGENT", AST_URGENT); | |
2d21ac55 | 131 | DECLARE("AST_BSD", AST_BSD); |
1c79356b | 132 | |
6d2010ae A |
133 | DECLARE("MAX_CPUS", MAX_CPUS); |
134 | ||
55e303ae A |
135 | /* Simple Lock structure */ |
136 | DECLARE("SLOCK_ILK", offsetof(usimple_lock_t, interlock)); | |
137 | #if MACH_LDEBUG | |
138 | DECLARE("SLOCK_TYPE", offsetof(usimple_lock_t, lock_type)); | |
139 | DECLARE("SLOCK_PC", offsetof(usimple_lock_t, debug.lock_pc)); | |
140 | DECLARE("SLOCK_THREAD", offsetof(usimple_lock_t, debug.lock_thread)); | |
141 | DECLARE("SLOCK_DURATIONH",offsetof(usimple_lock_t, debug.duration[0])); | |
142 | DECLARE("SLOCK_DURATIONL",offsetof(usimple_lock_t, debug.duration[1])); | |
143 | DECLARE("USLOCK_TAG", USLOCK_TAG); | |
144 | #endif /* MACH_LDEBUG */ | |
145 | ||
146 | /* Mutex structure */ | |
b0d623f7 A |
147 | DECLARE("MUTEX_OWNER", offsetof(lck_mtx_t *, lck_mtx_owner)); |
148 | DECLARE("MUTEX_PTR", offsetof(lck_mtx_t *, lck_mtx_ptr)); | |
149 | DECLARE("MUTEX_STATE", offsetof(lck_mtx_t *, lck_mtx_state)); | |
150 | #ifdef __i386__ | |
151 | DECLARE("MUTEX_TYPE", offsetof(lck_mtx_ext_t *, lck_mtx_deb.type)); | |
152 | DECLARE("MUTEX_PC", offsetof(lck_mtx_ext_t *, lck_mtx_deb.pc)); | |
b0d623f7 A |
153 | DECLARE("MUTEX_ATTR", offsetof(lck_mtx_ext_t *, lck_mtx_attr)); |
154 | DECLARE("MUTEX_ATTR_DEBUG", LCK_MTX_ATTR_DEBUG); | |
155 | DECLARE("MUTEX_ATTR_DEBUGb", LCK_MTX_ATTR_DEBUGb); | |
156 | DECLARE("MUTEX_ATTR_STAT", LCK_MTX_ATTR_STAT); | |
157 | DECLARE("MUTEX_ATTR_STATb", LCK_MTX_ATTR_STATb); | |
55e303ae | 158 | DECLARE("MUTEX_TAG", MUTEX_TAG); |
b0d623f7 | 159 | #endif |
91447636 | 160 | DECLARE("MUTEX_IND", LCK_MTX_TAG_INDIRECT); |
91447636 | 161 | DECLARE("MUTEX_PTR", offsetof(lck_mtx_t *, lck_mtx_ptr)); |
2d21ac55 A |
162 | DECLARE("MUTEX_ASSERT_OWNED", LCK_MTX_ASSERT_OWNED); |
163 | DECLARE("MUTEX_ASSERT_NOTOWNED",LCK_MTX_ASSERT_NOTOWNED); | |
b0d623f7 A |
164 | DECLARE("GRP_MTX_STAT_UTIL", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt)); |
165 | DECLARE("GRP_MTX_STAT_MISS", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt)); | |
166 | DECLARE("GRP_MTX_STAT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt)); | |
167 | ||
168 | /* x86 only */ | |
169 | DECLARE("MUTEX_DESTROYED", LCK_MTX_TAG_DESTROYED); | |
170 | ||
2d21ac55 A |
171 | /* Per-mutex statistic element */ |
172 | DECLARE("MTX_ACQ_TSC", offsetof(lck_mtx_ext_t *, lck_mtx_stat)); | |
173 | ||
174 | /* Mutex group statistics elements */ | |
175 | DECLARE("MUTEX_GRP", offsetof(lck_mtx_ext_t *, lck_mtx_grp)); | |
176 | ||
2d21ac55 A |
177 | /* |
178 | * The use of this field is somewhat at variance with the alias. | |
179 | */ | |
180 | DECLARE("GRP_MTX_STAT_DIRECT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_cnt)); | |
181 | ||
182 | DECLARE("GRP_MTX_STAT_HELD_MAX", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_max)); | |
183 | /* Reader writer lock types */ | |
184 | DECLARE("RW_SHARED", LCK_RW_TYPE_SHARED); | |
185 | DECLARE("RW_EXCL", LCK_RW_TYPE_EXCLUSIVE); | |
91447636 | 186 | |
1c79356b A |
187 | DECLARE("TH_RECOVER", offsetof(thread_t, recover)); |
188 | DECLARE("TH_CONTINUATION", offsetof(thread_t, continuation)); | |
1c79356b | 189 | DECLARE("TH_KERNEL_STACK", offsetof(thread_t, kernel_stack)); |
6d2010ae A |
190 | DECLARE("TH_MUTEX_COUNT", offsetof(thread_t, mutex_count)); |
191 | DECLARE("TH_WAS_PROMOTED_ON_WAKEUP", offsetof(thread_t, was_promoted_on_wakeup)); | |
1c79356b | 192 | |
6d2010ae A |
193 | DECLARE("TH_SYSCALLS_MACH", offsetof(thread_t, syscalls_mach)); |
194 | DECLARE("TH_SYSCALLS_UNIX", offsetof(thread_t, syscalls_unix)); | |
1c79356b | 195 | |
2d21ac55 A |
196 | DECLARE("TASK_VTIMERS", offsetof(struct task *, vtimers)); |
197 | ||
1c79356b | 198 | /* These fields are being added on demand */ |
6d2010ae A |
199 | DECLARE("TH_TASK", offsetof(thread_t, task)); |
200 | DECLARE("TH_AST", offsetof(thread_t, ast)); | |
201 | DECLARE("TH_MAP", offsetof(thread_t, map)); | |
202 | DECLARE("TH_SPF", offsetof(thread_t, machine.specFlags)); | |
203 | DECLARE("TH_PCB_ISS", offsetof(thread_t, machine.iss)); | |
204 | DECLARE("TH_PCB_IDS", offsetof(thread_t, machine.ids)); | |
205 | DECLARE("TH_PCB_FPS", offsetof(thread_t, machine.ifps)); | |
b0d623f7 | 206 | #if NCOPY_WINDOWS > 0 |
6d2010ae | 207 | DECLARE("TH_COPYIO_STATE", offsetof(thread_t, machine.copyio_state)); |
0c530ab8 | 208 | DECLARE("WINDOWS_CLEAN", WINDOWS_CLEAN); |
b0d623f7 | 209 | #endif |
1c79356b A |
210 | |
211 | DECLARE("MAP_PMAP", offsetof(vm_map_t, pmap)); | |
212 | ||
b0d623f7 | 213 | #define IEL_SIZE (sizeof(struct i386_exception_link *)) |
b0d623f7 | 214 | DECLARE("IKS_SIZE", sizeof(struct x86_kernel_state)); |
1c79356b | 215 | |
b0d623f7 A |
216 | /* |
217 | * KSS_* are offsets from the top of the kernel stack (cpu_kernel_stack) | |
218 | */ | |
219 | #if defined(__i386__) | |
6d2010ae A |
220 | DECLARE("KSS_EBX", offsetof(struct x86_kernel_state *, k_ebx)); |
221 | DECLARE("KSS_ESP", offsetof(struct x86_kernel_state *, k_esp)); | |
222 | DECLARE("KSS_EBP", offsetof(struct x86_kernel_state *, k_ebp)); | |
223 | DECLARE("KSS_EDI", offsetof(struct x86_kernel_state *, k_edi)); | |
224 | DECLARE("KSS_ESI", offsetof(struct x86_kernel_state *, k_esi)); | |
225 | DECLARE("KSS_EIP", offsetof(struct x86_kernel_state *, k_eip)); | |
b0d623f7 | 226 | #elif defined(__x86_64__) |
6d2010ae A |
227 | DECLARE("KSS_RBX", offsetof(struct x86_kernel_state *, k_rbx)); |
228 | DECLARE("KSS_RSP", offsetof(struct x86_kernel_state *, k_rsp)); | |
229 | DECLARE("KSS_RBP", offsetof(struct x86_kernel_state *, k_rbp)); | |
230 | DECLARE("KSS_R12", offsetof(struct x86_kernel_state *, k_r12)); | |
231 | DECLARE("KSS_R13", offsetof(struct x86_kernel_state *, k_r13)); | |
232 | DECLARE("KSS_R14", offsetof(struct x86_kernel_state *, k_r14)); | |
233 | DECLARE("KSS_R15", offsetof(struct x86_kernel_state *, k_r15)); | |
234 | DECLARE("KSS_RIP", offsetof(struct x86_kernel_state *, k_rip)); | |
b0d623f7 A |
235 | #else |
236 | #error Unsupported architecture | |
237 | #endif | |
238 | ||
0c530ab8 A |
239 | DECLARE("DS_DR0", offsetof(struct x86_debug_state32 *, dr0)); |
240 | DECLARE("DS_DR1", offsetof(struct x86_debug_state32 *, dr1)); | |
241 | DECLARE("DS_DR2", offsetof(struct x86_debug_state32 *, dr2)); | |
242 | DECLARE("DS_DR3", offsetof(struct x86_debug_state32 *, dr3)); | |
243 | DECLARE("DS_DR4", offsetof(struct x86_debug_state32 *, dr4)); | |
244 | DECLARE("DS_DR5", offsetof(struct x86_debug_state32 *, dr5)); | |
245 | DECLARE("DS_DR6", offsetof(struct x86_debug_state32 *, dr6)); | |
246 | DECLARE("DS_DR7", offsetof(struct x86_debug_state32 *, dr7)); | |
247 | ||
248 | DECLARE("DS64_DR0", offsetof(struct x86_debug_state64 *, dr0)); | |
249 | DECLARE("DS64_DR1", offsetof(struct x86_debug_state64 *, dr1)); | |
250 | DECLARE("DS64_DR2", offsetof(struct x86_debug_state64 *, dr2)); | |
251 | DECLARE("DS64_DR3", offsetof(struct x86_debug_state64 *, dr3)); | |
252 | DECLARE("DS64_DR4", offsetof(struct x86_debug_state64 *, dr4)); | |
253 | DECLARE("DS64_DR5", offsetof(struct x86_debug_state64 *, dr5)); | |
254 | DECLARE("DS64_DR6", offsetof(struct x86_debug_state64 *, dr6)); | |
255 | DECLARE("DS64_DR7", offsetof(struct x86_debug_state64 *, dr7)); | |
256 | ||
060df5ea | 257 | DECLARE("FP_VALID", offsetof(struct x86_fx_thread_state *,fp_valid)); |
0c530ab8 A |
258 | |
259 | DECLARE("SS_FLAVOR", offsetof(x86_saved_state_t *, flavor)); | |
260 | DECLARE("SS_32", x86_SAVED_STATE32); | |
261 | DECLARE("SS_64", x86_SAVED_STATE64); | |
262 | ||
263 | #define R_(x) offsetof(x86_saved_state_t *, ss_32.x) | |
b0d623f7 A |
264 | DECLARE("R32_CS", R_(cs)); |
265 | DECLARE("R32_SS", R_(ss)); | |
266 | DECLARE("R32_DS", R_(ds)); | |
267 | DECLARE("R32_ES", R_(es)); | |
268 | DECLARE("R32_FS", R_(fs)); | |
269 | DECLARE("R32_GS", R_(gs)); | |
270 | DECLARE("R32_UESP", R_(uesp)); | |
271 | DECLARE("R32_EBP", R_(ebp)); | |
272 | DECLARE("R32_EAX", R_(eax)); | |
273 | DECLARE("R32_EBX", R_(ebx)); | |
274 | DECLARE("R32_ECX", R_(ecx)); | |
275 | DECLARE("R32_EDX", R_(edx)); | |
276 | DECLARE("R32_ESI", R_(esi)); | |
277 | DECLARE("R32_EDI", R_(edi)); | |
278 | DECLARE("R32_TRAPNO", R_(trapno)); | |
279 | DECLARE("R32_ERR", R_(err)); | |
280 | DECLARE("R32_EFLAGS", R_(efl)); | |
281 | DECLARE("R32_EIP", R_(eip)); | |
282 | DECLARE("R32_CR2", R_(cr2)); | |
0c530ab8 A |
283 | DECLARE("ISS32_SIZE", sizeof (x86_saved_state32_t)); |
284 | ||
285 | #define R64_(x) offsetof(x86_saved_state_t *, ss_64.x) | |
286 | DECLARE("R64_FS", R64_(fs)); | |
287 | DECLARE("R64_GS", R64_(gs)); | |
288 | DECLARE("R64_R8", R64_(r8)); | |
289 | DECLARE("R64_R9", R64_(r9)); | |
290 | DECLARE("R64_R10", R64_(r10)); | |
291 | DECLARE("R64_R11", R64_(r11)); | |
292 | DECLARE("R64_R12", R64_(r12)); | |
293 | DECLARE("R64_R13", R64_(r13)); | |
294 | DECLARE("R64_R14", R64_(r14)); | |
295 | DECLARE("R64_R15", R64_(r15)); | |
296 | DECLARE("R64_RBP", R64_(rbp)); | |
297 | DECLARE("R64_RAX", R64_(rax)); | |
298 | DECLARE("R64_RBX", R64_(rbx)); | |
299 | DECLARE("R64_RCX", R64_(rcx)); | |
300 | DECLARE("R64_RDX", R64_(rdx)); | |
301 | DECLARE("R64_RSI", R64_(rsi)); | |
302 | DECLARE("R64_RDI", R64_(rdi)); | |
303 | DECLARE("R64_V_ARG6", R64_(v_arg6)); | |
304 | DECLARE("R64_V_ARG7", R64_(v_arg7)); | |
305 | DECLARE("R64_V_ARG8", R64_(v_arg8)); | |
306 | DECLARE("R64_CS", R64_(isf.cs)); | |
307 | DECLARE("R64_SS", R64_(isf.ss)); | |
308 | DECLARE("R64_RSP", R64_(isf.rsp)); | |
309 | DECLARE("R64_TRAPNO", R64_(isf.trapno)); | |
310 | DECLARE("R64_TRAPFN", R64_(isf.trapfn)); | |
311 | DECLARE("R64_ERR", R64_(isf.err)); | |
312 | DECLARE("R64_RFLAGS", R64_(isf.rflags)); | |
313 | DECLARE("R64_RIP", R64_(isf.rip)); | |
314 | DECLARE("R64_CR2", R64_(cr2)); | |
315 | DECLARE("ISS64_OFFSET", R64_(isf)); | |
316 | DECLARE("ISS64_SIZE", sizeof (x86_saved_state64_t)); | |
317 | ||
318 | #define ISF64_(x) offsetof(x86_64_intr_stack_frame_t *, x) | |
319 | DECLARE("ISF64_TRAPNO", ISF64_(trapno)); | |
320 | DECLARE("ISF64_TRAPFN", ISF64_(trapfn)); | |
321 | DECLARE("ISF64_ERR", ISF64_(err)); | |
322 | DECLARE("ISF64_RIP", ISF64_(rip)); | |
323 | DECLARE("ISF64_CS", ISF64_(cs)); | |
324 | DECLARE("ISF64_RFLAGS", ISF64_(rflags)); | |
325 | DECLARE("ISF64_RSP", ISF64_(rsp)); | |
326 | DECLARE("ISF64_SS", ISF64_(ss)); | |
327 | DECLARE("ISF64_SIZE", sizeof(x86_64_intr_stack_frame_t)); | |
328 | ||
329 | DECLARE("ISC32_OFFSET", offsetof(x86_saved_state_compat32_t *, isf64)); | |
330 | #define ISC32_(x) offsetof(x86_saved_state_compat32_t *, isf64.x) | |
331 | DECLARE("ISC32_TRAPNO", ISC32_(trapno)); | |
332 | DECLARE("ISC32_TRAPFN", ISC32_(trapfn)); | |
333 | DECLARE("ISC32_ERR", ISC32_(err)); | |
334 | DECLARE("ISC32_RIP", ISC32_(rip)); | |
335 | DECLARE("ISC32_CS", ISC32_(cs)); | |
336 | DECLARE("ISC32_RFLAGS", ISC32_(rflags)); | |
337 | DECLARE("ISC32_RSP", ISC32_(rsp)); | |
338 | DECLARE("ISC32_SS", ISC32_(ss)); | |
1c79356b A |
339 | |
340 | DECLARE("NBPG", I386_PGBYTES); | |
91447636 A |
341 | DECLARE("PAGE_SIZE", I386_PGBYTES); |
342 | DECLARE("PAGE_MASK", I386_PGBYTES-1); | |
343 | DECLARE("PAGE_SHIFT", 12); | |
344 | DECLARE("NKPT", NKPT); | |
b0d623f7 | 345 | #ifdef __i386__ |
91447636 | 346 | DECLARE("KPTDI", KPTDI); |
b0d623f7 | 347 | #endif |
1c79356b A |
348 | DECLARE("VM_MIN_ADDRESS", VM_MIN_ADDRESS); |
349 | DECLARE("VM_MAX_ADDRESS", VM_MAX_ADDRESS); | |
350 | DECLARE("KERNELBASE", VM_MIN_KERNEL_ADDRESS); | |
351 | DECLARE("LINEAR_KERNELBASE", LINEAR_KERNEL_ADDRESS); | |
352 | DECLARE("KERNEL_STACK_SIZE", KERNEL_STACK_SIZE); | |
b0d623f7 | 353 | #ifdef __i386__ |
0c530ab8 | 354 | DECLARE("KERNEL_UBER_BASE_HI32", KERNEL_UBER_BASE_HI32); |
b0d623f7 | 355 | #endif |
1c79356b | 356 | |
b0d623f7 A |
357 | DECLARE("ASM_COMM_PAGE32_BASE_ADDRESS", _COMM_PAGE32_BASE_ADDRESS); |
358 | DECLARE("ASM_COMM_PAGE32_START_ADDRESS", _COMM_PAGE32_START_ADDRESS); | |
359 | DECLARE("ASM_COMM_PAGE_SCHED_GEN", _COMM_PAGE_SCHED_GEN); | |
91447636 | 360 | |
1c79356b | 361 | DECLARE("PDESHIFT", PDESHIFT); |
1c79356b | 362 | DECLARE("PTEMASK", PTEMASK); |
91447636 | 363 | DECLARE("PTEINDX", PTEINDX); |
b0d623f7 A |
364 | DECLARE("INTEL_PTE_PFN", INTEL_PTE_PFN); |
365 | DECLARE("INTEL_PTE_VALID", INTEL_PTE_VALID); | |
366 | DECLARE("INTEL_PTE_WRITE", INTEL_PTE_WRITE); | |
367 | DECLARE("INTEL_PTE_PS", INTEL_PTE_PS); | |
368 | DECLARE("INTEL_PTE_USER", INTEL_PTE_USER); | |
369 | DECLARE("INTEL_PTE_INVALID", INTEL_PTE_INVALID); | |
91447636 | 370 | DECLARE("NPGPTD", NPGPTD); |
b0d623f7 A |
371 | #if defined(__x86_64__) |
372 | DECLARE("INITPT_SEG_BASE",INITPT_SEG_BASE); | |
373 | DECLARE("INITGDT_SEG_BASE",INITGDT_SEG_BASE); | |
374 | DECLARE("SLEEP_SEG_BASE",SLEEP_SEG_BASE); | |
375 | DECLARE("PROT_MODE_GDT_SIZE",PROT_MODE_GDT_SIZE); | |
376 | DECLARE("KERNEL_PML4_INDEX",KERNEL_PML4_INDEX); | |
377 | #endif | |
1c79356b A |
378 | DECLARE("IDTSZ", IDTSZ); |
379 | DECLARE("GDTSZ", GDTSZ); | |
380 | DECLARE("LDTSZ", LDTSZ); | |
381 | ||
1c79356b A |
382 | DECLARE("KERNEL_DS", KERNEL_DS); |
383 | DECLARE("USER_CS", USER_CS); | |
384 | DECLARE("USER_DS", USER_DS); | |
b0d623f7 | 385 | DECLARE("KERNEL32_CS", KERNEL32_CS); |
0c530ab8 A |
386 | DECLARE("KERNEL64_CS", KERNEL64_CS); |
387 | DECLARE("USER64_CS", USER64_CS); | |
1c79356b A |
388 | DECLARE("KERNEL_TSS", KERNEL_TSS); |
389 | DECLARE("KERNEL_LDT", KERNEL_LDT); | |
b0d623f7 | 390 | #ifdef __i386__ |
0c530ab8 A |
391 | DECLARE("DF_TSS", DF_TSS); |
392 | DECLARE("MC_TSS", MC_TSS); | |
1c79356b A |
393 | #if MACH_KDB |
394 | DECLARE("DEBUG_TSS", DEBUG_TSS); | |
395 | #endif /* MACH_KDB */ | |
b0d623f7 A |
396 | DECLARE("CPU_DATA_GS", CPU_DATA_GS); |
397 | #endif /* __i386__ */ | |
0c530ab8 A |
398 | DECLARE("SYSENTER_CS", SYSENTER_CS); |
399 | DECLARE("SYSENTER_TF_CS",SYSENTER_TF_CS); | |
400 | DECLARE("SYSENTER_DS", SYSENTER_DS); | |
401 | DECLARE("SYSCALL_CS", SYSCALL_CS); | |
b0d623f7 | 402 | #ifdef __i386__ |
0c530ab8 A |
403 | DECLARE("USER_WINDOW_SEL", USER_WINDOW_SEL); |
404 | DECLARE("PHYS_WINDOW_SEL", PHYS_WINDOW_SEL); | |
b0d623f7 | 405 | #endif |
91447636 A |
406 | |
407 | DECLARE("CPU_THIS", | |
408 | offsetof(cpu_data_t *, cpu_this)); | |
409 | DECLARE("CPU_ACTIVE_THREAD", | |
410 | offsetof(cpu_data_t *, cpu_active_thread)); | |
91447636 A |
411 | DECLARE("CPU_ACTIVE_STACK", |
412 | offsetof(cpu_data_t *, cpu_active_stack)); | |
413 | DECLARE("CPU_KERNEL_STACK", | |
414 | offsetof(cpu_data_t *, cpu_kernel_stack)); | |
415 | DECLARE("CPU_INT_STACK_TOP", | |
416 | offsetof(cpu_data_t *, cpu_int_stack_top)); | |
1c79356b | 417 | #if MACH_RT |
91447636 A |
418 | DECLARE("CPU_PREEMPTION_LEVEL", |
419 | offsetof(cpu_data_t *, cpu_preemption_level)); | |
1c79356b | 420 | #endif /* MACH_RT */ |
b0d623f7 A |
421 | DECLARE("CPU_HIBERNATE", |
422 | offsetof(cpu_data_t *, cpu_hibernate)); | |
91447636 A |
423 | DECLARE("CPU_INTERRUPT_LEVEL", |
424 | offsetof(cpu_data_t *, cpu_interrupt_level)); | |
060df5ea | 425 | DECLARE("CPU_NESTED_ISTACK", |
6d2010ae | 426 | offsetof(cpu_data_t *, cpu_nested_istack)); |
91447636 | 427 | DECLARE("CPU_NUMBER_GS", |
55e303ae | 428 | offsetof(cpu_data_t *,cpu_number)); |
91447636 A |
429 | DECLARE("CPU_RUNNING", |
430 | offsetof(cpu_data_t *,cpu_running)); | |
431 | DECLARE("CPU_MCOUNT_OFF", | |
432 | offsetof(cpu_data_t *,cpu_mcount_off)); | |
433 | DECLARE("CPU_PENDING_AST", | |
434 | offsetof(cpu_data_t *,cpu_pending_ast)); | |
435 | DECLARE("CPU_DESC_TABLEP", | |
436 | offsetof(cpu_data_t *,cpu_desc_tablep)); | |
0c530ab8 A |
437 | DECLARE("CPU_DESC_INDEX", |
438 | offsetof(cpu_data_t *,cpu_desc_index)); | |
439 | DECLARE("CDI_GDT", | |
440 | offsetof(cpu_desc_index_t *,cdi_gdt)); | |
441 | DECLARE("CDI_IDT", | |
442 | offsetof(cpu_desc_index_t *,cdi_idt)); | |
91447636 A |
443 | DECLARE("CPU_PROCESSOR", |
444 | offsetof(cpu_data_t *,cpu_processor)); | |
0c530ab8 A |
445 | DECLARE("CPU_INT_STATE", |
446 | offsetof(cpu_data_t *, cpu_int_state)); | |
2d21ac55 A |
447 | DECLARE("CPU_INT_EVENT_TIME", |
448 | offsetof(cpu_data_t *, cpu_int_event_time)); | |
0c530ab8 | 449 | |
b0d623f7 | 450 | #ifdef __i386__ |
0c530ab8 A |
451 | DECLARE("CPU_HI_ISS", |
452 | offsetof(cpu_data_t *, cpu_hi_iss)); | |
b0d623f7 | 453 | #endif |
0c530ab8 A |
454 | DECLARE("CPU_TASK_CR3", |
455 | offsetof(cpu_data_t *, cpu_task_cr3)); | |
456 | DECLARE("CPU_ACTIVE_CR3", | |
457 | offsetof(cpu_data_t *, cpu_active_cr3)); | |
458 | DECLARE("CPU_KERNEL_CR3", | |
459 | offsetof(cpu_data_t *, cpu_kernel_cr3)); | |
b0d623f7 A |
460 | #ifdef __x86_64__ |
461 | DECLARE("CPU_TLB_INVALID", | |
462 | offsetof(cpu_data_t *, cpu_tlb_invalid)); | |
463 | #endif | |
0c530ab8 A |
464 | |
465 | DECLARE("CPU_IS64BIT", | |
466 | offsetof(cpu_data_t *, cpu_is64bit)); | |
467 | DECLARE("CPU_TASK_MAP", | |
468 | offsetof(cpu_data_t *, cpu_task_map)); | |
469 | DECLARE("TASK_MAP_32BIT", TASK_MAP_32BIT); | |
b0d623f7 A |
470 | DECLARE("TASK_MAP_64BIT", TASK_MAP_64BIT); |
471 | #ifdef __i386__ | |
0c530ab8 | 472 | DECLARE("TASK_MAP_64BIT_SHARED", TASK_MAP_64BIT_SHARED); |
b0d623f7 | 473 | #endif |
0c530ab8 A |
474 | DECLARE("CPU_UBER_USER_GS_BASE", |
475 | offsetof(cpu_data_t *, cpu_uber.cu_user_gs_base)); | |
476 | DECLARE("CPU_UBER_ISF", | |
477 | offsetof(cpu_data_t *, cpu_uber.cu_isf)); | |
478 | DECLARE("CPU_UBER_TMP", | |
479 | offsetof(cpu_data_t *, cpu_uber.cu_tmp)); | |
2d21ac55 A |
480 | DECLARE("CPU_UBER_ARG_STORE", |
481 | offsetof(cpu_data_t *, cpu_uber_arg_store)); | |
482 | DECLARE("CPU_UBER_ARG_STORE_VALID", | |
483 | offsetof(cpu_data_t *, cpu_uber_arg_store_valid)); | |
484 | ||
593a1d5f A |
485 | DECLARE("CPU_NANOTIME", |
486 | offsetof(cpu_data_t *, cpu_nanotime)); | |
487 | ||
0c530ab8 A |
488 | DECLARE("CPU_DR7", |
489 | offsetof(cpu_data_t *, cpu_dr7)); | |
490 | ||
491 | DECLARE("hwIntCnt", offsetof(cpu_data_t *,cpu_hwIntCnt)); | |
6d2010ae A |
492 | #if defined(__x86_64__) |
493 | DECLARE("CPU_ACTIVE_PCID", | |
494 | offsetof(cpu_data_t *, cpu_active_pcid)); | |
495 | DECLARE("CPU_PCID_COHERENTP", | |
496 | offsetof(cpu_data_t *, cpu_pmap_pcid_coherentp)); | |
497 | DECLARE("CPU_PCID_COHERENTP_KERNEL", | |
498 | offsetof(cpu_data_t *, cpu_pmap_pcid_coherentp_kernel)); | |
499 | DECLARE("CPU_PMAP_PCID_ENABLED", | |
500 | offsetof(cpu_data_t *, cpu_pmap_pcid_enabled)); | |
501 | ||
502 | #ifdef PCID_STATS | |
503 | DECLARE("CPU_PMAP_USER_RETS", | |
504 | offsetof(cpu_data_t *, cpu_pmap_user_rets)); | |
505 | DECLARE("CPU_PMAP_PCID_PRESERVES", | |
506 | offsetof(cpu_data_t *, cpu_pmap_pcid_preserves)); | |
507 | DECLARE("CPU_PMAP_PCID_FLUSHES", | |
508 | offsetof(cpu_data_t *, cpu_pmap_pcid_flushes)); | |
509 | #endif | |
510 | DECLARE("CPU_TLB_INVALID", | |
511 | offsetof(cpu_data_t *, cpu_tlb_invalid)); | |
512 | DECLARE("CPU_TLB_INVALID_LOCAL", | |
513 | offsetof(cpu_data_t *, cpu_tlb_invalid_local)); | |
514 | DECLARE("CPU_TLB_INVALID_GLOBAL", | |
515 | offsetof(cpu_data_t *, cpu_tlb_invalid_global)); | |
516 | #endif /* x86_64 */ | |
0c530ab8 A |
517 | DECLARE("enaExpTrace", enaExpTrace); |
518 | DECLARE("enaExpTraceb", enaExpTraceb); | |
519 | DECLARE("enaUsrFCall", enaUsrFCall); | |
520 | DECLARE("enaUsrFCallb", enaUsrFCallb); | |
521 | DECLARE("enaUsrPhyMp", enaUsrPhyMp); | |
522 | DECLARE("enaUsrPhyMpb", enaUsrPhyMpb); | |
523 | DECLARE("enaDiagSCs", enaDiagSCs); | |
524 | DECLARE("enaDiagSCsb", enaDiagSCsb); | |
525 | DECLARE("enaDiagEM", enaDiagEM); | |
526 | DECLARE("enaDiagEMb", enaDiagEMb); | |
527 | DECLARE("enaNotifyEM", enaNotifyEM); | |
528 | DECLARE("enaNotifyEMb", enaNotifyEMb); | |
529 | DECLARE("dgLock", offsetof(struct diagWork *, dgLock)); | |
530 | DECLARE("dgFlags", offsetof(struct diagWork *, dgFlags)); | |
531 | DECLARE("dgMisc1", offsetof(struct diagWork *, dgMisc1)); | |
532 | DECLARE("dgMisc2", offsetof(struct diagWork *, dgMisc2)); | |
533 | DECLARE("dgMisc3", offsetof(struct diagWork *, dgMisc3)); | |
534 | DECLARE("dgMisc4", offsetof(struct diagWork *, dgMisc4)); | |
535 | DECLARE("dgMisc5", offsetof(struct diagWork *, dgMisc5)); | |
91447636 | 536 | |
1c79356b | 537 | DECLARE("INTEL_PTE_KERNEL", INTEL_PTE_VALID|INTEL_PTE_WRITE); |
91447636 A |
538 | DECLARE("PDESHIFT", PDESHIFT); |
539 | DECLARE("PDESIZE", PDESIZE); | |
540 | DECLARE("PTESIZE", PTESIZE); | |
b0d623f7 A |
541 | #ifdef __i386__ |
542 | DECLARE("PTDPTDI", PTDPTDI); | |
91447636 | 543 | DECLARE("APTDPTDI", APTDPTDI); |
0c530ab8 A |
544 | DECLARE("HIGH_MEM_BASE", HIGH_MEM_BASE); |
545 | DECLARE("HIGH_IDT_BASE", pmap_index_to_virt(HIGH_FIXED_IDT)); | |
b0d623f7 | 546 | #endif |
1c79356b A |
547 | |
548 | DECLARE("KERNELBASEPDE", | |
549 | (LINEAR_KERNEL_ADDRESS >> PDESHIFT) * | |
550 | sizeof(pt_entry_t)); | |
551 | ||
552 | DECLARE("TSS_ESP0", offsetof(struct i386_tss *, esp0)); | |
553 | DECLARE("TSS_SS0", offsetof(struct i386_tss *, ss0)); | |
554 | DECLARE("TSS_LDT", offsetof(struct i386_tss *, ldt)); | |
555 | DECLARE("TSS_PDBR", offsetof(struct i386_tss *, cr3)); | |
556 | DECLARE("TSS_LINK", offsetof(struct i386_tss *, back_link)); | |
557 | ||
558 | DECLARE("K_TASK_GATE", ACC_P|ACC_PL_K|ACC_TASK_GATE); | |
559 | DECLARE("K_TRAP_GATE", ACC_P|ACC_PL_K|ACC_TRAP_GATE); | |
560 | DECLARE("U_TRAP_GATE", ACC_P|ACC_PL_U|ACC_TRAP_GATE); | |
561 | DECLARE("K_INTR_GATE", ACC_P|ACC_PL_K|ACC_INTR_GATE); | |
0c530ab8 | 562 | DECLARE("U_INTR_GATE", ACC_P|ACC_PL_U|ACC_INTR_GATE); |
1c79356b A |
563 | DECLARE("K_TSS", ACC_P|ACC_PL_K|ACC_TSS); |
564 | ||
565 | /* | |
566 | * usimple_lock fields | |
567 | */ | |
568 | DECLARE("USL_INTERLOCK", offsetof(usimple_lock_t, interlock)); | |
569 | ||
570 | DECLARE("INTSTACK_SIZE", INTSTACK_SIZE); | |
0c530ab8 A |
571 | DECLARE("KADDR", offsetof(struct boot_args *, kaddr)); |
572 | DECLARE("KSIZE", offsetof(struct boot_args *, ksize)); | |
573 | DECLARE("MEMORYMAP", offsetof(struct boot_args *, MemoryMap)); | |
574 | DECLARE("DEVICETREEP", offsetof(struct boot_args *, deviceTreeP)); | |
575 | ||
576 | DECLARE("RNT_TSC_BASE", | |
6d2010ae | 577 | offsetof(pal_rtc_nanotime_t *, tsc_base)); |
0c530ab8 | 578 | DECLARE("RNT_NS_BASE", |
6d2010ae | 579 | offsetof(pal_rtc_nanotime_t *, ns_base)); |
0c530ab8 | 580 | DECLARE("RNT_SCALE", |
6d2010ae | 581 | offsetof(pal_rtc_nanotime_t *, scale)); |
0c530ab8 | 582 | DECLARE("RNT_SHIFT", |
6d2010ae | 583 | offsetof(pal_rtc_nanotime_t *, shift)); |
2d21ac55 | 584 | DECLARE("RNT_GENERATION", |
6d2010ae | 585 | offsetof(pal_rtc_nanotime_t *, generation)); |
91447636 A |
586 | |
587 | /* values from kern/timer.h */ | |
b0d623f7 A |
588 | #ifdef __LP64__ |
589 | DECLARE("TIMER_ALL", offsetof(struct timer *, all_bits)); | |
590 | #else | |
591 | DECLARE("TIMER_LOW", offsetof(struct timer *, low_bits)); | |
592 | DECLARE("TIMER_HIGH", offsetof(struct timer *, high_bits)); | |
593 | DECLARE("TIMER_HIGHCHK", offsetof(struct timer *, high_bits_check)); | |
594 | #endif | |
91447636 A |
595 | #if !STAT_TIME |
596 | DECLARE("TIMER_TSTAMP", | |
597 | offsetof(struct timer *, tstamp)); | |
598 | ||
2d21ac55 A |
599 | DECLARE("THREAD_TIMER", |
600 | offsetof(struct processor *, processor_data.thread_timer)); | |
1c79356b | 601 | #endif |
2d21ac55 A |
602 | DECLARE("KERNEL_TIMER", |
603 | offsetof(struct processor *, processor_data.kernel_timer)); | |
91447636 A |
604 | DECLARE("SYSTEM_TIMER", |
605 | offsetof(struct thread *, system_timer)); | |
606 | DECLARE("USER_TIMER", | |
607 | offsetof(struct thread *, user_timer)); | |
2d21ac55 A |
608 | DECLARE("SYSTEM_STATE", |
609 | offsetof(struct processor *, processor_data.system_state)); | |
610 | DECLARE("USER_STATE", | |
611 | offsetof(struct processor *, processor_data.user_state)); | |
612 | DECLARE("IDLE_STATE", | |
613 | offsetof(struct processor *, processor_data.idle_state)); | |
614 | DECLARE("CURRENT_STATE", | |
615 | offsetof(struct processor *, processor_data.current_state)); | |
1c79356b | 616 | |
0c530ab8 A |
617 | DECLARE("OnProc", OnProc); |
618 | ||
b0d623f7 | 619 | |
2d21ac55 A |
620 | #if CONFIG_DTRACE |
621 | DECLARE("LS_LCK_MTX_LOCK_ACQUIRE", LS_LCK_MTX_LOCK_ACQUIRE); | |
622 | DECLARE("LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE", LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE); | |
623 | DECLARE("LS_LCK_MTX_UNLOCK_RELEASE", LS_LCK_MTX_UNLOCK_RELEASE); | |
624 | DECLARE("LS_LCK_MTX_TRY_LOCK_ACQUIRE", LS_LCK_MTX_TRY_LOCK_ACQUIRE); | |
625 | DECLARE("LS_LCK_RW_LOCK_SHARED_ACQUIRE", LS_LCK_RW_LOCK_SHARED_ACQUIRE); | |
626 | DECLARE("LS_LCK_RW_DONE_RELEASE", LS_LCK_RW_DONE_RELEASE); | |
627 | DECLARE("LS_LCK_MTX_EXT_LOCK_ACQUIRE", LS_LCK_MTX_EXT_LOCK_ACQUIRE); | |
628 | DECLARE("LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE", LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE); | |
629 | DECLARE("LS_LCK_MTX_EXT_UNLOCK_RELEASE", LS_LCK_MTX_EXT_UNLOCK_RELEASE); | |
b0d623f7 A |
630 | DECLARE("LS_LCK_RW_LOCK_EXCL_ACQUIRE", LS_LCK_RW_LOCK_EXCL_ACQUIRE); |
631 | DECLARE("LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE", LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE); | |
632 | DECLARE("LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE", LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE); | |
633 | DECLARE("LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE", LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE); | |
634 | DECLARE("LS_LCK_MTX_LOCK_SPIN_ACQUIRE", LS_LCK_MTX_LOCK_SPIN_ACQUIRE); | |
2d21ac55 A |
635 | #endif |
636 | ||
1c79356b A |
637 | return (0); |
638 | } |