1/* 2 * Copyright (c) 2000-2014 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/* Copyright (c) 1997 Apple Computer, Inc. All rights reserved. 30 * 31 * kdebug.h - kernel_debug definitions 32 * 33 */ 34 35#ifndef BSD_SYS_KDEBUG_H 36#define BSD_SYS_KDEBUG_H 37 38#include <sys/appleapiopts.h> 39#include <sys/cdefs.h> 40__BEGIN_DECLS 41 42#ifdef __APPLE_API_UNSTABLE 43 44#include <mach/clock_types.h> 45#include <stdint.h> 46#if defined(KERNEL_BUILD) 47#include <kdebug.h> 48#endif /* KERNEL_BUILD */ 49 50#ifdef XNU_KERNEL_PRIVATE 51#include <stdint.h> 52#include <mach/branch_predicates.h> 53#endif 54 55typedef enum 56{ 57 KD_CALLBACK_KDEBUG_ENABLED, // Trace is now enabled. No arguments 58 KD_CALLBACK_KDEBUG_DISABLED, // Trace is now disabled. No arguments 59 KD_CALLBACK_SYNC_FLUSH, // Request the latest entries from the IOP, and block until complete. No arguments 60 KD_CALLBACK_TYPEFILTER_CHANGED, // Typefilter is enabled. A read-only pointer to the typefilter is provided, but is only valid while in the callback. 61} kd_callback_type; 62typedef void (*kd_callback_fn) (void* context, kd_callback_type reason, void* arg); 63 64struct kd_callback { 65 kd_callback_fn func; 66 void* context; 67 char iop_name[8]; // null-terminated string with name of core. 68}; 69 70typedef struct kd_callback kd_callback_t; 71 72/* 73 * Registers an IOP for participation in tracing. 74 * 75 * The registered callback function will be called with the 76 * supplied context as the first argument, followed by a 77 * kd_callback_type and an associated void* argument. 78 * 79 * The return value is a nonzero coreid that shall be used in 80 * kernel_debug_enter() to refer to your IOP. If the allocation 81 * failed, then 0 will be returned. 82 * 83 * 84 * Caveats: 85 * Note that not all callback calls will indicate a change in 86 * state (e.g. disabling trace twice would send two disable 87 * notifications). 88 * 89 */ 90extern int kernel_debug_register_callback(kd_callback_t callback); 91 92extern void kernel_debug_enter( 93 uint32_t coreid, 94 uint32_t debugid, 95 uint64_t timestamp, 96 uintptr_t arg1, 97 uintptr_t arg2, 98 uintptr_t arg3, 99 uintptr_t arg4, 100 uintptr_t threadid 101 ); 102 103 104/* 105 * state bits for hfs_update event 106 */ 107#define DBG_HFS_UPDATE_ACCTIME 0x01 108#define DBG_HFS_UPDATE_MODTIME 0x02 109#define DBG_HFS_UPDATE_CHGTIME 0x04 110#define DBG_HFS_UPDATE_MODIFIED 0x08 111#define DBG_HFS_UPDATE_FORCE 0x10 112#define DBG_HFS_UPDATE_DATEADDED 0x20 113 114 115/* 116 * types of faults that vm_fault handles 117 * and creates trace entries for 118 */ 119#define DBG_ZERO_FILL_FAULT 1 120#define DBG_PAGEIN_FAULT 2 121#define DBG_COW_FAULT 3 122#define DBG_CACHE_HIT_FAULT 4 123#define DBG_NZF_PAGE_FAULT 5 124#define DBG_GUARD_FAULT 6 125#define DBG_PAGEINV_FAULT 7 126#define DBG_PAGEIND_FAULT 8 127#define DBG_COMPRESSOR_FAULT 9 128#define DBG_COMPRESSOR_SWAPIN_FAULT 10 129 130 131/* The debug code consists of the following 132* 133* ---------------------------------------------------------------------- 134*| | | |Func | 135*| Class (8) | SubClass (8) | Code (14) |Qual(2)| 136* ---------------------------------------------------------------------- 137* The class specifies the higher level 138*/ 139 140/* The Function qualifiers */ 141#define DBG_FUNC_START 1 142#define DBG_FUNC_END 2 143#define DBG_FUNC_NONE 0 144 145 146/* The Kernel Debug Classes */ 147#define DBG_MACH 1 148#define DBG_NETWORK 2 149#define DBG_FSYSTEM 3 150#define DBG_BSD 4 151#define DBG_IOKIT 5 152#define DBG_DRIVERS 6 153#define DBG_TRACE 7 154#define DBG_DLIL 8 155#define DBG_WORKQUEUE 9 156#define DBG_CORESTORAGE 10 157#define DBG_CG 11 158#define DBG_MISC 20 159#define DBG_SECURITY 30 160#define DBG_DYLD 31 161#define DBG_QT 32 162#define DBG_APPS 33 163#define DBG_LAUNCHD 34 164#define DBG_PERF 37 165#define DBG_IMPORTANCE 38 166#define DBG_BANK 40 167#define DBG_XPC 41 168#define DBG_ATM 42 169 170#define DBG_MIG 255 171 172/* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */ 173#define DBG_MACH_EXCP_KTRAP_x86 0x02 /* Kernel Traps on x86 */ 174#define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */ 175#define DBG_MACH_EXCP_IFLT 0x04 /* Inst Translation Fault */ 176#define DBG_MACH_EXCP_INTR 0x05 /* Interrupts */ 177#define DBG_MACH_EXCP_ALNG 0x06 /* Alignment Exception */ 178#define DBG_MACH_EXCP_UTRAP_x86 0x07 /* User Traps on x86 */ 179#define DBG_MACH_EXCP_FP 0x08 /* FP Unavail */ 180#define DBG_MACH_EXCP_DECI 0x09 /* Decrementer Interrupt */ 181#define DBG_MACH_CHUD 0x0A /* CHUD */ 182#define DBG_MACH_EXCP_SC 0x0C /* System Calls */ 183#define DBG_MACH_EXCP_TRACE 0x0D /* Trace exception */ 184#define DBG_MACH_EXCP_EMUL 0x0E /* Instruction emulated */ 185#define DBG_MACH_IHDLR 0x10 /* Interrupt Handlers */ 186#define DBG_MACH_IPC 0x20 /* Inter Process Comm */ 187#define DBG_MACH_VM 0x30 /* Virtual Memory */ 188#define DBG_MACH_LEAKS 0x31 /* alloc/free */ 189#define DBG_MACH_SCHED 0x40 /* Scheduler */ 190#define DBG_MACH_MSGID_INVALID 0x50 /* Messages - invalid */ 191#define DBG_MACH_LOCKS 0x60 /* new lock APIs */ 192#define DBG_MACH_PMAP 0x70 /* pmap */ 193/* #define unused 0x80 */ 194#define DBG_MACH_MP 0x90 /* MP related */ 195#define DBG_MACH_VM_PRESSURE 0xA0 /* Memory Pressure Events */ 196#define DBG_MACH_STACKSHOT 0xA1 /* Stackshot/Microstackshot subsystem */ 197#define DBG_MACH_SFI 0xA2 /* Selective Forced Idle (SFI) */ 198#define DBG_MACH_ENERGY_PERF 0xA3 /* Energy/performance resource stats */ 199 200/* Codes for Scheduler (DBG_MACH_SCHED) */ 201#define MACH_SCHED 0x0 /* Scheduler */ 202#define MACH_STACK_ATTACH 0x1 /* stack_attach() */ 203#define MACH_STACK_HANDOFF 0x2 /* stack_handoff() */ 204#define MACH_CALL_CONT 0x3 /* call_continuation() */ 205#define MACH_CALLOUT 0x4 /* callouts */ 206#define MACH_STACK_DETACH 0x5 207#define MACH_MAKE_RUNNABLE 0x6 /* make thread runnable */ 208#define MACH_PROMOTE 0x7 /* promoted due to resource */ 209#define MACH_DEMOTE 0x8 /* promotion undone */ 210#define MACH_IDLE 0x9 /* processor idling */ 211#define MACH_STACK_DEPTH 0xa /* stack depth at switch */ 212#define MACH_MOVED 0xb /* did not use original scheduling decision */ 213#define MACH_FAIRSHARE_ENTER 0xc /* move to fairshare band */ 214#define MACH_FAIRSHARE_EXIT 0xd /* exit fairshare band */ 215#define MACH_FAILSAFE 0xe /* tripped fixed-pri/RT failsafe */ 216#define MACH_BLOCK 0xf /* thread block */ 217#define MACH_WAIT 0x10 /* thread wait assertion */ 218#define MACH_GET_URGENCY 0x14 /* Urgency queried by platform */ 219#define MACH_URGENCY 0x15 /* Urgency (RT/BG/NORMAL) communicated 220 * to platform 221 */ 222#define MACH_REDISPATCH 0x16 /* "next thread" thread redispatched */ 223#define MACH_REMOTE_AST 0x17 /* AST signal issued to remote processor */ 224 225#define MACH_SCHED_CHOOSE_PROCESSOR 0x18 /* Result of choose_processor */ 226#define MACH_DEEP_IDLE 0x19 /* deep idle on master processor */ 227#define MACH_SCHED_DECAY_PRIORITY 0x1a /* timeshare thread priority decayed/restored */ 228#define MACH_CPU_THROTTLE_DISABLE 0x1b /* Global CPU Throttle Disable */ 229#define MACH_RW_PROMOTE 0x1c /* promoted due to RW lock promotion */ 230#define MACH_RW_DEMOTE 0x1d /* promotion due to RW lock undone */ 231#define MACH_SCHED_MAINTENANCE 0x1f /* periodic maintenance thread */ 232#define MACH_DISPATCH 0x20 /* context switch completed */ 233#define MACH_QUANTUM_HANDOFF 0x21 /* quantum handoff occurred */ 234#define MACH_MULTIQ_DEQUEUE 0x22 /* Result of multiq dequeue */ 235#define MACH_SCHED_THREAD_SWITCH 0x23 /* attempt direct context switch to hinted thread */ 236#define MACH_SCHED_SMT_BALANCE 0x24 /* SMT load balancing ASTs */ 237 238/* Variants for MACH_MULTIQ_DEQUEUE */ 239#define MACH_MULTIQ_BOUND 1 240#define MACH_MULTIQ_GROUP 2 241#define MACH_MULTIQ_GLOBAL 3 242 243/* Codes for IPC (DBG_MACH_IPC) */ 244#define MACH_TASK_SUSPEND 0x0 /* Suspended a task */ 245#define MACH_TASK_RESUME 0x1 /* Resumed a task */ 246#define MACH_THREAD_SET_VOUCHER 0x2 247#define MACH_IPC_MSG_SEND 0x3 /* mach msg send, uniq msg info */ 248#define MACH_IPC_MSG_RECV 0x4 /* mach_msg receive */ 249#define MACH_IPC_MSG_RECV_VOUCHER_REFUSED 0x5 /* mach_msg receive, voucher refused */ 250#define MACH_IPC_KMSG_FREE 0x6 /* kernel free of kmsg data */ 251#define MACH_IPC_VOUCHER_CREATE 0x7 /* Voucher added to global voucher hashtable */ 252#define MACH_IPC_VOUCHER_CREATE_ATTR_DATA 0x8 /* Attr data for newly created voucher */ 253#define MACH_IPC_VOUCHER_DESTROY 0x9 /* Voucher removed from global voucher hashtable */ 254 255/* Codes for pmap (DBG_MACH_PMAP) */ 256#define PMAP__CREATE 0x0 257#define PMAP__DESTROY 0x1 258#define PMAP__PROTECT 0x2 259#define PMAP__PAGE_PROTECT 0x3 260#define PMAP__ENTER 0x4 261#define PMAP__REMOVE 0x5 262#define PMAP__NEST 0x6 263#define PMAP__UNNEST 0x7 264#define PMAP__FLUSH_TLBS 0x8 265#define PMAP__UPDATE_INTERRUPT 0x9 266#define PMAP__ATTRIBUTE_CLEAR 0xa 267#define PMAP__REUSABLE 0xb 268#define PMAP__QUERY_RESIDENT 0xc 269#define PMAP__FLUSH_KERN_TLBS 0xd 270#define PMAP__FLUSH_DELAYED_TLBS 0xe 271#define PMAP__FLUSH_TLBS_TO 0xf 272 273/* Codes for Stackshot/Microstackshot (DBG_MACH_STACKSHOT) */ 274#define MICROSTACKSHOT_RECORD 0x0 275#define MICROSTACKSHOT_GATHER 0x1 276 277/* Codes for Selective Forced Idle (DBG_MACH_SFI) */ 278#define SFI_SET_WINDOW 0x0 279#define SFI_CANCEL_WINDOW 0x1 280#define SFI_SET_CLASS_OFFTIME 0x2 281#define SFI_CANCEL_CLASS_OFFTIME 0x3 282#define SFI_THREAD_DEFER 0x4 283#define SFI_OFF_TIMER 0x5 284#define SFI_ON_TIMER 0x6 285#define SFI_WAIT_CANCELED 0x7 286#define SFI_PID_SET_MANAGED 0x8 287#define SFI_PID_CLEAR_MANAGED 0x9 288 289/* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */ 290#define DBG_NETIP 1 /* Internet Protocol */ 291#define DBG_NETARP 2 /* Address Resolution Protocol */ 292#define DBG_NETUDP 3 /* User Datagram Protocol */ 293#define DBG_NETTCP 4 /* Transmission Control Protocol */ 294#define DBG_NETICMP 5 /* Internet Control Message Protocol */ 295#define DBG_NETIGMP 6 /* Internet Group Management Protocol */ 296#define DBG_NETRIP 7 /* Routing Information Protocol */ 297#define DBG_NETOSPF 8 /* Open Shortest Path First */ 298#define DBG_NETISIS 9 /* Intermediate System to Intermediate System */ 299#define DBG_NETSNMP 10 /* Simple Network Management Protocol */ 300#define DBG_NETSOCK 11 /* Socket Layer */ 301 302/* For Apple talk */ 303#define DBG_NETAARP 100 /* Apple ARP */ 304#define DBG_NETDDP 101 /* Datagram Delivery Protocol */ 305#define DBG_NETNBP 102 /* Name Binding Protocol */ 306#define DBG_NETZIP 103 /* Zone Information Protocol */ 307#define DBG_NETADSP 104 /* Name Binding Protocol */ 308#define DBG_NETATP 105 /* Apple Transaction Protocol */ 309#define DBG_NETASP 106 /* Apple Session Protocol */ 310#define DBG_NETAFP 107 /* Apple Filing Protocol */ 311#define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */ 312#define DBG_NETAURP 109 /* Apple Update Routing Protocol */ 313 314#define DBG_NETIPSEC 128 /* IPsec Protocol */ 315#define DBG_NETVMNET 129 /* VMNet */ 316 317/* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */ 318#define DBG_IOINTC 0 /* Interrupt controller */ 319#define DBG_IOWORKLOOP 1 /* Work from work loop */ 320#define DBG_IOINTES 2 /* Interrupt event source */ 321#define DBG_IOCLKES 3 /* Clock event source */ 322#define DBG_IOCMDQ 4 /* Command queue latencies */ 323#define DBG_IOMCURS 5 /* Memory Cursor */ 324#define DBG_IOMDESC 6 /* Memory Descriptors */ 325#define DBG_IOPOWER 7 /* Power Managerment */ 326#define DBG_IOSERVICE 8 /* Matching etc. */ 327 328/* **** 9-32 reserved for internal IOKit usage **** */ 329 330#define DBG_IOSTORAGE 32 /* Storage layers */ 331#define DBG_IONETWORK 33 /* Network layers */ 332#define DBG_IOKEYBOARD 34 /* Keyboard */ 333#define DBG_IOHID 35 /* HID Devices */ 334#define DBG_IOAUDIO 36 /* Audio */ 335#define DBG_IOSERIAL 37 /* Serial */ 336#define DBG_IOTTY 38 /* TTY layers */ 337#define DBG_IOSAM 39 /* SCSI Architecture Model layers */ 338#define DBG_IOPARALLELATA 40 /* Parallel ATA */ 339#define DBG_IOPARALLELSCSI 41 /* Parallel SCSI */ 340#define DBG_IOSATA 42 /* Serial-ATA */ 341#define DBG_IOSAS 43 /* SAS */ 342#define DBG_IOFIBRECHANNEL 44 /* FiberChannel */ 343#define DBG_IOUSB 45 /* USB */ 344#define DBG_IOBLUETOOTH 46 /* Bluetooth */ 345#define DBG_IOFIREWIRE 47 /* FireWire */ 346#define DBG_IOINFINIBAND 48 /* Infiniband */ 347#define DBG_IOCPUPM 49 /* CPU Power Management */ 348#define DBG_IOGRAPHICS 50 /* Graphics */ 349#define DBG_HIBERNATE 51 /* hibernation related events */ 350#define DBG_IOTHUNDERBOLT 52 /* Thunderbolt */ 351 352 353/* Backwards compatibility */ 354#define DBG_IOPOINTING DBG_IOHID /* OBSOLETE: Use DBG_IOHID instead */ 355#define DBG_IODISK DBG_IOSTORAGE /* OBSOLETE: Use DBG_IOSTORAGE instead */ 356 357/* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */ 358#define DBG_DRVSTORAGE 1 /* Storage layers */ 359#define DBG_DRVNETWORK 2 /* Network layers */ 360#define DBG_DRVKEYBOARD 3 /* Keyboard */ 361#define DBG_DRVHID 4 /* HID Devices */ 362#define DBG_DRVAUDIO 5 /* Audio */ 363#define DBG_DRVSERIAL 7 /* Serial */ 364#define DBG_DRVSAM 8 /* SCSI Architecture Model layers */ 365#define DBG_DRVPARALLELATA 9 /* Parallel ATA */ 366#define DBG_DRVPARALLELSCSI 10 /* Parallel SCSI */ 367#define DBG_DRVSATA 11 /* Serial ATA */ 368#define DBG_DRVSAS 12 /* SAS */ 369#define DBG_DRVFIBRECHANNEL 13 /* FiberChannel */ 370#define DBG_DRVUSB 14 /* USB */ 371#define DBG_DRVBLUETOOTH 15 /* Bluetooth */ 372#define DBG_DRVFIREWIRE 16 /* FireWire */ 373#define DBG_DRVINFINIBAND 17 /* Infiniband */ 374#define DBG_DRVGRAPHICS 18 /* Graphics */ 375#define DBG_DRVSD 19 /* Secure Digital */ 376#define DBG_DRVNAND 20 /* NAND drivers and layers */ 377#define DBG_SSD 21 /* SSD */ 378#define DBG_DRVSPI 22 /* SPI */ 379 380/* Backwards compatibility */ 381#define DBG_DRVPOINTING DBG_DRVHID /* OBSOLETE: Use DBG_DRVHID instead */ 382#define DBG_DRVDISK DBG_DRVSTORAGE /* OBSOLETE: Use DBG_DRVSTORAGE instead */ 383 384/* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */ 385#define DBG_DLIL_STATIC 1 /* Static DLIL code */ 386#define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */ 387#define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */ 388#define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */ 389#define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */ 390 391/* The Kernel Debug Sub Classes for File System (DBG_FSYSTEM) */ 392#define DBG_FSRW 1 /* reads and writes to the filesystem */ 393#define DBG_DKRW 2 /* reads and writes to the disk */ 394#define DBG_FSVN 3 /* vnode operations (inc. locking/unlocking) */ 395#define DBG_FSLOOOKUP 4 /* namei and other lookup-related operations */ 396#define DBG_JOURNAL 5 /* journaling operations */ 397#define DBG_IOCTL 6 /* ioctl to the disk */ 398#define DBG_BOOTCACHE 7 /* bootcache operations */ 399#define DBG_HFS 8 /* HFS-specific events; see bsd/hfs/hfs_kdebug.h */ 400#define DBG_EXFAT 0xE /* ExFAT-specific events; see the exfat project */ 401#define DBG_MSDOS 0xF /* FAT-specific events; see the msdosfs project */ 402#define DBG_ACFS 0x10 /* Xsan-specific events; see the XsanFS project */ 403#define DBG_THROTTLE 0x11 /* I/O Throttling events */ 404#define DBG_CONTENT_PROT 0xCF /* Content Protection Events: see bsd/sys/cprotect.h */ 405 406/* The Kernel Debug Sub Classes for BSD */ 407#define DBG_BSD_PROC 0x01 /* process/signals related */ 408#define DBG_BSD_MEMSTAT 0x02 /* memorystatus / jetsam operations */ 409#define DBG_BSD_EXCP_SC 0x0C /* System Calls */ 410#define DBG_BSD_AIO 0x0D /* aio (POSIX async IO) */ 411#define DBG_BSD_SC_EXTENDED_INFO 0x0E /* System Calls, extended info */ 412#define DBG_BSD_SC_EXTENDED_INFO2 0x0F /* System Calls, extended info */ 413 414 415/* The Codes for BSD subcode class DBG_BSD_PROC */ 416#define BSD_PROC_EXIT 1 /* process exit */ 417#define BSD_PROC_FRCEXIT 2 /* Kernel force termination */ 418 419/* Codes for BSD subcode class DBG_BSD_MEMSTAT */ 420#define BSD_MEMSTAT_SCAN 1 /* memorystatus thread awake */ 421#define BSD_MEMSTAT_JETSAM 2 /* LRU jetsam */ 422#define BSD_MEMSTAT_JETSAM_HIWAT 3 /* highwater jetsam */ 423#define BSD_MEMSTAT_FREEZE 4 /* freeze process */ 424#define BSD_MEMSTAT_LATENCY_COALESCE 5 /* delay imposed to coalesce jetsam reports */ 425#define BSD_MEMSTAT_UPDATE 6 /* priority update */ 426#define BSD_MEMSTAT_IDLE_DEMOTE 7 /* idle demotion fired */ 427#define BSD_MEMSTAT_CLEAR_ERRORS 8 /* reset termination error state */ 428#define BSD_MEMSTAT_DIRTY_TRACK 9 /* track the process state */ 429#define BSD_MEMSTAT_DIRTY_SET 10 /* set the process state */ 430#define BSD_MEMSTAT_DIRTY_CLEAR 11 /* clear the process state */ 431#ifdef PRIVATE 432#define BSD_MEMSTAT_GRP_SET_PROP 12 /* set group properties */ 433#define BSD_MEMSTAT_DO_KILL 13 /* memorystatus kills */ 434#endif /* PRIVATE */ 435 436/* The Kernel Debug Sub Classes for DBG_TRACE */ 437#define DBG_TRACE_DATA 0 438#define DBG_TRACE_STRING 1 439#define DBG_TRACE_INFO 2 440 441/* 442 * TRACE_DATA_NEWTHREAD 0x1 443 * TRACE_DATA_EXEC 0x2 444 */ 445#define TRACE_DATA_THREAD_TERMINATE 0x3 /* thread has been queued for deallocation and can no longer run */ 446 447/* The Kernel Debug Sub Classes for DBG_CORESTORAGE */ 448#define DBG_CS_IO 0 449 450/* The Kernel Debug Sub Classes for DBG_SECURITY */ 451#define DBG_SEC_KERNEL 0 /* raw entropy collected by the kernel */ 452 453/* Sub-class codes for CoreGraphics (DBG_CG) are defined in its component. */ 454 455/* The Kernel Debug Sub Classes for DBG_MISC */ 456#define DBG_EVENT 0x10 457#define DBG_BUFFER 0x20 458 459/* The Kernel Debug Sub Classes for DBG_DYLD */ 460#define DBG_DYLD_STRING 5 461 462/* The Kernel Debug modifiers for the DBG_DKRW sub class */ 463#define DKIO_DONE 0x01 464#define DKIO_READ 0x02 465#define DKIO_ASYNC 0x04 466#define DKIO_META 0x08 467#define DKIO_PAGING 0x10 468#define DKIO_THROTTLE 0x20 /* Deprecated, still provided so fs_usage doesn't break */ 469#define DKIO_PASSIVE 0x40 470#define DKIO_NOCACHE 0x80 471#define DKIO_TIER_MASK 0xF00 472#define DKIO_TIER_SHIFT 8 473 474/* Kernel Debug Sub Classes for Applications (DBG_APPS) */ 475#define DBG_APP_LOGINWINDOW 0x03 476#define DBG_APP_AUDIO 0x04 477#define DBG_APP_SAMBA 0x80 478 479/* Kernel Debug codes for Throttling (DBG_THROTTLE) */ 480#define OPEN_THROTTLE_WINDOW 0x1 481#define PROCESS_THROTTLED 0x2 482#define IO_THROTTLE_DISABLE 0x3 483 484 485/* Subclasses for MACH Importance Policies (DBG_IMPORTANCE) */ 486/* TODO: Split up boost and task policy? */ 487#define IMP_ASSERTION 0x10 /* Task takes/drops a boost assertion */ 488#define IMP_BOOST 0x11 /* Task boost level changed */ 489#define IMP_MSG 0x12 /* boosting message sent by donating task on donating port */ 490#define IMP_WATCHPORT 0x13 /* port marked as watchport, and boost was transferred to the watched task */ 491#define IMP_TASK_SUPPRESSION 0x17 /* Task changed suppression behaviors */ 492#define IMP_TASK_APPTYPE 0x18 /* Task launched with apptype */ 493#define IMP_UPDATE 0x19 /* Requested -> effective calculation */ 494#define IMP_USYNCH_QOS_OVERRIDE 0x1A /* Userspace synchronization applied QoS override to resource owning thread */ 495#define IMP_DONOR_CHANGE 0x1B /* The iit_donor bit changed */ 496#define IMP_MAIN_THREAD_QOS 0x1C /* The task's main thread QoS was set */ 497/* DBG_IMPORTANCE subclasses 0x20 - 0x3F reserved for task policy flavors */ 498 499/* Codes for IMP_ASSERTION */ 500#define IMP_HOLD 0x2 /* Task holds a boost assertion */ 501#define IMP_DROP 0x4 /* Task drops a boost assertion */ 502#define IMP_EXTERN 0x8 /* boost assertion moved from kernel to userspace responsibility (externalized) */ 503 504/* Codes for IMP_BOOST */ 505#define IMP_BOOSTED 0x1 506#define IMP_UNBOOSTED 0x2 /* Task drops a boost assertion */ 507 508/* Codes for IMP_MSG */ 509#define IMP_MSG_SEND 0x1 /* boosting message sent by donating task on donating port */ 510#define IMP_MSG_DELV 0x2 /* boosting message delivered to task */ 511 512/* Codes for IMP_UPDATE */ 513#define IMP_UPDATE_TASK_CREATE 0x1 514 515/* Codes for IMP_USYNCH_QOS_OVERRIDE */ 516#define IMP_USYNCH_ADD_OVERRIDE 0x0 /* add override for a contended resource */ 517#define IMP_USYNCH_REMOVE_OVERRIDE 0x1 /* remove override for a contended resource */ 518 519/* Codes for IMP_DONOR_CHANGE */ 520#define IMP_DONOR_UPDATE_LIVE_DONOR_STATE 0x0 521#define IMP_DONOR_INIT_DONOR_STATE 0x1 522 523/* Subclasses for MACH Bank Voucher Attribute Manager (DBG_BANK) */ 524#define BANK_ACCOUNT_INFO 0x10 /* Trace points related to bank account struct */ 525#define BANK_TASK_INFO 0x11 /* Trace points related to bank task struct */ 526 527/* Subclasses for MACH ATM Voucher Attribute Manager (ATM) */ 528#define ATM_SUBAID_INFO 0x10 529#define ATM_GETVALUE_INFO 0x20 530#define ATM_UNREGISTER_INFO 0x30 531 532/* Codes for BANK_ACCOUNT_INFO */ 533#define BANK_SETTLE_CPU_TIME 0x1 /* Bank ledger(chit) rolled up to tasks. */ 534 535/* Codes for ATM_SUBAID_INFO */ 536#define ATM_MIN_CALLED 0x1 537#define ATM_MIN_LINK_LIST 0x2 538 539/* Codes for ATM_GETVALUE_INFO */ 540#define ATM_VALUE_REPLACED 0x1 541#define ATM_VALUE_ADDED 0x2 542 543/* Codes for ATM_UNREGISTER_INFO */ 544#define ATM_VALUE_UNREGISTERED 0x1 545#define ATM_VALUE_DIFF_MAILBOX 0x2 546 547/**********************************************************************/ 548 549#define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2)) 550 551#define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff) << 2)) 552 553#define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code) 554#define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code) 555#define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code) 556#define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code) 557#define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code) 558#define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code) 559#define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code) 560#define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code) 561#define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code) 562#define SECURITYDBG_CODE(SubClass,code) KDBG_CODE(DBG_SECURITY, SubClass, code) 563#define DYLDDBG_CODE(SubClass,code) KDBG_CODE(DBG_DYLD, SubClass, code) 564#define QTDBG_CODE(SubClass,code) KDBG_CODE(DBG_QT, SubClass, code) 565#define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code) 566#define CPUPM_CODE(code) IOKDBG_CODE(DBG_IOCPUPM, code) 567 568#define KMEM_ALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 0) 569#define KMEM_ALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 1) 570#define KMEM_FREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 2) 571#define KMEM_FREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 3) 572#define ZALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 4) 573#define ZALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 5) 574#define ZFREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 6) 575#define ZFREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 7) 576 577#define PMAP_CODE(code) MACHDBG_CODE(DBG_MACH_PMAP, code) 578 579 580#define IMPORTANCE_CODE(SubClass, code) KDBG_CODE(DBG_IMPORTANCE, (SubClass), (code)) 581#define BANK_CODE(SubClass, code) KDBG_CODE(DBG_BANK, (SubClass), (code)) 582#define ATM_CODE(SubClass, code) KDBG_CODE(DBG_ATM, (SubClass), (code)) 583 584/* Usage: 585* kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START), 586* offset, 0, 0, 0,0) 587* 588* For ex, 589* 590* #include <sys/kdebug.h> 591* 592* #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1) 593* 594* 595* void 596* ip_init() 597* { 598* register struct protosw *pr; 599* register int i; 600* 601* KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0) 602* -------- 603* KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0) 604* -------- 605* KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0) 606* } 607* 608 609*/ 610 611extern unsigned int kdebug_enable; 612#define KDEBUG_ENABLE_TRACE 0x1 613#define KDEBUG_ENABLE_ENTROPY 0x2 /* Obsolescent */ 614#define KDEBUG_ENABLE_CHUD 0x4 615#define KDEBUG_ENABLE_PPT 0x8 616 617/* 618 * Infer the supported kernel debug event level from config option. 619 * Use (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) as a guard to protect 620 * unaudited debug code. 621 */ 622#define KDEBUG_LEVEL_NONE 0 623#define KDEBUG_LEVEL_IST 1 624#define KDEBUG_LEVEL_STANDARD 2 625#define KDEBUG_LEVEL_FULL 3 626 627#if NO_KDEBUG 628#define KDEBUG_LEVEL KDEBUG_LEVEL_NONE 629#elif IST_KDEBUG 630#define KDEBUG_LEVEL KDEBUG_LEVEL_IST 631#elif KDEBUG 632#define KDEBUG_LEVEL KDEBUG_LEVEL_FULL 633#else 634#define KDEBUG_LEVEL KDEBUG_LEVEL_STANDARD 635#endif 636 637#if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) 638#ifdef XNU_KERNEL_PRIVATE 639#define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \ 640do { \ 641 if (__improbable(kdebug_enable & ~KDEBUG_ENABLE_PPT)) \ 642 kernel_debug(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 643 (uintptr_t)d,(uintptr_t)e); \ 644} while(0) 645 646#define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) \ 647do { \ 648 if (__improbable(kdebug_enable & ~KDEBUG_ENABLE_PPT)) \ 649 kernel_debug1(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 650 (uintptr_t)d,(uintptr_t)e); \ 651} while(0) 652 653#define KERNEL_DEBUG_EARLY(x,a,b,c,d) \ 654do { \ 655 kernel_debug_early((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 656 (uintptr_t)c, (uintptr_t)d); \ 657} while(0) 658#else /* XNU_KERNEL_PRIVATE */ 659#define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \ 660do { \ 661 if (kdebug_enable & ~KDEBUG_ENABLE_PPT) \ 662 kernel_debug(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 663 (uintptr_t)d,(uintptr_t)e); \ 664} while(0) 665 666#define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) \ 667do { \ 668 if (kdebug_enable & ~KDEBUG_ENABLE_PPT) \ 669 kernel_debug1(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 670 (uintptr_t)d,(uintptr_t)e); \ 671} while(0) 672 673#define KERNEL_DEBUG_EARLY(x,a,b,c,d) \ 674do { \ 675 kernel_debug_early((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 676 (uintptr_t)c, (uintptr_t)d); \ 677} while(0) 678#endif /* XNU_KERNEL_PRIVATE */ 679#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */ 680#define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) do { } while(0) 681#define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) do { } while(0) 682#define KERNEL_DEBUG_EARLY(x,a,b,c,d) do { } while(0) 683#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */ 684 685/* 686 * Specify KDEBUG_PPT to indicate that the event belongs to the 687 * limited PPT set. 688 */ 689#define KDEBUG_COMMON (KDEBUG_ENABLE_TRACE|KDEBUG_ENABLE_CHUD|KDEBUG_ENABLE_PPT) 690#define KDEBUG_TRACE (KDEBUG_ENABLE_TRACE|KDEBUG_ENABLE_CHUD) 691#define KDEBUG_PPT (KDEBUG_ENABLE_PPT) 692 693/* 694 * KERNEL_DEBUG_CONSTANT_IST events provide an audited subset of 695 * tracepoints for userland system tracing tools. 696 */ 697#if (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) 698#ifdef XNU_KERNEL_PRIVATE 699#define KERNEL_DEBUG_CONSTANT_IST(type,x,a,b,c,d,e) \ 700do { \ 701 if (__improbable(kdebug_enable & type)) \ 702 kernel_debug(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 703 (uintptr_t)d,(uintptr_t)e); \ 704} while(0) 705#else /* XNU_KERNEL_PRIVATE */ 706#define KERNEL_DEBUG_CONSTANT_IST(type,x,a,b,c,d,e) \ 707do { \ 708 if (kdebug_enable & type) \ 709 kernel_debug(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ 710 (uintptr_t)d,(uintptr_t)e); \ 711} while(0) 712#endif /* XNU_KERNEL_PRIVATE */ 713#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */ 714#define KERNEL_DEBUG_CONSTANT_IST(type,x,a,b,c,d,e) do { } while(0) 715#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */ 716 717#if NO_KDEBUG 718#define __kdebug_constant_only __unused 719#endif 720 721extern void kernel_debug( 722 uint32_t debugid, 723 uintptr_t arg1, 724 uintptr_t arg2, 725 uintptr_t arg3, 726 uintptr_t arg4, 727 uintptr_t arg5); 728 729extern void kernel_debug1( 730 uint32_t debugid, 731 uintptr_t arg1, 732 uintptr_t arg2, 733 uintptr_t arg3, 734 uintptr_t arg4, 735 uintptr_t arg5); 736 737extern void kernel_debug_early( 738 uint32_t debugid, 739 uintptr_t arg1, 740 uintptr_t arg2, 741 uintptr_t arg3, 742 uintptr_t arg4); 743 744extern void kernel_debug_string( 745 const char *message); 746 747#if (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL) 748#ifdef XNU_KERNEL_PRIVATE 749#define KERNEL_DEBUG(x,a,b,c,d,e) \ 750do { \ 751 if (__improbable(kdebug_enable & ~KDEBUG_ENABLE_PPT)) \ 752 kernel_debug((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 753 (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ 754} while(0) 755 756#define KERNEL_DEBUG1(x,a,b,c,d,e) \ 757do { \ 758 if (__improbable(kdebug_enable & ~KDEBUG_ENABLE_PPT)) \ 759 kernel_debug1((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 760 (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ 761} while(0) 762 763#define __kdebug_only 764#else /* !XNU_KERNEL_PRIVATE */ 765#define KERNEL_DEBUG(x,a,b,c,d,e) \ 766do { \ 767 if (kdebug_enable & ~KDEBUG_ENABLE_PPT) \ 768 kernel_debug((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 769 (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ 770} while(0) 771 772#define KERNEL_DEBUG1(x,a,b,c,d,e) \ 773do { \ 774 if (kdebug_enable & ~KDEBUG_ENABLE_PPT) \ 775 kernel_debug1((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ 776 (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ 777} while(0) 778#endif /* XNU_KERNEL_PRIVATE */ 779#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL) */ 780#define KERNEL_DEBUG(x,a,b,c,d,e) do {} while (0) 781#define KERNEL_DEBUG1(x,a,b,c,d,e) do {} while (0) 782 783#define __kdebug_only __unused 784#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL) */ 785 786#ifdef KERNEL_PRIVATE 787#include <mach/boolean.h> 788 789#define NUMPARMS 23 790 791struct proc; 792 793extern void kdebug_lookup_gen_events(long *dbg_parms, int dbg_namelen, void *dp, boolean_t lookup); 794extern void kdbg_trace_data(struct proc *proc, long *arg_pid); 795 796extern void kdbg_trace_string(struct proc *proc, long *arg1, long *arg2, long *arg3, long *arg4); 797 798extern void kdbg_dump_trace_to_file(const char *); 799void start_kern_tracing(unsigned int, boolean_t); 800void start_kern_tracing_with_typefilter(unsigned int, boolean_t, unsigned int); 801struct task; 802extern void kdbg_get_task_name(char*, int, struct task *task); 803void disable_wrap(uint32_t *old_slowcheck, uint32_t *old_flags); 804void enable_wrap(uint32_t old_slowcheck, boolean_t lostevents); 805void release_storage_unit(int cpu, uint32_t storage_unit); 806int allocate_storage_unit(int cpu); 807 808#define KDBG_CLASS_ENCODE(Class, SubClass) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16)) 809#define KDBG_CLASS_DECODE(Debugid) (Debugid & 0xFFFF0000) 810 811 812#endif /* KERNEL_PRIVATE */ 813 814 815#endif /* __APPLE_API_UNSTABLE */ 816__END_DECLS 817 818 819#ifdef PRIVATE 820#ifdef __APPLE_API_PRIVATE 821/* 822 * private kernel_debug definitions 823 */ 824 825typedef struct { 826 uint64_t timestamp; 827 uintptr_t arg1; 828 uintptr_t arg2; 829 uintptr_t arg3; 830 uintptr_t arg4; 831 uintptr_t arg5; /* will hold current thread */ 832 uint32_t debugid; 833#if defined(__LP64__) 834 uint32_t cpuid; 835 uintptr_t unused; 836#endif 837} kd_buf; 838 839#if !defined(__LP64__) 840#define KDBG_TIMESTAMP_MASK 0x00ffffffffffffffULL 841#define KDBG_CPU_MASK 0xff00000000000000ULL 842#define KDBG_CPU_SHIFT 56 843static inline void 844kdbg_set_cpu(kd_buf *kp, int cpu) 845{ 846 kp->timestamp = (kp->timestamp & KDBG_TIMESTAMP_MASK) | 847 (((uint64_t) cpu) << KDBG_CPU_SHIFT); 848} 849static inline int 850kdbg_get_cpu(kd_buf *kp) 851{ 852 return (int) (((kp)->timestamp & KDBG_CPU_MASK) >> KDBG_CPU_SHIFT); 853} 854static inline void 855kdbg_set_timestamp(kd_buf *kp, uint64_t thetime) 856{ 857 kp->timestamp = thetime & KDBG_TIMESTAMP_MASK; 858} 859static inline uint64_t 860kdbg_get_timestamp(kd_buf *kp) 861{ 862 return kp->timestamp & KDBG_TIMESTAMP_MASK; 863} 864static inline void 865kdbg_set_timestamp_and_cpu(kd_buf *kp, uint64_t thetime, int cpu) 866{ 867 kp->timestamp = (thetime & KDBG_TIMESTAMP_MASK) | 868 (((uint64_t) cpu) << KDBG_CPU_SHIFT); 869} 870#else 871#define KDBG_TIMESTAMP_MASK 0xffffffffffffffffULL 872static inline void 873kdbg_set_cpu(kd_buf *kp, int cpu) 874{ 875 kp->cpuid = cpu; 876} 877static inline int 878kdbg_get_cpu(kd_buf *kp) 879{ 880 return kp->cpuid; 881} 882static inline void 883kdbg_set_timestamp(kd_buf *kp, uint64_t thetime) 884{ 885 kp->timestamp = thetime; 886} 887static inline uint64_t 888kdbg_get_timestamp(kd_buf *kp) 889{ 890 return kp->timestamp; 891} 892static inline void 893kdbg_set_timestamp_and_cpu(kd_buf *kp, uint64_t thetime, int cpu) 894{ 895 kdbg_set_timestamp(kp, thetime); 896 kdbg_set_cpu(kp, cpu); 897} 898#endif 899 900/* 2^16 bits (8 kilobytes), one for each possible class/subclass combination */ 901#define KDBG_TYPEFILTER_BITMAP_SIZE ( (256 * 256) / 8 ) 902 903/* Debug Flags */ 904#define KDBG_INIT 0x001 905#define KDBG_NOWRAP 0x002 906#define KDBG_FREERUN 0x004 907#define KDBG_WRAPPED 0x008 908#define KDBG_USERFLAGS (KDBG_FREERUN|KDBG_NOWRAP|KDBG_INIT) 909#define KDBG_PIDCHECK 0x010 910#define KDBG_MAPINIT 0x020 911#define KDBG_PIDEXCLUDE 0x040 912#define KDBG_LOCKINIT 0x080 913#define KDBG_LP64 0x100 914 915typedef struct { 916 unsigned int type; 917 unsigned int value1; 918 unsigned int value2; 919 unsigned int value3; 920 unsigned int value4; 921 922} kd_regtype; 923 924typedef struct 925{ 926 int nkdbufs; 927 int nolog; 928 int flags; 929 int nkdthreads; 930 int bufid; 931} kbufinfo_t; 932 933typedef struct { 934 uintptr_t thread; 935 int valid; 936 char command[20]; 937} kd_threadmap; 938 939typedef struct { 940 uint32_t version_no; 941 uint32_t cpu_count; 942} kd_cpumap_header; 943 944/* cpumap flags */ 945#define KDBG_CPUMAP_IS_IOP 0x1 946 947typedef struct { 948 uint32_t cpu_id; 949 uint32_t flags; 950 char name[8]; 951} kd_cpumap; 952 953/* 954 * TRACE file formats... 955 * 956 * RAW_VERSION0 957 * 958 * uint32_t #threadmaps 959 * kd_threadmap[] 960 * kd_buf[] 961 * 962 * RAW_VERSION1 963 * 964 * RAW_header, with version_no set to RAW_VERSION1 965 * kd_threadmap[] 966 * Empty space to pad alignment to the nearest page boundary. 967 * kd_buf[] 968 * 969 * RAW_VERSION1+ 970 * 971 * RAW_header, with version_no set to RAW_VERSION1 972 * kd_threadmap[] 973 * kd_cpumap_header, with version_no set to RAW_VERSION1 974 * kd_cpumap[] 975 * Empty space to pad alignment to the nearest page boundary. 976 * kd_buf[] 977 * 978 * V1+ implementation details... 979 * 980 * It would have been nice to add the cpumap data "correctly", but there were 981 * several obstacles. Existing code attempts to parse both V1 and V0 files. 982 * Due to the fact that V0 has no versioning or header, the test looks like 983 * this: 984 * 985 * // Read header 986 * if (header.version_no != RAW_VERSION1) { // Assume V0 } 987 * 988 * If we add a VERSION2 file format, all existing code is going to treat that 989 * as a VERSION0 file when reading it, and crash terribly when trying to read 990 * RAW_VERSION2 threadmap entries. 991 * 992 * To differentiate between a V1 and V1+ file, read as V1 until you reach 993 * the padding bytes. Then: 994 * 995 * boolean_t is_v1plus = FALSE; 996 * if (padding_bytes >= sizeof(kd_cpumap_header)) { 997 * kd_cpumap_header header = // read header; 998 * if (header.version_no == RAW_VERSION1) { 999 * is_v1plus = TRUE; 1000 * } 1001 * } 1002 * 1003 */ 1004 1005typedef struct { 1006 int version_no; 1007 int thread_count; 1008 uint64_t TOD_secs; 1009 uint32_t TOD_usecs; 1010} RAW_header; 1011 1012#define RAW_VERSION0 0x55aa0000 1013#define RAW_VERSION1 0x55aa0101 1014 1015#define KDBG_CLASSTYPE 0x10000 1016#define KDBG_SUBCLSTYPE 0x20000 1017#define KDBG_RANGETYPE 0x40000 1018#define KDBG_TYPENONE 0x80000 1019#define KDBG_CKTYPES 0xF0000 1020 1021#define KDBG_RANGECHECK 0x100000 1022#define KDBG_VALCHECK 0x200000 /* Check up to 4 individual values */ 1023 1024#define KDBG_TYPEFILTER_CHECK ((uint32_t) 0x400000) /* Check class and subclass against a bitmap */ 1025 1026#define KDBG_BUFINIT 0x80000000 1027 1028/* Minimum value allowed when setting decrementer ticks */ 1029#define KDBG_MINRTCDEC 2500 1030 1031#endif /* __APPLE_API_PRIVATE */ 1032#endif /* PRIVATE */ 1033 1034#endif /* !BSD_SYS_KDEBUG_H */ 1035