Merge branch 'bundle'
[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 "picl.h"
22 #include "ec_ioctl.h"
23 #include "ec_probe.h"
24 #include "probes_manager.h"
25 #include "probes.h"
26 #include "event_tmpl.h"
27
28 ///////////////////////////////////////////////////////////////////////////////////////////////////
29
30 #ifndef __DISABLE_RELAYFS
31 extern struct rchan* GetRelayChannel(void);
32 extern struct dentry* GetRelayDir(void);
33 #endif //__DISABLE_RELAYFS
34
35 extern int EnableMultipleBuffer(void);
36 extern int DisableMultipleBuffer(void);
37 extern int EnableContinuousRetrieval(void);
38 extern int DisableContinuousRetrieval(void);
39
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41
42 extern unsigned int GetBufferSize(void);
43 extern int SetBufferSize(unsigned int nSize);
44 extern int ResetBuffer(void);
45
46 //extern spinlock_t buffer_spinlock;
47
48 ///////////////////////////////////////////////////////////////////////////////////////////////////
49
50 /*
51     Functions "storage_init()" and "storage_down()" are for initialization and
52     shutdown respectively.
53 */
54 extern int storage_init (void);
55 extern void storage_down (void);
56
57 /*
58     Function "pack_event_info()" saves information about event into buffer. It
59     is used in 'probes' to pack and save event data.
60 */
61 extern void pack_event_info (probe_id_t probe_id, record_type_t record_type, const char *fmt, ...);
62
63 /*
64     Function "set_us_proc_inst()" saves instrumentation info for user space process.
65 */
66 extern int set_us_proc_inst_info (ioctl_inst_usr_space_proc_t * inst_info);
67
68 /* Set most links from us_proc_info to data in the bundle */
69 int link_bundle();
70
71 /* Undo the actions of link_bundle() */
72 void unlink_bundle();
73
74 /*
75     Function "release_us_proc_inst_info()" destroys instrumentation info for user space process.
76 */
77 extern void release_us_proc_inst_info (void);
78
79 /*
80     Adds non-predefined kernel probe to the list.
81 */
82 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
83
84 /*
85     Removes non-predefined kernel probe from the list.
86 */
87 extern int remove_probe_from_list (unsigned long addr);
88
89 /*
90     Searches non-predefined kernel probe in the list.
91 */
92 extern kernel_probe_t *find_probe (unsigned long addr);
93
94 /*
95     Copies event from user space to buffer and updates its pid/tid/cpu/time.
96 */
97 extern int put_us_event (char *data, unsigned long len);
98
99 /*
100     Sets event mask.
101 */
102 extern int set_event_mask (int new_mask);
103
104 /*
105     Gets event mask.
106 */
107 extern int get_event_mask (int *mask);
108
109 /*
110     Sets predefined user space probes info.
111 */
112 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
113 /*
114     Gets predefined user space probes info length.
115 */
116 extern int get_predef_uprobes_size(int *size);
117 /*
118     Gets predefined user space probes info.
119 */
120 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
121
122
123 // internal bookkeeping of storage
124 extern char *p_buffer;
125
126 // list of selected non-predefined kernel probes
127 extern struct hlist_head kernel_probes;
128
129 // event mask
130 extern int event_mask;
131
132 typedef struct
133 {
134         char *name;
135         int installed;
136         struct jprobe jprobe;
137         struct kretprobe retprobe;
138         unsigned long offset;
139 } us_proc_ip_t;
140
141 typedef struct
142 {
143         int installed;
144         struct jprobe jprobe;
145         unsigned long addr;
146         struct list_head list;
147 } us_proc_vtp_t;
148
149 typedef struct
150 {
151         //char *name;
152         char type;
153         unsigned long size;
154         signed char reg;        // -1 - memory, 0..127 - register number  
155         long off;
156         struct list_head list;
157 } us_proc_vtp_data_t;
158
159 typedef struct dentry *STRUCT_DENTRY_PTR;
160
161 typedef struct
162 {
163         char *path;
164         STRUCT_DENTRY_PTR m_f_dentry;
165         unsigned ips_count;
166         us_proc_ip_t *p_ips;
167         unsigned vtps_count;
168         us_proc_vtp_t *p_vtps;
169         int loaded;
170 } us_proc_lib_t;
171
172 typedef struct
173 {
174         char *path;
175         STRUCT_DENTRY_PTR m_f_dentry;
176         pid_t tgid;
177         unsigned unres_ips_count;
178         unsigned unres_vtps_count;
179         //kprobe_opcode_t *mapped_codelets;
180         unsigned libs_count;
181         us_proc_lib_t *p_libs;
182 } inst_us_proc_t;
183
184 struct cond {
185         /* cond data itself */
186         struct event_tmpl tmpl;
187         /* linked list */
188         struct list_head list;
189         /* has been applied (for start and stop conditions) */
190         int applied;
191 };
192
193 extern struct cond cond_list;
194
195 /* macros for testing flags */
196 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
197 #define ET_FIELD_SET(flags, field) (flags |= field)
198 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
199
200 extern inst_us_proc_t us_proc_info;
201
202
203 #endif /* !defined(__STORAGE_H__) */