tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / kernel / swap / uprobe / arch / arm / swap-asm / swap_uprobes.h
1 /**
2  * @file uprobe/arch/asm-arm/swap_uprobes.h
3  * @author Alexey Gerenkov <a.gerenkov@samsung.com> User-Space Probes initial
4  * implementation; Support x86/ARM/MIPS for both user and kernel spaces.
5  * @author Ekaterina Gorelkina <e.gorelkina@samsung.com>: redesign module for
6  * separating core and arch parts
7  *
8  * @section LICENSE
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23  *
24  * @section COPYRIGHT
25  *
26  * Copyright (C) Samsung Electronics, 2006-2010
27  *
28  * @section DESCRIPTION
29  *
30  * Arch-dependent uprobe interface declaration.
31  */
32
33
34 #ifndef _ARM_SWAP_UPROBES_H
35 #define _ARM_SWAP_UPROBES_H
36
37
38 #include <linux/uaccess.h>
39 #include <swap-asm/swap_kprobes.h>      /* FIXME: for UPROBES_TRAMP_LEN */
40
41
42 struct kprobe;
43 struct task_struct;
44 struct uprobe;
45 struct uretprobe;
46 struct uretprobe_instance;
47
48 /**
49  * @struct arch_specific_tramp
50  * @brief Stores arch-dependent trampolines.
51  */
52 struct arch_specific_tramp {
53 };
54
55
56 static inline u32 swap_get_urp_float(struct pt_regs *regs)
57 {
58         return regs->ARM_r0;
59 }
60
61 static inline u64 swap_get_urp_double(struct pt_regs *regs)
62 {
63
64         return regs->ARM_r0 | (u64)regs->ARM_r1 << 32;
65 }
66
67 static inline void arch_ujprobe_return(void)
68 {
69 }
70
71 int arch_prepare_uprobe(struct uprobe *up);
72
73 int setjmp_upre_handler(struct kprobe *p, struct pt_regs *regs);
74 static inline int longjmp_break_uhandler(struct kprobe *p, struct pt_regs *regs)
75 {
76         return 0;
77 }
78
79 void arch_opcode_analysis_uretprobe(struct uretprobe *rp);
80 int arch_prepare_uretprobe(struct uretprobe_instance *ri, struct pt_regs *regs);
81 int arch_disarm_urp_inst(struct uretprobe_instance *ri,
82                          struct task_struct *task, unsigned long tr);
83 unsigned long arch_tramp_by_ri(struct uretprobe_instance *ri);
84
85 unsigned long arch_get_trampoline_addr(struct kprobe *p, struct pt_regs *regs);
86 void arch_set_orig_ret_addr(unsigned long orig_ret_addr, struct pt_regs *regs);
87 void arch_remove_uprobe(struct uprobe *up);
88 int arch_arm_uprobe(struct uprobe *p);
89 void arch_disarm_uprobe(struct kprobe *p, struct task_struct *task);
90
91 static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
92 {
93         u32 *ptr, addr = 0;
94
95         switch (n) {
96         case 0:
97                 return regs->ARM_r0;
98         case 1:
99                 return regs->ARM_r1;
100         case 2:
101                 return regs->ARM_r2;
102         case 3:
103                 return regs->ARM_r3;
104         }
105
106         ptr = (u32 *)regs->ARM_sp + n - 4;
107         if (get_user(addr, ptr))
108                 printk(KERN_INFO "failed to dereference a pointer, ptr=%p\n",
109                        ptr);
110
111         return addr;
112 }
113
114 static inline void swap_put_uarg(struct pt_regs *regs, unsigned long n,
115                                  unsigned long val)
116 {
117         u32 *ptr;
118
119         switch (n) {
120         case 0:
121                 regs->ARM_r0 = val;
122                 break;
123         case 1:
124                 regs->ARM_r1 = val;
125                 break;
126         case 2:
127                 regs->ARM_r2 = val;
128                 break;
129         case 3:
130                 regs->ARM_r3 = val;
131                 break;
132         default:
133                 ptr = (u32 *)regs->ARM_sp + n - 4;
134                 if (put_user(val, ptr))
135                         pr_err("failed to dereference a pointer[%p]\n", ptr);
136         }
137 }
138
139 int swap_arch_init_uprobes(void);
140 void swap_arch_exit_uprobes(void);
141
142 #endif /* _ARM_SWAP_UPROBES_H */