]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/dtrace_bsd.h
MFC @ r266724
[FreeBSD/FreeBSD.git] / sys / sys / dtrace_bsd.h
1 /*-
2  * Copyright (c) 2007-2008 John Birrell (jb@freebsd.org)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  *
28  * This file contains BSD shims for Sun's DTrace code.
29  */
30
31 #ifndef _SYS_DTRACE_BSD_H
32 #define _SYS_DTRACE_BSD_H
33
34 /* Forward definitions: */
35 struct mbuf;
36 struct trapframe;
37 struct thread;
38 struct vattr;
39 struct vnode;
40 struct reg;
41
42 /*
43  * Cyclic clock function type definition used to hook the cyclic
44  * subsystem into the appropriate timer interrupt.
45  */
46 typedef void (*cyclic_clock_func_t)(struct trapframe *);
47 extern cyclic_clock_func_t      cyclic_clock_func;
48
49 void clocksource_cyc_set(const struct bintime *t);
50
51 /*
52  * The dtrace module handles traps that occur during a DTrace probe.
53  * This type definition is used in the trap handler to provide a
54  * hook for the dtrace module to register it's handler with.
55  */
56 typedef int (*dtrace_trap_func_t)(struct trapframe *, u_int);
57
58 int     dtrace_trap(struct trapframe *, u_int);
59
60 extern dtrace_trap_func_t       dtrace_trap_func;
61
62 /* Used by the machine dependent trap() code. */
63 typedef void (*dtrace_doubletrap_func_t)(void);
64
65 /* Global variables in trap.c */
66 extern  dtrace_doubletrap_func_t        dtrace_doubletrap_func;
67
68 /* Pid provider hooks */
69 typedef int (*dtrace_pid_probe_ptr_t)(struct reg *);
70 extern  dtrace_pid_probe_ptr_t  dtrace_pid_probe_ptr;
71 typedef int (*dtrace_return_probe_ptr_t)(struct reg *);
72 extern  dtrace_return_probe_ptr_t       dtrace_return_probe_ptr;
73
74 /* Virtual time hook function type. */
75 typedef void (*dtrace_vtime_switch_func_t)(struct thread *);
76
77 extern int                      dtrace_vtime_active;
78 extern dtrace_vtime_switch_func_t       dtrace_vtime_switch_func;
79
80 /* The fasttrap module hooks into the fork, exit and exit. */
81 typedef void (*dtrace_fork_func_t)(struct proc *, struct proc *);
82 typedef void (*dtrace_execexit_func_t)(struct proc *);
83
84 /* Global variable in kern_fork.c */
85 extern dtrace_fork_func_t       dtrace_fasttrap_fork;
86
87 /* Global variable in kern_exec.c */
88 extern dtrace_execexit_func_t   dtrace_fasttrap_exec;
89
90 /* Global variable in kern_exit.c */
91 extern dtrace_execexit_func_t   dtrace_fasttrap_exit;
92
93 /* The dtmalloc provider hooks into malloc. */
94 typedef void (*dtrace_malloc_probe_func_t)(u_int32_t, uintptr_t arg0,
95     uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
96
97 extern dtrace_malloc_probe_func_t   dtrace_malloc_probe;
98
99 /* dtnfsclient NFSv[34] access cache provider hooks. */
100 typedef void (*dtrace_nfsclient_accesscache_flush_probe_func_t)(uint32_t,
101     struct vnode *);
102 extern dtrace_nfsclient_accesscache_flush_probe_func_t
103     dtrace_nfsclient_accesscache_flush_done_probe;
104 extern dtrace_nfsclient_accesscache_flush_probe_func_t
105     dtrace_nfscl_accesscache_flush_done_probe;
106
107 typedef void (*dtrace_nfsclient_accesscache_get_probe_func_t)(uint32_t,
108     struct vnode *, uid_t, uint32_t);
109 extern dtrace_nfsclient_accesscache_get_probe_func_t
110     dtrace_nfsclient_accesscache_get_hit_probe,
111     dtrace_nfsclient_accesscache_get_miss_probe;
112 extern dtrace_nfsclient_accesscache_get_probe_func_t
113     dtrace_nfscl_accesscache_get_hit_probe,
114     dtrace_nfscl_accesscache_get_miss_probe;
115
116 typedef void (*dtrace_nfsclient_accesscache_load_probe_func_t)(uint32_t,
117     struct vnode *, uid_t, uint32_t, int);
118 extern dtrace_nfsclient_accesscache_load_probe_func_t
119     dtrace_nfsclient_accesscache_load_done_probe;
120 extern dtrace_nfsclient_accesscache_load_probe_func_t
121     dtrace_nfscl_accesscache_load_done_probe;
122
123 /* dtnfsclient NFSv[234] attribute cache provider hooks. */
124 typedef void (*dtrace_nfsclient_attrcache_flush_probe_func_t)(uint32_t,
125     struct vnode *);
126 extern dtrace_nfsclient_attrcache_flush_probe_func_t
127     dtrace_nfsclient_attrcache_flush_done_probe;
128 extern dtrace_nfsclient_attrcache_flush_probe_func_t
129     dtrace_nfscl_attrcache_flush_done_probe;
130
131 typedef void (*dtrace_nfsclient_attrcache_get_hit_probe_func_t)(uint32_t,
132     struct vnode *, struct vattr *);
133 extern dtrace_nfsclient_attrcache_get_hit_probe_func_t
134     dtrace_nfsclient_attrcache_get_hit_probe;
135 extern dtrace_nfsclient_attrcache_get_hit_probe_func_t
136     dtrace_nfscl_attrcache_get_hit_probe;
137
138 typedef void (*dtrace_nfsclient_attrcache_get_miss_probe_func_t)(uint32_t,
139     struct vnode *);
140 extern dtrace_nfsclient_attrcache_get_miss_probe_func_t
141     dtrace_nfsclient_attrcache_get_miss_probe;
142 extern dtrace_nfsclient_attrcache_get_miss_probe_func_t
143     dtrace_nfscl_attrcache_get_miss_probe;
144
145 typedef void (*dtrace_nfsclient_attrcache_load_probe_func_t)(uint32_t,
146     struct vnode *, struct vattr *, int);
147 extern dtrace_nfsclient_attrcache_load_probe_func_t
148     dtrace_nfsclient_attrcache_load_done_probe;
149 extern dtrace_nfsclient_attrcache_load_probe_func_t
150     dtrace_nfscl_attrcache_load_done_probe;
151
152 /* dtnfsclient NFSv[234] RPC provider hooks. */
153 typedef void (*dtrace_nfsclient_nfs23_start_probe_func_t)(uint32_t,
154     struct vnode *, struct mbuf *, struct ucred *, int);
155 extern dtrace_nfsclient_nfs23_start_probe_func_t
156     dtrace_nfsclient_nfs23_start_probe;
157 extern dtrace_nfsclient_nfs23_start_probe_func_t
158     dtrace_nfscl_nfs234_start_probe;
159
160 typedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t,
161     struct vnode *, struct mbuf *, struct ucred *, int, int);
162 extern dtrace_nfsclient_nfs23_done_probe_func_t
163     dtrace_nfsclient_nfs23_done_probe;
164 extern dtrace_nfsclient_nfs23_done_probe_func_t
165     dtrace_nfscl_nfs234_done_probe;
166
167 /*
168  * Functions which allow the dtrace module to check that the kernel 
169  * hooks have been compiled with sufficient space for it's private
170  * structures.
171  */
172 size_t  kdtrace_proc_size(void);
173 size_t  kdtrace_thread_size(void);
174
175 /*
176  * OpenSolaris compatible time functions returning nanoseconds.
177  * On OpenSolaris these return hrtime_t which we define as uint64_t.
178  */
179 uint64_t        dtrace_gethrtime(void);
180 uint64_t        dtrace_gethrestime(void);
181
182 #endif /* _SYS_DTRACE_BSD_H */