ef499483008d980bd226d66390596792bdaf575f
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / kernel / swap / us_manager / sspt / sspt_proc.h
1 #ifndef __SSPT_PROC__
2 #define __SSPT_PROC__
3
4 /**
5  * @file us_manager/sspt/sspt_proc.h
6  * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
7  *
8  * @section LICENSE
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @section COPYRIGHT
24  * Copyright (C) Samsung Electronics, 2013
25  */
26
27 #include <linux/types.h>
28 #include "sspt_file.h"
29
30 struct slot_manager;
31 struct task_struct;
32 struct pf_group;
33 struct sspt_filter;
34 struct us_ip;
35
36 /** Flags for sspt_*_uninstall() */
37 enum US_FLAGS {
38         US_UNREGS_PROBE,        /**< probes remove and disarm */
39         US_DISARM,              /**< probes disarm */
40         US_UNINSTALL            /**< probes remove from list install */
41 };
42
43 /**
44  * @struct sspt_proc
45  * @breaf Image of process for specified process
46  */
47 struct sspt_proc {
48         struct list_head list;          /**< For global process list */
49         pid_t tgid;                     /**< Thread group ID */
50         struct task_struct *task;       /**< Ptr to the task */
51         struct mm_struct *__mm;
52         struct task_struct *__task;
53         unsigned long r_state_addr;     /**< address of r_state */
54         struct slot_manager *sm;        /**< Ptr to the manager slot */
55         struct list_head file_list;     /**< For sspt_file */
56         rwlock_t filter_lock;
57         struct list_head filter_list;   /**< Filter list */
58         unsigned first_install:1;       /**< Install flag */
59         struct sspt_feature *feature;   /**< Ptr to the feature */
60         atomic_t usage;
61
62         /* FIXME: for preload (remove those fields) */
63         void *private_data;             /**< Process private data */
64 };
65
66 struct sspt_proc_cb {
67         void *(*priv_create)(struct sspt_proc *);
68         void (*priv_destroy)(struct sspt_proc *, void *);
69 };
70
71
72 struct list_head *sspt_proc_list(void);
73
74 struct sspt_proc *sspt_proc_create(struct task_struct *task);
75 void sspt_proc_cleanup(struct sspt_proc *proc);
76 struct sspt_proc *sspt_proc_get(struct sspt_proc *proc);
77 void sspt_proc_put(struct sspt_proc *proc);
78
79 void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *),
80                           void *data);
81 void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data);
82
83 struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task);
84 struct sspt_proc *sspt_proc_get_by_task_no_lock(struct task_struct *task);
85 struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task);
86 void sspt_proc_free_all(void);
87
88 struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc,
89                                       struct dentry *dentry);
90 struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc,
91                                              struct dentry *dentry);
92
93 void sspt_proc_install_probe(struct sspt_proc *proc, unsigned long vaddr,
94                              struct probe_info *probe_i);
95 void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr);
96 void sspt_proc_install(struct sspt_proc *proc);
97 int sspt_proc_uninstall(struct sspt_proc *proc,
98                         struct task_struct *task,
99                         enum US_FLAGS flag);
100
101 int sspt_proc_get_files_by_region(struct sspt_proc *proc,
102                                   struct list_head *head,
103                                   unsigned long start, size_t len);
104 void sspt_proc_insert_files(struct sspt_proc *proc, struct list_head *head);
105
106 void sspt_proc_read_lock(void);
107 void sspt_proc_read_unlock(void);
108 void sspt_proc_write_lock(void);
109 void sspt_proc_write_unlock(void);
110
111 void sspt_proc_add_filter(struct sspt_proc *proc, struct pf_group *pfg);
112 void sspt_proc_del_filter(struct sspt_proc *proc, struct pf_group *pfg);
113 void sspt_proc_del_all_filters(struct sspt_proc *proc);
114 bool sspt_proc_is_filter_new(struct sspt_proc *proc, struct pf_group *pfg);
115
116 void sspt_proc_on_each_filter(struct sspt_proc *proc,
117                               void (*func)(struct sspt_filter *, void *),
118                               void *data);
119
120 void sspt_proc_on_each_ip(struct sspt_proc *proc,
121                           void (*func)(struct us_ip *, void *), void *data);
122
123 bool sspt_proc_is_send_event(struct sspt_proc *proc);
124
125 int sspt_proc_cb_set(struct sspt_proc_cb *cb);
126 void sspt_proc_priv_create(struct sspt_proc *proc);
127 void sspt_proc_priv_destroy(struct sspt_proc *proc);
128
129 #endif /* __SSPT_PROC__ */