2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2006, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7 * Updated for 2.6.34: Mark Salter <msalter@redhat.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/ptrace.h>
14 #include <linux/tracehook.h>
15 #include <linux/regset.h>
16 #include <linux/elf.h>
18 #include <asm/cacheflush.h>
20 #define PT_REG_SIZE (sizeof(struct pt_regs))
23 * Called by kernel/ptrace.c when detaching.
25 void ptrace_disable(struct task_struct
*child
)
31 * Get a register number from live pt_regs for the specified task.
33 static inline long get_reg(struct task_struct
*task
, int regno
)
35 long *addr
= (long *)task_pt_regs(task
);
37 if (regno
== PT_TSR
|| regno
== PT_CSR
)
44 * Write contents of register REGNO in task TASK.
46 static inline int put_reg(struct task_struct
*task
,
50 unsigned long *addr
= (unsigned long *)task_pt_regs(task
);
52 if (regno
!= PT_TSR
&& regno
!= PT_CSR
)
58 /* regset get/set implementations */
60 static int gpr_get(struct task_struct
*target
,
61 const struct user_regset
*regset
,
62 unsigned int pos
, unsigned int count
,
63 void *kbuf
, void __user
*ubuf
)
65 struct pt_regs
*regs
= task_pt_regs(target
);
67 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
,
72 static int gpr_set(struct task_struct
*target
,
73 const struct user_regset
*regset
,
74 unsigned int pos
, unsigned int count
,
75 const void *kbuf
, const void __user
*ubuf
)
78 struct pt_regs
*regs
= task_pt_regs(target
);
80 /* Don't copyin TSR or CSR */
81 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
83 0, PT_TSR
* sizeof(long));
87 ret
= user_regset_copyin_ignore(&pos
, &count
, &kbuf
, &ubuf
,
88 PT_TSR
* sizeof(long),
89 (PT_TSR
+ 1) * sizeof(long));
93 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
95 (PT_TSR
+ 1) * sizeof(long),
96 PT_CSR
* sizeof(long));
100 ret
= user_regset_copyin_ignore(&pos
, &count
, &kbuf
, &ubuf
,
101 PT_CSR
* sizeof(long),
102 (PT_CSR
+ 1) * sizeof(long));
106 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
108 (PT_CSR
+ 1) * sizeof(long), -1);
116 static const struct user_regset c6x_regsets
[] = {
118 .core_note_type
= NT_PRSTATUS
,
121 .align
= sizeof(u32
),
127 static const struct user_regset_view user_c6x_native_view
= {
129 .e_machine
= EM_TI_C6000
,
130 .regsets
= c6x_regsets
,
131 .n
= ARRAY_SIZE(c6x_regsets
),
134 const struct user_regset_view
*task_user_regset_view(struct task_struct
*task
)
136 return &user_c6x_native_view
;
140 * Perform ptrace request
142 long arch_ptrace(struct task_struct
*child
, long request
,
143 unsigned long addr
, unsigned long data
)
149 * write the word at location addr.
151 case PTRACE_POKETEXT
:
152 ret
= generic_ptrace_pokedata(child
, addr
, data
);
153 if (ret
== 0 && request
== PTRACE_POKETEXT
)
154 flush_icache_range(addr
, addr
+ 4);
157 ret
= ptrace_request(child
, request
, addr
, data
);
165 * handle tracing of system call entry
166 * - return the revised system call number or ULONG_MAX to cause ENOSYS
168 asmlinkage
unsigned long syscall_trace_entry(struct pt_regs
*regs
)
170 if (tracehook_report_syscall_entry(regs
))
171 /* tracing decided this syscall should not happen, so
172 * We'll return a bogus call number to get an ENOSYS
173 * error, but leave the original number in
182 * handle tracing of system call exit
184 asmlinkage
void syscall_trace_exit(struct pt_regs
*regs
)
186 tracehook_report_syscall_exit(regs
, 0);