[POWERPC] ptrace cleanups
[safe/jmp/linux-2.6] / arch / powerpc / kernel / ptrace-ppc32.h
1 /*
2  *    Copyright (c) 2007 Benjamin Herrenschmidt, IBM Coproration
3  *    Extracted from ptrace.c and ptrace32.c
4  *
5  * This file is subject to the terms and conditions of the GNU General
6  * Public License.  See the file README.legal in the main directory of
7  * this archive for more details.
8  */
9
10 #ifndef _POWERPC_PTRACE_PPC32_H
11 #define _POWERPC_PTRACE_PPC32_H
12
13 /*
14  * Set of msr bits that gdb can change on behalf of a process.
15  */
16 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
17 #define MSR_DEBUGCHANGE 0
18 #else
19 #define MSR_DEBUGCHANGE (MSR_SE | MSR_BE)
20 #endif
21
22 /*
23  * Max register writeable via put_reg
24  */
25 #define PT_MAX_PUT_REG  PT_MQ
26
27 /*
28  * Munging of MSR on return from get_regs
29  *
30  * Nothing to do on ppc32
31  */
32 #define PT_MUNGE_MSR(msr, task) (msr)
33
34
35 #ifdef CONFIG_SPE
36
37 /*
38  * For get_evrregs/set_evrregs functions 'data' has the following layout:
39  *
40  * struct {
41  *   u32 evr[32];
42  *   u64 acc;
43  *   u32 spefscr;
44  * }
45  */
46
47 /*
48  * Get contents of SPE register state in task TASK.
49  */
50 static inline int get_evrregs(unsigned long *data, struct task_struct *task)
51 {
52         int i;
53
54         if (!access_ok(VERIFY_WRITE, data, 35 * sizeof(unsigned long)))
55                 return -EFAULT;
56
57         /* copy SPEFSCR */
58         if (__put_user(task->thread.spefscr, &data[34]))
59                 return -EFAULT;
60
61         /* copy SPE registers EVR[0] .. EVR[31] */
62         for (i = 0; i < 32; i++, data++)
63                 if (__put_user(task->thread.evr[i], data))
64                         return -EFAULT;
65
66         /* copy ACC */
67         if (__put_user64(task->thread.acc, (unsigned long long *)data))
68                 return -EFAULT;
69
70         return 0;
71 }
72
73 /*
74  * Write contents of SPE register state into task TASK.
75  */
76 static inline int set_evrregs(struct task_struct *task, unsigned long *data)
77 {
78         int i;
79
80         if (!access_ok(VERIFY_READ, data, 35 * sizeof(unsigned long)))
81                 return -EFAULT;
82
83         /* copy SPEFSCR */
84         if (__get_user(task->thread.spefscr, &data[34]))
85                 return -EFAULT;
86
87         /* copy SPE registers EVR[0] .. EVR[31] */
88         for (i = 0; i < 32; i++, data++)
89                 if (__get_user(task->thread.evr[i], data))
90                         return -EFAULT;
91         /* copy ACC */
92         if (__get_user64(task->thread.acc, (unsigned long long*)data))
93                 return -EFAULT;
94
95         return 0;
96 }
97 #endif /* CONFIG_SPE */
98
99
100 #endif /* _POWERPC_PTRACE_PPC32_H */