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,
76 static const struct user_regset c6x_regsets[] = {
78 .core_note_type = NT_PRSTATUS,
86 static const struct user_regset_view user_c6x_native_view = {
88 .e_machine = EM_TI_C6000,
89 .regsets = c6x_regsets,
90 .n = ARRAY_SIZE(c6x_regsets),
93 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
95 return &user_c6x_native_view;
99 * Perform ptrace request
101 long arch_ptrace(struct task_struct *child, long request,
102 unsigned long addr, unsigned long data)
108 * write the word at location addr.
110 case PTRACE_POKETEXT:
111 ret = generic_ptrace_pokedata(child, addr, data);
112 if (ret == 0 && request == PTRACE_POKETEXT)
113 flush_icache_range(addr, addr + 4);
116 ret = ptrace_request(child, request, addr, data);
124 * handle tracing of system call entry
125 * - return the revised system call number or ULONG_MAX to cause ENOSYS
127 asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs)
129 if (tracehook_report_syscall_entry(regs))
130 /* tracing decided this syscall should not happen, so
131 * We'll return a bogus call number to get an ENOSYS
132 * error, but leave the original number in
141 * handle tracing of system call exit
143 asmlinkage void syscall_trace_exit(struct pt_regs *regs)
145 tracehook_report_syscall_exit(regs, 0);