1/* 2 * Copyright (c) 2000-2012 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_ldebug.h> 59 60/* 61 * Pass field offsets to assembly code. 62 */ 63#include <kern/ast.h> 64#include <kern/thread.h> 65#include <kern/task.h> 66#include <kern/lock.h> 67#include <kern/locks.h> 68#include <kern/host.h> 69#include <kern/misc_protos.h> 70#include <ipc/ipc_space.h> 71#include <ipc/ipc_port.h> 72#include <ipc/ipc_pset.h> 73#include <vm/vm_map.h> 74#include <i386/pmap.h> 75#include <i386/Diagnostics.h> 76#include <i386/mp_desc.h> 77#include <i386/seg.h> 78#include <i386/thread.h> 79#include <i386/cpu_data.h> 80#include <i386/tss.h> 81#include <i386/cpu_capabilities.h> 82#include <i386/cpuid.h> 83#include <i386/pmCPU.h> 84#include <mach/i386/vm_param.h> 85#include <mach/i386/thread_status.h> 86#include <machine/commpage.h> 87#include <pexpert/i386/boot.h> 88 89#if CONFIG_DTRACE 90#define NEED_DTRACE_DEFS 91#include <../bsd/sys/lockstat.h> 92#endif 93 94/* 95 * genassym.c is used to produce an 96 * assembly file which, intermingled with unuseful assembly code, 97 * has all the necessary definitions emitted. This assembly file is 98 * then postprocessed with sed to extract only these definitions 99 * and thus the final assyms.s is created. 100 * 101 * This convoluted means is necessary since the structure alignment 102 * and packing may be different between the host machine and the 103 * target so we are forced into using the cross compiler to generate 104 * the values, but we cannot run anything on the target machine. 105 */ 106 107#undef offsetof 108#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE)0)->MEMBER) 109 110#if 0 111#define DECLARE(SYM,VAL) \ 112 __asm("#DEFINITION#\t.set\t" SYM ",\t%0" : : "n" ((u_int)(VAL))) 113#else 114#define DECLARE(SYM,VAL) \ 115 __asm("#DEFINITION##define " SYM "\t%0" : : "n" ((u_int)(VAL))) 116#endif 117 118int main( 119 int argc, 120 char ** argv); 121 122int 123main( 124 int argc, 125 char **argv) 126{ 127 128 DECLARE("AST_URGENT", AST_URGENT); 129 DECLARE("AST_BSD", AST_BSD); 130 131 DECLARE("MAX_CPUS", MAX_CPUS); 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_OWNER", offsetof(lck_mtx_t *, lck_mtx_owner)); 146 DECLARE("MUTEX_PTR", offsetof(lck_mtx_t *, lck_mtx_ptr)); 147 DECLARE("MUTEX_STATE", offsetof(lck_mtx_t *, lck_mtx_state)); 148 DECLARE("MUTEX_IND", LCK_MTX_TAG_INDIRECT); 149 DECLARE("MUTEX_PTR", offsetof(lck_mtx_t *, lck_mtx_ptr)); 150 DECLARE("MUTEX_ASSERT_OWNED", LCK_MTX_ASSERT_OWNED); 151 DECLARE("MUTEX_ASSERT_NOTOWNED",LCK_MTX_ASSERT_NOTOWNED); 152 DECLARE("GRP_MTX_STAT_UTIL", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_util_cnt)); 153 DECLARE("GRP_MTX_STAT_MISS", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_miss_cnt)); 154 DECLARE("GRP_MTX_STAT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_wait_cnt)); 155 156 /* x86 only */ 157 DECLARE("MUTEX_DESTROYED", LCK_MTX_TAG_DESTROYED); 158 159 /* Per-mutex statistic element */ 160 DECLARE("MTX_ACQ_TSC", offsetof(lck_mtx_ext_t *, lck_mtx_stat)); 161 162 /* Mutex group statistics elements */ 163 DECLARE("MUTEX_GRP", offsetof(lck_mtx_ext_t *, lck_mtx_grp)); 164 165 /* 166 * The use of this field is somewhat at variance with the alias. 167 */ 168 DECLARE("GRP_MTX_STAT_DIRECT_WAIT", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_cnt)); 169 170 DECLARE("GRP_MTX_STAT_HELD_MAX", offsetof(lck_grp_t *, lck_grp_stat.lck_grp_mtx_stat.lck_grp_mtx_held_max)); 171 /* Reader writer lock types */ 172 DECLARE("RW_SHARED", LCK_RW_TYPE_SHARED); 173 DECLARE("RW_EXCL", LCK_RW_TYPE_EXCLUSIVE); 174 175 DECLARE("TH_RECOVER", offsetof(thread_t, recover)); 176 DECLARE("TH_CONTINUATION", offsetof(thread_t, continuation)); 177 DECLARE("TH_KERNEL_STACK", offsetof(thread_t, kernel_stack)); 178 DECLARE("TH_MUTEX_COUNT", offsetof(thread_t, mutex_count)); 179 DECLARE("TH_WAS_PROMOTED_ON_WAKEUP", offsetof(thread_t, was_promoted_on_wakeup)); 180 DECLARE("TH_IOTIER_OVERRIDE", offsetof(thread_t, iotier_override)); 181 182 DECLARE("TH_SYSCALLS_MACH", offsetof(thread_t, syscalls_mach)); 183 DECLARE("TH_SYSCALLS_UNIX", offsetof(thread_t, syscalls_unix)); 184 185 DECLARE("TASK_VTIMERS", offsetof(struct task *, vtimers)); 186 187 /* These fields are being added on demand */ 188 DECLARE("TH_TASK", offsetof(thread_t, task)); 189 DECLARE("TH_AST", offsetof(thread_t, ast)); 190 DECLARE("TH_MAP", offsetof(thread_t, map)); 191 DECLARE("TH_SPF", offsetof(thread_t, machine.specFlags)); 192 DECLARE("TH_PCB_ISS", offsetof(thread_t, machine.iss)); 193 DECLARE("TH_PCB_IDS", offsetof(thread_t, machine.ids)); 194 DECLARE("TH_PCB_FPS", offsetof(thread_t, machine.ifps)); 195#if NCOPY_WINDOWS > 0 196 DECLARE("TH_COPYIO_STATE", offsetof(thread_t, machine.copyio_state)); 197 DECLARE("WINDOWS_CLEAN", WINDOWS_CLEAN); 198#endif 199 DECLARE("TH_RWLOCK_COUNT", offsetof(thread_t, rwlock_count)); 200 201 DECLARE("MAP_PMAP", offsetof(vm_map_t, pmap)); 202 203#define IEL_SIZE (sizeof(struct i386_exception_link *)) 204 DECLARE("IKS_SIZE", sizeof(struct x86_kernel_state)); 205 206 /* 207 * KSS_* are offsets from the top of the kernel stack (cpu_kernel_stack) 208 */ 209 DECLARE("KSS_RBX", offsetof(struct x86_kernel_state *, k_rbx)); 210 DECLARE("KSS_RSP", offsetof(struct x86_kernel_state *, k_rsp)); 211 DECLARE("KSS_RBP", offsetof(struct x86_kernel_state *, k_rbp)); 212 DECLARE("KSS_R12", offsetof(struct x86_kernel_state *, k_r12)); 213 DECLARE("KSS_R13", offsetof(struct x86_kernel_state *, k_r13)); 214 DECLARE("KSS_R14", offsetof(struct x86_kernel_state *, k_r14)); 215 DECLARE("KSS_R15", offsetof(struct x86_kernel_state *, k_r15)); 216 DECLARE("KSS_RIP", offsetof(struct x86_kernel_state *, k_rip)); 217 218 DECLARE("DS_DR0", offsetof(struct x86_debug_state32 *, dr0)); 219 DECLARE("DS_DR1", offsetof(struct x86_debug_state32 *, dr1)); 220 DECLARE("DS_DR2", offsetof(struct x86_debug_state32 *, dr2)); 221 DECLARE("DS_DR3", offsetof(struct x86_debug_state32 *, dr3)); 222 DECLARE("DS_DR4", offsetof(struct x86_debug_state32 *, dr4)); 223 DECLARE("DS_DR5", offsetof(struct x86_debug_state32 *, dr5)); 224 DECLARE("DS_DR6", offsetof(struct x86_debug_state32 *, dr6)); 225 DECLARE("DS_DR7", offsetof(struct x86_debug_state32 *, dr7)); 226 227 DECLARE("DS64_DR0", offsetof(struct x86_debug_state64 *, dr0)); 228 DECLARE("DS64_DR1", offsetof(struct x86_debug_state64 *, dr1)); 229 DECLARE("DS64_DR2", offsetof(struct x86_debug_state64 *, dr2)); 230 DECLARE("DS64_DR3", offsetof(struct x86_debug_state64 *, dr3)); 231 DECLARE("DS64_DR4", offsetof(struct x86_debug_state64 *, dr4)); 232 DECLARE("DS64_DR5", offsetof(struct x86_debug_state64 *, dr5)); 233 DECLARE("DS64_DR6", offsetof(struct x86_debug_state64 *, dr6)); 234 DECLARE("DS64_DR7", offsetof(struct x86_debug_state64 *, dr7)); 235 236 DECLARE("FP_VALID", offsetof(struct x86_fx_thread_state *,fp_valid)); 237 238 DECLARE("SS_FLAVOR", offsetof(x86_saved_state_t *, flavor)); 239 DECLARE("SS_32", x86_SAVED_STATE32); 240 DECLARE("SS_64", x86_SAVED_STATE64); 241 242#define R_(x) offsetof(x86_saved_state_t *, ss_32.x) 243 DECLARE("R32_CS", R_(cs)); 244 DECLARE("R32_SS", R_(ss)); 245 DECLARE("R32_DS", R_(ds)); 246 DECLARE("R32_ES", R_(es)); 247 DECLARE("R32_FS", R_(fs)); 248 DECLARE("R32_GS", R_(gs)); 249 DECLARE("R32_UESP", R_(uesp)); 250 DECLARE("R32_EBP", R_(ebp)); 251 DECLARE("R32_EAX", R_(eax)); 252 DECLARE("R32_EBX", R_(ebx)); 253 DECLARE("R32_ECX", R_(ecx)); 254 DECLARE("R32_EDX", R_(edx)); 255 DECLARE("R32_ESI", R_(esi)); 256 DECLARE("R32_EDI", R_(edi)); 257 DECLARE("R32_TRAPNO", R_(trapno)); 258 DECLARE("R32_ERR", R_(err)); 259 DECLARE("R32_EFLAGS", R_(efl)); 260 DECLARE("R32_EIP", R_(eip)); 261 DECLARE("R32_CR2", R_(cr2)); 262 DECLARE("ISS32_SIZE", sizeof (x86_saved_state32_t)); 263 264#define R64_(x) offsetof(x86_saved_state_t *, ss_64.x) 265 DECLARE("R64_FS", R64_(fs)); 266 DECLARE("R64_GS", R64_(gs)); 267 DECLARE("R64_R8", R64_(r8)); 268 DECLARE("R64_R9", R64_(r9)); 269 DECLARE("R64_R10", R64_(r10)); 270 DECLARE("R64_R11", R64_(r11)); 271 DECLARE("R64_R12", R64_(r12)); 272 DECLARE("R64_R13", R64_(r13)); 273 DECLARE("R64_R14", R64_(r14)); 274 DECLARE("R64_R15", R64_(r15)); 275 DECLARE("R64_RBP", R64_(rbp)); 276 DECLARE("R64_RAX", R64_(rax)); 277 DECLARE("R64_RBX", R64_(rbx)); 278 DECLARE("R64_RCX", R64_(rcx)); 279 DECLARE("R64_RDX", R64_(rdx)); 280 DECLARE("R64_RSI", R64_(rsi)); 281 DECLARE("R64_RDI", R64_(rdi)); 282 DECLARE("R64_V_ARG6", R64_(v_arg6)); 283 DECLARE("R64_V_ARG7", R64_(v_arg7)); 284 DECLARE("R64_V_ARG8", R64_(v_arg8)); 285 DECLARE("R64_CS", R64_(isf.cs)); 286 DECLARE("R64_SS", R64_(isf.ss)); 287 DECLARE("R64_RSP", R64_(isf.rsp)); 288 DECLARE("R64_TRAPNO", R64_(isf.trapno)); 289 DECLARE("R64_TRAPFN", R64_(isf.trapfn)); 290 DECLARE("R64_ERR", R64_(isf.err)); 291 DECLARE("R64_RFLAGS", R64_(isf.rflags)); 292 DECLARE("R64_RIP", R64_(isf.rip)); 293 DECLARE("R64_CR2", R64_(cr2)); 294 DECLARE("ISS64_OFFSET", R64_(isf)); 295 DECLARE("ISS64_SIZE", sizeof (x86_saved_state64_t)); 296 297#define ISF64_(x) offsetof(x86_64_intr_stack_frame_t *, x) 298 DECLARE("ISF64_TRAPNO", ISF64_(trapno)); 299 DECLARE("ISF64_TRAPFN", ISF64_(trapfn)); 300 DECLARE("ISF64_ERR", ISF64_(err)); 301 DECLARE("ISF64_RIP", ISF64_(rip)); 302 DECLARE("ISF64_CS", ISF64_(cs)); 303 DECLARE("ISF64_RFLAGS", ISF64_(rflags)); 304 DECLARE("ISF64_RSP", ISF64_(rsp)); 305 DECLARE("ISF64_SS", ISF64_(ss)); 306 DECLARE("ISF64_SIZE", sizeof(x86_64_intr_stack_frame_t)); 307 308 DECLARE("NBPG", I386_PGBYTES); 309 DECLARE("PAGE_SIZE", I386_PGBYTES); 310 DECLARE("PAGE_MASK", I386_PGBYTES-1); 311 DECLARE("PAGE_SHIFT", 12); 312 DECLARE("NKPT", NKPT); 313 DECLARE("VM_MIN_ADDRESS", VM_MIN_ADDRESS); 314 DECLARE("VM_MAX_ADDRESS", VM_MAX_ADDRESS); 315 DECLARE("KERNELBASE", VM_MIN_KERNEL_ADDRESS); 316 DECLARE("LINEAR_KERNELBASE", LINEAR_KERNEL_ADDRESS); 317 DECLARE("KERNEL_STACK_SIZE", KERNEL_STACK_SIZE); 318 319 DECLARE("ASM_COMM_PAGE32_BASE_ADDRESS", _COMM_PAGE32_BASE_ADDRESS); 320 DECLARE("ASM_COMM_PAGE32_START_ADDRESS", _COMM_PAGE32_START_ADDRESS); 321 DECLARE("ASM_COMM_PAGE_SCHED_GEN", _COMM_PAGE_SCHED_GEN); 322 323 DECLARE("PDESHIFT", PDESHIFT); 324 DECLARE("PTEMASK", PTEMASK); 325 DECLARE("PTEINDX", PTEINDX); 326 DECLARE("INTEL_PTE_PFN", INTEL_PTE_PFN); 327 DECLARE("INTEL_PTE_VALID", INTEL_PTE_VALID); 328 DECLARE("INTEL_PTE_WRITE", INTEL_PTE_WRITE); 329 DECLARE("INTEL_PTE_PS", INTEL_PTE_PS); 330 DECLARE("INTEL_PTE_USER", INTEL_PTE_USER); 331 DECLARE("INTEL_PTE_INVALID", INTEL_PTE_INVALID); 332 DECLARE("NPGPTD", NPGPTD); 333 DECLARE("KERNEL_PML4_INDEX",KERNEL_PML4_INDEX); 334 DECLARE("IDTSZ", IDTSZ); 335 DECLARE("GDTSZ", GDTSZ); 336 DECLARE("LDTSZ", LDTSZ); 337 338 DECLARE("KERNEL_DS", KERNEL_DS); 339 DECLARE("USER_CS", USER_CS); 340 DECLARE("USER_DS", USER_DS); 341 DECLARE("KERNEL32_CS", KERNEL32_CS); 342 DECLARE("KERNEL64_CS", KERNEL64_CS); 343 DECLARE("USER64_CS", USER64_CS); 344 DECLARE("KERNEL_TSS", KERNEL_TSS); 345 DECLARE("KERNEL_LDT", KERNEL_LDT); 346 DECLARE("SYSENTER_CS", SYSENTER_CS); 347 DECLARE("SYSENTER_TF_CS",SYSENTER_TF_CS); 348 DECLARE("SYSENTER_DS", SYSENTER_DS); 349 DECLARE("SYSCALL_CS", SYSCALL_CS); 350 351 DECLARE("CPU_THIS", 352 offsetof(cpu_data_t *, cpu_this)); 353 DECLARE("CPU_ACTIVE_THREAD", 354 offsetof(cpu_data_t *, cpu_active_thread)); 355 DECLARE("CPU_ACTIVE_STACK", 356 offsetof(cpu_data_t *, cpu_active_stack)); 357 DECLARE("CPU_KERNEL_STACK", 358 offsetof(cpu_data_t *, cpu_kernel_stack)); 359 DECLARE("CPU_INT_STACK_TOP", 360 offsetof(cpu_data_t *, cpu_int_stack_top)); 361#if MACH_RT 362 DECLARE("CPU_PREEMPTION_LEVEL", 363 offsetof(cpu_data_t *, cpu_preemption_level)); 364#endif /* MACH_RT */ 365 DECLARE("CPU_HIBERNATE", 366 offsetof(cpu_data_t *, cpu_hibernate)); 367 DECLARE("CPU_INTERRUPT_LEVEL", 368 offsetof(cpu_data_t *, cpu_interrupt_level)); 369 DECLARE("CPU_NESTED_ISTACK", 370 offsetof(cpu_data_t *, cpu_nested_istack)); 371 DECLARE("CPU_NUMBER_GS", 372 offsetof(cpu_data_t *,cpu_number)); 373 DECLARE("CPU_RUNNING", 374 offsetof(cpu_data_t *,cpu_running)); 375 DECLARE("CPU_PENDING_AST", 376 offsetof(cpu_data_t *,cpu_pending_ast)); 377 DECLARE("CPU_DESC_TABLEP", 378 offsetof(cpu_data_t *,cpu_desc_tablep)); 379 DECLARE("CPU_DESC_INDEX", 380 offsetof(cpu_data_t *,cpu_desc_index)); 381 DECLARE("CDI_GDT", 382 offsetof(cpu_desc_index_t *,cdi_gdt)); 383 DECLARE("CDI_IDT", 384 offsetof(cpu_desc_index_t *,cdi_idt)); 385 DECLARE("CPU_PROCESSOR", 386 offsetof(cpu_data_t *,cpu_processor)); 387 DECLARE("CPU_INT_STATE", 388 offsetof(cpu_data_t *, cpu_int_state)); 389 DECLARE("CPU_INT_EVENT_TIME", 390 offsetof(cpu_data_t *, cpu_int_event_time)); 391 392 DECLARE("CPU_TASK_CR3", 393 offsetof(cpu_data_t *, cpu_task_cr3)); 394 DECLARE("CPU_ACTIVE_CR3", 395 offsetof(cpu_data_t *, cpu_active_cr3)); 396 DECLARE("CPU_KERNEL_CR3", 397 offsetof(cpu_data_t *, cpu_kernel_cr3)); 398 DECLARE("CPU_TLB_INVALID", 399 offsetof(cpu_data_t *, cpu_tlb_invalid)); 400 401 DECLARE("CPU_TASK_MAP", 402 offsetof(cpu_data_t *, cpu_task_map)); 403 DECLARE("TASK_MAP_32BIT", TASK_MAP_32BIT); 404 DECLARE("TASK_MAP_64BIT", TASK_MAP_64BIT); 405 DECLARE("CPU_UBER_USER_GS_BASE", 406 offsetof(cpu_data_t *, cpu_uber.cu_user_gs_base)); 407 DECLARE("CPU_UBER_ISF", 408 offsetof(cpu_data_t *, cpu_uber.cu_isf)); 409 DECLARE("CPU_UBER_TMP", 410 offsetof(cpu_data_t *, cpu_uber.cu_tmp)); 411 412 DECLARE("CPU_NANOTIME", 413 offsetof(cpu_data_t *, cpu_nanotime)); 414 415 DECLARE("CPU_DR7", 416 offsetof(cpu_data_t *, cpu_dr7)); 417 418 DECLARE("hwIntCnt", offsetof(cpu_data_t *,cpu_hwIntCnt)); 419 DECLARE("CPU_ACTIVE_PCID", 420 offsetof(cpu_data_t *, cpu_active_pcid)); 421 DECLARE("CPU_PCID_COHERENTP", 422 offsetof(cpu_data_t *, cpu_pmap_pcid_coherentp)); 423 DECLARE("CPU_PCID_COHERENTP_KERNEL", 424 offsetof(cpu_data_t *, cpu_pmap_pcid_coherentp_kernel)); 425 DECLARE("CPU_PMAP_PCID_ENABLED", 426 offsetof(cpu_data_t *, cpu_pmap_pcid_enabled)); 427 428#ifdef PCID_STATS 429 DECLARE("CPU_PMAP_USER_RETS", 430 offsetof(cpu_data_t *, cpu_pmap_user_rets)); 431 DECLARE("CPU_PMAP_PCID_PRESERVES", 432 offsetof(cpu_data_t *, cpu_pmap_pcid_preserves)); 433 DECLARE("CPU_PMAP_PCID_FLUSHES", 434 offsetof(cpu_data_t *, cpu_pmap_pcid_flushes)); 435#endif 436 DECLARE("CPU_TLB_INVALID", 437 offsetof(cpu_data_t *, cpu_tlb_invalid)); 438 DECLARE("CPU_TLB_INVALID_LOCAL", 439 offsetof(cpu_data_t *, cpu_tlb_invalid_local)); 440 DECLARE("CPU_TLB_INVALID_GLOBAL", 441 offsetof(cpu_data_t *, cpu_tlb_invalid_global)); 442 DECLARE("enaExpTrace", enaExpTrace); 443 DECLARE("enaUsrFCall", enaUsrFCall); 444 DECLARE("enaUsrPhyMp", enaUsrPhyMp); 445 DECLARE("enaDiagSCs", enaDiagSCs); 446 DECLARE("enaDiagEM", enaDiagEM); 447 DECLARE("enaNotifyEM", enaNotifyEM); 448 DECLARE("dgLock", offsetof(struct diagWork *, dgLock)); 449 DECLARE("dgFlags", offsetof(struct diagWork *, dgFlags)); 450 DECLARE("dgMisc1", offsetof(struct diagWork *, dgMisc1)); 451 DECLARE("dgMisc2", offsetof(struct diagWork *, dgMisc2)); 452 DECLARE("dgMisc3", offsetof(struct diagWork *, dgMisc3)); 453 DECLARE("dgMisc4", offsetof(struct diagWork *, dgMisc4)); 454 DECLARE("dgMisc5", offsetof(struct diagWork *, dgMisc5)); 455 456 DECLARE("INTEL_PTE_KERNEL", INTEL_PTE_VALID|INTEL_PTE_WRITE); 457 DECLARE("PDESHIFT", PDESHIFT); 458 DECLARE("PDESIZE", PDESIZE); 459 DECLARE("PTESIZE", PTESIZE); 460 461 DECLARE("KERNELBASEPDE", 462 (LINEAR_KERNEL_ADDRESS >> PDESHIFT) * 463 sizeof(pt_entry_t)); 464 465 DECLARE("TSS_ESP0", offsetof(struct i386_tss *, esp0)); 466 DECLARE("TSS_SS0", offsetof(struct i386_tss *, ss0)); 467 DECLARE("TSS_LDT", offsetof(struct i386_tss *, ldt)); 468 DECLARE("TSS_PDBR", offsetof(struct i386_tss *, cr3)); 469 DECLARE("TSS_LINK", offsetof(struct i386_tss *, back_link)); 470 471 DECLARE("K_TASK_GATE", ACC_P|ACC_PL_K|ACC_TASK_GATE); 472 DECLARE("K_TRAP_GATE", ACC_P|ACC_PL_K|ACC_TRAP_GATE); 473 DECLARE("U_TRAP_GATE", ACC_P|ACC_PL_U|ACC_TRAP_GATE); 474 DECLARE("K_INTR_GATE", ACC_P|ACC_PL_K|ACC_INTR_GATE); 475 DECLARE("U_INTR_GATE", ACC_P|ACC_PL_U|ACC_INTR_GATE); 476 DECLARE("K_TSS", ACC_P|ACC_PL_K|ACC_TSS); 477 478 /* 479 * usimple_lock fields 480 */ 481 DECLARE("USL_INTERLOCK", offsetof(usimple_lock_t, interlock)); 482 483 DECLARE("INTSTACK_SIZE", INTSTACK_SIZE); 484 DECLARE("KADDR", offsetof(struct boot_args *, kaddr)); 485 DECLARE("KSIZE", offsetof(struct boot_args *, ksize)); 486 DECLARE("MEMORYMAP", offsetof(struct boot_args *, MemoryMap)); 487 DECLARE("DEVICETREEP", offsetof(struct boot_args *, deviceTreeP)); 488 489 DECLARE("RNT_TSC_BASE", 490 offsetof(pal_rtc_nanotime_t *, tsc_base)); 491 DECLARE("RNT_NS_BASE", 492 offsetof(pal_rtc_nanotime_t *, ns_base)); 493 DECLARE("RNT_SCALE", 494 offsetof(pal_rtc_nanotime_t *, scale)); 495 DECLARE("RNT_SHIFT", 496 offsetof(pal_rtc_nanotime_t *, shift)); 497 DECLARE("RNT_GENERATION", 498 offsetof(pal_rtc_nanotime_t *, generation)); 499 500 /* values from kern/timer.h */ 501#ifdef __LP64__ 502 DECLARE("TIMER_ALL", offsetof(struct timer *, all_bits)); 503#else 504 DECLARE("TIMER_LOW", offsetof(struct timer *, low_bits)); 505 DECLARE("TIMER_HIGH", offsetof(struct timer *, high_bits)); 506 DECLARE("TIMER_HIGHCHK", offsetof(struct timer *, high_bits_check)); 507#endif 508 DECLARE("TIMER_TSTAMP", 509 offsetof(struct timer *, tstamp)); 510 511 DECLARE("THREAD_TIMER", 512 offsetof(struct processor *, processor_data.thread_timer)); 513 DECLARE("KERNEL_TIMER", 514 offsetof(struct processor *, processor_data.kernel_timer)); 515 DECLARE("SYSTEM_TIMER", 516 offsetof(struct thread *, system_timer)); 517 DECLARE("USER_TIMER", 518 offsetof(struct thread *, user_timer)); 519 DECLARE("SYSTEM_STATE", 520 offsetof(struct processor *, processor_data.system_state)); 521 DECLARE("USER_STATE", 522 offsetof(struct processor *, processor_data.user_state)); 523 DECLARE("IDLE_STATE", 524 offsetof(struct processor *, processor_data.idle_state)); 525 DECLARE("CURRENT_STATE", 526 offsetof(struct processor *, processor_data.current_state)); 527 528 DECLARE("OnProc", OnProc); 529 530 531#if CONFIG_DTRACE 532 DECLARE("LS_LCK_MTX_LOCK_ACQUIRE", LS_LCK_MTX_LOCK_ACQUIRE); 533 DECLARE("LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE", LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE); 534 DECLARE("LS_LCK_MTX_UNLOCK_RELEASE", LS_LCK_MTX_UNLOCK_RELEASE); 535 DECLARE("LS_LCK_MTX_TRY_LOCK_ACQUIRE", LS_LCK_MTX_TRY_LOCK_ACQUIRE); 536 DECLARE("LS_LCK_RW_LOCK_SHARED_ACQUIRE", LS_LCK_RW_LOCK_SHARED_ACQUIRE); 537 DECLARE("LS_LCK_RW_DONE_RELEASE", LS_LCK_RW_DONE_RELEASE); 538 DECLARE("LS_LCK_MTX_EXT_LOCK_ACQUIRE", LS_LCK_MTX_EXT_LOCK_ACQUIRE); 539 DECLARE("LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE", LS_LCK_MTX_TRY_EXT_LOCK_ACQUIRE); 540 DECLARE("LS_LCK_MTX_EXT_UNLOCK_RELEASE", LS_LCK_MTX_EXT_UNLOCK_RELEASE); 541 DECLARE("LS_LCK_RW_LOCK_EXCL_ACQUIRE", LS_LCK_RW_LOCK_EXCL_ACQUIRE); 542 DECLARE("LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE", LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE); 543 DECLARE("LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE", LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE); 544 DECLARE("LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE", LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE); 545 DECLARE("LS_LCK_MTX_LOCK_SPIN_ACQUIRE", LS_LCK_MTX_LOCK_SPIN_ACQUIRE); 546#endif 547 548 return (0); 549} 550