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>
25 #include "probes_manager.h"
27 #include "event_tmpl.h"
29 ///////////////////////////////////////////////////////////////////////////////////////////////////
31 #ifndef __DISABLE_RELAYFS
32 extern struct rchan* GetRelayChannel(void);
33 extern struct dentry* GetRelayDir(void);
34 #endif //__DISABLE_RELAYFS
36 extern int EnableMultipleBuffer(void);
37 extern int DisableMultipleBuffer(void);
38 extern int EnableContinuousRetrieval(void);
39 extern int DisableContinuousRetrieval(void);
41 ///////////////////////////////////////////////////////////////////////////////////////////////////
43 extern unsigned int GetBufferSize(void);
44 extern int SetBufferSize(unsigned int nSize);
45 extern int ResetBuffer(void);
47 extern int SetPid(unsigned int pid);
49 //extern spinlock_t buffer_spinlock;
51 ///////////////////////////////////////////////////////////////////////////////////////////////////
54 Functions "storage_init()" and "storage_down()" are for initialization and
55 shutdown respectively.
57 extern int storage_init (void);
58 extern void storage_down (void);
61 Function "pack_event_info()" saves information about event into buffer. It
62 is used in 'probes' to pack and save event data.
64 extern void pack_event_info (probe_id_t probe_id, record_type_t record_type, const char *fmt, ...);
66 /* Set most links from us_proc_info to data in the bundle */
67 int link_bundle(void);
69 /* Undo the actions of link_bundle() */
70 void unlink_bundle(void);
73 Adds non-predefined kernel probe to the list.
75 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
78 Removes non-predefined kernel probe from the list.
80 extern int remove_probe_from_list (unsigned long addr);
83 Searches non-predefined kernel probe in the list.
85 extern kernel_probe_t *find_probe (unsigned long addr);
88 Copies event from user space to buffer and updates its pid/tid/cpu/time.
90 extern int put_us_event (char *data, unsigned long len);
95 extern int set_event_mask (int new_mask);
100 extern int get_event_mask (int *mask);
103 Sets predefined user space probes info.
105 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
107 Gets predefined user space probes info length.
109 extern int get_predef_uprobes_size(int *size);
111 Gets predefined user space probes info.
113 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
116 // internal bookkeeping of storage
117 extern char *p_buffer;
119 // list of selected non-predefined kernel probes
120 extern struct hlist_head kernel_probes;
122 /* list of on-the-go installed kernel probes */
123 extern struct hlist_head otg_kernel_probes;
125 extern struct list_head otg_us_proc_info;
128 extern int event_mask;
130 // process pid to instrument
131 extern unsigned int inst_pid;
137 struct jprobe jprobe;
138 struct kretprobe retprobe;
139 unsigned long offset;
146 struct list_head list;
152 struct jprobe jprobe;
154 struct list_head list;
162 signed char reg; // -1 - memory, 0..127 - register number
164 struct list_head list;
165 } us_proc_vtp_data_t;
167 typedef struct dentry *STRUCT_DENTRY_PTR;
168 typedef struct vfsmount *STRUCT_VFSMOUNT_PTR;
173 STRUCT_DENTRY_PTR m_f_dentry;
174 STRUCT_VFSMOUNT_PTR m_vfs_mount;
178 us_proc_vtp_t *p_vtps;
185 STRUCT_DENTRY_PTR m_f_dentry;
187 unsigned unres_ips_count;
188 unsigned unres_vtps_count;
189 //kprobe_opcode_t *mapped_codelets;
191 us_proc_lib_t *p_libs;
197 unsigned int inst_type;
209 dex_proc_ip_t *p_ips;
215 /* cond data itself */
216 struct event_tmpl tmpl;
218 struct list_head list;
219 /* has been applied (for start and stop conditions) */
223 extern struct cond cond_list;
225 /* macros for testing flags */
226 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
227 #define ET_FIELD_SET(flags, field) (flags |= field)
228 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
230 extern inst_us_proc_t us_proc_info;
231 extern inst_dex_proc_t dex_proc_info;
233 #endif /* !defined(__STORAGE_H__) */