1147191Sjkoshy/*-
2147191Sjkoshy * Copyright (c) 2005, Joseph Koshy
3147191Sjkoshy * All rights reserved.
4147191Sjkoshy *
5147191Sjkoshy * Redistribution and use in source and binary forms, with or without
6147191Sjkoshy * modification, are permitted provided that the following conditions
7147191Sjkoshy * are met:
8147191Sjkoshy * 1. Redistributions of source code must retain the above copyright
9147191Sjkoshy *    notice, this list of conditions and the following disclaimer.
10147191Sjkoshy * 2. Redistributions in binary form must reproduce the above copyright
11147191Sjkoshy *    notice, this list of conditions and the following disclaimer in the
12147191Sjkoshy *    documentation and/or other materials provided with the distribution.
13147191Sjkoshy *
14147191Sjkoshy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15147191Sjkoshy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16147191Sjkoshy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17147191Sjkoshy * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18147191Sjkoshy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19147191Sjkoshy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20147191Sjkoshy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21147191Sjkoshy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22147191Sjkoshy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23147191Sjkoshy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24147191Sjkoshy * SUCH DAMAGE.
25147191Sjkoshy *
26147191Sjkoshy * $FreeBSD$
27147191Sjkoshy */
28147191Sjkoshy
29147191Sjkoshy/* Machine dependent interfaces */
30147191Sjkoshy
31147191Sjkoshy#ifndef _DEV_HWPMC_PPRO_H_
32147191Sjkoshy#define	_DEV_HWPMC_PPRO_H_
33147191Sjkoshy
34147191Sjkoshy/* Intel PPro, Celeron, P-II, P-III, Pentium-M PMCS */
35147191Sjkoshy
36184802Sjkoshy#define	P6_NPMCS	2		/* 2 PMCs */
37147191Sjkoshy
38147191Sjkoshy#define	P6_EVSEL_CMASK_MASK		0xFF000000
39147191Sjkoshy#define	P6_EVSEL_TO_CMASK(C)		(((C) & 0xFF) << 24)
40147191Sjkoshy#define	P6_EVSEL_INV			(1 << 23)
41147191Sjkoshy#define	P6_EVSEL_EN			(1 << 22)
42147191Sjkoshy#define	P6_EVSEL_INT			(1 << 20)
43147191Sjkoshy#define	P6_EVSEL_PC			(1 << 19)
44147191Sjkoshy#define	P6_EVSEL_E			(1 << 18)
45147191Sjkoshy#define	P6_EVSEL_OS			(1 << 17)
46147191Sjkoshy#define	P6_EVSEL_USR			(1 << 16)
47147191Sjkoshy#define	P6_EVSEL_UMASK_MASK		0x0000FF00
48147191Sjkoshy#define	P6_EVSEL_TO_UMASK(U)		(((U) & 0xFF) << 8)
49147191Sjkoshy#define	P6_EVSEL_EVENT_SELECT(ES)	((ES) & 0xFF)
50147191Sjkoshy#define	P6_EVSEL_RESERVED		(1 << 21)
51147191Sjkoshy
52147191Sjkoshy#define	P6_MSR_EVSEL0			0x0186
53147191Sjkoshy#define	P6_MSR_EVSEL1			0x0187
54147191Sjkoshy#define	P6_MSR_PERFCTR0			0x00C1
55147191Sjkoshy#define	P6_MSR_PERFCTR1			0x00C2
56147191Sjkoshy
57147191Sjkoshy#define	P6_PERFCTR_READ_MASK		0xFFFFFFFFFFLL	/* 40 bits */
58147191Sjkoshy#define	P6_PERFCTR_WRITE_MASK		0xFFFFFFFFU	/* 32 bits */
59147191Sjkoshy
60147191Sjkoshy#define	P6_RELOAD_COUNT_TO_PERFCTR_VALUE(R)	(-(R))
61147191Sjkoshy#define	P6_PERFCTR_VALUE_TO_RELOAD_COUNT(P)	(-(P))
62147191Sjkoshy
63147191Sjkoshy#define	P6_PMC_HAS_OVERFLOWED(P)	((rdpmc(P) & (1LL << 39)) == 0)
64147191Sjkoshy
65147191Sjkoshystruct pmc_md_ppro_op_pmcallocate {
66147191Sjkoshy	uint32_t	pm_ppro_config;
67147191Sjkoshy};
68147191Sjkoshy
69147191Sjkoshy#ifdef _KERNEL
70147191Sjkoshy
71147191Sjkoshy/* MD extension for 'struct pmc' */
72147191Sjkoshystruct pmc_md_ppro_pmc {
73147191Sjkoshy	uint32_t	pm_ppro_evsel;
74147191Sjkoshy};
75147191Sjkoshy
76147191Sjkoshy/*
77147191Sjkoshy * Prototypes
78147191Sjkoshy */
79147191Sjkoshy
80184802Sjkoshyint	pmc_p6_initialize(struct pmc_mdep *_md, int _ncpus);
81184802Sjkoshyvoid	pmc_p6_finalize(struct pmc_mdep *_md);
82147191Sjkoshy
83147191Sjkoshy#endif /* _KERNEL */
84147191Sjkoshy#endif /* _DEV_HWPMC_PPRO_H_ */
85