Merge branch 'kernel' of 106.109.8.71:/srv/git/dbi into kernel
[kernel/swap-modules.git] / us_manager / sspt / ip.c
1 /*
2  *  Dynamic Binary Instrumentation Module based on KProbes
3  *  modules/driver/sspt/ip.c
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 <v.cherkashin@samsung.com>
22  *
23  */
24
25 #include <linux/slab.h>
26 #include "ip.h"
27 #include "sspt_page.h"
28 #include "sspt_file.h"
29
30 /* FIXME: */
31 #include "../../driver/us_def_handler.h"
32
33 struct us_ip *create_ip(unsigned long offset, const char *args)
34 {
35         struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
36         memset(ip, 0, sizeof(*ip));
37
38         INIT_LIST_HEAD(&ip->list);
39         ip->offset = offset;
40
41         ip->got_addr = 0;
42         ip->flag_got = 1;
43
44         /* jprobe */
45         ip->jprobe.pre_entry = ujprobe_event_pre_handler;
46         ip->jprobe.entry = ujprobe_event_handler;
47
48         /* TODO: or copy args?! */
49         ip->jprobe.args = args;
50
51         /* retprobe */
52         ip->flag_retprobe = 1;
53         ip->retprobe.handler = uretprobe_event_handler;
54
55         return ip;
56 }
57
58 void free_ip(struct us_ip *ip)
59 {
60         kfree(ip);
61 }