blob: c80ec7d09993fa306fc490d2161617699d78fd3d [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
9 */
10
11#ifndef OP_X86_MODEL_H
12#define OP_X86_MODEL_H
13
Robert Richterff9faa82009-05-22 15:36:29 +020014#define CTR_IS_RESERVED(msrs, c) (msrs->counters[(c)].addr ? 1 : 0)
15#define CTRL_IS_RESERVED(msrs, c) (msrs->controls[(c)].addr ? 1 : 0)
16#define CTRL_SET_ACTIVE(n) (n |= (1<<22))
17#define CTRL_SET_ENABLE(val) (val |= 1<<20)
18#define CTRL_SET_INACTIVE(n) (n &= ~(1<<22))
19#define CTRL_SET_KERN(val, k) (val |= ((k & 1) << 17))
20#define CTRL_SET_UM(val, m) (val |= (m << 8))
21#define CTRL_SET_USR(val, u) (val |= ((u & 1) << 16))
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023struct op_saved_msr {
24 unsigned int high;
25 unsigned int low;
26};
27
28struct op_msr {
29 unsigned long addr;
30 struct op_saved_msr saved;
31};
32
33struct op_msrs {
Robert Richter25ad2912008-09-05 17:12:36 +020034 struct op_msr *counters;
35 struct op_msr *controls;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036};
37
38struct pt_regs;
39
40/* The model vtable abstracts the differences between
Simon Arlott27b46d72007-10-20 01:13:56 +020041 * various x86 CPU models' perfctr support.
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 */
43struct op_x86_model_spec {
Robert Richter06552cc2009-05-28 02:12:36 +020044 unsigned int num_counters;
45 unsigned int num_controls;
46 int (*init)(struct oprofile_operations *ops);
47 void (*exit)(void);
48 void (*fill_in_addresses)(struct op_msrs * const msrs);
49 void (*setup_ctrs)(struct op_msrs const * const msrs);
50 int (*check_ctrs)(struct pt_regs * const regs,
51 struct op_msrs const * const msrs);
52 void (*start)(struct op_msrs const * const msrs);
53 void (*stop)(struct op_msrs const * const msrs);
54 void (*shutdown)(struct op_msrs const * const msrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055};
56
Robert Richter849620f2009-05-14 17:10:52 +020057extern struct op_x86_model_spec const op_ppro_spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058extern struct op_x86_model_spec const op_p4_spec;
59extern struct op_x86_model_spec const op_p4_ht2_spec;
Robert Richter6657fe42008-07-22 21:08:50 +020060extern struct op_x86_model_spec const op_amd_spec;
Andi Kleenb9917022008-08-18 14:50:31 +020061extern struct op_x86_model_spec op_arch_perfmon_spec;
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif /* OP_X86_MODEL_H */