xref: /freebsd/sys/dev/hwpmc/hwpmc_powerpc.h (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2013 Justin Hibbits
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #ifndef _DEV_HWPMC_POWERPC_H_
32 #define	_DEV_HWPMC_POWERPC_H_ 1
33 
34 #ifdef _KERNEL
35 
36 #define	POWERPC_PMC_CAPS	(PMC_CAP_INTERRUPT | PMC_CAP_USER |     \
37 				 PMC_CAP_SYSTEM | PMC_CAP_EDGE |	\
38 				 PMC_CAP_THRESHOLD | PMC_CAP_READ |	\
39 				 PMC_CAP_WRITE | PMC_CAP_INVERT |	\
40 				 PMC_CAP_QUALIFIER)
41 
42 #define POWERPC_PMC_KERNEL_ENABLE	(0x1 << 30)
43 #define POWERPC_PMC_USER_ENABLE		(0x1 << 31)
44 
45 #define POWERPC_PMC_ENABLE	(POWERPC_PMC_KERNEL_ENABLE | POWERPC_PMC_USER_ENABLE)
46 #define	POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(V)	(0x80000000-(V))
47 #define	POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(P)	(0x80000000-(P))
48 
49 struct powerpc_cpu {
50 	struct pmc_hw   *pc_ppcpmcs;
51 	enum pmc_class	 pc_class;
52 };
53 
54 extern struct powerpc_cpu **powerpc_pcpu;
55 
56 extern int pmc_e500_initialize(struct pmc_mdep *pmc_mdep);
57 extern int pmc_mpc7xxx_initialize(struct pmc_mdep *pmc_mdep);
58 extern int pmc_ppc970_initialize(struct pmc_mdep *pmc_mdep);
59 
60 extern int powerpc_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc);
61 extern int powerpc_get_config(int cpu, int ri, struct pmc **ppm);
62 #endif /* _KERNEL */
63 
64 #endif	/* _DEV_HWPMC_POWERPC_H_ */
65