1/* 2 * Copyright (c) 2000-2008 Apple 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 * @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> 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> 69#include <kern/locks.h> 70#include <kern/host.h> 71#include <kern/misc_protos.h> 72#include <ipc/ipc_space.h> 73#include <ipc/ipc_port.h> 74#include <ipc/ipc_pset.h> 75#include <vm/vm_map.h> 76#include <i386/cpu_data.h> 77#include <i386/thread.h> 78#include <i386/seg.h> 79#include <i386/pmap.h> 80#include <i386/tss.h> 81#include <i386/cpu_capabilities.h> 82#include <i386/cpuid.h> 83#include <i386/Diagnostics.h> 84#include <i386/pmCPU.h> 85#include <mach/i386/vm_param.h> 86#include <mach/i386/thread_status.h> 87#include <machine/commpage.h> 88#include <i386/mp_desc.h> 89#include <pexpert/i386/boot.h> 90 91#if CONFIG_DTRACE 92#define NEED_DTRACE_DEFS 93#include <../bsd/sys/lockstat.h> 94#endif 95 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 109#undef offsetof 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 120int main( 121 int argc, 122 char ** argv); 123 124int 125main( 126 int argc, 127 char **argv) 128{ 129 130 DECLARE("AST_URGENT", AST_URGENT); 131 DECLARE("AST_BSD", AST_BSD); 132 133 /* Simple Lock structure */ 134 DECLARE("SLOCK_ILK", offsetof(usimple_lock_t, interlock)); 135#if MACH_LDEBUG 136 DECLARE("SLOCK_TYPE", offsetof(usimple_lock_t, lock_type)); 137 DECLARE("SLOCK_PC", offsetof(usimple_lock_t, debug.lock_pc)); 138 DECLARE("SLOCK_THREAD", offsetof(usimple_lock_t, debug.lock_thread)); 139 DECLARE("SLOCK_DURATIONH",offsetof(usimple_lock_t, debug.duration[0])); 140 DECLARE("SLOCK_DURATIONL",offsetof(usimple_lock_t, debug.duration[1])); 141 DECLARE("USLOCK_TAG", USLOCK_TAG); 142#endif /* MACH_LDEBUG */ 143 144 /* Mutex structure */ 145 DECLARE("MUTEX_LOCKED", offsetof(mutex_t *, lck_mtx.lck_mtx_locked)); 146 DECLARE("MUTEX_WAITERS",offsetof(mutex_t *, lck_mtx.lck_mtx_waiters)); 147 DECLARE("MUTEX_PROMOTED_PRI",offsetof(mutex_t *, lck_mtx.lck_mtx_pri)); 148#if MACH_LDEBUG 149 DECLARE("MUTEX_TYPE", offsetof(mutex_t *, type)); 150 DECLARE("MUTEX_PC", offsetof(mutex_t *, pc)); 151 DECLARE("MUTEX_THREAD", offsetof(mutex_t *, thread)); 152 DECLARE("MUTEX_TAG", MUTEX_TAG); 153#endif /* MACH_LDEBUG */ 154 DECLARE("MUTEX_IND", LCK_MTX_TAG_INDIRECT); 155 DECLARE("MUTEX_DESTROYED", LCK_MTX_TAG_DESTROYED); 156 DECLARE("MUTEX_LOCKED_AS_SPIN", MUTEX_LOCKED_AS_SPIN); 157 DECLARE("MUTEX_ITAG", offsetof(lck_mtx_t *, lck_mtx_tag)); 158 DECLARE("MUTEX_PTR", offsetof(lck_mtx_t *, lck_mtx_ptr)); 159 DECLARE("MUTEX_ASSERT_OWNED", LCK_MTX_ASSERT_OWNED); 160 DECLARE("MUTEX_ASSERT_NOTOWNED",LCK_MTX_ASSERT_NOTOWNED); 161 /* Per-mutex statistic element */ 162 DECLARE("MTX_ACQ_TSC", offsetof(lck_mtx_ext_t *, lck_mtx_stat)); 163 164 /* Mutex group statistics elements */ 165 DECLARE("MUTEX_GRP", offsetof(lck_mtx_ext_t *, lck_mtx_grp)); 166 167 DECLARE("GRP_MTX_STAT_UTIL", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt)); 168 DECLARE("GRP_MTX_STAT_MISS", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt)); 169 DECLARE("GRP_MTX_STAT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt)); 170 /* 171 * The use of this field is somewhat at variance with the alias. 172 */ 173 DECLARE("GRP_MTX_STAT_DIRECT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_cnt)); 174 175 DECLARE("GRP_MTX_STAT_HELD_MAX", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_max)); 176 /* Reader writer lock types */ 177 DECLARE("RW_SHARED", LCK_RW_TYPE_SHARED); 178 DECLARE("RW_EXCL", LCK_RW_TYPE_EXCLUSIVE); 179 180 DECLARE("TH_RECOVER", offsetof(thread_t, recover)); 181 DECLARE("TH_CONTINUATION", offsetof(thread_t, continuation)); 182 DECLARE("TH_KERNEL_STACK", offsetof(thread_t, kernel_stack)); 183 184 DECLARE("TASK_MACH_EXC_PORT", 185 offsetof(task_t, exc_actions[EXC_MACH_SYSCALL].port)); 186 DECLARE("TASK_SYSCALLS_MACH", offsetof(struct task *, syscalls_mach)); 187 DECLARE("TASK_SYSCALLS_UNIX", offsetof(struct task *, syscalls_unix)); 188 189 DECLARE("TASK_VTIMERS", offsetof(struct task *, vtimers)); 190 191 /* These fields are being added on demand */ 192 DECLARE("ACT_MACH_EXC_PORT", 193 offsetof(thread_t, exc_actions[EXC_MACH_SYSCALL].port)); 194 195 DECLARE("ACT_TASK", offsetof(thread_t, task)); 196 DECLARE("ACT_AST", offsetof(thread_t, ast)); 197 DECLARE("ACT_PCB", offsetof(thread_t, machine.pcb)); 198 DECLARE("ACT_SPF", offsetof(thread_t, machine.specFlags)); 199 DECLARE("ACT_MAP", offsetof(thread_t, map)); 200 DECLARE("ACT_COPYIO_STATE", offsetof(thread_t, machine.copyio_state)); 201 DECLARE("ACT_PCB_ISS", offsetof(thread_t, machine.xxx_pcb.iss)); 202 DECLARE("ACT_PCB_IDS", offsetof(thread_t, machine.xxx_pcb.ids)); 203 204 DECLARE("WINDOWS_CLEAN", WINDOWS_CLEAN); 205 206 DECLARE("MAP_PMAP", offsetof(vm_map_t, pmap)); 207 208#define IKS ((size_t) (STACK_IKS(0))) 209 210 DECLARE("KSS_EBX", IKS + offsetof(struct x86_kernel_state32 *, k_ebx)); 211 DECLARE("KSS_ESP", IKS + offsetof(struct x86_kernel_state32 *, k_esp)); 212 DECLARE("KSS_EBP", IKS + offsetof(struct x86_kernel_state32 *, k_ebp)); 213 DECLARE("KSS_EDI", IKS + offsetof(struct x86_kernel_state32 *, k_edi)); 214 DECLARE("KSS_ESI", IKS + offsetof(struct x86_kernel_state32 *, k_esi)); 215 DECLARE("KSS_EIP", IKS + offsetof(struct x86_kernel_state32 *, k_eip)); 216 217 DECLARE("IKS_SIZE", sizeof(struct x86_kernel_state32)); 218 DECLARE("IEL_SIZE", sizeof(struct i386_exception_link)); 219 220 DECLARE("PCB_FPS", offsetof(pcb_t, ifps)); 221 DECLARE("PCB_ISS", offsetof(pcb_t, iss)); 222 223 DECLARE("DS_DR0", offsetof(struct x86_debug_state32 *, dr0)); 224 DECLARE("DS_DR1", offsetof(struct x86_debug_state32 *, dr1)); 225 DECLARE("DS_DR2", offsetof(struct x86_debug_state32 *, dr2)); 226 DECLARE("DS_DR3", offsetof(struct x86_debug_state32 *, dr3)); 227 DECLARE("DS_DR4", offsetof(struct x86_debug_state32 *, dr4)); 228 DECLARE("DS_DR5", offsetof(struct x86_debug_state32 *, dr5)); 229 DECLARE("DS_DR6", offsetof(struct x86_debug_state32 *, dr6)); 230 DECLARE("DS_DR7", offsetof(struct x86_debug_state32 *, dr7)); 231 232 DECLARE("DS64_DR0", offsetof(struct x86_debug_state64 *, dr0)); 233 DECLARE("DS64_DR1", offsetof(struct x86_debug_state64 *, dr1)); 234 DECLARE("DS64_DR2", offsetof(struct x86_debug_state64 *, dr2)); 235 DECLARE("DS64_DR3", offsetof(struct x86_debug_state64 *, dr3)); 236 DECLARE("DS64_DR4", offsetof(struct x86_debug_state64 *, dr4)); 237 DECLARE("DS64_DR5", offsetof(struct x86_debug_state64 *, dr5)); 238 DECLARE("DS64_DR6", offsetof(struct x86_debug_state64 *, dr6)); 239 DECLARE("DS64_DR7", offsetof(struct x86_debug_state64 *, dr7)); 240 241 DECLARE("FP_VALID", offsetof(struct x86_fpsave_state *,fp_valid)); 242 243 DECLARE("SS_FLAVOR", offsetof(x86_saved_state_t *, flavor)); 244 DECLARE("SS_32", x86_SAVED_STATE32); 245 DECLARE("SS_64", x86_SAVED_STATE64); 246 247#define R_(x) offsetof(x86_saved_state_t *, ss_32.x) 248 DECLARE("R_CS", R_(cs)); 249 DECLARE("R_SS", R_(ss)); 250 DECLARE("R_DS", R_(ds)); 251 DECLARE("R_ES", R_(es)); 252 DECLARE("R_FS", R_(fs)); 253 DECLARE("R_GS", R_(gs)); 254 DECLARE("R_UESP", R_(uesp)); 255 DECLARE("R_EBP", R_(ebp)); 256 DECLARE("R_EAX", R_(eax)); 257 DECLARE("R_EBX", R_(ebx)); 258 DECLARE("R_ECX", R_(ecx)); 259 DECLARE("R_EDX", R_(edx)); 260 DECLARE("R_ESI", R_(esi)); 261 DECLARE("R_EDI", R_(edi)); 262 DECLARE("R_TRAPNO", R_(trapno)); 263 DECLARE("R_ERR", R_(err)); 264 DECLARE("R_EFLAGS", R_(efl)); 265 DECLARE("R_EIP", R_(eip)); 266 DECLARE("R_CR2", R_(cr2)); 267 DECLARE("ISS32_SIZE", sizeof (x86_saved_state32_t)); 268 269#define R64_(x) offsetof(x86_saved_state_t *, ss_64.x) 270 DECLARE("R64_FS", R64_(fs)); 271 DECLARE("R64_GS", R64_(gs)); 272 DECLARE("R64_R8", R64_(r8)); 273 DECLARE("R64_R9", R64_(r9)); 274 DECLARE("R64_R10", R64_(r10)); 275 DECLARE("R64_R11", R64_(r11)); 276 DECLARE("R64_R12", R64_(r12)); 277 DECLARE("R64_R13", R64_(r13)); 278 DECLARE("R64_R14", R64_(r14)); 279 DECLARE("R64_R15", R64_(r15)); 280 DECLARE("R64_RBP", R64_(rbp)); 281 DECLARE("R64_RAX", R64_(rax)); 282 DECLARE("R64_RBX", R64_(rbx)); 283 DECLARE("R64_RCX", R64_(rcx)); 284 DECLARE("R64_RDX", R64_(rdx)); 285 DECLARE("R64_RSI", R64_(rsi)); 286 DECLARE("R64_RDI", R64_(rdi)); 287 DECLARE("R64_V_ARG6", R64_(v_arg6)); 288 DECLARE("R64_V_ARG7", R64_(v_arg7)); 289 DECLARE("R64_V_ARG8", R64_(v_arg8)); 290 DECLARE("R64_CS", R64_(isf.cs)); 291 DECLARE("R64_SS", R64_(isf.ss)); 292 DECLARE("R64_RSP", R64_(isf.rsp)); 293 DECLARE("R64_TRAPNO", R64_(isf.trapno)); 294 DECLARE("R64_TRAPFN", R64_(isf.trapfn)); 295 DECLARE("R64_ERR", R64_(isf.err)); 296 DECLARE("R64_RFLAGS", R64_(isf.rflags)); 297 DECLARE("R64_RIP", R64_(isf.rip)); 298 DECLARE("R64_CR2", R64_(cr2)); 299 DECLARE("ISS64_OFFSET", R64_(isf)); 300 DECLARE("ISS64_SIZE", sizeof (x86_saved_state64_t)); 301 302#define ISF64_(x) offsetof(x86_64_intr_stack_frame_t *, x) 303 DECLARE("ISF64_TRAPNO", ISF64_(trapno)); 304 DECLARE("ISF64_TRAPFN", ISF64_(trapfn)); 305 DECLARE("ISF64_ERR", ISF64_(err)); 306 DECLARE("ISF64_RIP", ISF64_(rip)); 307 DECLARE("ISF64_CS", ISF64_(cs)); 308 DECLARE("ISF64_RFLAGS", ISF64_(rflags)); 309 DECLARE("ISF64_RSP", ISF64_(rsp)); 310 DECLARE("ISF64_SS", ISF64_(ss)); 311 DECLARE("ISF64_SIZE", sizeof(x86_64_intr_stack_frame_t)); 312 313 DECLARE("ISC32_OFFSET", offsetof(x86_saved_state_compat32_t *, isf64)); 314#define ISC32_(x) offsetof(x86_saved_state_compat32_t *, isf64.x) 315 DECLARE("ISC32_TRAPNO", ISC32_(trapno)); 316 DECLARE("ISC32_TRAPFN", ISC32_(trapfn)); 317 DECLARE("ISC32_ERR", ISC32_(err)); 318 DECLARE("ISC32_RIP", ISC32_(rip)); 319 DECLARE("ISC32_CS", ISC32_(cs)); 320 DECLARE("ISC32_RFLAGS", ISC32_(rflags)); 321 DECLARE("ISC32_RSP", ISC32_(rsp)); 322 DECLARE("ISC32_SS", ISC32_(ss)); 323 324 DECLARE("NBPG", I386_PGBYTES); 325 DECLARE("PAGE_SIZE", I386_PGBYTES); 326 DECLARE("PAGE_MASK", I386_PGBYTES-1); 327 DECLARE("PAGE_SHIFT", 12); 328 DECLARE("NKPT", NKPT); 329 DECLARE("KPTDI", KPTDI); 330 DECLARE("VM_MIN_ADDRESS", VM_MIN_ADDRESS); 331 DECLARE("VM_MAX_ADDRESS", VM_MAX_ADDRESS); 332 DECLARE("KERNELBASE", VM_MIN_KERNEL_ADDRESS); 333 DECLARE("LINEAR_KERNELBASE", LINEAR_KERNEL_ADDRESS); 334 DECLARE("KERNEL_STACK_SIZE", KERNEL_STACK_SIZE); 335 DECLARE("KERNEL_UBER_BASE_HI32", KERNEL_UBER_BASE_HI32); 336 337 DECLARE("COMM_PAGE_BASE_ADDR", _COMM_PAGE_BASE_ADDRESS); 338 339 DECLARE("PDESHIFT", PDESHIFT); 340 DECLARE("PTEMASK", PTEMASK); 341 DECLARE("PTEINDX", PTEINDX); 342 DECLARE("PTE_PFN", INTEL_PTE_PFN); 343 DECLARE("PTE_V", INTEL_PTE_VALID); 344 DECLARE("PTE_W", INTEL_PTE_WRITE); 345 DECLARE("PTE_PS", INTEL_PTE_PS); 346 DECLARE("PTE_U", INTEL_PTE_USER); 347 DECLARE("PTE_INVALID", ~INTEL_PTE_VALID); 348 DECLARE("NPGPTD", NPGPTD); 349 350 DECLARE("IDTSZ", IDTSZ); 351 DECLARE("GDTSZ", GDTSZ); 352 DECLARE("LDTSZ", LDTSZ); 353 354 DECLARE("KERNEL_CS", KERNEL_CS); 355 DECLARE("KERNEL_DS", KERNEL_DS); 356 DECLARE("USER_CS", USER_CS); 357 DECLARE("USER_DS", USER_DS); 358 DECLARE("KERNEL64_CS", KERNEL64_CS); 359 DECLARE("USER64_CS", USER64_CS); 360 DECLARE("KERNEL_TSS", KERNEL_TSS); 361 DECLARE("KERNEL_LDT", KERNEL_LDT); 362 DECLARE("DF_TSS", DF_TSS); 363 DECLARE("MC_TSS", MC_TSS); 364#if MACH_KDB 365 DECLARE("DEBUG_TSS", DEBUG_TSS); 366#endif /* MACH_KDB */ 367 DECLARE("CPU_DATA_GS", CPU_DATA_GS); 368 DECLARE("SYSENTER_CS", SYSENTER_CS); 369 DECLARE("SYSENTER_TF_CS",SYSENTER_TF_CS); 370 DECLARE("SYSENTER_DS", SYSENTER_DS); 371 DECLARE("SYSCALL_CS", SYSCALL_CS); 372 DECLARE("USER_WINDOW_SEL", USER_WINDOW_SEL); 373 DECLARE("PHYS_WINDOW_SEL", PHYS_WINDOW_SEL); 374 375 DECLARE("CPU_THIS", 376 offsetof(cpu_data_t *, cpu_this)); 377 DECLARE("CPU_ACTIVE_THREAD", 378 offsetof(cpu_data_t *, cpu_active_thread)); 379 DECLARE("CPU_ACTIVE_STACK", 380 offsetof(cpu_data_t *, cpu_active_stack)); 381 DECLARE("CPU_KERNEL_STACK", 382 offsetof(cpu_data_t *, cpu_kernel_stack)); 383 DECLARE("CPU_INT_STACK_TOP", 384 offsetof(cpu_data_t *, cpu_int_stack_top)); 385#if MACH_RT 386 DECLARE("CPU_PREEMPTION_LEVEL", 387 offsetof(cpu_data_t *, cpu_preemption_level)); 388#endif /* MACH_RT */ 389 DECLARE("CPU_INTERRUPT_LEVEL", 390 offsetof(cpu_data_t *, cpu_interrupt_level)); 391 DECLARE("CPU_SIMPLE_LOCK_COUNT", 392 offsetof(cpu_data_t *,cpu_simple_lock_count)); 393 DECLARE("CPU_NUMBER_GS", 394 offsetof(cpu_data_t *,cpu_number)); 395 DECLARE("CPU_RUNNING", 396 offsetof(cpu_data_t *,cpu_running)); 397 DECLARE("CPU_MCOUNT_OFF", 398 offsetof(cpu_data_t *,cpu_mcount_off)); 399 DECLARE("CPU_PENDING_AST", 400 offsetof(cpu_data_t *,cpu_pending_ast)); 401 DECLARE("CPU_DESC_TABLEP", 402 offsetof(cpu_data_t *,cpu_desc_tablep)); 403 DECLARE("CPU_DESC_INDEX", 404 offsetof(cpu_data_t *,cpu_desc_index)); 405 DECLARE("CDI_GDT", 406 offsetof(cpu_desc_index_t *,cdi_gdt)); 407 DECLARE("CDI_IDT", 408 offsetof(cpu_desc_index_t *,cdi_idt)); 409 DECLARE("CPU_PROCESSOR", 410 offsetof(cpu_data_t *,cpu_processor)); 411 DECLARE("CPU_INT_STATE", 412 offsetof(cpu_data_t *, cpu_int_state)); 413 DECLARE("CPU_INT_EVENT_TIME", 414 offsetof(cpu_data_t *, cpu_int_event_time)); 415 416 DECLARE("CPU_HI_ISS", 417 offsetof(cpu_data_t *, cpu_hi_iss)); 418 DECLARE("CPU_TASK_CR3", 419 offsetof(cpu_data_t *, cpu_task_cr3)); 420 DECLARE("CPU_ACTIVE_CR3", 421 offsetof(cpu_data_t *, cpu_active_cr3)); 422 DECLARE("CPU_KERNEL_CR3", 423 offsetof(cpu_data_t *, cpu_kernel_cr3)); 424 425 DECLARE("CPU_IS64BIT", 426 offsetof(cpu_data_t *, cpu_is64bit)); 427 DECLARE("CPU_TASK_MAP", 428 offsetof(cpu_data_t *, cpu_task_map)); 429 DECLARE("TASK_MAP_32BIT", TASK_MAP_32BIT); 430 DECLARE("TASK_MAP_64BIT", TASK_MAP_64BIT); 431 DECLARE("TASK_MAP_64BIT_SHARED", TASK_MAP_64BIT_SHARED); 432 DECLARE("CPU_UBER_USER_GS_BASE", 433 offsetof(cpu_data_t *, cpu_uber.cu_user_gs_base)); 434 DECLARE("CPU_UBER_ISF", 435 offsetof(cpu_data_t *, cpu_uber.cu_isf)); 436 DECLARE("CPU_UBER_TMP", 437 offsetof(cpu_data_t *, cpu_uber.cu_tmp)); 438 DECLARE("CPU_UBER_ARG_STORE", 439 offsetof(cpu_data_t *, cpu_uber_arg_store)); 440 DECLARE("CPU_UBER_ARG_STORE_VALID", 441 offsetof(cpu_data_t *, cpu_uber_arg_store_valid)); 442 443 DECLARE("CPU_NANOTIME", 444 offsetof(cpu_data_t *, cpu_nanotime)); 445 446 DECLARE("CPU_DR7", 447 offsetof(cpu_data_t *, cpu_dr7)); 448 449 DECLARE("hwIntCnt", offsetof(cpu_data_t *,cpu_hwIntCnt)); 450 451 DECLARE("enaExpTrace", enaExpTrace); 452 DECLARE("enaExpTraceb", enaExpTraceb); 453 DECLARE("enaUsrFCall", enaUsrFCall); 454 DECLARE("enaUsrFCallb", enaUsrFCallb); 455 DECLARE("enaUsrPhyMp", enaUsrPhyMp); 456 DECLARE("enaUsrPhyMpb", enaUsrPhyMpb); 457 DECLARE("enaDiagSCs", enaDiagSCs); 458 DECLARE("enaDiagSCsb", enaDiagSCsb); 459 DECLARE("enaDiagEM", enaDiagEM); 460 DECLARE("enaDiagEMb", enaDiagEMb); 461 DECLARE("enaNotifyEM", enaNotifyEM); 462 DECLARE("enaNotifyEMb", enaNotifyEMb); 463 DECLARE("dgLock", offsetof(struct diagWork *, dgLock)); 464 DECLARE("dgFlags", offsetof(struct diagWork *, dgFlags)); 465 DECLARE("dgMisc1", offsetof(struct diagWork *, dgMisc1)); 466 DECLARE("dgMisc2", offsetof(struct diagWork *, dgMisc2)); 467 DECLARE("dgMisc3", offsetof(struct diagWork *, dgMisc3)); 468 DECLARE("dgMisc4", offsetof(struct diagWork *, dgMisc4)); 469 DECLARE("dgMisc5", offsetof(struct diagWork *, dgMisc5)); 470 471 DECLARE("INTEL_PTE_KERNEL", INTEL_PTE_VALID|INTEL_PTE_WRITE); 472 DECLARE("PTDPTDI", PTDPTDI); 473 DECLARE("PDESHIFT", PDESHIFT); 474 DECLARE("PDESIZE", PDESIZE); 475 DECLARE("PTESIZE", PTESIZE); 476 DECLARE("APTDPTDI", APTDPTDI); 477 DECLARE("HIGH_MEM_BASE", HIGH_MEM_BASE); 478 DECLARE("HIGH_IDT_BASE", pmap_index_to_virt(HIGH_FIXED_IDT)); 479 480 DECLARE("KERNELBASEPDE", 481 (LINEAR_KERNEL_ADDRESS >> PDESHIFT) * 482 sizeof(pt_entry_t)); 483 484 DECLARE("TSS_ESP0", offsetof(struct i386_tss *, esp0)); 485 DECLARE("TSS_SS0", offsetof(struct i386_tss *, ss0)); 486 DECLARE("TSS_LDT", offsetof(struct i386_tss *, ldt)); 487 DECLARE("TSS_PDBR", offsetof(struct i386_tss *, cr3)); 488 DECLARE("TSS_LINK", offsetof(struct i386_tss *, back_link)); 489 490 DECLARE("K_TASK_GATE", ACC_P|ACC_PL_K|ACC_TASK_GATE); 491 DECLARE("K_TRAP_GATE", ACC_P|ACC_PL_K|ACC_TRAP_GATE); 492 DECLARE("U_TRAP_GATE", ACC_P|ACC_PL_U|ACC_TRAP_GATE); 493 DECLARE("K_INTR_GATE", ACC_P|ACC_PL_K|ACC_INTR_GATE); 494 DECLARE("U_INTR_GATE", ACC_P|ACC_PL_U|ACC_INTR_GATE); 495 DECLARE("K_TSS", ACC_P|ACC_PL_K|ACC_TSS); 496 497 /* 498 * usimple_lock fields 499 */ 500 DECLARE("USL_INTERLOCK", offsetof(usimple_lock_t, interlock)); 501 502 DECLARE("INTSTACK_SIZE", INTSTACK_SIZE); 503 DECLARE("TIMER_LOW", offsetof(struct timer *, low_bits)); 504 DECLARE("TIMER_HIGH", offsetof(struct timer *, high_bits)); 505 DECLARE("TIMER_HIGHCHK", offsetof(struct timer *, high_bits_check)); 506 DECLARE("KADDR", offsetof(struct boot_args *, kaddr)); 507 DECLARE("KSIZE", offsetof(struct boot_args *, ksize)); 508 DECLARE("MEMORYMAP", offsetof(struct boot_args *, MemoryMap)); 509 DECLARE("DEVICETREEP", offsetof(struct boot_args *, deviceTreeP)); 510 511 DECLARE("RNT_TSC_BASE", 512 offsetof(rtc_nanotime_t *, tsc_base)); 513 DECLARE("RNT_NS_BASE", 514 offsetof(rtc_nanotime_t *, ns_base)); 515 DECLARE("RNT_SCALE", 516 offsetof(rtc_nanotime_t *, scale)); 517 DECLARE("RNT_SHIFT", 518 offsetof(rtc_nanotime_t *, shift)); 519 DECLARE("RNT_GENERATION", 520 offsetof(rtc_nanotime_t *, generation)); 521 522 /* values from kern/timer.h */ 523 DECLARE("TIMER_LOW", 524 offsetof(struct timer *, low_bits)); 525 DECLARE("TIMER_HIGH", 526 offsetof(struct timer *, high_bits)); 527 DECLARE("TIMER_HIGHCHK", 528 offsetof(struct timer *, high_bits_check)); 529#if !STAT_TIME 530 DECLARE("TIMER_TSTAMP", 531 offsetof(struct timer *, tstamp)); 532 533 DECLARE("THREAD_TIMER", 534 offsetof(struct processor *, processor_data.thread_timer)); 535#endif 536 DECLARE("KERNEL_TIMER", 537 offsetof(struct processor *, processor_data.kernel_timer)); 538 DECLARE("SYSTEM_TIMER", 539 offsetof(struct thread *, system_timer)); 540 DECLARE("USER_TIMER", 541 offsetof(struct thread *, user_timer)); 542 DECLARE("SYSTEM_STATE", 543 offsetof(struct processor *, processor_data.system_state)); 544 DECLARE("USER_STATE", 545 offsetof(struct processor *, processor_data.user_state)); 546 DECLARE("IDLE_STATE", 547 offsetof(struct processor *, processor_data.idle_state)); 548 DECLARE("CURRENT_STATE", 549 offsetof(struct processor *, processor_data.current_state)); 550 551 DECLARE("OnProc", OnProc); 552 553#if CONFIG_DTRACE 554 DECLARE("LS_LCK_MTX_LOCK_ACQUIRE", LS_LCK_MTX_LOCK_ACQUIRE); 555 DECLARE("LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE", LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE); 556 DECLARE("LS_LCK_MTX_UNLOCK_RELEASE", LS_LCK_MTX_UNLOCK_RELEASE); 557 DECLARE("LS_LCK_MTX_TRY_LOCK_ACQUIRE", LS_LCK_MTX_TRY_LOCK_ACQUIRE); 558 DECLARE("LS_LCK_RW_LOCK_SHARED_ACQUIRE", LS_LCK_RW_LOCK_SHARED_ACQUIRE); 559 DECLARE("LS_LCK_RW_DONE_RELEASE", LS_LCK_RW_DONE_RELEASE); 560 DECLARE("LS_LCK_MTX_EXT_LOCK_ACQUIRE", LS_LCK_MTX_EXT_LOCK_ACQUIRE); 561 DECLARE("LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE", LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE); 562 DECLARE("LS_LCK_MTX_EXT_UNLOCK_RELEASE", LS_LCK_MTX_EXT_UNLOCK_RELEASE); 563 564 DECLARE("LS_MUTEX_LOCK_ACQUIRE", LS_MUTEX_LOCK_ACQUIRE); 565 DECLARE("LS_MUTEX_TRY_SPIN_ACQUIRE", LS_MUTEX_TRY_SPIN_ACQUIRE); 566 DECLARE("LS_MUTEX_TRY_LOCK_ACQUIRE", LS_MUTEX_TRY_LOCK_ACQUIRE); 567 DECLARE("LS_MUTEX_UNLOCK_RELEASE", LS_MUTEX_UNLOCK_RELEASE); 568 DECLARE("LS_MUTEX_LOCK_SPIN_ACQUIRE", LS_MUTEX_LOCK_SPIN_ACQUIRE); 569 DECLARE("LS_MUTEX_CONVERT_SPIN_ACQUIRE", LS_MUTEX_CONVERT_SPIN_ACQUIRE); 570#endif 571 572 return (0); 573} 574