1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / ftrace.h
blob8fa940d62bed168451c940532520a184b479d124
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_FTRACE_H
27 #define _SYS_FTRACE_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
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
47 #if !defined(_ASM)
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 {
60 char *ftr_event;
61 kthread_t *ftr_thread;
62 uint64_t ftr_tick;
63 caddr_t ftr_caller;
64 ulong_t ftr_data1;
65 ulong_t ftr_data2;
66 ulong_t ftr_data3;
67 #ifdef _LP64
68 ulong_t __pad;
69 #endif
70 } ftrace_record_t;
73 * Default per-CPU event ring buffer size.
75 #define FTRACE_NENT 1024
77 #ifdef _KERNEL
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,
94 caddr_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()
124 #endif /* _KERNEL */
126 #endif /* !defined(_ASM) */
128 #ifdef __cplusplus
130 #endif
132 #endif /* _SYS_FTRACE_H */