[REFACTOR] remove 'struct hlist_head otg_kernel_probes'
[kernel/swap-modules.git] / driver / storage.h
1 ////////////////////////////////////////////////////////////////////////////////////
2 //
3 //      FILE:           storage.h
4 //
5 //      DESCRIPTION:
6 //      This file is C source for SWAP.
7 //
8 //      SEE ALSO:       storage.c
9 //      AUTHOR:         L.Komkov, S.Dianov, A.Gerenkov
10 //      COMPANY NAME:   Samsung Research Center in Moscow
11 //      DEPT NAME:      Advanced Software Group
12 //      CREATED:        2008.02.15
13 //      VERSION:        1.0
14 //      REVISION DATE:  2008.12.03
15 //
16 ////////////////////////////////////////////////////////////////////////////////////
17
18 #if !defined(__STORAGE_H__)
19 #define __STORAGE_H__
20
21 #include <linux/mount.h>
22 #include <linux/module.h>
23 #include <linux/list.h>
24 #include <linux/spinlock.h>
25 #include "picl.h"
26 #include "ec_ioctl.h"
27 #include "ec_probe.h"
28 #include "probes_manager.h"
29 #include "probes.h"
30 #include "event_tmpl.h"
31 #include "error_storage.h"
32
33 extern int EnableContinuousRetrieval(void);
34 extern int DisableContinuousRetrieval(void);
35
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 extern unsigned int GetBufferSize(void);
39 extern int SetBufferSize(unsigned int nSize);
40 extern int ResetBuffer(void);
41
42 extern int SetPid(unsigned int pid);
43
44 //extern spinlock_t buffer_spinlock;
45
46 ///////////////////////////////////////////////////////////////////////////////////////////////////
47
48 /*
49     Functions "storage_init()" and "storage_down()" are for initialization and
50     shutdown respectively.
51 */
52 extern int storage_init (void);
53 extern void storage_down (void);
54
55 /*
56     Function "pack_event_info()" saves information about event into buffer. It
57     is used in 'probes' to pack and save event data.
58 */
59 extern void pack_task_event_info (struct task_struct *task, probe_id_t probe_id,
60                 record_type_t record_type, const char *fmt, ...);
61 #define pack_event_info(probe_id, record_type, fmt, ...) \
62         pack_task_event_info(current, probe_id, record_type, fmt, __VA_ARGS__)
63
64 /* Set most links from us_proc_info to data in the bundle */
65 int link_bundle(void);
66 /* Undo the actions of link_bundle() */
67 void unlink_bundle(void);
68
69 /*
70     Adds non-predefined kernel probe to the list.
71 */
72 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
73
74 /*
75     Removes non-predefined kernel probe from the list.
76 */
77 extern int remove_probe_from_list (unsigned long addr);
78
79 /*
80     Searches non-predefined kernel probe in the list.
81 */
82 extern kernel_probe_t *find_probe (unsigned long addr);
83
84 /*
85     Copies event from user space to buffer and updates its pid/tid/cpu/time.
86 */
87 extern int put_us_event (char *data, unsigned long len);
88
89 /*
90     Sets event mask.
91 */
92 extern int set_event_mask (int new_mask);
93
94 /*
95     Gets event mask.
96 */
97 extern int get_event_mask (int *mask);
98
99 /*
100     Sets predefined user space probes info.
101 */
102 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
103 /*
104     Gets predefined user space probes info length.
105 */
106 extern int get_predef_uprobes_size(int *size);
107 /*
108     Gets predefined user space probes info.
109 */
110 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
111
112
113 // internal bookkeeping of storage
114 extern char *p_buffer;
115
116 // list of selected non-predefined kernel probes
117 extern struct hlist_head kernel_probes;
118
119 // multiple handlers stuff
120 /*struct dbi_modules_handlers {
121         struct list_head        modules_handlers;
122         spinlock_t              lock;
123 };
124
125 struct dbi_modules_handlers_info {
126         struct module           *dbi_module;
127         struct handler_map      *dbi_handlers;
128         int                     dbi_nr_handlers;
129         struct list_head        dbi_list_head;
130 };
131
132 extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
133 extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
134 //unsigned long get_dbi_modules_handlers(void);*/
135
136 // event mask
137 extern int event_mask;
138
139 // process pid to instrument
140 extern unsigned int inst_pid;
141
142 typedef struct
143 {
144         struct list_head list;
145         char *name;
146         int installed;
147         struct jprobe jprobe;
148         struct kretprobe retprobe;
149         unsigned long offset;
150         unsigned long got_addr;
151
152         unsigned flag_retprobe:1;
153         unsigned flag_got:1;
154 } us_proc_ip_t;
155
156 typedef struct
157 {
158         int installed;
159         struct jprobe jprobe;
160         unsigned long addr;
161         struct list_head list;
162 } us_proc_vtp_t;
163
164 typedef struct
165 {
166         char *name;
167         char type;
168         unsigned long size;
169         signed char reg;        // -1 - memory, 0..127 - register number
170         long off;
171         struct list_head list;
172 } us_proc_vtp_data_t;
173
174 typedef struct
175 {
176         unsigned func_addr;
177         unsigned got_addr;
178         unsigned real_func_addr;
179 } us_proc_plt_t;
180
181 typedef struct
182 {
183         char *path;
184         char *path_dyn;
185         struct dentry *m_f_dentry;
186         unsigned ips_count;
187         us_proc_ip_t *p_ips;
188         unsigned vtps_count;
189         us_proc_vtp_t *p_vtps;
190         int loaded;
191         unsigned plt_count;
192         us_proc_plt_t *p_plt;
193         unsigned long vma_start;
194         unsigned long vma_end;
195         unsigned vma_flag;
196 } us_proc_lib_t;
197
198
199 typedef struct
200 {
201         char *path;
202         struct dentry *m_f_dentry;
203         pid_t tgid;
204         unsigned unres_ips_count;
205         unsigned unres_vtps_count;
206         //kprobe_opcode_t *mapped_codelets;
207         int is_plt;
208         unsigned libs_count;
209         us_proc_lib_t *p_libs;
210
211         // new_dpf
212         struct sspt_procs *pp;
213 } inst_us_proc_t;
214
215 typedef struct
216 {
217         unsigned int addr;
218         unsigned int inst_type;
219         char *name;
220         char *class_name;
221         char *method_name;
222         char *prototype;
223
224 }dex_proc_ip_t;
225
226 typedef struct
227 {
228         char *path;
229         unsigned ips_count;
230         dex_proc_ip_t *p_ips;
231
232 }inst_dex_proc_t;
233
234
235 struct cond {
236         /* cond data itself */
237         struct event_tmpl tmpl;
238         /* linked list */
239         struct list_head list;
240         /* has been applied (for start and stop conditions) */
241         int applied;
242 };
243
244 extern struct cond cond_list;
245
246 /* macros for testing flags */
247 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
248 #define ET_FIELD_SET(flags, field) (flags |= field)
249 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
250
251 extern inst_us_proc_t us_proc_info;
252 extern inst_dex_proc_t dex_proc_info;
253
254 #endif /* !defined(__STORAGE_H__) */