2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2010 Fabien Thomas
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 #ifndef _DEV_HWPMC_UNCORE_H_
32 #define _DEV_HWPMC_UNCORE_H_ 1
35 * Fixed-function PMCs.
37 struct pmc_md_ucf_op_pmcallocate {
38 uint16_t pm_ucf_flags; /* additional flags */
47 struct pmc_md_ucp_op_pmcallocate {
48 uint32_t pm_ucp_config;
51 #define UCP_EVSEL(C) ((C) & 0xFF)
52 #define UCP_UMASK(C) ((C) & 0xFF00)
53 #define UCP_CTRR (1 << 17)
54 #define UCP_EDGE (1 << 18)
55 #define UCP_INT (1 << 20)
56 #define UCP_EN (1 << 22)
57 #define UCP_INV (1 << 23)
58 #define UCP_CMASK(C) (((C) & 0xFF) << 24)
61 #define DCTL_FLAG_UNC_PMI (1ULL << 13)
64 * Fixed-function counters.
69 #define UCF_CTR0 0x394
72 #define UCF_OFFSET_SB 29
73 #define UCF_CTRL 0x395
76 * Programmable counters.
79 #define UCP_PMC0 0x3B0
80 #define UCP_EVSEL0 0x3C0
81 #define UCP_OPCODE_MATCH 0x396
82 #define UCP_CB0_EVSEL0 0x700
85 * Simplified programming interface in Intel Performance Architecture
89 #define UC_GLOBAL_STATUS 0x392
90 #define UC_GLOBAL_CTRL 0x391
91 #define UC_GLOBAL_OVF_CTRL 0x393
93 #define UC_GLOBAL_STATUS_FLAG_CLRCHG (1ULL << 63)
94 #define UC_GLOBAL_STATUS_FLAG_OVFPMI (1ULL << 61)
95 #define UC_GLOBAL_CTRL_FLAG_FRZ (1ULL << 63)
96 #define UC_GLOBAL_CTRL_FLAG_ENPMICORE0 (1ULL << 48)
99 * Model specific registers.
102 #define MSR_GQ_SNOOP_MESF 0x301
104 struct pmc_md_ucf_pmc {
105 uint64_t pm_ucf_ctrl;
108 struct pmc_md_ucp_pmc {
109 uint32_t pm_ucp_evsel;
116 int pmc_uncore_initialize(struct pmc_mdep *_md, int _maxcpu);
117 void pmc_uncore_finalize(struct pmc_mdep *_md);
119 int pmc_ucf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width);
120 void pmc_ucf_finalize(struct pmc_mdep *_md);
122 int pmc_ucp_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width,
124 void pmc_ucp_finalize(struct pmc_mdep *_md);
127 #endif /* _DEV_HWPMC_UNCORE_H */