blob: 3220d4ce63223f5e48034a8571fbd953e2c351e1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
2 * @file op_x86_model.h
3 * interface to x86 model-specific MSR operations
4 *
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author Graydon Hoare
Robert Richter3370d352009-05-25 15:10:32 +02009 * @author Robert Richter <robert.richter@amd.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
12#ifndef OP_X86_MODEL_H
13#define OP_X86_MODEL_H
14
Robert Richter3370d352009-05-25 15:10:32 +020015#include <asm/types.h>
Robert Richterec064c02009-05-25 15:05:50 +020016#include <asm/intel_arch_perfmon.h>
17
18#define CTR_IS_RESERVED(msrs, c) ((msrs)->counters[(c)].addr ? 1 : 0)
19#define CTRL_IS_RESERVED(msrs, c) ((msrs)->controls[(c)].addr ? 1 : 0)
20#define CTRL_SET_ACTIVE(val) ((val) |= ARCH_PERFMON_EVENTSEL0_ENABLE)
Robert Richterec064c02009-05-25 15:05:50 +020021#define CTRL_SET_INACTIVE(val) ((val) &= ~ARCH_PERFMON_EVENTSEL0_ENABLE)
Robert Richterff9faa82009-05-22 15:36:29 +020022
Linus Torvalds1da177e2005-04-16 15:20:36 -070023struct op_saved_msr {
24 unsigned int high;
25 unsigned int low;
26};
27
28struct op_msr {
29 unsigned long addr;
30 struct op_saved_msr saved;
31};
32
33struct op_msrs {
Robert Richter25ad2912008-09-05 17:12:36 +020034 struct op_msr *counters;
35 struct op_msr *controls;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036};
37
38struct pt_regs;
39
Robert Richter3370d352009-05-25 15:10:32 +020040struct oprofile_operations;
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042/* The model vtable abstracts the differences between
Simon Arlott27b46d72007-10-20 01:13:56 +020043 * various x86 CPU models' perfctr support.
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 */
45struct op_x86_model_spec {
Robert Richter06552cc2009-05-28 02:12:36 +020046 unsigned int num_counters;
47 unsigned int num_controls;
Robert Richter3370d352009-05-25 15:10:32 +020048 u64 reserved;
49 u16 event_mask;
Robert Richter06552cc2009-05-28 02:12:36 +020050 int (*init)(struct oprofile_operations *ops);
51 void (*exit)(void);
52 void (*fill_in_addresses)(struct op_msrs * const msrs);
Robert Richteref8828d2009-05-25 19:31:44 +020053 void (*setup_ctrs)(struct op_x86_model_spec const *model,
54 struct op_msrs const * const msrs);
Robert Richter06552cc2009-05-28 02:12:36 +020055 int (*check_ctrs)(struct pt_regs * const regs,
56 struct op_msrs const * const msrs);
57 void (*start)(struct op_msrs const * const msrs);
58 void (*stop)(struct op_msrs const * const msrs);
59 void (*shutdown)(struct op_msrs const * const msrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
Robert Richter3370d352009-05-25 15:10:32 +020062struct op_counter_config;
63
64extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
65 struct op_counter_config *counter_config);
66
Robert Richter849620f2009-05-14 17:10:52 +020067extern struct op_x86_model_spec const op_ppro_spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern struct op_x86_model_spec const op_p4_spec;
69extern struct op_x86_model_spec const op_p4_ht2_spec;
Robert Richter6657fe42008-07-22 21:08:50 +020070extern struct op_x86_model_spec const op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020071extern struct op_x86_model_spec op_arch_perfmon_spec;
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#endif /* OP_X86_MODEL_H */