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];
45 * Write contents of register REGNO in task TASK.
47 static inline int put_reg(struct task_struct *task, int regno,
50 if (regno < PT_SOFTE) {
52 data = (data & MSR_DEBUGCHANGE)
53 | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
54 ((unsigned long *)task->thread.regs)[regno] = data;
60 static inline void set_single_step(struct task_struct *task)
62 struct pt_regs *regs = task->thread.regs;
65 set_tsk_thread_flag(task, TIF_SINGLESTEP);
68 static inline void clear_single_step(struct task_struct *task)
70 struct pt_regs *regs = task->thread.regs;
73 clear_tsk_thread_flag(task, TIF_SINGLESTEP);
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))
102 data += (regsize / sizeof(unsigned long));
105 regsize = 1 * sizeof(vector128);
106 if (copy_to_user(data, &task->thread.vscr, regsize))
108 data += (regsize / sizeof(unsigned long));
111 if (put_user(task->thread.vrsave, (u32 __user *)data))
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))
129 data += (regsize / sizeof(unsigned long));
132 regsize = 1 * sizeof(vector128);
133 if (copy_from_user(&task->thread.vscr, data, regsize))
135 data += (regsize / sizeof(unsigned long));
138 if (get_user(task->thread.vrsave, (u32 __user *)data))
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 */
152 /* The bottom 3 bits are flags */
153 if ((data & ~0x7UL) >= TASK_SIZE)
156 /* Ensure translation is on */
157 if (data && !(data & DABR_TRANSLATION))
160 task->thread.dabr = data;
164 #endif /* _PPC64_PTRACE_COMMON_H */