2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2005, Joseph Koshy
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
31 /* Machine dependent interfaces */
33 #ifndef _DEV_HWPMC_PPRO_H_
34 #define _DEV_HWPMC_PPRO_H_
36 /* Intel PPro, Celeron, P-II, P-III, Pentium-M PMCS */
38 #define P6_NPMCS 2 /* 2 PMCs */
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)
54 #define P6_MSR_EVSEL0 0x0186
55 #define P6_MSR_EVSEL1 0x0187
56 #define P6_MSR_PERFCTR0 0x00C1
57 #define P6_MSR_PERFCTR1 0x00C2
59 #define P6_PERFCTR_READ_MASK 0xFFFFFFFFFFLL /* 40 bits */
60 #define P6_PERFCTR_WRITE_MASK 0xFFFFFFFFU /* 32 bits */
62 #define P6_RELOAD_COUNT_TO_PERFCTR_VALUE(R) (-(R))
63 #define P6_PERFCTR_VALUE_TO_RELOAD_COUNT(P) (-(P))
65 #define P6_PMC_HAS_OVERFLOWED(P) ((rdpmc(P) & (1LL << 39)) == 0)
67 struct pmc_md_ppro_op_pmcallocate {
68 uint32_t pm_ppro_config;
73 /* MD extension for 'struct pmc' */
74 struct pmc_md_ppro_pmc {
75 uint32_t pm_ppro_evsel;
82 int pmc_p6_initialize(struct pmc_mdep *_md, int _ncpus);
83 void pmc_p6_finalize(struct pmc_mdep *_md);
86 #endif /* _DEV_HWPMC_PPRO_H_ */