xref: /freebsd/sys/cddl/dev/fbt/fbt.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  *
21  * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
22  *
23  */
24 
25 /*
26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #ifndef _FBT_H_
31 #define _FBT_H_
32 
33 #include "fbt_isa.h"
34 
35 #define	FBT_ENTRY	"entry"
36 #define	FBT_RETURN	"return"
37 
38 /*
39  * fbt_probe is a bit of a misnomer.  One of these structures is created for
40  * each trace point of an FBT probe.  A probe might have multiple trace points
41  * (e.g., a function with multiple return instructions), and different probes
42  * might have a trace point at the same address (e.g., GNU ifuncs).
43  */
44 typedef struct fbt_probe {
45 	struct fbt_probe *fbtp_hashnext;	/* global hash table linkage */
46 	struct fbt_probe *fbtp_tracenext;	/* next probe for tracepoint */
47 	struct fbt_probe *fbtp_probenext;	/* next tracepoint for probe */
48 	int		fbtp_enabled;
49 	fbt_patchval_t  *fbtp_patchpoint;
50 	int8_t		fbtp_rval;
51 	fbt_patchval_t	fbtp_patchval;
52 	fbt_patchval_t	fbtp_savedval;
53 	uintptr_t	fbtp_roffset;
54 	dtrace_id_t	fbtp_id;
55 	const char	*fbtp_name;
56 	modctl_t	*fbtp_ctl;
57 	int		fbtp_loadcnt;
58 	int		fbtp_symindx;
59 } fbt_probe_t;
60 
61 struct linker_file;
62 struct linker_symval;
63 struct trapframe;
64 
65 int	fbt_invop(uintptr_t, struct trapframe *, uintptr_t);
66 void	fbt_patch_tracepoint(fbt_probe_t *, fbt_patchval_t);
67 int	fbt_provide_module_function(struct linker_file *, int,
68 	    struct linker_symval *, void *);
69 int	fbt_excluded(const char *name);
70 
71 extern dtrace_provider_id_t	fbt_id;
72 extern fbt_probe_t		**fbt_probetab;
73 extern int			fbt_probetab_mask;
74 
75 #define	FBT_ADDR2NDX(addr)	((((uintptr_t)(addr)) >> 4) & fbt_probetab_mask)
76 #define	FBT_PROBETAB_SIZE	0x8000		/* 32k entries -- 128K total */
77 
78 #ifdef MALLOC_DECLARE
79 MALLOC_DECLARE(M_FBT);
80 #endif
81 
82 #endif
83