blob: 7b8e75d1608125aa81e7069d781d08bf15052e40 [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
60extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
61 struct op_counter_config *counter_config);
Robert Richterd8471ad2009-07-16 13:04:43 +020062extern int op_x86_phys_to_virt(int phys);
Robert Richter61d149d2009-07-10 15:47:17 +020063extern int op_x86_virt_to_phys(int virt);
Robert Richter3370d352009-05-25 15:10:32 +020064
Robert Richter259a83a2009-07-09 15:12:35 +020065extern struct op_x86_model_spec op_ppro_spec;
66extern struct op_x86_model_spec op_p4_spec;
67extern struct op_x86_model_spec op_p4_ht2_spec;
68extern struct op_x86_model_spec op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020069extern struct op_x86_model_spec op_arch_perfmon_spec;
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#endif /* OP_X86_MODEL_H */