[CONNECTOR]: Update documentation to match reality.
[linux-2.6/verdex.git] / include / asm-ppc64 / ptrace-common.h
blobb1babb7296733632baeaa2ea60a21e0399bc60e0
1 /*
2 * linux/arch/ppc64/kernel/ptrace-common.h
4 * Copyright (c) 2002 Stephen Rothwell, IBM Coproration
5 * Extracted from ptrace.c and ptrace32.c
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.
12 #ifndef _PPC64_PTRACE_COMMON_H
13 #define _PPC64_PTRACE_COMMON_H
15 #include <linux/config.h>
16 #include <asm/system.h>
19 * Set of msr bits that gdb can change on behalf of a process.
21 #define MSR_DEBUGCHANGE (MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
24 * Get contents of register REGNO in task TASK.
26 static inline unsigned long get_reg(struct task_struct *task, int regno)
28 unsigned long tmp = 0;
31 * Put the correct FP bits in, they might be wrong as a result
32 * of our lazy FP restore.
34 if (regno == PT_MSR) {
35 tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
36 tmp |= task->thread.fpexc_mode;
37 } else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
38 tmp = ((unsigned long *)task->thread.regs)[regno];
41 return tmp;
45 * Write contents of register REGNO in task TASK.
47 static inline int put_reg(struct task_struct *task, int regno,
48 unsigned long data)
50 if (regno < PT_SOFTE) {
51 if (regno == PT_MSR)
52 data = (data & MSR_DEBUGCHANGE)
53 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
54 ((unsigned long *)task->thread.regs)[regno] = data;
55 return 0;
57 return -EIO;
60 static inline void set_single_step(struct task_struct *task)
62 struct pt_regs *regs = task->thread.regs;
63 if (regs != NULL)
64 regs->msr |= MSR_SE;
65 set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
68 static inline void clear_single_step(struct task_struct *task)
70 struct pt_regs *regs = task->thread.regs;
71 if (regs != NULL)
72 regs->msr &= ~MSR_SE;
73 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
76 #ifdef CONFIG_ALTIVEC
78 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
79 * The transfer totals 34 quadword. Quadwords 0-31 contain the
80 * corresponding vector registers. Quadword 32 contains the vscr as the
81 * last word (offset 12) within that quadword. Quadword 33 contains the
82 * vrsave as the first word (offset 0) within the quadword.
84 * This definition of the VMX state is compatible with the current PPC32
85 * ptrace interface. This allows signal handling and ptrace to use the
86 * same structures. This also simplifies the implementation of a bi-arch
87 * (combined (32- and 64-bit) gdb.
91 * Get contents of AltiVec register state in task TASK
93 static inline int get_vrregs(unsigned long __user *data,
94 struct task_struct *task)
96 unsigned long regsize;
98 /* copy AltiVec registers VR[0] .. VR[31] */
99 regsize = 32 * sizeof(vector128);
100 if (copy_to_user(data, task->thread.vr, regsize))
101 return -EFAULT;
102 data += (regsize / sizeof(unsigned long));
104 /* copy VSCR */
105 regsize = 1 * sizeof(vector128);
106 if (copy_to_user(data, &task->thread.vscr, regsize))
107 return -EFAULT;
108 data += (regsize / sizeof(unsigned long));
110 /* copy VRSAVE */
111 if (put_user(task->thread.vrsave, (u32 __user *)data))
112 return -EFAULT;
114 return 0;
118 * Write contents of AltiVec register state into task TASK.
120 static inline int set_vrregs(struct task_struct *task,
121 unsigned long __user *data)
123 unsigned long regsize;
125 /* copy AltiVec registers VR[0] .. VR[31] */
126 regsize = 32 * sizeof(vector128);
127 if (copy_from_user(task->thread.vr, data, regsize))
128 return -EFAULT;
129 data += (regsize / sizeof(unsigned long));
131 /* copy VSCR */
132 regsize = 1 * sizeof(vector128);
133 if (copy_from_user(&task->thread.vscr, data, regsize))
134 return -EFAULT;
135 data += (regsize / sizeof(unsigned long));
137 /* copy VRSAVE */
138 if (get_user(task->thread.vrsave, (u32 __user *)data))
139 return -EFAULT;
141 return 0;
143 #endif
145 static inline int ptrace_set_debugreg(struct task_struct *task,
146 unsigned long addr, unsigned long data)
148 /* We only support one DABR and no IABRS at the moment */
149 if (addr > 0)
150 return -EINVAL;
152 /* The bottom 3 bits are flags */
153 if ((data & ~0x7UL) >= TASK_SIZE)
154 return -EIO;
156 /* Ensure translation is on */
157 if (data && !(data & DABR_TRANSLATION))
158 return -EIO;
160 task->thread.dabr = data;
161 return 0;
164 #endif /* _PPC64_PTRACE_COMMON_H */