Merge "[REFACTOR] Buffer: move getting next queue element into separate function"
[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         AT_TIZEN_WEB_APP        = 0x04
38 };
39
40 enum {
41         SIZE_APP_TYPE = 4
42 };
43
44 /* Basic application information */
45 struct app_info_data {
46         enum APP_TYPE app_type;
47         pid_t tgid;
48         char *exec_path;
49 };
50
51 /* Configuration struct */
52 struct conf_data {
53         u64 use_features0;
54         u64 use_features1;
55         u32 sys_trace_period;
56         u32 data_msg_period;
57 };
58
59 /* Application and library functions to set probes */
60 struct func_inst_data {
61         u64 addr;
62         char *args;
63         char ret_type;
64 };
65
66 /* Library struct */
67 struct lib_inst_data {
68         char *path;
69         u32 cnt_func;
70         struct func_inst_data **func;
71 };
72
73 /* Application struct */
74 struct app_inst_data {
75         struct app_info_data *app_info;
76         u32 cnt_func;
77         struct func_inst_data **func;
78         u32 cnt_lib;
79         struct lib_inst_data **lib;
80 };
81
82 /* User space instrumentation struct */
83 struct us_inst_data {
84         u32 cnt;
85         struct app_inst_data **app_inst;
86 };
87
88
89 struct app_info_data *create_app_info(struct msg_buf *mb);
90 void destroy_app_info(struct app_info_data *app_info);
91
92 struct conf_data *create_conf_data(struct msg_buf *mb);
93 void destroy_conf_data(struct conf_data *conf);
94
95 void save_config(const struct conf_data *conf);
96 void restore_config(struct conf_data *conf);
97
98 struct func_inst_data *create_func_inst_data(struct msg_buf *mb);
99 void destroy_func_inst_data(struct func_inst_data *func_inst);
100
101 struct lib_inst_data *create_lib_inst_data(struct msg_buf *mb);
102 void destroy_lib_inst_data(struct lib_inst_data *lib_inst);
103
104 struct app_inst_data *create_app_inst_data(struct msg_buf *mb);
105 void destroy_app_inst_data(struct app_inst_data *app_inst);
106
107 struct us_inst_data *create_us_inst_data(struct msg_buf *mb);
108 void destroy_us_inst_data(struct us_inst_data *us_inst);
109
110
111 /* empty functions for calculating size fields in structures */
112 struct func_inst_data make_func_inst_data(void);
113 struct lib_inst_data make_lib_inst_data(void);
114 struct app_inst_data make_app_inst_data(void);
115 struct us_inst_data make_us_inst_data(void);
116
117 enum {
118         MIN_SIZE_STRING = 1,
119         MIN_SIZE_FUNC_INST = sizeof(make_func_inst_data().addr) +
120                              MIN_SIZE_STRING,
121         MIN_SIZE_LIB_INST = MIN_SIZE_STRING +
122                             sizeof(make_lib_inst_data().cnt_func),
123         MIN_SIZE_APP_INFO = SIZE_APP_TYPE + MIN_SIZE_STRING + MIN_SIZE_STRING,
124         MIN_SIZE_APP_INST = MIN_SIZE_APP_INFO +
125                             sizeof(make_app_inst_data().cnt_func) +
126                             sizeof(make_app_inst_data().cnt_lib),
127         MIN_SIZE_US_INST = sizeof(make_us_inst_data().cnt)
128 };
129
130 #endif /* _MSG_PARSER_H */