xref: /minix3/sys/arch/i386/include/pmc.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: pmc.h,v 1.8 2007/04/16 19:12:18 ad Exp $	*/
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc /*-
4*0a6a1f1dSLionel Sambuc  * Copyright (c) 2000 Zembu Labs, Inc.
5*0a6a1f1dSLionel Sambuc  * All rights reserved.
6*0a6a1f1dSLionel Sambuc  *
7*0a6a1f1dSLionel Sambuc  * Author: Jason R. Thorpe <thorpej@zembu.com>
8*0a6a1f1dSLionel Sambuc  *
9*0a6a1f1dSLionel Sambuc  * Redistribution and use in source and binary forms, with or without
10*0a6a1f1dSLionel Sambuc  * modification, are permitted provided that the following conditions
11*0a6a1f1dSLionel Sambuc  * are met:
12*0a6a1f1dSLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
13*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
14*0a6a1f1dSLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
15*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
16*0a6a1f1dSLionel Sambuc  *    documentation and/or other materials provided with the distribution.
17*0a6a1f1dSLionel Sambuc  * 3. All advertising materials mentioning features or use of this software
18*0a6a1f1dSLionel Sambuc  *    must display the following acknowledgement:
19*0a6a1f1dSLionel Sambuc  *	This product includes software developed by Zembu Labs, Inc.
20*0a6a1f1dSLionel Sambuc  * 4. Neither the name of Zembu Labs nor the names of its employees may
21*0a6a1f1dSLionel Sambuc  *    be used to endorse or promote products derived from this software
22*0a6a1f1dSLionel Sambuc  *    without specific prior written permission.
23*0a6a1f1dSLionel Sambuc  *
24*0a6a1f1dSLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS
25*0a6a1f1dSLionel Sambuc  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
26*0a6a1f1dSLionel Sambuc  * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
27*0a6a1f1dSLionel Sambuc  * CLAIMED.  IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
28*0a6a1f1dSLionel Sambuc  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29*0a6a1f1dSLionel Sambuc  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30*0a6a1f1dSLionel Sambuc  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31*0a6a1f1dSLionel Sambuc  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32*0a6a1f1dSLionel Sambuc  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33*0a6a1f1dSLionel Sambuc  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*0a6a1f1dSLionel Sambuc  */
35*0a6a1f1dSLionel Sambuc 
36*0a6a1f1dSLionel Sambuc #ifndef _I386_PMC_H_
37*0a6a1f1dSLionel Sambuc #define	_I386_PMC_H_
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc #define	PMC_CLASS_I586		0x10000		/* i586-compatible */
40*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_I586_TSC	0x10001		/* cycle counter */
41*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_I586_PMCx	0x10002		/* performance counter */
42*0a6a1f1dSLionel Sambuc 
43*0a6a1f1dSLionel Sambuc #define	PMC_CLASS_I686		0x20000		/* i686-compatible */
44*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_I686_TSC	0x20001		/* cycle counter */
45*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_I686_PMCx	0x20002		/* performance counter */
46*0a6a1f1dSLionel Sambuc 
47*0a6a1f1dSLionel Sambuc #define	PMC_CLASS_K7		0x30000		/* K7-compatible */
48*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_K7_TSC		0x30001		/* cycle counter */
49*0a6a1f1dSLionel Sambuc #define	PMC_TYPE_K7_PMCx	0x30002		/* performance counter */
50*0a6a1f1dSLionel Sambuc 
51*0a6a1f1dSLionel Sambuc /*
52*0a6a1f1dSLionel Sambuc  * Each PMC event on the x86 is associated with a processor unit.  We
53*0a6a1f1dSLionel Sambuc  * encode the unit in the upper 16 bits of the event ID.
54*0a6a1f1dSLionel Sambuc  */
55*0a6a1f1dSLionel Sambuc #define	__PMC_EVID_EVENT_MASK	0x0000ffff
56*0a6a1f1dSLionel Sambuc #define	__PMC_EVID_UNIT_MASK	0xffff0000
57*0a6a1f1dSLionel Sambuc 
58*0a6a1f1dSLionel Sambuc #define	__PMC_UNIT(x)		((x) << 16)
59*0a6a1f1dSLionel Sambuc #define	__PMC_GET_UNIT(x)	(((x) & __PMC_EVID_UNIT_MASK) >> 16)
60*0a6a1f1dSLionel Sambuc #define	__PMC_GET_EVENT(x)	((x) & __PMC_EVID_EVENT_MASK)
61*0a6a1f1dSLionel Sambuc 
62*0a6a1f1dSLionel Sambuc #if defined(_KERNEL)
63*0a6a1f1dSLionel Sambuc /*
64*0a6a1f1dSLionel Sambuc  * LEGACY PMC support
65*0a6a1f1dSLionel Sambuc  */
66*0a6a1f1dSLionel Sambuc struct x86_pmc_info_args;
67*0a6a1f1dSLionel Sambuc struct x86_pmc_startstop_args;
68*0a6a1f1dSLionel Sambuc struct x86_pmc_read_args;
69*0a6a1f1dSLionel Sambuc int	pmc_info(struct lwp *, struct x86_pmc_info_args *,
70*0a6a1f1dSLionel Sambuc 	    register_t *);
71*0a6a1f1dSLionel Sambuc int	pmc_startstop(struct lwp *, struct x86_pmc_startstop_args *,
72*0a6a1f1dSLionel Sambuc 	    register_t *);
73*0a6a1f1dSLionel Sambuc int	pmc_read(struct lwp *, struct x86_pmc_read_args *,
74*0a6a1f1dSLionel Sambuc 	    register_t *);
75*0a6a1f1dSLionel Sambuc /* END LEGACY PMC SUPPORT */
76*0a6a1f1dSLionel Sambuc 
77*0a6a1f1dSLionel Sambuc #define pmc_md_fork(p1,p2)
78*0a6a1f1dSLionel Sambuc #define pmc_get_num_counters()			(0)
79*0a6a1f1dSLionel Sambuc #define pmc_get_counter_type(c)			(0)
80*0a6a1f1dSLionel Sambuc #define pmc_save_context(p)
81*0a6a1f1dSLionel Sambuc #define pmc_restore_context(p)
82*0a6a1f1dSLionel Sambuc #define pmc_enable_counter(p,c)
83*0a6a1f1dSLionel Sambuc #define pmc_disable_counter(p,c)
84*0a6a1f1dSLionel Sambuc #define pmc_accumulate(p1,p2)
85*0a6a1f1dSLionel Sambuc #define pmc_process_exit(p1)
86*0a6a1f1dSLionel Sambuc #define pmc_counter_isconfigured(p,c)		(0)
87*0a6a1f1dSLionel Sambuc #define pmc_counter_isrunning(p,c)		(0)
88*0a6a1f1dSLionel Sambuc #define pmc_start_profiling(c,f)		(0)
89*0a6a1f1dSLionel Sambuc #define pmc_stop_profiling(c)			(0)
90*0a6a1f1dSLionel Sambuc #define pmc_alloc_kernel_counter(c,f)		(0)
91*0a6a1f1dSLionel Sambuc #define pmc_free_kernel_counter(c)		(0)
92*0a6a1f1dSLionel Sambuc #define pmc_configure_counter(p,c,f)		(0)
93*0a6a1f1dSLionel Sambuc #define pmc_get_counter_value(p,c,f,pv)		(0)
94*0a6a1f1dSLionel Sambuc 
95*0a6a1f1dSLionel Sambuc #define PMC_ENABLED(p)		(0)
96*0a6a1f1dSLionel Sambuc 
97*0a6a1f1dSLionel Sambuc #endif /* _KERNEL */
98*0a6a1f1dSLionel Sambuc 
99*0a6a1f1dSLionel Sambuc #endif /* _I386_PMC_H_ */
100