1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef OPROFILE_H
14#define OPROFILE_H
15
16#include <linux/types.h>
17#include <linux/spinlock.h>
18#include <asm/atomic.h>
19
20
21
22
23
24
25
26#define ESCAPE_CODE ~0UL
27#define CTX_SWITCH_CODE 1
28#define CPU_SWITCH_CODE 2
29#define COOKIE_SWITCH_CODE 3
30#define KERNEL_ENTER_SWITCH_CODE 4
31#define KERNEL_EXIT_SWITCH_CODE 5
32#define MODULE_LOADED_CODE 6
33#define CTX_TGID_CODE 7
34#define TRACE_BEGIN_CODE 8
35#define TRACE_END_CODE 9
36#define XEN_ENTER_SWITCH_CODE 10
37#define SPU_PROFILING_CODE 11
38#define SPU_CTX_SWITCH_CODE 12
39
40struct super_block;
41struct dentry;
42struct file_operations;
43struct pt_regs;
44
45
46struct oprofile_operations {
47
48
49 int (*create_files)(struct super_block * sb, struct dentry * root);
50
51 int (*setup)(void);
52
53 void (*shutdown)(void);
54
55 int (*start)(void);
56
57 void (*stop)(void);
58
59
60
61
62
63 int (*sync_start)(void);
64 int (*sync_stop)(void);
65
66
67 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
68
69 char * cpu_type;
70};
71
72
73
74
75
76
77
78
79int oprofile_arch_init(struct oprofile_operations * ops);
80
81
82
83
84void oprofile_arch_exit(void);
85
86
87
88
89
90
91void add_event_entry(unsigned long data);
92
93
94
95
96
97void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
98
99
100
101
102
103
104
105
106void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
107 unsigned long event, int is_kernel);
108
109
110
111void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
112
113
114void oprofile_add_trace(unsigned long eip);
115
116
117
118
119
120
121int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
122 char const * name, const struct file_operations * fops);
123
124int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
125 char const * name, const struct file_operations * fops, int perm);
126
127
128int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
129 char const * name, ulong * val);
130
131
132int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
133 char const * name, ulong * val);
134
135
136int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
137 char const * name, atomic_t * val);
138
139
140struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
141 char const * name);
142
143
144
145
146
147ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
148
149
150
151
152
153ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
154
155
156
157
158
159int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
160
161
162extern spinlock_t oprofilefs_lock;
163
164#endif
165