1 /*- 2 * Copyright (c) 2003, Joseph Koshy 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 /* Machine dependent interfaces */ 30 31 #ifndef _MACHINE_PMC_MDEP_H 32 #define _MACHINE_PMC_MDEP_H 1 33 34 #include <machine/specialreg.h> 35 36 /* AMD K7 PMCs */ 37 38 #define K8_NPMCS 5 /* 1 TSC + 4 PMCs */ 39 40 #define K8_PMC_COUNTERMASK 0xFF000000 41 #define K8_PMC_TO_COUNTER(x) (((x) << 24) & K8_PMC_COUNTERMASK) 42 #define K8_PMC_INVERT (1 << 23) 43 #define K8_PMC_ENABLE (1 << 22) 44 #define K8_PMC_INT (1 << 20) 45 #define K8_PMC_PC (1 << 19) 46 #define K8_PMC_EDGE (1 << 18) 47 #define K8_PMC_OS (1 << 17) 48 #define K8_PMC_USR (1 << 16) 49 50 #define K8_PMC_UNITMASK_M 0x10 51 #define K8_PMC_UNITMASK_O 0x08 52 #define K8_PMC_UNITMASK_E 0x04 53 #define K8_PMC_UNITMASK_S 0x02 54 #define K8_PMC_UNITMASK_I 0x01 55 #define K8_PMC_UNITMASK_MOESI 0x1F 56 57 #define K8_PMC_UNITMASK 0xFF00 58 #define K8_PMC_EVENTMASK 0x00FF 59 #define K8_PMC_TO_UNITMASK(x) (((x) << 8) & K8_PMC_UNITMASK) 60 #define K8_PMC_TO_EVENTMASK(x) ((x) & 0xFF) 61 #define K8_VALID_BITS (K8_PMC_COUNTERMASK | K8_PMC_INVERT | \ 62 K8_PMC_ENABLE | K8_PMC_INT | K8_PMC_PC | K8_PMC_EDGE | K8_PMC_OS | \ 63 K8_PMC_USR | K8_PMC_UNITMASK | K8_PMC_EVENTMASK) 64 65 #ifdef _KERNEL 66 67 /* 68 * Prototypes 69 */ 70 71 #if defined(__amd64__) 72 struct pmc_mdep *pmc_amd_initialize(void); 73 #endif /* defined(__i386__) */ 74 75 #endif /* _KERNEL */ 76 #endif /* _MACHINE_PMC_MDEP_H */ 77