4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
36 * Constants used by both asm and non-asm code.
40 * Flags determining the state of tracing -
41 * both for the "ftrace_state" variable, and for the per-CPU variable
42 * "cpu[N]->cpu_ftrace_state".
44 #define FTRACE_READY 0x00000001
45 #define FTRACE_ENABLED 0x00000002
49 #include <sys/thread.h>
50 #include <sys/cpuvar.h>
51 #include <sys/types.h>
54 * The record of a single event.
56 * Should fit nicely into a standard cache line.
57 * Here, the 32-bit version is 32 bytes, and the 64-bit version is 64 bytes.
59 typedef struct ftrace_record
{
61 kthread_t
*ftr_thread
;
73 * Default per-CPU event ring buffer size.
75 #define FTRACE_NENT 1024
80 * Tunable parameters in /etc/system.
82 extern int ftrace_atboot
; /* Whether to start fast tracing on boot. */
83 extern int ftrace_nent
; /* Size of the per-CPU event ring buffer. */
85 extern int ftrace_cpu_setup(cpu_setup_t
, int, void *);
86 extern void ftrace_init(void);
87 extern int ftrace_start(void);
88 extern int ftrace_stop(void);
89 extern void ftrace_0(char *, caddr_t
);
90 extern void ftrace_1(char *, ulong_t
, caddr_t
);
91 extern void ftrace_2(char *, ulong_t
, ulong_t
, caddr_t
);
92 extern void ftrace_3(char *, ulong_t
, ulong_t
, ulong_t
, caddr_t
);
93 extern void ftrace_3_notick(char *, ulong_t
, ulong_t
, ulong_t
,
96 typedef uintptr_t ftrace_icookie_t
;
97 extern ftrace_icookie_t
ftrace_interrupt_disable(void);
98 extern void ftrace_interrupt_enable(ftrace_icookie_t
);
99 extern caddr_t
caller(void);
101 #define FTRACE_0(fmt) \
103 if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \
104 ftrace_0(fmt, caller()); \
106 #define FTRACE_1(fmt, d1) \
108 if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \
109 ftrace_1(fmt, d1, caller()); \
111 #define FTRACE_2(fmt, d1, d2) \
113 if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \
114 ftrace_2(fmt, d1, d2, caller()); \
116 #define FTRACE_3(fmt, d1, d2, d3) \
118 if (CPU->cpu_ftrace.ftd_state & FTRACE_ENABLED) \
119 ftrace_3(fmt, d1, d2, d3, caller()); \
121 #define FTRACE_START() ftrace_start()
122 #define FTRACE_STOP() ftrace_stop()
126 #endif /* !defined(_ASM) */
132 #endif /* _SYS_FTRACE_H */