1 /******************************************************************************
2  * asm-x86/xenoprof.h
3  * xenoprof x86 arch specific header file
4  *
5  * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
6  *                    VA Linux Systems Japan K.K.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __ASM_X86_XENOPROF_H__
23 #define __ASM_X86_XENOPROF_H__
24 
25 struct vcpu;
26 
27 #ifdef CONFIG_XENOPROF
28 
29 int nmi_reserve_counters(void);
30 int nmi_setup_events(void);
31 int nmi_enable_virq(void);
32 int nmi_start(void);
33 void nmi_stop(void);
34 void nmi_disable_virq(void);
35 void nmi_release_counters(void);
36 
37 int xenoprof_arch_init(int *num_events, char *cpu_type);
38 #define xenoprof_arch_reserve_counters()        nmi_reserve_counters()
39 #define xenoprof_arch_setup_events()            nmi_setup_events()
40 #define xenoprof_arch_enable_virq()             nmi_enable_virq()
41 #define xenoprof_arch_start()                   nmi_start()
42 #define xenoprof_arch_stop()                    nmi_stop()
43 #define xenoprof_arch_disable_virq()            nmi_disable_virq()
44 #define xenoprof_arch_release_counters()        nmi_release_counters()
45 
46 int xenoprof_arch_counter(XEN_GUEST_HANDLE_PARAM(void) arg);
47 int compat_oprof_arch_counter(XEN_GUEST_HANDLE_PARAM(void) arg);
48 int xenoprof_arch_ibs_counter(XEN_GUEST_HANDLE_PARAM(void) arg);
49 
50 struct cpu_user_regs;
51 
52 /* AMD IBS support */
53 void ibs_init(void);
54 extern u32 ibs_caps;
55 
56 int xenoprofile_get_mode(struct vcpu *, const struct cpu_user_regs *);
57 
xenoprof_backtrace_supported(void)58 static inline int xenoprof_backtrace_supported(void)
59 {
60     return 1;
61 }
62 
63 void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *,
64                         unsigned long depth, int mode);
65 
66 int passive_domain_do_rdmsr(unsigned int msr, uint64_t *msr_content);
67 int passive_domain_do_wrmsr(unsigned int msr, uint64_t msr_content);
68 void passive_domain_destroy(struct vcpu *v);
69 
70 #else
71 
passive_domain_do_rdmsr(unsigned int msr,uint64_t * msr_content)72 static inline int passive_domain_do_rdmsr(unsigned int msr,
73                                           uint64_t *msr_content)
74 {
75     return 0;
76 }
77 
passive_domain_do_wrmsr(unsigned int msr,uint64_t msr_content)78 static inline int passive_domain_do_wrmsr(unsigned int msr,
79                                           uint64_t msr_content)
80 {
81     return 0;
82 }
83 
passive_domain_destroy(struct vcpu * v)84 static inline void passive_domain_destroy(struct vcpu *v) {}
85 
86 #endif /* CONFIG_XENOPROF */
87 
88 #endif /* __ASM_X86_XENOPROF_H__ */
89 
90 /*
91  * Local variables:
92  * mode: C
93  * c-file-style: "BSD"
94  * c-basic-offset: 4
95  * tab-width: 4
96  * indent-tabs-mode: nil
97  * End:
98  */
99