diff options
Diffstat (limited to 'arch/powerpc/kernel/ptrace-common.h')
-rw-r--r-- | arch/powerpc/kernel/ptrace-common.h | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/arch/powerpc/kernel/ptrace-common.h b/arch/powerpc/kernel/ptrace-common.h deleted file mode 100644 index 21884535fee6..000000000000 --- a/arch/powerpc/kernel/ptrace-common.h +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2002 Stephen Rothwell, IBM Coproration | ||
3 | * Copyright (c) 2007 Benjamin Herrenschmidt, IBM Coproration | ||
4 | * Extracted from ptrace.c and ptrace32.c | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General | ||
7 | * Public License. See the file README.legal in the main directory of | ||
8 | * this archive for more details. | ||
9 | */ | ||
10 | |||
11 | #ifndef _POWERPC_PTRACE_COMMON_H | ||
12 | #define _POWERPC_PTRACE_COMMON_H | ||
13 | |||
14 | /* | ||
15 | * Get contents of register REGNO in task TASK. | ||
16 | */ | ||
17 | static inline unsigned long get_reg(struct task_struct *task, int regno) | ||
18 | { | ||
19 | unsigned long tmp = 0; | ||
20 | |||
21 | if (task->thread.regs == NULL) | ||
22 | return -EIO; | ||
23 | |||
24 | if (regno == PT_MSR) { | ||
25 | tmp = ((unsigned long *)task->thread.regs)[PT_MSR]; | ||
26 | return PT_MUNGE_MSR(tmp, task); | ||
27 | } | ||
28 | |||
29 | if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) | ||
30 | return ((unsigned long *)task->thread.regs)[regno]; | ||
31 | |||
32 | return -EIO; | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * Write contents of register REGNO in task TASK. | ||
37 | */ | ||
38 | static inline int put_reg(struct task_struct *task, int regno, | ||
39 | unsigned long data) | ||
40 | { | ||
41 | if (task->thread.regs == NULL) | ||
42 | return -EIO; | ||
43 | |||
44 | if (regno <= PT_MAX_PUT_REG) { | ||
45 | if (regno == PT_MSR) | ||
46 | data = (data & MSR_DEBUGCHANGE) | ||
47 | | (task->thread.regs->msr & ~MSR_DEBUGCHANGE); | ||
48 | ((unsigned long *)task->thread.regs)[regno] = data; | ||
49 | return 0; | ||
50 | } | ||
51 | return -EIO; | ||
52 | } | ||
53 | |||
54 | |||
55 | static inline int get_fpregs(void __user *data, | ||
56 | struct task_struct *task, | ||
57 | int has_fpscr) | ||
58 | { | ||
59 | unsigned int count = has_fpscr ? 33 : 32; | ||
60 | |||
61 | if (copy_to_user(data, task->thread.fpr, count * sizeof(double))) | ||
62 | return -EFAULT; | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static inline int set_fpregs(void __user *data, | ||
67 | struct task_struct *task, | ||
68 | int has_fpscr) | ||
69 | { | ||
70 | unsigned int count = has_fpscr ? 33 : 32; | ||
71 | |||
72 | if (copy_from_user(task->thread.fpr, data, count * sizeof(double))) | ||
73 | return -EFAULT; | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | |||
78 | #ifdef CONFIG_ALTIVEC | ||
79 | /* | ||
80 | * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go. | ||
81 | * The transfer totals 34 quadword. Quadwords 0-31 contain the | ||
82 | * corresponding vector registers. Quadword 32 contains the vscr as the | ||
83 | * last word (offset 12) within that quadword. Quadword 33 contains the | ||
84 | * vrsave as the first word (offset 0) within the quadword. | ||
85 | * | ||
86 | * This definition of the VMX state is compatible with the current PPC32 | ||
87 | * ptrace interface. This allows signal handling and ptrace to use the | ||
88 | * same structures. This also simplifies the implementation of a bi-arch | ||
89 | * (combined (32- and 64-bit) gdb. | ||
90 | */ | ||
91 | |||
92 | /* | ||
93 | * Get contents of AltiVec register state in task TASK | ||
94 | */ | ||
95 | static inline int get_vrregs(unsigned long __user *data, | ||
96 | struct task_struct *task) | ||
97 | { | ||
98 | unsigned long regsize; | ||
99 | |||
100 | /* copy AltiVec registers VR[0] .. VR[31] */ | ||
101 | regsize = 32 * sizeof(vector128); | ||
102 | if (copy_to_user(data, task->thread.vr, regsize)) | ||
103 | return -EFAULT; | ||
104 | data += (regsize / sizeof(unsigned long)); | ||
105 | |||
106 | /* copy VSCR */ | ||
107 | regsize = 1 * sizeof(vector128); | ||
108 | if (copy_to_user(data, &task->thread.vscr, regsize)) | ||
109 | return -EFAULT; | ||
110 | data += (regsize / sizeof(unsigned long)); | ||
111 | |||
112 | /* copy VRSAVE */ | ||
113 | if (put_user(task->thread.vrsave, (u32 __user *)data)) | ||
114 | return -EFAULT; | ||
115 | |||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Write contents of AltiVec register state into task TASK. | ||
121 | */ | ||
122 | static inline int set_vrregs(struct task_struct *task, | ||
123 | unsigned long __user *data) | ||
124 | { | ||
125 | unsigned long regsize; | ||
126 | |||
127 | /* copy AltiVec registers VR[0] .. VR[31] */ | ||
128 | regsize = 32 * sizeof(vector128); | ||
129 | if (copy_from_user(task->thread.vr, data, regsize)) | ||
130 | return -EFAULT; | ||
131 | data += (regsize / sizeof(unsigned long)); | ||
132 | |||
133 | /* copy VSCR */ | ||
134 | regsize = 1 * sizeof(vector128); | ||
135 | if (copy_from_user(&task->thread.vscr, data, regsize)) | ||
136 | return -EFAULT; | ||
137 | data += (regsize / sizeof(unsigned long)); | ||
138 | |||
139 | /* copy VRSAVE */ | ||
140 | if (get_user(task->thread.vrsave, (u32 __user *)data)) | ||
141 | return -EFAULT; | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | #endif /* CONFIG_ALTIVEC */ | ||
146 | |||
147 | static inline void set_single_step(struct task_struct *task) | ||
148 | { | ||
149 | struct pt_regs *regs = task->thread.regs; | ||
150 | |||
151 | if (regs != NULL) { | ||
152 | #if defined(CONFIG_40x) || defined(CONFIG_BOOKE) | ||
153 | task->thread.dbcr0 = DBCR0_IDM | DBCR0_IC; | ||
154 | regs->msr |= MSR_DE; | ||
155 | #else | ||
156 | regs->msr |= MSR_SE; | ||
157 | #endif | ||
158 | } | ||
159 | set_tsk_thread_flag(task, TIF_SINGLESTEP); | ||
160 | } | ||
161 | |||
162 | static inline void clear_single_step(struct task_struct *task) | ||
163 | { | ||
164 | struct pt_regs *regs = task->thread.regs; | ||
165 | |||
166 | if (regs != NULL) { | ||
167 | #if defined(CONFIG_40x) || defined(CONFIG_BOOKE) | ||
168 | task->thread.dbcr0 = 0; | ||
169 | regs->msr &= ~MSR_DE; | ||
170 | #else | ||
171 | regs->msr &= ~MSR_SE; | ||
172 | #endif | ||
173 | } | ||
174 | clear_tsk_thread_flag(task, TIF_SINGLESTEP); | ||
175 | } | ||
176 | |||
177 | #endif /* _POWERPC_PTRACE_COMMON_H */ | ||