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>
17 #include <linux/sched/task_stack.h>
19 #include <asm/cacheflush.h>
21 #define PT_REG_SIZE (sizeof(struct pt_regs))
24 * Called by kernel/ptrace.c when detaching.
26 void ptrace_disable(struct task_struct
*child
)
32 * Get a register number from live pt_regs for the specified task.
34 static inline long get_reg(struct task_struct
*task
, int regno
)
36 long *addr
= (long *)task_pt_regs(task
);
38 if (regno
== PT_TSR
|| regno
== PT_CSR
)
45 * Write contents of register REGNO in task TASK.
47 static inline int put_reg(struct task_struct
*task
,
51 unsigned long *addr
= (unsigned long *)task_pt_regs(task
);
53 if (regno
!= PT_TSR
&& regno
!= PT_CSR
)
59 /* regset get/set implementations */
61 static int gpr_get(struct task_struct
*target
,
62 const struct user_regset
*regset
,
63 unsigned int pos
, unsigned int count
,
64 void *kbuf
, void __user
*ubuf
)
66 struct pt_regs
*regs
= task_pt_regs(target
);
68 return user_regset_copyout(&pos
, &count
, &kbuf
, &ubuf
,
73 static int gpr_set(struct task_struct
*target
,
74 const struct user_regset
*regset
,
75 unsigned int pos
, unsigned int count
,
76 const void *kbuf
, const void __user
*ubuf
)
79 struct pt_regs
*regs
= task_pt_regs(target
);
81 /* Don't copyin TSR or CSR */
82 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
84 0, PT_TSR
* sizeof(long));
88 ret
= user_regset_copyin_ignore(&pos
, &count
, &kbuf
, &ubuf
,
89 PT_TSR
* sizeof(long),
90 (PT_TSR
+ 1) * sizeof(long));
94 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
96 (PT_TSR
+ 1) * sizeof(long),
97 PT_CSR
* sizeof(long));
101 ret
= user_regset_copyin_ignore(&pos
, &count
, &kbuf
, &ubuf
,
102 PT_CSR
* sizeof(long),
103 (PT_CSR
+ 1) * sizeof(long));
107 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
109 (PT_CSR
+ 1) * sizeof(long), -1);
117 static const struct user_regset c6x_regsets
[] = {
119 .core_note_type
= NT_PRSTATUS
,
122 .align
= sizeof(u32
),
128 static const struct user_regset_view user_c6x_native_view
= {
130 .e_machine
= EM_TI_C6000
,
131 .regsets
= c6x_regsets
,
132 .n
= ARRAY_SIZE(c6x_regsets
),
135 const struct user_regset_view
*task_user_regset_view(struct task_struct
*task
)
137 return &user_c6x_native_view
;
141 * Perform ptrace request
143 long arch_ptrace(struct task_struct
*child
, long request
,
144 unsigned long addr
, unsigned long data
)
150 * write the word at location addr.
152 case PTRACE_POKETEXT
:
153 ret
= generic_ptrace_pokedata(child
, addr
, data
);
154 if (ret
== 0 && request
== PTRACE_POKETEXT
)
155 flush_icache_range(addr
, addr
+ 4);
158 ret
= ptrace_request(child
, request
, addr
, data
);
166 * handle tracing of system call entry
167 * - return the revised system call number or ULONG_MAX to cause ENOSYS
169 asmlinkage
unsigned long syscall_trace_entry(struct pt_regs
*regs
)
171 if (tracehook_report_syscall_entry(regs
))
172 /* tracing decided this syscall should not happen, so
173 * We'll return a bogus call number to get an ENOSYS
174 * error, but leave the original number in
183 * handle tracing of system call exit
185 asmlinkage
void syscall_trace_exit(struct pt_regs
*regs
)
187 tracehook_report_syscall_exit(regs
, 0);