blob: 59fa2bdb0da3216bb029748cc32d6961b72c3d25 [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>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020016#include <asm/perf_event.h>
Robert Richterec064c02009-05-25 15:05:50 +020017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018struct op_msr {
Robert Richter95e74e62009-06-03 19:09:27 +020019 unsigned long addr;
20 u64 saved;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021};
22
23struct op_msrs {
Robert Richter25ad2912008-09-05 17:12:36 +020024 struct op_msr *counters;
25 struct op_msr *controls;
Jason Yeh4d4036e2009-07-08 13:49:38 +020026 struct op_msr *multiplex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
29struct pt_regs;
30
Robert Richter3370d352009-05-25 15:10:32 +020031struct oprofile_operations;
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/* The model vtable abstracts the differences between
Simon Arlott27b46d72007-10-20 01:13:56 +020034 * various x86 CPU models' perfctr support.
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 */
36struct op_x86_model_spec {
Robert Richter06552cc2009-05-28 02:12:36 +020037 unsigned int num_counters;
38 unsigned int num_controls;
Jason Yeh4d4036e2009-07-08 13:49:38 +020039 unsigned int num_virt_counters;
Robert Richter3370d352009-05-25 15:10:32 +020040 u64 reserved;
41 u16 event_mask;
Robert Richter06552cc2009-05-28 02:12:36 +020042 int (*init)(struct oprofile_operations *ops);
43 void (*exit)(void);
44 void (*fill_in_addresses)(struct op_msrs * const msrs);
Robert Richteref8828d2009-05-25 19:31:44 +020045 void (*setup_ctrs)(struct op_x86_model_spec const *model,
46 struct op_msrs const * const msrs);
Robert Richter06552cc2009-05-28 02:12:36 +020047 int (*check_ctrs)(struct pt_regs * const regs,
48 struct op_msrs const * const msrs);
49 void (*start)(struct op_msrs const * const msrs);
50 void (*stop)(struct op_msrs const * const msrs);
51 void (*shutdown)(struct op_msrs const * const msrs);
Jason Yeh4d4036e2009-07-08 13:49:38 +020052#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
53 void (*switch_ctrl)(struct op_x86_model_spec const *model,
54 struct op_msrs const * const msrs);
55#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070056};
57
Robert Richter3370d352009-05-25 15:10:32 +020058struct op_counter_config;
59
Robert Richter98a2e732010-02-23 18:14:58 +010060static inline void op_x86_warn_in_use(int counter)
61{
62 pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
63 counter, smp_processor_id());
64}
65
66static inline void op_x86_warn_reserved(int counter)
67{
68 pr_warning("oprofile: counter #%d is already reserved\n", counter);
69}
70
Robert Richter3370d352009-05-25 15:10:32 +020071extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
72 struct op_counter_config *counter_config);
Robert Richterd8471ad2009-07-16 13:04:43 +020073extern int op_x86_phys_to_virt(int phys);
Robert Richter61d149d2009-07-10 15:47:17 +020074extern int op_x86_virt_to_phys(int virt);
Robert Richter3370d352009-05-25 15:10:32 +020075
Robert Richter259a83a2009-07-09 15:12:35 +020076extern struct op_x86_model_spec op_ppro_spec;
77extern struct op_x86_model_spec op_p4_spec;
78extern struct op_x86_model_spec op_p4_ht2_spec;
79extern struct op_x86_model_spec op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020080extern struct op_x86_model_spec op_arch_perfmon_spec;
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif /* OP_X86_MODEL_H */