hwpmc_uncore.h revision 229469
1206089Sfabient/*- 2206089Sfabient * Copyright (c) 2010 Fabien Thomas 3206089Sfabient * All rights reserved. 4206089Sfabient * 5206089Sfabient * Redistribution and use in source and binary forms, with or without 6206089Sfabient * modification, are permitted provided that the following conditions 7206089Sfabient * are met: 8206089Sfabient * 1. Redistributions of source code must retain the above copyright 9206089Sfabient * notice, this list of conditions and the following disclaimer. 10206089Sfabient * 2. Redistributions in binary form must reproduce the above copyright 11206089Sfabient * notice, this list of conditions and the following disclaimer in the 12206089Sfabient * documentation and/or other materials provided with the distribution. 13206089Sfabient * 14206089Sfabient * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15206089Sfabient * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16206089Sfabient * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17206089Sfabient * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18206089Sfabient * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19206089Sfabient * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20206089Sfabient * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21206089Sfabient * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22206089Sfabient * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23206089Sfabient * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24206089Sfabient * SUCH DAMAGE. 25206089Sfabient * 26206089Sfabient * $FreeBSD: head/sys/dev/hwpmc/hwpmc_uncore.h 229469 2012-01-04 07:33:06Z fabient $ 27206089Sfabient */ 28206089Sfabient 29206089Sfabient#ifndef _DEV_HWPMC_UNCORE_H_ 30206089Sfabient#define _DEV_HWPMC_UNCORE_H_ 1 31206089Sfabient 32206089Sfabient/* 33206089Sfabient * Fixed-function PMCs. 34206089Sfabient */ 35206089Sfabientstruct pmc_md_ucf_op_pmcallocate { 36206089Sfabient uint16_t pm_ucf_flags; /* additional flags */ 37206089Sfabient}; 38206089Sfabient 39206089Sfabient#define UCF_EN 0x1 40206089Sfabient#define UCF_PMI 0x4 41206089Sfabient 42206089Sfabient/* 43206089Sfabient * Programmable PMCs. 44206089Sfabient */ 45206089Sfabientstruct pmc_md_ucp_op_pmcallocate { 46206089Sfabient uint32_t pm_ucp_config; 47206089Sfabient}; 48206089Sfabient 49206089Sfabient#define UCP_EVSEL(C) ((C) & 0xFF) 50206089Sfabient#define UCP_UMASK(C) ((C) & 0xFF00) 51206089Sfabient#define UCP_CTRR (1 << 17) 52206089Sfabient#define UCP_EDGE (1 << 18) 53206089Sfabient#define UCP_INT (1 << 20) 54206089Sfabient#define UCP_EN (1 << 22) 55206089Sfabient#define UCP_INV (1 << 23) 56206089Sfabient#define UCP_CMASK(C) (((C) & 0xFF) << 24) 57206089Sfabient 58206089Sfabient#ifdef _KERNEL 59206089Sfabient 60206089Sfabient#define DCTL_FLAG_UNC_PMI (1ULL << 13) 61206089Sfabient 62206089Sfabient/* 63206089Sfabient * Fixed-function counters. 64206089Sfabient */ 65206089Sfabient 66206089Sfabient#define UCF_MASK 0xF 67206089Sfabient 68206089Sfabient#define UCF_CTR0 0x394 69206089Sfabient 70206089Sfabient#define UCF_OFFSET 32 71206089Sfabient#define UCF_CTRL 0x395 72206089Sfabient 73206089Sfabient/* 74206089Sfabient * Programmable counters. 75206089Sfabient */ 76206089Sfabient 77206089Sfabient#define UCP_PMC0 0x3B0 78206089Sfabient#define UCP_EVSEL0 0x3C0 79206089Sfabient#define UCP_OPCODE_MATCH 0x396 80206089Sfabient 81206089Sfabient/* 82206089Sfabient * Simplified programming interface in Intel Performance Architecture 83206089Sfabient * v2 and later. 84206089Sfabient */ 85206089Sfabient 86206089Sfabient#define UC_GLOBAL_STATUS 0x392 87206089Sfabient#define UC_GLOBAL_CTRL 0x391 88206089Sfabient#define UC_GLOBAL_OVF_CTRL 0x393 89206089Sfabient 90229469Sfabient 91206089Sfabient#define UC_GLOBAL_STATUS_FLAG_CLRCHG (1ULL << 63) 92206089Sfabient#define UC_GLOBAL_STATUS_FLAG_OVFPMI (1ULL << 61) 93206089Sfabient#define UC_GLOBAL_CTRL_FLAG_FRZ (1ULL << 63) 94206089Sfabient#define UC_GLOBAL_CTRL_FLAG_ENPMICORE0 (1ULL << 48) 95206089Sfabient 96229469Sfabient/* 97229469Sfabient * Model specific registers. 98229469Sfabient */ 99229469Sfabient 100229469Sfabient#define MSR_GQ_SNOOP_MESF 0x301 101229469Sfabient 102206089Sfabientstruct pmc_md_ucf_pmc { 103206089Sfabient uint64_t pm_ucf_ctrl; 104206089Sfabient}; 105206089Sfabient 106206089Sfabientstruct pmc_md_ucp_pmc { 107206089Sfabient uint32_t pm_ucp_evsel; 108206089Sfabient}; 109206089Sfabient 110206089Sfabient/* 111206089Sfabient * Prototypes. 112206089Sfabient */ 113206089Sfabient 114206089Sfabientint pmc_uncore_initialize(struct pmc_mdep *_md, int _maxcpu); 115206089Sfabientvoid pmc_uncore_finalize(struct pmc_mdep *_md); 116206089Sfabient 117206089Sfabientvoid pmc_uncore_mark_started(int _cpu, int _pmc); 118206089Sfabient 119206089Sfabientint pmc_ucf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width); 120206089Sfabientvoid pmc_ucf_finalize(struct pmc_mdep *_md); 121206089Sfabient 122206089Sfabientint pmc_ucp_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width, 123206089Sfabient int _flags); 124206089Sfabientvoid pmc_ucp_finalize(struct pmc_mdep *_md); 125206089Sfabient 126206089Sfabient#endif /* _KERNEL */ 127206089Sfabient#endif /* _DEV_HWPMC_UNCORE_H */ 128