Home | History | Annotate | Line # | Download | only in kern
kern_sdt.c revision 1.1
      1  1.1  darran /*	$NetBSD: kern_sdt.c,v 1.1 2010/03/01 21:10:17 darran Exp $	*/
      2  1.1  darran 
      3  1.1  darran /*-
      4  1.1  darran  * Copyright (c) 2010 The NetBSD Foundation, Inc.
      5  1.1  darran  * All rights reserved.
      6  1.1  darran  *
      7  1.1  darran  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  darran  * by CoyotePoint Systems, Inc. It was developed under contract to
      9  1.1  darran  * CoyotePoint by Darran Hunt.
     10  1.1  darran  *
     11  1.1  darran  * Redistribution and use in source and binary forms, with or without
     12  1.1  darran  * modification, are permitted provided that the following conditions
     13  1.1  darran  * are met:
     14  1.1  darran  * 1. Redistributions of source code must retain the above copyright
     15  1.1  darran  *    notice, this list of conditions and the following disclaimer.
     16  1.1  darran  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  darran  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  darran  *    documentation and/or other materials provided with the distribution.
     19  1.1  darran  *
     20  1.1  darran  *
     21  1.1  darran  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     22  1.1  darran  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23  1.1  darran  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24  1.1  darran  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     25  1.1  darran  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  1.1  darran  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  1.1  darran  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  1.1  darran  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.1  darran  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  1.1  darran  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31  1.1  darran  * POSSIBILITY OF SUCH DAMAGE.
     32  1.1  darran  */
     33  1.1  darran 
     34  1.1  darran /*-
     35  1.1  darran  * Copyright 2006-2008 John Birrell <jb (at) FreeBSD.org>
     36  1.1  darran  *
     37  1.1  darran  * Redistribution and use in source and binary forms, with or without
     38  1.1  darran  * modification, are permitted provided that the following conditions
     39  1.1  darran  * are met:
     40  1.1  darran  * 1. Redistributions of source code must retain the above copyright
     41  1.1  darran  *    notice, this list of conditions and the following disclaimer.
     42  1.1  darran  * 2. Redistributions in binary form must reproduce the above copyright
     43  1.1  darran  *    notice, this list of conditions and the following disclaimer in the
     44  1.1  darran  *    documentation and/or other materials provided with the distribution.
     45  1.1  darran  *
     46  1.1  darran  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     47  1.1  darran  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     48  1.1  darran  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     49  1.1  darran  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
     50  1.1  darran  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     51  1.1  darran  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     52  1.1  darran  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     53  1.1  darran  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     54  1.1  darran  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     55  1.1  darran  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     56  1.1  darran  * SUCH DAMAGE.
     57  1.1  darran  *
     58  1.1  darran  * $FreeBSD: src/sys/kern/kern_sdt.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $
     59  1.1  darran  *
     60  1.1  darran  * Backend for the Statically Defined Tracing (SDT) kernel support. This is
     61  1.1  darran  * required to allow a module to load even though DTrace kernel support may
     62  1.1  darran  * not be present. A module may be built with SDT probes in it.
     63  1.1  darran  *
     64  1.1  darran  */
     65  1.1  darran 
     66  1.1  darran #include <sys/cdefs.h>
     67  1.1  darran #include <sys/param.h>
     68  1.1  darran #include <sys/systm.h>
     69  1.1  darran #include <sys/sdt.h>
     70  1.1  darran 
     71  1.1  darran void sdt_probe_stub(u_int32_t, uintptr_t, uintptr_t,
     72  1.1  darran 	uintptr_t, uintptr_t, uintptr_t);
     73  1.1  darran 
     74  1.1  darran /*
     75  1.1  darran  * Hook for the DTrace probe function. The 'sdt' provider will set this
     76  1.1  darran  * to dtrace_probe when it loads.
     77  1.1  darran  */
     78  1.1  darran sdt_probe_func_t sdt_probe_func = sdt_probe_stub;
     79  1.1  darran 
     80  1.1  darran /*
     81  1.1  darran  * This is a stub for probe calls in case kernel DTrace support isn't
     82  1.1  darran  * compiled in. It should never get called because there is no DTrace
     83  1.1  darran  * support to enable it.
     84  1.1  darran  */
     85  1.1  darran void
     86  1.1  darran sdt_probe_stub(u_int32_t id, uintptr_t arg0, uintptr_t arg1,
     87  1.1  darran     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
     88  1.1  darran {
     89  1.1  darran 	printf("%s: XXX should not be called\n", __func__);
     90  1.1  darran }
     91  1.1  darran 
     92  1.1  darran /*
     93  1.1  darran  * initialize the SDT dtrace probe function
     94  1.1  darran  */
     95  1.1  darran void
     96  1.1  darran sdt_init(void *dtrace_probe)
     97  1.1  darran {
     98  1.1  darran 
     99  1.1  darran 	sdt_probe_func = dtrace_probe;
    100  1.1  darran }
    101  1.1  darran 
    102  1.1  darran /*
    103  1.1  darran  * Disable the SDT dtrace probe function
    104  1.1  darran  */
    105  1.1  darran void
    106  1.1  darran sdt_exit(void)
    107  1.1  darran {
    108  1.1  darran 
    109  1.1  darran 	sdt_probe_func = sdt_probe_stub;
    110  1.1  darran }
    111