oprofile: Introduce op_x86_phys_to_virt()
[safe/jmp/linux-2.6] / arch / x86 / oprofile / op_x86_model.h
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  * @author Robert Richter <robert.richter@amd.com>
10  */
11
12 #ifndef OP_X86_MODEL_H
13 #define OP_X86_MODEL_H
14
15 #include <asm/types.h>
16 #include <asm/perf_counter.h>
17
18 struct op_msr {
19         unsigned long   addr;
20         u64             saved;
21 };
22
23 struct op_msrs {
24         struct op_msr *counters;
25         struct op_msr *controls;
26         struct op_msr *multiplex;
27 };
28
29 struct pt_regs;
30
31 struct oprofile_operations;
32
33 /* The model vtable abstracts the differences between
34  * various x86 CPU models' perfctr support.
35  */
36 struct op_x86_model_spec {
37         unsigned int    num_counters;
38         unsigned int    num_controls;
39         unsigned int    num_virt_counters;
40         unsigned int    num_virt_controls;
41         u64             reserved;
42         u16             event_mask;
43         int             (*init)(struct oprofile_operations *ops);
44         void            (*exit)(void);
45         void            (*fill_in_addresses)(struct op_msrs * const msrs);
46         void            (*setup_ctrs)(struct op_x86_model_spec const *model,
47                                       struct op_msrs const * const msrs);
48         int             (*check_ctrs)(struct pt_regs * const regs,
49                                       struct op_msrs const * const msrs);
50         void            (*start)(struct op_msrs const * const msrs);
51         void            (*stop)(struct op_msrs const * const msrs);
52         void            (*shutdown)(struct op_msrs const * const msrs);
53 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
54         void            (*switch_ctrl)(struct op_x86_model_spec const *model,
55                                        struct op_msrs const * const msrs);
56 #endif
57 };
58
59 struct op_counter_config;
60
61 extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
62                            struct op_counter_config *counter_config);
63 extern int op_x86_phys_to_virt(int phys);
64
65 extern struct op_x86_model_spec const op_ppro_spec;
66 extern struct op_x86_model_spec const op_p4_spec;
67 extern struct op_x86_model_spec const op_p4_ht2_spec;
68 extern struct op_x86_model_spec const op_amd_spec;
69 extern struct op_x86_model_spec op_arch_perfmon_spec;
70
71 #endif /* OP_X86_MODEL_H */