tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / kernel / swap / writer / swap_msg.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * Copyright (C) Samsung Electronics, 2015
17  *
18  * 2015         Vyacheslav Cherkashin <v.cherkashin@samsung.com>
19  *
20  */
21
22
23 #ifndef _SWAP_MSG_H
24 #define _SWAP_MSG_H
25
26
27 #include <linux/time.h>
28 #include <linux/types.h>
29
30
31 enum swap_msg_id {
32         MSG_PROC_INFO                   = 0x0001,
33         MSG_TERMINATE                   = 0x0002,
34         MSG_ERROR                       = 0x0003,
35         MSG_SAMPLE                      = 0x0004,
36         MSG_FUNCTION_ENTRY              = 0x0008,
37         MSG_FUNCTION_EXIT               = 0x0009,
38         MSG_SYSCALL_ENTRY               = 0x000a,
39         MSG_SYSCALL_EXIT                = 0x000b,
40         MSG_FILE_FUNCTION_ENTRY         = 0x000c,
41         MSG_FILE_FUNCTION_EXIT          = 0x000d,
42         MSG_PROCESS_STATUS_INFO         = 0x000e,
43         MSG_CONTEXT_SWITCH_ENTRY        = 0x0010,
44         MSG_CONTEXT_SWITCH_EXIT         = 0x0011,
45         MSG_PROC_MAP                    = 0x0012,
46         MSG_PROC_UNMAP                  = 0x0013,
47         MSG_PROC_COMM                   = 0x0014,
48         MSG_WEB_FUNCTION_ENTRY          = 0x0015,
49         MSG_WEB_FUNCTION_EXIT           = 0x0016,
50         MSG_NSP                         = 0x0019,
51         MSG_WSP                         = 0x001a,
52         MSG_FBI                         = 0x0020
53 };
54
55 enum {
56         SWAP_MSG_PRIV_DATA = 20,
57         SWAP_MSG_BUF_SIZE = 32 * 1024,
58         SWAP_MSG_PAYLOAD_SIZE = SWAP_MSG_BUF_SIZE - SWAP_MSG_PRIV_DATA
59 };
60
61
62 struct swap_msg;
63
64
65 static inline u64 swap_msg_spec2time(struct timespec *ts)
66 {
67         return ((u64)ts->tv_nsec) << 32 | ts->tv_sec;
68 }
69
70 static inline u64 swap_msg_current_time(void)
71 {
72         struct timespec ts;
73         getnstimeofday(&ts);
74         return swap_msg_spec2time(&ts);
75 }
76
77 struct swap_msg *swap_msg_get(enum swap_msg_id id);
78 int swap_msg_flush(struct swap_msg *m, size_t size);
79 int swap_msg_flush_wakeupoff(struct swap_msg *m, size_t size);
80 void swap_msg_put(struct swap_msg *m);
81
82 static inline void *swap_msg_payload(struct swap_msg *m)
83 {
84         return (void *)m + SWAP_MSG_PRIV_DATA;
85 }
86
87 static inline size_t swap_msg_size(struct swap_msg *m)
88 {
89         return (size_t)SWAP_MSG_PAYLOAD_SIZE;
90 }
91
92
93 int swap_msg_pack_args(char *buf, int len,
94                        const char *fmt, struct pt_regs *regs);
95 int swap_msg_pack_ret_val(char *buf, int len,
96                           char ret_type, struct pt_regs *regs);
97
98
99 int swap_msg_raw(void *buf, size_t size);
100 void swap_msg_error(const char *fmt, ...);
101
102 void swap_msg_seq_num_reset(void);
103 void swap_msg_discard_reset(void);
104 int swap_msg_discard_get(void);
105
106 int swap_msg_init(void);
107 void swap_msg_exit(void);
108
109
110 #endif /* _SWAP_MSG_H */