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>
18 * Set of msr bits that gdb can change on behalf of a process.
20 #define MSR_DEBUGCHANGE (MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
23 * Get contents of register REGNO in task TASK.
25 static inline unsigned long get_reg(struct task_struct *task, int regno)
27 unsigned long tmp = 0;
30 * Put the correct FP bits in, they might be wrong as a result
31 * of our lazy FP restore.
33 if (regno == PT_MSR) {
34 tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
35 tmp |= task->thread.fpexc_mode;
36 } else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
37 tmp = ((unsigned long *)task->thread.regs)[regno];
44 * Write contents of register REGNO in task TASK.
46 static inline int put_reg(struct task_struct *task, int regno,
49 if (regno < PT_SOFTE) {
51 data = (data & MSR_DEBUGCHANGE)
52 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
53 ((unsigned long *)task->thread.regs)[regno] = data;
59 static inline void set_single_step(struct task_struct *task)
61 struct pt_regs *regs = task->thread.regs;
64 set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
67 static inline void clear_single_step(struct task_struct *task)
69 struct pt_regs *regs = task->thread.regs;
72 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
77 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
78 * The transfer totals 34 quadword. Quadwords 0-31 contain the
79 * corresponding vector registers. Quadword 32 contains the vscr as the
80 * last word (offset 12) within that quadword. Quadword 33 contains the
81 * vrsave as the first word (offset 0) within the quadword.
83 * This definition of the VMX state is compatible with the current PPC32
84 * ptrace interface. This allows signal handling and ptrace to use the
85 * same structures. This also simplifies the implementation of a bi-arch
86 * (combined (32- and 64-bit) gdb.
90 * Get contents of AltiVec register state in task TASK
92 static inline int get_vrregs(unsigned long __user *data,
93 struct task_struct *task)
95 unsigned long regsize;
97 /* copy AltiVec registers VR[0] .. VR[31] */
98 regsize = 32 * sizeof(vector128);
99 if (copy_to_user(data, task->thread.vr, regsize))
101 data += (regsize / sizeof(unsigned long));
104 regsize = 1 * sizeof(vector128);
105 if (copy_to_user(data, &task->thread.vscr, regsize))
107 data += (regsize / sizeof(unsigned long));
110 if (put_user(task->thread.vrsave, (u32 __user *)data))
117 * Write contents of AltiVec register state into task TASK.
119 static inline int set_vrregs(struct task_struct *task,
120 unsigned long __user *data)
122 unsigned long regsize;
124 /* copy AltiVec registers VR[0] .. VR[31] */
125 regsize = 32 * sizeof(vector128);
126 if (copy_from_user(task->thread.vr, data, regsize))
128 data += (regsize / sizeof(unsigned long));
131 regsize = 1 * sizeof(vector128);
132 if (copy_from_user(&task->thread.vscr, data, regsize))
134 data += (regsize / sizeof(unsigned long));
137 if (get_user(task->thread.vrsave, (u32 __user *)data))
144 #endif /* _PPC64_PTRACE_COMMON_H */