Removing almost all dependencies between inperfa_driver and Memory Error Checker.
[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 /*
69     Function "release_us_proc_inst_info()" destroys instrumentation info for user space process.
70 */
71 extern void release_us_proc_inst_info (void);
72
73 /*
74     Adds non-predefined kernel probe to the list.
75 */
76 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
77
78 /*
79     Removes non-predefined kernel probe from the list.
80 */
81 extern int remove_probe_from_list (unsigned long addr);
82
83 /*
84     Searches non-predefined kernel probe in the list.
85 */
86 extern kernel_probe_t *find_probe (unsigned long addr);
87
88 /*
89     Copies event from user space to buffer and updates its pid/tid/cpu/time.
90 */
91 extern int put_us_event (char *data, unsigned long len);
92
93 /*
94     Sets event mask.
95 */
96 extern int set_event_mask (int new_mask);
97
98 /*
99     Gets event mask.
100 */
101 extern int get_event_mask (int *mask);
102
103 /*
104     Sets predefined user space probes info.
105 */
106 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
107 /*
108     Gets predefined user space probes info length.
109 */
110 extern int get_predef_uprobes_size(int *size);
111 /*
112     Gets predefined user space probes info.
113 */
114 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
115
116
117 // internal bookkeeping of storage
118 extern char *p_buffer;
119
120 // list of selected non-predefined kernel probes
121 extern struct hlist_head kernel_probes;
122
123 // event mask
124 extern int event_mask;
125
126 typedef struct
127 {
128         char *name;
129         int installed;
130         struct jprobe jprobe;
131         struct kretprobe retprobe;
132         unsigned long offset;
133 } us_proc_ip_t;
134
135 typedef struct
136 {
137         int installed;
138         struct jprobe jprobe;
139         unsigned long addr;
140         struct list_head list;
141 } us_proc_vtp_t;
142
143 typedef struct
144 {
145         //char *name;
146         char type;
147         unsigned long size;
148         signed char reg;        // -1 - memory, 0..127 - register number  
149         long off;
150         struct list_head list;
151 } us_proc_vtp_data_t;
152
153 typedef struct dentry *STRUCT_DENTRY_PTR;
154
155 typedef struct
156 {
157         char *path;
158         STRUCT_DENTRY_PTR m_f_dentry;
159         unsigned ips_count;
160         us_proc_ip_t *p_ips;
161         unsigned vtps_count;
162         us_proc_vtp_t *p_vtps;
163         int loaded;
164 } us_proc_lib_t;
165
166 typedef struct
167 {
168         char *path;
169         STRUCT_DENTRY_PTR m_f_dentry;
170         pid_t tgid;
171         unsigned unres_ips_count;
172         unsigned unres_vtps_count;
173         //kprobe_opcode_t *mapped_codelets;
174         unsigned libs_count;
175         us_proc_lib_t *p_libs;
176 } inst_us_proc_t;
177
178 struct cond {
179         /* cond data itself */
180         struct event_tmpl tmpl;
181         /* linked list */
182         struct list_head list;
183         /* has been applied (for start and stop conditions) */
184         int applied;
185 };
186
187 extern struct cond cond_list;
188
189 /* macros for testing flags */
190 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
191 #define ET_FIELD_SET(flags, field) (flags |= field)
192 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
193
194 extern inst_us_proc_t us_proc_info;
195
196
197 #endif /* !defined(__STORAGE_H__) */