]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kperf/buffer.h
xnu-2422.1.72.tar.gz
[apple/xnu.git] / osfmk / kperf / buffer.h
CommitLineData
316670eb
A
1/*
2 * Copyright (c) 2011 Apple Computer, 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/* wrapper around kdebug */
30
31#include <sys/kdebug.h>
32
33/* KDEBUG codes */
34#define PERF_CODE(SubClass, code) KDBG_CODE(DBG_PERF, SubClass, code)
35
36/* broad sub-classes */
37#define PERF_GENERIC (0)
38#define PERF_THREADINFO (1)
39#define PERF_CALLSTACK (2)
40#define PERF_TIMER (3)
41#define PERF_PET (4)
39236c6e
A
42#define PERF_AST (5)
43#define PERF_KPC (6)
44#define PERF_KDBG (7)
316670eb
A
45
46/* sub-class codes */
47#define PERF_GEN_CODE(code) PERF_CODE(PERF_GENERIC, code)
48#define PERF_GEN_EVENT PERF_GEN_CODE(0)
49
50#define PERF_TI_CODE(code) PERF_CODE(PERF_THREADINFO, code)
51#define PERF_TI_SAMPLE PERF_TI_CODE(0)
52#define PERF_TI_DATA PERF_TI_CODE(1)
53#define PERF_TI_XSAMPLE PERF_TI_CODE(2)
54#define PERF_TI_XPEND PERF_TI_CODE(3)
55#define PERF_TI_XDATA PERF_TI_CODE(4)
39236c6e 56#define PERF_TI_CSWITCH PERF_TI_CODE(5)
316670eb
A
57
58#define PERF_CS_CODE(code) PERF_CODE(PERF_CALLSTACK, code)
59#define PERF_CS_KSAMPLE PERF_CS_CODE(0)
60#define PERF_CS_UPEND PERF_CS_CODE(1)
61#define PERF_CS_USAMPLE PERF_CS_CODE(2)
62#define PERF_CS_KDATA PERF_CS_CODE(3)
63#define PERF_CS_UDATA PERF_CS_CODE(4)
39236c6e
A
64#define PERF_CS_KHDR PERF_CS_CODE(5)
65#define PERF_CS_UHDR PERF_CS_CODE(6)
66#define PERF_CS_ERROR PERF_CS_CODE(7)
316670eb
A
67
68#define PERF_TM_CODE(code) PERF_CODE(PERF_TIMER, code)
69#define PERF_TM_ASCHED PERF_TM_CODE(0)
70#define PERF_TM_SCHED PERF_TM_CODE(1)
71#define PERF_TM_HNDLR PERF_TM_CODE(2)
72
73#define PERF_PET_CODE(code) PERF_CODE(PERF_PET, code)
74#define PERF_PET_THREAD PERF_PET_CODE(0)
75#define PERF_PET_ERROR PERF_PET_CODE(1)
76#define PERF_PET_RUN PERF_PET_CODE(2)
77#define PERF_PET_PAUSE PERF_PET_CODE(3)
78#define PERF_PET_IDLE PERF_PET_CODE(4)
79#define PERF_PET_SAMPLE PERF_PET_CODE(5)
39236c6e
A
80#define PERF_PET_SCHED PERF_PET_CODE(6)
81#define PERF_PET_END PERF_PET_CODE(7)
316670eb
A
82
83#define PERF_AST_CODE(code) PERF_CODE(PERF_AST, code)
39236c6e
A
84#define PERF_AST_HNDLR PERF_AST_CODE(0)
85#define PERF_AST_ERROR PERF_AST_CODE(1)
86
87#define PERF_KPC_CODE(code) PERF_CODE(PERF_KPC, code)
88#define PERF_KPC_HNDLR PERF_KPC_CODE(0)
89#define PERF_KPC_FCOUNTER PERF_KPC_CODE(1)
90#define PERF_KPC_COUNTER PERF_KPC_CODE(2)
91#define PERF_KPC_DATA PERF_KPC_CODE(3)
92#define PERF_KPC_CONFIG PERF_KPC_CODE(4)
93#define PERF_KPC_CFG_REG PERF_KPC_CODE(5)
94#define PERF_KPC_DATA32 PERF_KPC_CODE(6)
95#define PERF_KPC_CFG_REG32 PERF_KPC_CODE(7)
96
97#define PERF_KDBG_CODE(code) PERF_CODE(PERF_KDBG, code)
98#define PERF_KDBG_HNDLR PERF_KDBG_CODE(0)
316670eb
A
99
100/* error sub-codes for trace data */
101enum
102{
103 ERR_TASK,
104 ERR_THREAD,
105 ERR_PID,
106 ERR_FRAMES,
107 ERR_GETSTACK,
108 ERR_NOMEM,
109};
110
39236c6e
A
111/* level of trace debug */
112#define KPERF_DEBUG_DATA 0
113#define KPERF_DEBUG_INFO 1
114#define KPERF_DEBUG_VERBOSE 2
115extern int kperf_debug_level;
116
316670eb 117/* for logging information / debugging -- optional */
39236c6e 118#define BUF_INFO( id, a0, a1, a2, a3) if (kperf_debug_level >= KPERF_DEBUG_INFO) KERNEL_DEBUG_CONSTANT_IST(~KDEBUG_ENABLE_PPT, id,a0,a1,a2,a3,0)
316670eb
A
119
120#define BUF_INFO1( id, a0 ) BUF_INFO(id, a0, 0, 0, 0 )
121#define BUF_INFO2( id, a0, a1 ) BUF_INFO(id, a0, a1, 0, 0 )
122#define BUF_INFO3( id, a0, a1, a2 ) BUF_INFO(id, a0, a1, a2, 0 )
123
124/* for logging actual data -- never compiled out */
39236c6e 125#define BUF_DATA( id, a0, a1, a2, a3) KERNEL_DEBUG_CONSTANT_IST(~KDEBUG_ENABLE_PPT, id,a0,a1,a2,a3,0)
316670eb
A
126
127/* code neatness */
128#define BUF_DATA1( id, a0 ) BUF_DATA(id, a0, 0, 0, 0 )
129#define BUF_DATA2( id, a0, a1 ) BUF_DATA(id, a0, a1, 0, 0 )
39236c6e 130#define BUF_DATA3( id, a0, a1, a2 ) BUF_DATA(id, a0, a1, a2, 0 )