1 ////////////////////////////////////////////////////////////////////////////////////
6 // This file is C source for SWAP.
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
14 // REVISION DATE: 2008.12.03
16 ////////////////////////////////////////////////////////////////////////////////////
18 #if !defined(__STORAGE_H__)
21 #include <linux/mount.h>
22 #include <linux/module.h>
23 #include <linux/list.h>
24 #include <linux/spinlock.h>
28 #include "probes_manager.h"
30 #include "event_tmpl.h"
32 ///////////////////////////////////////////////////////////////////////////////////////////////////
34 extern int EnableContinuousRetrieval(void);
35 extern int DisableContinuousRetrieval(void);
37 ///////////////////////////////////////////////////////////////////////////////////////////////////
39 extern unsigned int GetBufferSize(void);
40 extern int SetBufferSize(unsigned int nSize);
41 extern int ResetBuffer(void);
43 extern int SetPid(unsigned int pid);
45 //extern spinlock_t buffer_spinlock;
47 ///////////////////////////////////////////////////////////////////////////////////////////////////
50 Functions "storage_init()" and "storage_down()" are for initialization and
51 shutdown respectively.
53 extern int storage_init (void);
54 extern void storage_down (void);
57 Function "pack_event_info()" saves information about event into buffer. It
58 is used in 'probes' to pack and save event data.
60 extern void pack_task_event_info (struct task_struct *task, probe_id_t probe_id,
61 record_type_t record_type, const char *fmt, ...);
62 #define pack_event_info(probe_id, record_type, fmt, ...) \
63 pack_task_event_info(current, probe_id, record_type, fmt, __VA_ARGS__)
65 /* Set most links from us_proc_info to data in the bundle */
66 int link_bundle(void);
68 /* Undo the actions of link_bundle() */
69 void unlink_bundle(void);
72 Adds non-predefined kernel probe to the list.
74 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
77 Removes non-predefined kernel probe from the list.
79 extern int remove_probe_from_list (unsigned long addr);
82 Searches non-predefined kernel probe in the list.
84 extern kernel_probe_t *find_probe (unsigned long addr);
87 Copies event from user space to buffer and updates its pid/tid/cpu/time.
89 extern int put_us_event (char *data, unsigned long len);
94 extern int set_event_mask (int new_mask);
99 extern int get_event_mask (int *mask);
102 Sets predefined user space probes info.
104 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
106 Gets predefined user space probes info length.
108 extern int get_predef_uprobes_size(int *size);
110 Gets predefined user space probes info.
112 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
115 // internal bookkeeping of storage
116 extern char *p_buffer;
118 // list of selected non-predefined kernel probes
119 extern struct hlist_head kernel_probes;
121 // multiple handlers stuff
122 /*struct dbi_modules_handlers {
123 struct list_head modules_handlers;
127 struct dbi_modules_handlers_info {
128 struct module *dbi_module;
129 struct handler_map *dbi_handlers;
131 struct list_head dbi_list_head;
134 extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
135 extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
136 //unsigned long get_dbi_modules_handlers(void);*/
138 /* list of on-the-go installed kernel probes */
139 extern struct hlist_head otg_kernel_probes;
142 extern int event_mask;
144 // process pid to instrument
145 extern unsigned int inst_pid;
149 struct list_head list;
152 struct jprobe jprobe;
153 struct kretprobe retprobe;
154 unsigned long offset;
155 unsigned long got_addr;
157 unsigned flag_retprobe:1;
164 struct jprobe jprobe;
166 struct list_head list;
174 signed char reg; // -1 - memory, 0..127 - register number
176 struct list_head list;
177 } us_proc_vtp_data_t;
183 unsigned real_func_addr;
190 struct dentry *m_f_dentry;
194 us_proc_vtp_t *p_vtps;
197 us_proc_plt_t *p_plt;
198 unsigned long vma_start;
199 unsigned long vma_end;
207 struct dentry *m_f_dentry;
209 unsigned unres_ips_count;
210 unsigned unres_vtps_count;
211 //kprobe_opcode_t *mapped_codelets;
214 us_proc_lib_t *p_libs;
216 unsigned long libdvm_start;
217 unsigned long libdvm_end;
218 us_proc_ip_t libdvm_entry_ip;
219 us_proc_ip_t libdvm_return_ip;
220 #endif /* __ANDROID */
223 struct proc_probes *pp;
229 unsigned int inst_type;
241 dex_proc_ip_t *p_ips;
247 /* cond data itself */
248 struct event_tmpl tmpl;
250 struct list_head list;
251 /* has been applied (for start and stop conditions) */
255 extern struct cond cond_list;
257 /* macros for testing flags */
258 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
259 #define ET_FIELD_SET(flags, field) (flags |= field)
260 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
262 extern inst_us_proc_t us_proc_info;
263 extern inst_dex_proc_t dex_proc_info;
265 #endif /* !defined(__STORAGE_H__) */