]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/hwpmc/hwpmc_ppro.h
Increase the number of fdt memory regions we support to 16. Some SoCs have
[FreeBSD/FreeBSD.git] / sys / dev / hwpmc / hwpmc_ppro.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2005, Joseph Koshy
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 /* Machine dependent interfaces */
32
33 #ifndef _DEV_HWPMC_PPRO_H_
34 #define _DEV_HWPMC_PPRO_H_
35
36 /* Intel PPro, Celeron, P-II, P-III, Pentium-M PMCS */
37
38 #define P6_NPMCS        2               /* 2 PMCs */
39
40 #define P6_EVSEL_CMASK_MASK             0xFF000000
41 #define P6_EVSEL_TO_CMASK(C)            (((C) & 0xFF) << 24)
42 #define P6_EVSEL_INV                    (1 << 23)
43 #define P6_EVSEL_EN                     (1 << 22)
44 #define P6_EVSEL_INT                    (1 << 20)
45 #define P6_EVSEL_PC                     (1 << 19)
46 #define P6_EVSEL_E                      (1 << 18)
47 #define P6_EVSEL_OS                     (1 << 17)
48 #define P6_EVSEL_USR                    (1 << 16)
49 #define P6_EVSEL_UMASK_MASK             0x0000FF00
50 #define P6_EVSEL_TO_UMASK(U)            (((U) & 0xFF) << 8)
51 #define P6_EVSEL_EVENT_SELECT(ES)       ((ES) & 0xFF)
52 #define P6_EVSEL_RESERVED               (1 << 21)
53
54 #define P6_MSR_EVSEL0                   0x0186
55 #define P6_MSR_EVSEL1                   0x0187
56 #define P6_MSR_PERFCTR0                 0x00C1
57 #define P6_MSR_PERFCTR1                 0x00C2
58
59 #define P6_PERFCTR_READ_MASK            0xFFFFFFFFFFLL  /* 40 bits */
60 #define P6_PERFCTR_WRITE_MASK           0xFFFFFFFFU     /* 32 bits */
61
62 #define P6_RELOAD_COUNT_TO_PERFCTR_VALUE(R)     (-(R))
63 #define P6_PERFCTR_VALUE_TO_RELOAD_COUNT(P)     (-(P))
64
65 #define P6_PMC_HAS_OVERFLOWED(P)        ((rdpmc(P) & (1LL << 39)) == 0)
66
67 struct pmc_md_ppro_op_pmcallocate {
68         uint32_t        pm_ppro_config;
69 };
70
71 #ifdef _KERNEL
72
73 /* MD extension for 'struct pmc' */
74 struct pmc_md_ppro_pmc {
75         uint32_t        pm_ppro_evsel;
76 };
77
78 /*
79  * Prototypes
80  */
81
82 int     pmc_p6_initialize(struct pmc_mdep *_md, int _ncpus);
83 void    pmc_p6_finalize(struct pmc_mdep *_md);
84
85 #endif /* _KERNEL */
86 #endif /* _DEV_HWPMC_PPRO_H_ */