2 * Copyright (c) 2002 Stephen Rothwell, IBM Coproration
3 * Extracted from ptrace.c and ptrace32.c
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.
10 #ifndef _PPC64_PTRACE_COMMON_H
11 #define _PPC64_PTRACE_COMMON_H
13 #include <linux/config.h>
14 #include <asm/system.h>
17 * Set of msr bits that gdb can change on behalf of a process.
19 #define MSR_DEBUGCHANGE (MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
22 * Get contents of register REGNO in task TASK.
24 static inline unsigned long get_reg(struct task_struct *task, int regno)
26 unsigned long tmp = 0;
29 * Put the correct FP bits in, they might be wrong as a result
30 * of our lazy FP restore.
32 if (regno == PT_MSR) {
33 tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
34 tmp |= task->thread.fpexc_mode;
35 } else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
36 tmp = ((unsigned long *)task->thread.regs)[regno];
43 * Write contents of register REGNO in task TASK.
45 static inline int put_reg(struct task_struct *task, int regno,
48 if (regno < PT_SOFTE) {
50 data = (data & MSR_DEBUGCHANGE)
51 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
52 ((unsigned long *)task->thread.regs)[regno] = data;
58 static inline void set_single_step(struct task_struct *task)
60 struct pt_regs *regs = task->thread.regs;
63 set_tsk_thread_flag(task, TIF_SINGLESTEP);
66 static inline void clear_single_step(struct task_struct *task)
68 struct pt_regs *regs = task->thread.regs;
71 clear_tsk_thread_flag(task, TIF_SINGLESTEP);
76 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
77 * The transfer totals 34 quadword. Quadwords 0-31 contain the
78 * corresponding vector registers. Quadword 32 contains the vscr as the
79 * last word (offset 12) within that quadword. Quadword 33 contains the
80 * vrsave as the first word (offset 0) within the quadword.
82 * This definition of the VMX state is compatible with the current PPC32
83 * ptrace interface. This allows signal handling and ptrace to use the
84 * same structures. This also simplifies the implementation of a bi-arch
85 * (combined (32- and 64-bit) gdb.
89 * Get contents of AltiVec register state in task TASK
91 static inline int get_vrregs(unsigned long __user *data,
92 struct task_struct *task)
94 unsigned long regsize;
96 /* copy AltiVec registers VR[0] .. VR[31] */
97 regsize = 32 * sizeof(vector128);
98 if (copy_to_user(data, task->thread.vr, regsize))
100 data += (regsize / sizeof(unsigned long));
103 regsize = 1 * sizeof(vector128);
104 if (copy_to_user(data, &task->thread.vscr, regsize))
106 data += (regsize / sizeof(unsigned long));
109 if (put_user(task->thread.vrsave, (u32 __user *)data))
116 * Write contents of AltiVec register state into task TASK.
118 static inline int set_vrregs(struct task_struct *task,
119 unsigned long __user *data)
121 unsigned long regsize;
123 /* copy AltiVec registers VR[0] .. VR[31] */
124 regsize = 32 * sizeof(vector128);
125 if (copy_from_user(task->thread.vr, data, regsize))
127 data += (regsize / sizeof(unsigned long));
130 regsize = 1 * sizeof(vector128);
131 if (copy_from_user(&task->thread.vscr, data, regsize))
133 data += (regsize / sizeof(unsigned long));
136 if (get_user(task->thread.vrsave, (u32 __user *)data))
143 static inline int ptrace_set_debugreg(struct task_struct *task,
144 unsigned long addr, unsigned long data)
146 /* We only support one DABR and no IABRS at the moment */
150 /* The bottom 3 bits are flags */
151 if ((data & ~0x7UL) >= TASK_SIZE)
154 /* Ensure translation is on */
155 if (data && !(data & DABR_TRANSLATION))
158 task->thread.dabr = data;
162 #endif /* _PPC64_PTRACE_COMMON_H */