Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /** |
| 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 |
| 9 | */ |
| 10 | |
| 11 | #ifndef OP_X86_MODEL_H |
| 12 | #define OP_X86_MODEL_H |
| 13 | |
Robert Richter | ec064c0 | 2009-05-25 15:05:50 +0200 | [diff] [blame^] | 14 | #include <asm/intel_arch_perfmon.h> |
| 15 | |
| 16 | #define CTR_IS_RESERVED(msrs, c) ((msrs)->counters[(c)].addr ? 1 : 0) |
| 17 | #define CTRL_IS_RESERVED(msrs, c) ((msrs)->controls[(c)].addr ? 1 : 0) |
| 18 | #define CTRL_SET_ACTIVE(val) ((val) |= ARCH_PERFMON_EVENTSEL0_ENABLE) |
| 19 | #define CTRL_SET_ENABLE(val) ((val) |= ARCH_PERFMON_EVENTSEL_INT) |
| 20 | #define CTRL_SET_INACTIVE(val) ((val) &= ~ARCH_PERFMON_EVENTSEL0_ENABLE) |
| 21 | #define CTRL_SET_KERN(val, k) ((val) |= ((k) ? ARCH_PERFMON_EVENTSEL_OS : 0)) |
| 22 | #define CTRL_SET_USR(val, u) ((val) |= ((u) ? ARCH_PERFMON_EVENTSEL_USR : 0)) |
| 23 | #define CTRL_SET_UM(val, m) ((val) |= ((m) << 8)) |
Robert Richter | ff9faa8 | 2009-05-22 15:36:29 +0200 | [diff] [blame] | 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | struct op_saved_msr { |
| 26 | unsigned int high; |
| 27 | unsigned int low; |
| 28 | }; |
| 29 | |
| 30 | struct op_msr { |
| 31 | unsigned long addr; |
| 32 | struct op_saved_msr saved; |
| 33 | }; |
| 34 | |
| 35 | struct op_msrs { |
Robert Richter | 25ad291 | 2008-09-05 17:12:36 +0200 | [diff] [blame] | 36 | struct op_msr *counters; |
| 37 | struct op_msr *controls; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct pt_regs; |
| 41 | |
| 42 | /* The model vtable abstracts the differences between |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 43 | * various x86 CPU models' perfctr support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | */ |
| 45 | struct op_x86_model_spec { |
Robert Richter | 06552cc | 2009-05-28 02:12:36 +0200 | [diff] [blame] | 46 | unsigned int num_counters; |
| 47 | unsigned int num_controls; |
| 48 | int (*init)(struct oprofile_operations *ops); |
| 49 | void (*exit)(void); |
| 50 | void (*fill_in_addresses)(struct op_msrs * const msrs); |
| 51 | void (*setup_ctrs)(struct op_msrs const * const msrs); |
| 52 | int (*check_ctrs)(struct pt_regs * const regs, |
| 53 | struct op_msrs const * const msrs); |
| 54 | void (*start)(struct op_msrs const * const msrs); |
| 55 | void (*stop)(struct op_msrs const * const msrs); |
| 56 | void (*shutdown)(struct op_msrs const * const msrs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
Robert Richter | 849620f | 2009-05-14 17:10:52 +0200 | [diff] [blame] | 59 | extern struct op_x86_model_spec const op_ppro_spec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern struct op_x86_model_spec const op_p4_spec; |
| 61 | extern struct op_x86_model_spec const op_p4_ht2_spec; |
Robert Richter | 6657fe4 | 2008-07-22 21:08:50 +0200 | [diff] [blame] | 62 | extern struct op_x86_model_spec const op_amd_spec; |
Andi Kleen | b991702 | 2008-08-18 14:50:31 +0200 | [diff] [blame] | 63 | extern struct op_x86_model_spec op_arch_perfmon_spec; |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #endif /* OP_X86_MODEL_H */ |