12 #include <linux/kernel.h>
13 #include <linux/sched.h>
16 #include <linux/errno.h>
17 #include <linux/ptrace.h>
20 #include <linux/elf.h>
22 #include <asm/uaccess.h>
23 #include <asm/pgtable.h>
24 #include <asm/processor.h>
25 #include <asm/cacheflush.h>
27 #include <asm/asm-offsets.h>
32 static const u8 ptrace_regid_to_frame[] = {
33 [
PT_A3 << 2] = REG_A3,
35 [
PT_D3 << 2] = REG_D3,
36 [
PT_D2 << 2] = REG_D2,
41 [
PT_E1 << 2] = REG_E1,
42 [
PT_E0 << 2] = REG_E0,
43 [
PT_E7 << 2] = REG_E7,
44 [
PT_E6 << 2] = REG_E6,
45 [
PT_E5 << 2] = REG_E5,
46 [
PT_E4 << 2] = REG_E4,
47 [
PT_E3 << 2] = REG_E3,
48 [
PT_E2 << 2] = REG_E2,
53 [
PT_A1 << 2] = REG_A1,
54 [
PT_A0 << 2] = REG_A0,
55 [
PT_D1 << 2] = REG_D1,
56 [
PT_D0 << 2] = REG_D0,
64 return *(
unsigned long *)
69 int put_stack_long(
struct task_struct *task,
int offset,
unsigned long data)
73 stack = (
unsigned long) task->
thread.uregs + offset;
74 *(
unsigned long *) stack =
data;
83 unsigned int pos,
unsigned int count,
84 void *kbuf,
void __user *ubuf)
90 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
95 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
101 return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
110 unsigned int pos,
unsigned int count,
111 const void *kbuf,
const void __user *ubuf)
118 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
123 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
131 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
133 PT_PC *
sizeof(
long));
134 tmp &= EPSW_FLAG_V | EPSW_FLAG_C | EPSW_FLAG_N | EPSW_FLAG_Z;
135 tmp |= regs->
epsw & ~(EPSW_FLAG_V | EPSW_FLAG_C | EPSW_FLAG_N |
143 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
144 ®s->
pc,
PT_PC *
sizeof(
long),
150 return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
159 unsigned int pos,
unsigned int count,
160 void *kbuf,
void __user *ubuf)
167 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
168 fpregs, 0,
sizeof(*fpregs));
172 return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
173 sizeof(*fpregs), -1);
181 unsigned int pos,
unsigned int count,
182 const void *kbuf,
const void __user *ubuf)
187 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
188 &fpu_state, 0,
sizeof(fpu_state));
193 target->
thread.fpu_state = fpu_state;
194 set_using_fpu(target);
196 return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
197 sizeof(fpu_state), -1);
203 static int fpuregs_active(
struct task_struct *target,
206 return is_using_fpu(target) ? regset->
n : 0;
217 static const struct user_regset mn10300_regsets[] = {
227 .size =
sizeof(
long),
228 .
align =
sizeof(
long),
240 .
align =
sizeof(
long),
243 .active = fpuregs_active,
250 .regsets = mn10300_regsets,
256 return &user_mn10300_native_view;
264 #ifndef CONFIG_MN10300_USING_JTAG
268 tmp = get_stack_long(child, (
unsigned long) &dummy->
regs.epsw);
270 put_stack_long(child, (
unsigned long) &dummy->
regs.epsw, tmp);
279 #ifndef CONFIG_MN10300_USING_JTAG
283 tmp = get_stack_long(child, (
unsigned long) &dummy->
regs.epsw);
285 put_stack_long(child, (
unsigned long) &dummy->
regs.epsw, tmp);
298 unsigned long addr,
unsigned long data)
302 unsigned long __user *datap = (
unsigned long __user *) data;
308 if ((addr & 3) || addr >
sizeof(
struct user) - 3)
313 tmp = get_stack_long(child,
314 ptrace_regid_to_frame[addr]);
321 if ((addr & 3) || addr >
sizeof(
struct user) - 3)
326 ret = put_stack_long(child, ptrace_regid_to_frame[addr],
331 return copy_regset_to_user(child, &user_mn10300_native_view,
337 return copy_regset_from_user(child, &user_mn10300_native_view,
343 return copy_regset_to_user(child, &user_mn10300_native_view,
349 return copy_regset_from_user(child, &user_mn10300_native_view,
368 if (tracehook_report_syscall_entry(regs))
384 tracehook_report_syscall_exit(regs, 0);