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
,
77 static const struct user_regset c6x_regsets
[] = {
79 .core_note_type
= NT_PRSTATUS
,
87 static const struct user_regset_view user_c6x_native_view
= {
89 .e_machine
= EM_TI_C6000
,
90 .regsets
= c6x_regsets
,
91 .n
= ARRAY_SIZE(c6x_regsets
),
94 const struct user_regset_view
*task_user_regset_view(struct task_struct
*task
)
96 return &user_c6x_native_view
;
100 * Perform ptrace request
102 long arch_ptrace(struct task_struct
*child
, long request
,
103 unsigned long addr
, unsigned long data
)
109 * write the word at location addr.
111 case PTRACE_POKETEXT
:
112 ret
= generic_ptrace_pokedata(child
, addr
, data
);
113 if (ret
== 0 && request
== PTRACE_POKETEXT
)
114 flush_icache_range(addr
, addr
+ 4);
117 ret
= ptrace_request(child
, request
, addr
, data
);
125 * handle tracing of system call entry
126 * - return the revised system call number or ULONG_MAX to cause ENOSYS
128 asmlinkage
unsigned long syscall_trace_entry(struct pt_regs
*regs
)
130 if (tracehook_report_syscall_entry(regs
))
131 /* tracing decided this syscall should not happen, so
132 * We'll return a bogus call number to get an ENOSYS
133 * error, but leave the original number in
142 * handle tracing of system call exit
144 asmlinkage
void syscall_trace_exit(struct pt_regs
*regs
)
146 tracehook_report_syscall_exit(regs
, 0);