xref: /freebsd/sys/cddl/dev/fbt/fbt.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1266b4a78SMark Johnston /*
2266b4a78SMark Johnston  * CDDL HEADER START
3266b4a78SMark Johnston  *
4266b4a78SMark Johnston  * The contents of this file are subject to the terms of the
5266b4a78SMark Johnston  * Common Development and Distribution License (the "License").
6266b4a78SMark Johnston  * You may not use this file except in compliance with the License.
7266b4a78SMark Johnston  *
8266b4a78SMark Johnston  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9266b4a78SMark Johnston  * or http://www.opensolaris.org/os/licensing.
10266b4a78SMark Johnston  * See the License for the specific language governing permissions
11266b4a78SMark Johnston  * and limitations under the License.
12266b4a78SMark Johnston  *
13266b4a78SMark Johnston  * When distributing Covered Code, include this CDDL HEADER in each
14266b4a78SMark Johnston  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15266b4a78SMark Johnston  * If applicable, add the following below this CDDL HEADER, with the
16266b4a78SMark Johnston  * fields enclosed by brackets "[]" replaced with your own identifying
17266b4a78SMark Johnston  * information: Portions Copyright [yyyy] [name of copyright owner]
18266b4a78SMark Johnston  *
19266b4a78SMark Johnston  * CDDL HEADER END
20266b4a78SMark Johnston  *
21266b4a78SMark Johnston  * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
22266b4a78SMark Johnston  *
23266b4a78SMark Johnston  */
24266b4a78SMark Johnston 
25266b4a78SMark Johnston /*
26266b4a78SMark Johnston  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27266b4a78SMark Johnston  * Use is subject to license terms.
28266b4a78SMark Johnston  */
29266b4a78SMark Johnston 
30266b4a78SMark Johnston #ifndef _FBT_H_
31266b4a78SMark Johnston #define _FBT_H_
32266b4a78SMark Johnston 
33266b4a78SMark Johnston #include "fbt_isa.h"
34266b4a78SMark Johnston 
35*aad16850SChristos Margiolis #define	FBT_ENTRY	"entry"
36*aad16850SChristos Margiolis #define	FBT_RETURN	"return"
37*aad16850SChristos Margiolis 
38c208cb99SMark Johnston /*
39c208cb99SMark Johnston  * fbt_probe is a bit of a misnomer.  One of these structures is created for
40c208cb99SMark Johnston  * each trace point of an FBT probe.  A probe might have multiple trace points
41c208cb99SMark Johnston  * (e.g., a function with multiple return instructions), and different probes
42c208cb99SMark Johnston  * might have a trace point at the same address (e.g., GNU ifuncs).
43c208cb99SMark Johnston  */
44266b4a78SMark Johnston typedef struct fbt_probe {
45c208cb99SMark Johnston 	struct fbt_probe *fbtp_hashnext;	/* global hash table linkage */
46c208cb99SMark Johnston 	struct fbt_probe *fbtp_tracenext;	/* next probe for tracepoint */
47c208cb99SMark Johnston 	struct fbt_probe *fbtp_probenext;	/* next tracepoint for probe */
48c208cb99SMark Johnston 	int		fbtp_enabled;
49266b4a78SMark Johnston 	fbt_patchval_t  *fbtp_patchpoint;
50266b4a78SMark Johnston 	int8_t		fbtp_rval;
51266b4a78SMark Johnston 	fbt_patchval_t	fbtp_patchval;
52266b4a78SMark Johnston 	fbt_patchval_t	fbtp_savedval;
53266b4a78SMark Johnston 	uintptr_t	fbtp_roffset;
54266b4a78SMark Johnston 	dtrace_id_t	fbtp_id;
55266b4a78SMark Johnston 	const char	*fbtp_name;
56266b4a78SMark Johnston 	modctl_t	*fbtp_ctl;
57266b4a78SMark Johnston 	int		fbtp_loadcnt;
58266b4a78SMark Johnston 	int		fbtp_symindx;
59266b4a78SMark Johnston } fbt_probe_t;
60266b4a78SMark Johnston 
61266b4a78SMark Johnston struct linker_file;
62266b4a78SMark Johnston struct linker_symval;
636c280659SMark Johnston struct trapframe;
64266b4a78SMark Johnston 
656c280659SMark Johnston int	fbt_invop(uintptr_t, struct trapframe *, uintptr_t);
66266b4a78SMark Johnston void	fbt_patch_tracepoint(fbt_probe_t *, fbt_patchval_t);
67266b4a78SMark Johnston int	fbt_provide_module_function(struct linker_file *, int,
68266b4a78SMark Johnston 	    struct linker_symval *, void *);
690ff41755SRuslan Bukin int	fbt_excluded(const char *name);
70266b4a78SMark Johnston 
71266b4a78SMark Johnston extern dtrace_provider_id_t	fbt_id;
72266b4a78SMark Johnston extern fbt_probe_t		**fbt_probetab;
73266b4a78SMark Johnston extern int			fbt_probetab_mask;
74266b4a78SMark Johnston 
75266b4a78SMark Johnston #define	FBT_ADDR2NDX(addr)	((((uintptr_t)(addr)) >> 4) & fbt_probetab_mask)
76266b4a78SMark Johnston #define	FBT_PROBETAB_SIZE	0x8000		/* 32k entries -- 128K total */
77266b4a78SMark Johnston 
78266b4a78SMark Johnston #ifdef MALLOC_DECLARE
79266b4a78SMark Johnston MALLOC_DECLARE(M_FBT);
80266b4a78SMark Johnston #endif
81266b4a78SMark Johnston 
82266b4a78SMark Johnston #endif
83