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.
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.
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.
16 * Copyright (C) Samsung Electronics, 2016
18 * 2015 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
23 #include <linux/sched.h>
24 #include <linux/string.h>
25 #include <writer/swap_msg.h>
31 * +-------------+----------+----------+
32 * | name | type | lenght |
33 * +-------------+----------+----------+
35 * | wsp_id | int | 4 |
36 * | wsp_payload | variable | variable |
37 * +-------------+----------+----------+
40 * - WSP_RES_LOAD_BEGIN = 0x0001
41 * - WSP_RES_LOAD_END = 0x0002
42 * - WSP_RES_PROC_BEGIN = 0x0003
43 * - WSP_RES_PROC_END = 0x0004
44 * - WSP_DRAW_BEGIN = 0x0005
45 * - WSP_DRAW_END = 0x0006
49 * 1. WSP_RES_LOAD_BEGIN:
50 * +--------+--------+----------+
51 * | name | type | lenght |
52 * +--------+--------+----------+
53 * | res_id | int | 4 |
54 * | path | string | variable |
55 * +--------+--------+----------+
57 * 2. WSP_RES_LOAD_END, WSP_RES_PROC_BEGIN, WSP_RES_PROC_END:
58 * +--------+--------+----------+
59 * | name | type | lenght |
60 * +--------+--------+----------+
61 * | res_id | int | 4 |
62 * +--------+--------+----------+
64 * 3. WSP_DRAW_BEGIN, WSP_DRAW_END:
68 static int pack_wsp_msg(void *data, size_t size, enum wsp_id id,
69 u32 res_id, const char *path)
72 const size_t old_size = size;
75 *(u32 *)data = (u32)current->tgid;
80 *(u32 *)data = (u32)id;
84 /* pack wsp_payload */
86 case WSP_RES_LOAD_BEGIN:
87 len = strlen(path) + 1;
91 /* '+ 4' - skip space for res_id */
92 memcpy(data + 4, path, len);
94 case WSP_RES_LOAD_END:
95 case WSP_RES_PROC_BEGIN:
96 case WSP_RES_PROC_END:
98 *(u32 *)data = res_id;
107 printk(KERN_ERR "unknown wsp_id: id=%u\n", (unsigned)id);
111 return old_size - size;
114 void wsp_msg(enum wsp_id id, u32 res_id, const char *path)
121 m = swap_msg_get(MSG_WSP);
122 data = swap_msg_payload(m);
123 size = swap_msg_size(m);
124 ret = pack_wsp_msg(data, size, id, res_id, path);
126 printk(KERN_ERR "error MSG_WSP packing, ret=%d\n", ret);
130 swap_msg_flush(m, ret);