Merge commit '1b93c9c0d8b9' into kernel
[kernel/swap-modules.git] / parser / msg_parser.h
1 /*
2  *  SWAP Parser
3  *  modules/parser/msg_parser.h
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Copyright (C) Samsung Electronics, 2013
20  *
21  * 2013  Vyacheslav Cherkashin, Vitaliy Cherepanov: SWAP Parser implement
22  *
23  */
24
25
26 #ifndef _MSG_PARSER_H
27 #define _MSG_PARSER_H
28
29 #include <linux/types.h>
30
31 struct msg_buf;
32
33 enum APP_TYPE {
34         AT_TIZEN_NATIVE_APP     = 0x01,
35         AT_PID                  = 0x02,
36         AT_COMMON_EXEC          = 0x03
37 };
38
39 enum {
40         SIZE_APP_TYPE = 4
41 };
42
43 /* Basic application information */
44 struct app_info_data {
45         enum APP_TYPE app_type;
46         pid_t tgid;
47         char *exec_path;
48 };
49
50 /* Configuration struct */
51 struct conf_data {
52         u64 use_features0;
53         u64 use_features1;
54         u32 sys_trace_period;
55         u32 data_msg_period;
56 };
57
58 /* Application and library functions to set probes */
59 struct func_inst_data {
60         u64 addr;
61         char *args;
62 };
63
64 /* Library struct */
65 struct lib_inst_data {
66         char *path;
67         u32 cnt_func;
68         struct func_inst_data **func;
69 };
70
71 /* Application struct */
72 struct app_inst_data {
73         struct app_info_data *app_info;
74         u32 cnt_func;
75         struct func_inst_data **func;
76         u32 cnt_lib;
77         struct lib_inst_data **lib;
78 };
79
80 /* User space instrumentation struct */
81 struct us_inst_data {
82         u32 cnt;
83         struct app_inst_data **app_inst;
84 };
85
86
87 struct app_info_data *create_app_info(struct msg_buf *mb);
88 void destroy_app_info(struct app_info_data *app_info);
89
90 struct conf_data *create_conf_data(struct msg_buf *mb);
91 void destroy_conf_data(struct conf_data *conf);
92
93 struct func_inst_data *create_func_inst_data(struct msg_buf *mb);
94 void destroy_func_inst_data(struct func_inst_data *func_inst);
95
96 struct lib_inst_data *create_lib_inst_data(struct msg_buf *mb);
97 void destroy_lib_inst_data(struct lib_inst_data *lib_inst);
98
99 struct app_inst_data *create_app_inst_data(struct msg_buf *mb);
100 void destroy_app_inst_data(struct app_inst_data *app_inst);
101
102 struct us_inst_data *create_us_inst_data(struct msg_buf *mb);
103 void destroy_us_inst_data(struct us_inst_data *us_inst);
104
105
106 /* empty functions for calculating size fields in structures */
107 struct func_inst_data make_func_inst_data(void);
108 struct lib_inst_data make_lib_inst_data(void);
109 struct app_inst_data make_app_inst_data(void);
110 struct us_inst_data make_us_inst_data(void);
111
112 enum {
113         MIN_SIZE_STRING = 1,
114         MIN_SIZE_FUNC_INST = sizeof(make_func_inst_data().addr) +
115                              MIN_SIZE_STRING,
116         MIN_SIZE_LIB_INST = MIN_SIZE_STRING +
117                             sizeof(make_lib_inst_data().cnt_func),
118         MIN_SIZE_APP_INFO = SIZE_APP_TYPE + MIN_SIZE_STRING + MIN_SIZE_STRING,
119         MIN_SIZE_APP_INST = MIN_SIZE_APP_INFO +
120                             sizeof(make_app_inst_data().cnt_func) +
121                             sizeof(make_app_inst_data().cnt_lib),
122         MIN_SIZE_US_INST = sizeof(make_us_inst_data().cnt)
123 };
124
125 #endif /* _MSG_PARSER_H */