ALSA: ice1724 - Check for ac97 to avoid kernel oops
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / h8300 / kernel / ptrace.c
blob497fa89b5df40815ca3b20b4c252a8d9e09c3d1a
1 /*
2 * linux/arch/h8300/kernel/ptrace.c
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
6 * Based on:
7 * linux/arch/m68k/kernel/ptrace.c
9 * Copyright (C) 1994 by Hamish Macdonald
10 * Taken from linux/kernel/ptrace.c and modified for M680x0.
11 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file COPYING in the main directory of
15 * this archive for more details.
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
20 #include <linux/mm.h>
21 #include <linux/smp.h>
22 #include <linux/errno.h>
23 #include <linux/ptrace.h>
24 #include <linux/user.h>
25 #include <linux/signal.h>
27 #include <asm/uaccess.h>
28 #include <asm/page.h>
29 #include <asm/pgtable.h>
30 #include <asm/system.h>
31 #include <asm/processor.h>
32 #include <asm/signal.h>
34 /* cpu depend functions */
35 extern long h8300_get_reg(struct task_struct *task, int regno);
36 extern int h8300_put_reg(struct task_struct *task, int regno, unsigned long data);
39 void user_disable_single_step(struct task_struct *child)
44 * does not yet catch signals sent when the child dies.
45 * in exit.c or in signal.c.
48 void ptrace_disable(struct task_struct *child)
50 user_disable_single_step(child);
53 long arch_ptrace(struct task_struct *child, long request,
54 unsigned long addr, unsigned long data)
56 int ret;
57 int regno = addr >> 2;
58 unsigned long __user *datap = (unsigned long __user *) data;
60 switch (request) {
61 /* read the word at location addr in the USER area. */
62 case PTRACE_PEEKUSR: {
63 unsigned long tmp = 0;
65 if ((addr & 3) || addr >= sizeof(struct user)) {
66 ret = -EIO;
67 break ;
70 ret = 0; /* Default return condition */
72 if (regno < H8300_REGS_NO)
73 tmp = h8300_get_reg(child, regno);
74 else {
75 switch (regno) {
76 case 49:
77 tmp = child->mm->start_code;
78 break ;
79 case 50:
80 tmp = child->mm->start_data;
81 break ;
82 case 51:
83 tmp = child->mm->end_code;
84 break ;
85 case 52:
86 tmp = child->mm->end_data;
87 break ;
88 default:
89 ret = -EIO;
92 if (!ret)
93 ret = put_user(tmp, datap);
94 break ;
97 /* when I and D space are separate, this will have to be fixed. */
98 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
99 if ((addr & 3) || addr >= sizeof(struct user)) {
100 ret = -EIO;
101 break ;
104 if (regno == PT_ORIG_ER0) {
105 ret = -EIO;
106 break ;
108 if (regno < H8300_REGS_NO) {
109 ret = h8300_put_reg(child, regno, data);
110 break ;
112 ret = -EIO;
113 break ;
115 case PTRACE_GETREGS: { /* Get all gp regs from the child. */
116 int i;
117 unsigned long tmp;
118 for (i = 0; i < H8300_REGS_NO; i++) {
119 tmp = h8300_get_reg(child, i);
120 if (put_user(tmp, datap)) {
121 ret = -EFAULT;
122 break;
124 datap++;
126 ret = 0;
127 break;
130 case PTRACE_SETREGS: { /* Set all gp regs in the child. */
131 int i;
132 unsigned long tmp;
133 for (i = 0; i < H8300_REGS_NO; i++) {
134 if (get_user(tmp, datap)) {
135 ret = -EFAULT;
136 break;
138 h8300_put_reg(child, i, tmp);
139 datap++;
141 ret = 0;
142 break;
145 default:
146 ret = ptrace_request(child, request, addr, data);
147 break;
149 return ret;
152 asmlinkage void do_syscall_trace(void)
154 if (!test_thread_flag(TIF_SYSCALL_TRACE))
155 return;
156 if (!(current->ptrace & PT_PTRACED))
157 return;
158 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
159 ? 0x80 : 0));
161 * this isn't the same as continuing with a signal, but it will do
162 * for normal use. strace only continues with a signal if the
163 * stopping signal is not SIGTRAP. -brl
165 if (current->exit_code) {
166 send_sig(current->exit_code, current, 1);
167 current->exit_code = 0;