3 * modules/parser/swap_msg_parser.c
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.
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.
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.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Vyacheslav Cherkashin, Vitaliy Cherepanov: SWAP Parser implement
26 #include <linux/module.h>
27 #include <linux/vmalloc.h>
28 #include <asm/uaccess.h>
30 #include "parser_defs.h"
34 #include <driver/driver_to_msg.h>
35 #include <driver/swap_ioctl.h>
38 MSG_KEEP_ALIVE = 0x0001,
42 MSG_SWAP_INST_ADD = 0x0008,
43 MSG_SWAP_INST_REMOVE = 0x0009
46 struct basic_msg_fmt {
49 } __attribute__((packed));
51 static int msg_handler(void __user *msg)
58 struct basic_msg_fmt bmf;
60 ret = copy_from_user(&bmf, (void*)msg, sizeof(bmf));
65 ret = init_mb(&mb, size);
69 payload = msg + sizeof(bmf);
71 ret = copy_from_user(mb.begin, (void*)payload, size);
79 print_parse_debug("MSG_KEEP_ALIVE. size=%d\n", size);
80 ret = msg_keep_alive(&mb);
83 print_parse_debug("MSG_START. size=%d\n", size);
87 print_parse_debug("MSG_STOP. size=%d\n", size);
91 print_parse_debug("MSG_CONFIG. size=%d\n", size);
92 ret = msg_config(&mb);
94 case MSG_SWAP_INST_ADD:
95 print_parse_debug("MSG_SWAP_INST_ADD. size=%d\n", size);
96 ret = msg_swap_inst_add(&mb);
98 case MSG_SWAP_INST_REMOVE:
99 print_parse_debug("MSG_SWAP_INST_REMOVE. size=%d\n", size);
100 ret = msg_swap_inst_remove(&mb);
103 print_err("incorrect message ID [%u]. size=%d\n", msg_id, size);
113 static void register_msg_handler(void)
115 set_msg_handler(msg_handler);
118 static void unregister_msg_handler(void)
120 set_msg_handler(NULL);
123 static int __init swap_parser_init(void)
126 register_msg_handler();
133 static void __exit swap_parser_exit(void)
136 unregister_msg_handler();
139 module_init(swap_parser_init);
140 module_exit(swap_parser_exit);
142 MODULE_LICENSE("GPL");