1179064Sjb/*- 2179064Sjb * Copyright (c) 2007-2008 John Birrell (jb@freebsd.org) 3179064Sjb * All rights reserved. 4179064Sjb * 5179064Sjb * Redistribution and use in source and binary forms, with or without 6179064Sjb * modification, are permitted provided that the following conditions 7179064Sjb * are met: 8179064Sjb * 1. Redistributions of source code must retain the above copyright 9179064Sjb * notice, this list of conditions and the following disclaimer. 10179064Sjb * 2. Redistributions in binary form must reproduce the above copyright 11179064Sjb * notice, this list of conditions and the following disclaimer in the 12179064Sjb * documentation and/or other materials provided with the distribution. 13179064Sjb * 14179064Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15179064Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16179064Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17179064Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18179064Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19179064Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20179064Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21179064Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22179064Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23179064Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24179064Sjb * SUCH DAMAGE. 25179064Sjb * 26179064Sjb * $FreeBSD$ 27179064Sjb * 28179064Sjb * This file contains BSD shims for Sun's DTrace code. 29179064Sjb */ 30179064Sjb 31179064Sjb#ifndef _SYS_DTRACE_BSD_H 32179064Sjb#define _SYS_DTRACE_BSD_H 33179064Sjb 34179064Sjb/* Forward definitions: */ 35190293Srwatsonstruct mbuf; 36179064Sjbstruct trapframe; 37179064Sjbstruct thread; 38190380Srwatsonstruct vattr; 39190380Srwatsonstruct vnode; 40211813Srpaulostruct reg; 41238366Sgnnstruct devstat; 42238366Sgnnstruct bio; 43179064Sjb 44179064Sjb/* 45179064Sjb * Cyclic clock function type definition used to hook the cyclic 46179064Sjb * subsystem into the appropriate timer interrupt. 47179064Sjb */ 48179064Sjbtypedef void (*cyclic_clock_func_t)(struct trapframe *); 49221990Savgextern cyclic_clock_func_t cyclic_clock_func; 50179064Sjb 51221990Savgvoid clocksource_cyc_set(const struct bintime *t); 52179064Sjb 53179064Sjb/* 54179064Sjb * The dtrace module handles traps that occur during a DTrace probe. 55179064Sjb * This type definition is used in the trap handler to provide a 56179064Sjb * hook for the dtrace module to register it's handler with. 57179064Sjb */ 58179064Sjbtypedef int (*dtrace_trap_func_t)(struct trapframe *, u_int); 59179064Sjb 60179064Sjbint dtrace_trap(struct trapframe *, u_int); 61179064Sjb 62179064Sjbextern dtrace_trap_func_t dtrace_trap_func; 63179064Sjb 64269752Smarkj/* 65269752Smarkj * A hook which removes active FBT probes before executing the double fault 66269752Smarkj * handler. We want to ensure that DTrace doesn't trigger another trap, which 67269752Smarkj * would result in a reset. 68269752Smarkj */ 69179064Sjbtypedef int (*dtrace_invop_func_t)(uintptr_t, uintptr_t *, uintptr_t); 70179064Sjbtypedef void (*dtrace_doubletrap_func_t)(void); 71179064Sjbextern dtrace_invop_func_t dtrace_invop_func; 72179064Sjbextern dtrace_doubletrap_func_t dtrace_doubletrap_func; 73179064Sjb 74211813Srpaulo/* Pid provider hooks */ 75211813Srpaulotypedef int (*dtrace_pid_probe_ptr_t)(struct reg *); 76211813Srpauloextern dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; 77211813Srpaulotypedef int (*dtrace_return_probe_ptr_t)(struct reg *); 78211813Srpauloextern dtrace_return_probe_ptr_t dtrace_return_probe_ptr; 79211813Srpaulo 80179064Sjb/* Virtual time hook function type. */ 81179064Sjbtypedef void (*dtrace_vtime_switch_func_t)(struct thread *); 82179064Sjb 83179064Sjbextern int dtrace_vtime_active; 84179064Sjbextern dtrace_vtime_switch_func_t dtrace_vtime_switch_func; 85179064Sjb 86179064Sjb/* The fasttrap module hooks into the fork, exit and exit. */ 87179064Sjbtypedef void (*dtrace_fork_func_t)(struct proc *, struct proc *); 88179064Sjbtypedef void (*dtrace_execexit_func_t)(struct proc *); 89179064Sjb 90179064Sjb/* Global variable in kern_fork.c */ 91179064Sjbextern dtrace_fork_func_t dtrace_fasttrap_fork; 92179064Sjb 93179064Sjb/* Global variable in kern_exec.c */ 94179064Sjbextern dtrace_execexit_func_t dtrace_fasttrap_exec; 95179064Sjb 96179064Sjb/* Global variable in kern_exit.c */ 97179064Sjbextern dtrace_execexit_func_t dtrace_fasttrap_exit; 98179064Sjb 99179064Sjb/* The dtmalloc provider hooks into malloc. */ 100179064Sjbtypedef void (*dtrace_malloc_probe_func_t)(u_int32_t, uintptr_t arg0, 101179064Sjb uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); 102179064Sjb 103179064Sjbextern dtrace_malloc_probe_func_t dtrace_malloc_probe; 104179064Sjb 105223280Srmacklem/* dtnfsclient NFSv[34] access cache provider hooks. */ 106190380Srwatsontypedef void (*dtrace_nfsclient_accesscache_flush_probe_func_t)(uint32_t, 107190380Srwatson struct vnode *); 108190380Srwatsonextern dtrace_nfsclient_accesscache_flush_probe_func_t 109190380Srwatson dtrace_nfsclient_accesscache_flush_done_probe; 110223280Srmacklemextern dtrace_nfsclient_accesscache_flush_probe_func_t 111223280Srmacklem dtrace_nfscl_accesscache_flush_done_probe; 112190380Srwatson 113190380Srwatsontypedef void (*dtrace_nfsclient_accesscache_get_probe_func_t)(uint32_t, 114190380Srwatson struct vnode *, uid_t, uint32_t); 115190380Srwatsonextern dtrace_nfsclient_accesscache_get_probe_func_t 116190380Srwatson dtrace_nfsclient_accesscache_get_hit_probe, 117190380Srwatson dtrace_nfsclient_accesscache_get_miss_probe; 118223280Srmacklemextern dtrace_nfsclient_accesscache_get_probe_func_t 119223280Srmacklem dtrace_nfscl_accesscache_get_hit_probe, 120223280Srmacklem dtrace_nfscl_accesscache_get_miss_probe; 121190380Srwatson 122190380Srwatsontypedef void (*dtrace_nfsclient_accesscache_load_probe_func_t)(uint32_t, 123190380Srwatson struct vnode *, uid_t, uint32_t, int); 124190380Srwatsonextern dtrace_nfsclient_accesscache_load_probe_func_t 125190380Srwatson dtrace_nfsclient_accesscache_load_done_probe; 126223280Srmacklemextern dtrace_nfsclient_accesscache_load_probe_func_t 127223280Srmacklem dtrace_nfscl_accesscache_load_done_probe; 128190380Srwatson 129223280Srmacklem/* dtnfsclient NFSv[234] attribute cache provider hooks. */ 130190380Srwatsontypedef void (*dtrace_nfsclient_attrcache_flush_probe_func_t)(uint32_t, 131190380Srwatson struct vnode *); 132190380Srwatsonextern dtrace_nfsclient_attrcache_flush_probe_func_t 133190380Srwatson dtrace_nfsclient_attrcache_flush_done_probe; 134223280Srmacklemextern dtrace_nfsclient_attrcache_flush_probe_func_t 135223280Srmacklem dtrace_nfscl_attrcache_flush_done_probe; 136190380Srwatson 137190380Srwatsontypedef void (*dtrace_nfsclient_attrcache_get_hit_probe_func_t)(uint32_t, 138190380Srwatson struct vnode *, struct vattr *); 139190380Srwatsonextern dtrace_nfsclient_attrcache_get_hit_probe_func_t 140190380Srwatson dtrace_nfsclient_attrcache_get_hit_probe; 141223280Srmacklemextern dtrace_nfsclient_attrcache_get_hit_probe_func_t 142223280Srmacklem dtrace_nfscl_attrcache_get_hit_probe; 143190380Srwatson 144190380Srwatsontypedef void (*dtrace_nfsclient_attrcache_get_miss_probe_func_t)(uint32_t, 145190380Srwatson struct vnode *); 146190380Srwatsonextern dtrace_nfsclient_attrcache_get_miss_probe_func_t 147190380Srwatson dtrace_nfsclient_attrcache_get_miss_probe; 148223280Srmacklemextern dtrace_nfsclient_attrcache_get_miss_probe_func_t 149223280Srmacklem dtrace_nfscl_attrcache_get_miss_probe; 150190380Srwatson 151190380Srwatsontypedef void (*dtrace_nfsclient_attrcache_load_probe_func_t)(uint32_t, 152190380Srwatson struct vnode *, struct vattr *, int); 153190380Srwatsonextern dtrace_nfsclient_attrcache_load_probe_func_t 154190380Srwatson dtrace_nfsclient_attrcache_load_done_probe; 155223280Srmacklemextern dtrace_nfsclient_attrcache_load_probe_func_t 156223280Srmacklem dtrace_nfscl_attrcache_load_done_probe; 157190380Srwatson 158223280Srmacklem/* dtnfsclient NFSv[234] RPC provider hooks. */ 159190380Srwatsontypedef void (*dtrace_nfsclient_nfs23_start_probe_func_t)(uint32_t, 160190293Srwatson struct vnode *, struct mbuf *, struct ucred *, int); 161190293Srwatsonextern dtrace_nfsclient_nfs23_start_probe_func_t 162190293Srwatson dtrace_nfsclient_nfs23_start_probe; 163223280Srmacklemextern dtrace_nfsclient_nfs23_start_probe_func_t 164223280Srmacklem dtrace_nfscl_nfs234_start_probe; 165190380Srwatson 166190380Srwatsontypedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t, 167190380Srwatson struct vnode *, struct mbuf *, struct ucred *, int, int); 168190293Srwatsonextern dtrace_nfsclient_nfs23_done_probe_func_t 169190293Srwatson dtrace_nfsclient_nfs23_done_probe; 170223280Srmacklemextern dtrace_nfsclient_nfs23_done_probe_func_t 171223280Srmacklem dtrace_nfscl_nfs234_done_probe; 172190293Srwatson 173238366Sgnn/* IO Provider hooks, really hook into devstat */ 174238366Sgnntypedef void (*dtrace_io_start_probe_func_t)(uint32_t, struct bio *, 175238366Sgnn struct devstat *); 176238366Sgnnextern dtrace_io_start_probe_func_t dtrace_io_start_probe; 177238366Sgnn 178238366Sgnntypedef void (*dtrace_io_done_probe_func_t)(uint32_t, struct bio *, 179238366Sgnn struct devstat *); 180238366Sgnnextern dtrace_io_done_probe_func_t dtrace_io_done_probe; 181238366Sgnn 182238366Sgnntypedef void (*dtrace_io_wait_start_probe_func_t)(uint32_t, uintptr_t *, 183238366Sgnn struct devstat *); 184238366Sgnnextern dtrace_io_wait_start_probe_func_t dtrace_io_wait_start_probe; 185238366Sgnn 186238366Sgnntypedef void (*dtrace_io_wait_done_probe_func_t)(uint32_t, uintptr_t *, 187238366Sgnn struct devstat *); 188238366Sgnnextern dtrace_io_wait_done_probe_func_t dtrace_io_wait_done_probe; 189238366Sgnn 190179064Sjb/* 191179064Sjb * Functions which allow the dtrace module to check that the kernel 192179064Sjb * hooks have been compiled with sufficient space for it's private 193179064Sjb * structures. 194179064Sjb */ 195179064Sjbsize_t kdtrace_proc_size(void); 196179064Sjbsize_t kdtrace_thread_size(void); 197179064Sjb 198179064Sjb/* 199179064Sjb * OpenSolaris compatible time functions returning nanoseconds. 200179064Sjb * On OpenSolaris these return hrtime_t which we define as uint64_t. 201179064Sjb */ 202179064Sjbuint64_t dtrace_gethrtime(void); 203179064Sjbuint64_t dtrace_gethrestime(void); 204179064Sjb 205179064Sjb#endif /* _SYS_DTRACE_BSD_H */ 206