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#define IBS_FETCH_CODE 13
40#define IBS_OP_CODE 14
41
42struct super_block;
43struct dentry;
44struct file_operations;
45struct pt_regs;
46
47
48struct oprofile_operations {
49
50
51 int (*create_files)(struct super_block * sb, struct dentry * root);
52
53 int (*setup)(void);
54
55 void (*shutdown)(void);
56
57 int (*start)(void);
58
59 void (*stop)(void);
60
61
62
63
64
65 int (*sync_start)(void);
66 int (*sync_stop)(void);
67
68
69 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
70
71 char * cpu_type;
72};
73
74
75
76
77
78
79
80
81int oprofile_arch_init(struct oprofile_operations * ops);
82
83
84
85
86void oprofile_arch_exit(void);
87
88
89
90
91void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
92
93
94
95
96
97
98
99
100void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
101 unsigned long event, int is_kernel);
102
103
104
105void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
106
107
108void oprofile_add_trace(unsigned long eip);
109
110
111
112
113
114
115int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
116 char const * name, const struct file_operations * fops);
117
118int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
119 char const * name, const struct file_operations * fops, int perm);
120
121
122int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
123 char const * name, ulong * val);
124
125
126int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
127 char const * name, ulong * val);
128
129
130int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
131 char const * name, atomic_t * val);
132
133
134struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
135 char const * name);
136
137
138
139
140
141ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
142
143
144
145
146
147ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
148
149
150
151
152
153int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
154
155
156extern spinlock_t oprofilefs_lock;
157
158
159
160
161void oprofile_put_buff(unsigned long *buf, unsigned int start,
162 unsigned int stop, unsigned int max);
163
164unsigned long oprofile_get_cpu_buffer_size(void);
165void oprofile_cpu_buffer_inc_smpl_lost(void);
166
167
168
169struct op_sample;
170
171struct op_entry {
172 struct ring_buffer_event *event;
173 struct op_sample *sample;
174 unsigned long irq_flags;
175 unsigned long size;
176 unsigned long *data;
177};
178
179void oprofile_write_reserve(struct op_entry *entry,
180 struct pt_regs * const regs,
181 unsigned long pc, int code, int size);
182int oprofile_add_data(struct op_entry *entry, unsigned long val);
183int oprofile_write_commit(struct op_entry *entry);
184
185#endif
186