Linux-2.6.12-rc2
[linux-flexiantxendom0-natty.git] / include / asm-ppc64 / ptrace-common.h
1 /*
2  *  linux/arch/ppc64/kernel/ptrace-common.h
3  *
4  *    Copyright (c) 2002 Stephen Rothwell, IBM Coproration
5  *    Extracted from ptrace.c and ptrace32.c
6  *
7  * This file is subject to the terms and conditions of the GNU General
8  * Public License.  See the file README.legal in the main directory of
9  * this archive for more details.
10  */
11
12 #ifndef _PPC64_PTRACE_COMMON_H
13 #define _PPC64_PTRACE_COMMON_H
14 /*
15  * Set of msr bits that gdb can change on behalf of a process.
16  */
17 #define MSR_DEBUGCHANGE (MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
18
19 /*
20  * Get contents of register REGNO in task TASK.
21  */
22 static inline unsigned long get_reg(struct task_struct *task, int regno)
23 {
24         unsigned long tmp = 0;
25
26         /*
27          * Put the correct FP bits in, they might be wrong as a result
28          * of our lazy FP restore.
29          */
30         if (regno == PT_MSR) {
31                 tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
32                 tmp |= task->thread.fpexc_mode;
33         } else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
34                 tmp = ((unsigned long *)task->thread.regs)[regno];
35         }
36
37         return tmp;
38 }
39
40 /*
41  * Write contents of register REGNO in task TASK.
42  */
43 static inline int put_reg(struct task_struct *task, int regno,
44                           unsigned long data)
45 {
46         if (regno < PT_SOFTE) {
47                 if (regno == PT_MSR)
48                         data = (data & MSR_DEBUGCHANGE)
49                                 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
50                 ((unsigned long *)task->thread.regs)[regno] = data;
51                 return 0;
52         }
53         return -EIO;
54 }
55
56 static inline void set_single_step(struct task_struct *task)
57 {
58         struct pt_regs *regs = task->thread.regs;
59         if (regs != NULL)
60                 regs->msr |= MSR_SE;
61         set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
62 }
63
64 static inline void clear_single_step(struct task_struct *task)
65 {
66         struct pt_regs *regs = task->thread.regs;
67         if (regs != NULL)
68                 regs->msr &= ~MSR_SE;
69         clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
70 }
71
72 #endif /* _PPC64_PTRACE_COMMON_H */