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 #ifndef __DISABLE_RELAYFS
35 extern struct rchan* GetRelayChannel(void);
36 extern struct dentry* GetRelayDir(void);
37 #endif //__DISABLE_RELAYFS
39 extern int EnableMultipleBuffer(void);
40 extern int DisableMultipleBuffer(void);
41 extern int EnableContinuousRetrieval(void);
42 extern int DisableContinuousRetrieval(void);
44 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 extern unsigned int GetBufferSize(void);
47 extern int SetBufferSize(unsigned int nSize);
48 extern int ResetBuffer(void);
50 extern int SetPid(unsigned int pid);
52 //extern spinlock_t buffer_spinlock;
54 ///////////////////////////////////////////////////////////////////////////////////////////////////
57 Functions "storage_init()" and "storage_down()" are for initialization and
58 shutdown respectively.
60 extern int storage_init (void);
61 extern void storage_down (void);
64 Function "pack_event_info()" saves information about event into buffer. It
65 is used in 'probes' to pack and save event data.
67 extern void pack_event_info (probe_id_t probe_id, record_type_t record_type, const char *fmt, ...);
69 /* Set most links from us_proc_info to data in the bundle */
70 int link_bundle(void);
72 /* Undo the actions of link_bundle() */
73 void unlink_bundle(void);
76 Adds non-predefined kernel probe to the list.
78 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
81 Removes non-predefined kernel probe from the list.
83 extern int remove_probe_from_list (unsigned long addr);
86 Searches non-predefined kernel probe in the list.
88 extern kernel_probe_t *find_probe (unsigned long addr);
91 Copies event from user space to buffer and updates its pid/tid/cpu/time.
93 extern int put_us_event (char *data, unsigned long len);
98 extern int set_event_mask (int new_mask);
103 extern int get_event_mask (int *mask);
106 Sets predefined user space probes info.
108 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
110 Gets predefined user space probes info length.
112 extern int get_predef_uprobes_size(int *size);
114 Gets predefined user space probes info.
116 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
119 // internal bookkeeping of storage
120 extern char *p_buffer;
122 // list of selected non-predefined kernel probes
123 extern struct hlist_head kernel_probes;
125 // multiple handlers stuff
126 /*struct dbi_modules_handlers {
127 struct list_head modules_handlers;
131 struct dbi_modules_handlers_info {
132 struct module *dbi_module;
133 struct handler_map *dbi_handlers;
135 struct list_head dbi_list_head;
138 extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
139 extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
140 //unsigned long get_dbi_modules_handlers(void);*/
142 /* list of on-the-go installed kernel probes */
143 extern struct hlist_head otg_kernel_probes;
145 extern struct list_head otg_us_proc_info;
148 extern int event_mask;
150 // process pid to instrument
151 extern unsigned int inst_pid;
157 struct jprobe jprobe;
158 struct kretprobe retprobe;
159 unsigned long offset;
166 struct list_head list;
172 struct jprobe jprobe;
174 struct list_head list;
182 signed char reg; // -1 - memory, 0..127 - register number
184 struct list_head list;
185 } us_proc_vtp_data_t;
187 typedef struct dentry *STRUCT_DENTRY_PTR;
188 typedef struct vfsmount *STRUCT_VFSMOUNT_PTR;
194 STRUCT_DENTRY_PTR m_f_dentry;
195 STRUCT_VFSMOUNT_PTR m_vfs_mount;
199 us_proc_vtp_t *p_vtps;
204 //#include "new_dpf.h"
209 STRUCT_DENTRY_PTR m_f_dentry;
211 unsigned unres_ips_count;
212 unsigned unres_vtps_count;
213 unsigned unres_otg_ips_count;
214 //kprobe_opcode_t *mapped_codelets;
216 us_proc_lib_t *p_libs;
218 unsigned long libdvm_start;
219 unsigned long libdvm_end;
220 us_proc_ip_t libdvm_entry_ip;
221 us_proc_ip_t libdvm_return_ip;
222 #endif /* __ANDROID */
225 struct proc_probes *pp;
231 unsigned int inst_type;
243 dex_proc_ip_t *p_ips;
249 /* cond data itself */
250 struct event_tmpl tmpl;
252 struct list_head list;
253 /* has been applied (for start and stop conditions) */
257 extern struct cond cond_list;
259 /* macros for testing flags */
260 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
261 #define ET_FIELD_SET(flags, field) (flags |= field)
262 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
264 extern inst_us_proc_t us_proc_info;
265 extern inst_dex_proc_t dex_proc_info;
267 #endif /* !defined(__STORAGE_H__) */