Deleted Added
full compact
pmc_mdep.h (183033) pmc_mdep.h (184802)
1/*-
2 * Copyright (c) 2003-2008 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
1/*-
2 * Copyright (c) 2003-2008 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sys/amd64/include/pmc_mdep.h 183033 2008-09-15 06:47:52Z jkoshy $
30 * $FreeBSD: head/sys/amd64/include/pmc_mdep.h 184802 2008-11-09 17:37:54Z jkoshy $
31 */
32
33/* Machine dependent interfaces */
34
35#ifndef _MACHINE_PMC_MDEP_H
36#define _MACHINE_PMC_MDEP_H 1
37
31 */
32
33/* Machine dependent interfaces */
34
35#ifndef _MACHINE_PMC_MDEP_H
36#define _MACHINE_PMC_MDEP_H 1
37
38#ifdef _KERNEL
39struct pmc_mdep;
40#endif
41
38#include <dev/hwpmc/hwpmc_amd.h>
39#include <dev/hwpmc/hwpmc_piv.h>
42#include <dev/hwpmc/hwpmc_amd.h>
43#include <dev/hwpmc/hwpmc_piv.h>
44#include <dev/hwpmc/hwpmc_tsc.h>
40
45
46/*
47 * Intel processors implementing V2 and later of the Intel performance
48 * measurement architecture have PMCs of the following classes: TSC,
49 * IAF and IAP.
50 */
51#define PMC_MDEP_CLASS_INDEX_TSC 0
52#define PMC_MDEP_CLASS_INDEX_K8 1
53#define PMC_MDEP_CLASS_INDEX_P4 1
54#define PMC_MDEP_CLASS_INDEX_IAF 1
55#define PMC_MDEP_CLASS_INDEX_IAP 2
56
57/*
58 * On the amd64 platform we support the following PMCs.
59 *
60 * TSC The timestamp counter
61 * K8 AMD Athlon64 and Opteron PMCs in 64 bit mode.
62 * PIV Intel P4/HTT and P4/EMT64
63 * IAP Intel Core/Core2/Atom CPUs in 64 bits mode.
64 * IAF Intel fixed-function PMCs in Core2 and later CPUs.
65 */
66
41union pmc_md_op_pmcallocate {
42 struct pmc_md_amd_op_pmcallocate pm_amd;
43 struct pmc_md_p4_op_pmcallocate pm_p4;
44 uint64_t __pad[4];
45};
46
47/* Logging */
48#define PMCLOG_READADDR PMCLOG_READ64
49#define PMCLOG_EMITADDR PMCLOG_EMIT64
50
51#ifdef _KERNEL
52
53union pmc_md_pmc {
54 struct pmc_md_amd_pmc pm_amd;
55 struct pmc_md_p4_pmc pm_p4;
56};
57
67union pmc_md_op_pmcallocate {
68 struct pmc_md_amd_op_pmcallocate pm_amd;
69 struct pmc_md_p4_op_pmcallocate pm_p4;
70 uint64_t __pad[4];
71};
72
73/* Logging */
74#define PMCLOG_READADDR PMCLOG_READ64
75#define PMCLOG_EMITADDR PMCLOG_EMIT64
76
77#ifdef _KERNEL
78
79union pmc_md_pmc {
80 struct pmc_md_amd_pmc pm_amd;
81 struct pmc_md_p4_pmc pm_p4;
82};
83
58struct pmc;
59
60#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_rip)
61#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_rbp)
62#define PMC_TRAPFRAME_TO_USER_SP(TF) ((TF)->tf_rsp)
63#define PMC_TRAPFRAME_TO_KERNEL_SP(TF) ((TF)->tf_rsp)
64
65#define PMC_AT_FUNCTION_PROLOGUE_PUSH_BP(I) \
66 (((I) & 0xffffffff) == 0xe5894855) /* pushq %rbp; movq %rsp,%rbp */
67#define PMC_AT_FUNCTION_PROLOGUE_MOV_SP_BP(I) \

--- 15 unchanged lines hidden (view full) ---

83
84/*
85 * Prototypes
86 */
87
88void start_exceptions(void), end_exceptions(void);
89void pmc_x86_lapic_enable_pmc_interrupt(void);
90
84#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_rip)
85#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_rbp)
86#define PMC_TRAPFRAME_TO_USER_SP(TF) ((TF)->tf_rsp)
87#define PMC_TRAPFRAME_TO_KERNEL_SP(TF) ((TF)->tf_rsp)
88
89#define PMC_AT_FUNCTION_PROLOGUE_PUSH_BP(I) \
90 (((I) & 0xffffffff) == 0xe5894855) /* pushq %rbp; movq %rsp,%rbp */
91#define PMC_AT_FUNCTION_PROLOGUE_MOV_SP_BP(I) \

--- 15 unchanged lines hidden (view full) ---

107
108/*
109 * Prototypes
110 */
111
112void start_exceptions(void), end_exceptions(void);
113void pmc_x86_lapic_enable_pmc_interrupt(void);
114
91#endif
115struct pmc_mdep *pmc_amd_initialize(void);
116void pmc_amd_finalize(struct pmc_mdep *_md);
117struct pmc_mdep *pmc_intel_initialize(void);
118void pmc_intel_finalize(struct pmc_mdep *_md);
119
120#endif /* _KERNEL */
92#endif /* _MACHINE_PMC_MDEP_H */
121#endif /* _MACHINE_PMC_MDEP_H */