x86/oprofile: pass the model to setup_ctrs() functions
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / oprofile / op_x86_model.h
blob6161c7f0e7fbe8f687d28fcf3cf816be97b1117a
1 /**
2 * @file op_x86_model.h
3 * interface to x86 model-specific MSR operations
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
8 * @author Graydon Hoare
9 */
11 #ifndef OP_X86_MODEL_H
12 #define OP_X86_MODEL_H
14 #include <asm/intel_arch_perfmon.h>
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))
25 struct op_saved_msr {
26 unsigned int high;
27 unsigned int low;
30 struct op_msr {
31 unsigned long addr;
32 struct op_saved_msr saved;
35 struct op_msrs {
36 struct op_msr *counters;
37 struct op_msr *controls;
40 struct pt_regs;
42 /* The model vtable abstracts the differences between
43 * various x86 CPU models' perfctr support.
45 struct op_x86_model_spec {
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_x86_model_spec const *model,
52 struct op_msrs const * const msrs);
53 int (*check_ctrs)(struct pt_regs * const regs,
54 struct op_msrs const * const msrs);
55 void (*start)(struct op_msrs const * const msrs);
56 void (*stop)(struct op_msrs const * const msrs);
57 void (*shutdown)(struct op_msrs const * const msrs);
60 extern struct op_x86_model_spec const op_ppro_spec;
61 extern struct op_x86_model_spec const op_p4_spec;
62 extern struct op_x86_model_spec const op_p4_ht2_spec;
63 extern struct op_x86_model_spec const op_amd_spec;
64 extern struct op_x86_model_spec op_arch_perfmon_spec;
66 #endif /* OP_X86_MODEL_H */