fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-powerpc / tracehook.h
1 /*
2  * Tracing hooks, PowerPC CPU support
3  *
4  * Copyright (C) 2006, 2007 Red Hat, Inc.  All rights reserved.
5  *
6  * This copyrighted material is made available to anyone wishing to use,
7  * modify, copy, or redistribute it subject to the terms and conditions
8  * of the GNU General Public License v.2.
9  *
10  * Red Hat Author: Roland McGrath.
11  */
12
13 #ifndef _ASM_TRACEHOOK_H
14 #define _ASM_TRACEHOOK_H        1
15
16 #include <linux/sched.h>
17 #include <asm/ptrace.h>
18
19 /*
20  * See linux/tracehook.h for the descriptions of what these need to do.
21  */
22
23 #define ARCH_HAS_SINGLE_STEP    (1)
24
25 static inline void tracehook_enable_single_step(struct task_struct *task)
26 {
27         struct pt_regs *regs = task->thread.regs;
28         if (regs != NULL) {
29 #if defined(CONFIG_PPC32) && (defined(CONFIG_40x) || defined(CONFIG_BOOKE))
30                 task->thread.dbcr0 = DBCR0_IDM | DBCR0_IC;
31                 regs->msr |= MSR_DE;
32 #else
33                 regs->msr |= MSR_SE;
34 #endif
35         }
36         set_tsk_thread_flag(task, TIF_SINGLESTEP);
37 }
38
39 static inline void tracehook_disable_single_step(struct task_struct *task)
40 {
41         struct pt_regs *regs = task->thread.regs;
42         if (regs != NULL) {
43 #if defined(CONFIG_PPC32) && (defined(CONFIG_40x) || defined(CONFIG_BOOKE))
44                 task->thread.dbcr0 = 0;
45                 regs->msr &= ~MSR_DE;
46 #else
47                 regs->msr &= ~MSR_SE;
48 #endif
49         }
50         clear_tsk_thread_flag(task, TIF_SINGLESTEP);
51 }
52
53 static inline int tracehook_single_step_enabled(struct task_struct *tsk)
54 {
55         return test_tsk_thread_flag(tsk, TIF_SINGLESTEP);
56 }
57
58 static inline void tracehook_enable_syscall_trace(struct task_struct *tsk)
59 {
60         set_tsk_thread_flag(tsk, TIF_SYSCALL_TRACE);
61 }
62
63 static inline void tracehook_disable_syscall_trace(struct task_struct *tsk)
64 {
65         clear_tsk_thread_flag(tsk, TIF_SYSCALL_TRACE);
66 }
67
68 static inline void tracehook_abort_syscall(struct pt_regs *regs)
69 {
70         regs->orig_gpr3 = -1L;
71 }
72
73
74 extern const struct utrace_regset_view utrace_ppc_native_view;
75 static inline const struct utrace_regset_view *
76 utrace_native_view(struct task_struct *tsk)
77 {
78 #ifdef CONFIG_PPC64
79         extern const struct utrace_regset_view utrace_ppc32_view;
80
81         if (test_tsk_thread_flag(tsk, TIF_32BIT))
82                 return &utrace_ppc32_view;
83 #endif
84         return &utrace_ppc_native_view;
85 }
86
87
88 #endif