3 * interface to x86 model-specific MSR operations
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
8 * @author Graydon Hoare
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))
32 struct op_saved_msr saved
;
36 struct op_msr
*counters
;
37 struct op_msr
*controls
;
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
);
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 */