#include <mach/clock_types.h>
#include <stdint.h>
-#if defined(KERNEL_BUILD)
-#include <kdebug.h>
-#endif /* KERNEL_BUILD */
+
+#ifndef KERNEL
+#include <Availability.h>
+#endif
#ifdef XNU_KERNEL_PRIVATE
#include <stdint.h>
#include <mach/branch_predicates.h>
#endif
+#ifdef KERNEL_PRIVATE
+
typedef enum
{
KD_CALLBACK_KDEBUG_ENABLED, // Trace is now enabled. No arguments
uintptr_t threadid
);
-
-/*
- * state bits for hfs_update event
- */
-#define DBG_HFS_UPDATE_ACCTIME 0x01
-#define DBG_HFS_UPDATE_MODTIME 0x02
-#define DBG_HFS_UPDATE_CHGTIME 0x04
-#define DBG_HFS_UPDATE_MODIFIED 0x08
-#define DBG_HFS_UPDATE_FORCE 0x10
-#define DBG_HFS_UPDATE_DATEADDED 0x20
-
-
-/*
- * types of faults that vm_fault handles
- * and creates trace entries for
- */
-#define DBG_ZERO_FILL_FAULT 1
-#define DBG_PAGEIN_FAULT 2
-#define DBG_COW_FAULT 3
-#define DBG_CACHE_HIT_FAULT 4
-#define DBG_NZF_PAGE_FAULT 5
-#define DBG_GUARD_FAULT 6
-#define DBG_PAGEINV_FAULT 7
-#define DBG_PAGEIND_FAULT 8
-#define DBG_COMPRESSOR_FAULT 9
-#define DBG_COMPRESSOR_SWAPIN_FAULT 10
-
+#endif /* KERNEL_PRIVATE */
/* The debug code consists of the following
*
#define DBG_BANK 40
#define DBG_XPC 41
#define DBG_ATM 42
+#define DBG_ARIADNE 43
+
#define DBG_MIG 255
+#ifdef PRIVATE
+/*
+ * OS components can use the full precision of the "code" field
+ * (Class, SubClass, Code) to inject events using kdebug_trace() by
+ * using:
+ *
+ * kdebug_trace(KDBG_CODE(DBG_XPC, 15, 1) | DBG_FUNC_NONE, 1, 2, 3, 4);
+ *
+ * These trace points can be included in production code, since they
+ * use reserved, non-overlapping ranges. The performance impact when
+ * kernel tracing is not enabled is minimal. Classes can be reserved
+ * by filing a Radar in xnu|all.
+ *
+ * 64-bit arguments may be truncated if the system is using a 32-bit
+ * kernel.
+ *
+ * On error, -1 will be returned and errno will indicate the error.
+ */
+#ifndef KERNEL
+extern int kdebug_trace(uint32_t code, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) __OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_NA);
+#endif
+#endif /* PRIVATE */
+
/* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */
#define DBG_MACH_EXCP_KTRAP_x86 0x02 /* Kernel Traps on x86 */
#define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */
#define MACH_MULTIQ_GROUP 2
#define MACH_MULTIQ_GLOBAL 3
+/* Arguments for vm_fault (DBG_MACH_VM) */
+#define DBG_ZERO_FILL_FAULT 1
+#define DBG_PAGEIN_FAULT 2
+#define DBG_COW_FAULT 3
+#define DBG_CACHE_HIT_FAULT 4
+#define DBG_NZF_PAGE_FAULT 5
+#define DBG_GUARD_FAULT 6
+#define DBG_PAGEINV_FAULT 7
+#define DBG_PAGEIND_FAULT 8
+#define DBG_COMPRESSOR_FAULT 9
+#define DBG_COMPRESSOR_SWAPIN_FAULT 10
+
/* Codes for IPC (DBG_MACH_IPC) */
#define MACH_TASK_SUSPEND 0x0 /* Suspended a task */
#define MACH_TASK_RESUME 0x1 /* Resumed a task */
/* Codes for Selective Forced Idle (DBG_MACH_SFI) */
#define SFI_SET_WINDOW 0x0
#define SFI_CANCEL_WINDOW 0x1
-#define SFI_SET_CLASS_OFFTIME 0x2
+#define SFI_SET_CLASS_OFFTIME 0x2
#define SFI_CANCEL_CLASS_OFFTIME 0x3
#define SFI_THREAD_DEFER 0x4
#define SFI_OFF_TIMER 0x5
#define SFI_ON_TIMER 0x6
#define SFI_WAIT_CANCELED 0x7
#define SFI_PID_SET_MANAGED 0x8
-#define SFI_PID_CLEAR_MANAGED 0x9
-
+#define SFI_PID_CLEAR_MANAGED 0x9
+#define SFI_GLOBAL_DEFER 0xa
/* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */
#define DBG_NETIP 1 /* Internet Protocol */
#define DBG_NETARP 2 /* Address Resolution Protocol */
#define DBG_THROTTLE 0x11 /* I/O Throttling events */
#define DBG_CONTENT_PROT 0xCF /* Content Protection Events: see bsd/sys/cprotect.h */
+/*
+ * For Kernel Debug Sub Class DBG_HFS, state bits for hfs_update event
+ */
+#define DBG_HFS_UPDATE_ACCTIME 0x01
+#define DBG_HFS_UPDATE_MODTIME 0x02
+#define DBG_HFS_UPDATE_CHGTIME 0x04
+#define DBG_HFS_UPDATE_MODIFIED 0x08
+#define DBG_HFS_UPDATE_FORCE 0x10
+#define DBG_HFS_UPDATE_DATEADDED 0x20
+
/* The Kernel Debug Sub Classes for BSD */
#define DBG_BSD_PROC 0x01 /* process/signals related */
#define DBG_BSD_MEMSTAT 0x02 /* memorystatus / jetsam operations */
#define DBG_TRACE_STRING 1
#define DBG_TRACE_INFO 2
-/*
- * TRACE_DATA_NEWTHREAD 0x1
- * TRACE_DATA_EXEC 0x2
- */
-#define TRACE_DATA_THREAD_TERMINATE 0x3 /* thread has been queued for deallocation and can no longer run */
+/* The Kernel Debug events: */
+#define TRACE_DATA_NEWTHREAD (TRACEDBG_CODE(DBG_TRACE_DATA, 1))
+#define TRACE_DATA_EXEC (TRACEDBG_CODE(DBG_TRACE_DATA, 2))
+#define TRACE_DATA_THREAD_TERMINATE (TRACEDBG_CODE(DBG_TRACE_DATA, 3))
+#define TRACE_STRING_NEWTHREAD (TRACEDBG_CODE(DBG_TRACE_STRING, 1))
+#define TRACE_STRING_EXEC (TRACEDBG_CODE(DBG_TRACE_STRING, 2))
+#define TRACE_PANIC (TRACEDBG_CODE(DBG_TRACE_INFO, 0))
+#define TRACE_TIMESTAMPS (TRACEDBG_CODE(DBG_TRACE_INFO, 1))
+#define TRACE_LOST_EVENTS (TRACEDBG_CODE(DBG_TRACE_INFO, 2))
+#define TRACE_WRITING_EVENTS (TRACEDBG_CODE(DBG_TRACE_INFO, 3))
+#define TRACE_INFO_STRING (TRACEDBG_CODE(DBG_TRACE_INFO, 4))
/* The Kernel Debug Sub Classes for DBG_CORESTORAGE */
#define DBG_CS_IO 0
#define DYLDDBG_CODE(SubClass,code) KDBG_CODE(DBG_DYLD, SubClass, code)
#define QTDBG_CODE(SubClass,code) KDBG_CODE(DBG_QT, SubClass, code)
#define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code)
+#define ARIADNEDBG_CODE(SubClass, code) KDBG_CODE(DBG_ARIADNE, SubClass, code)
#define CPUPM_CODE(code) IOKDBG_CODE(DBG_IOCPUPM, code)
#define KMEM_ALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 0)
#define KDEBUG_ENABLE_ENTROPY 0x2 /* Obsolescent */
#define KDEBUG_ENABLE_CHUD 0x4
#define KDEBUG_ENABLE_PPT 0x8
+#define KDEBUG_ENABLE_SERIAL 0x10
/*
* Infer the supported kernel debug event level from config option.
/* Minimum value allowed when setting decrementer ticks */
#define KDBG_MINRTCDEC 2500
+/* VFS lookup events for serial traces */
+#define VFS_LOOKUP (FSDBG_CODE(DBG_FSRW,36))
+#define VFS_LOOKUP_DONE (FSDBG_CODE(DBG_FSRW,39))
+
+#if (DEVELOPMENT || DEBUG)
+#define KDEBUG_MOJO_TRACE 1
+#endif
+
#endif /* __APPLE_API_PRIVATE */
#endif /* PRIVATE */