Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | |
3 | * License. See the file "COPYING" in the main directory of this archive | |
4 | * for more details. | |
5 | * | |
6 | * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle | |
7 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. | |
8 | */ | |
9 | #ifndef _ASM_PTRACE_H | |
10 | #define _ASM_PTRACE_H | |
11 | ||
1da177e4 | 12 | |
0926bf95 | 13 | #include <linux/compiler.h> |
1da177e4 | 14 | #include <linux/linkage.h> |
f6a3176a | 15 | #include <linux/types.h> |
8f9a2b32 | 16 | #include <asm/isadep.h> |
61730c53 | 17 | #include <uapi/asm/ptrace.h> |
1da177e4 | 18 | |
8f657933 DD |
19 | /* |
20 | * This struct defines the way the registers are stored on the stack during a | |
21 | * system call/exception. As usual the registers k0/k1 aren't being saved. | |
22 | */ | |
23 | struct pt_regs { | |
24 | #ifdef CONFIG_32BIT | |
25 | /* Pad bytes for argument save space on the stack. */ | |
e90e6fdd | 26 | unsigned long pad0[8]; |
8f657933 DD |
27 | #endif |
28 | ||
29 | /* Saved main processor registers. */ | |
30 | unsigned long regs[32]; | |
31 | ||
32 | /* Saved special registers. */ | |
33 | unsigned long cp0_status; | |
34 | unsigned long hi; | |
35 | unsigned long lo; | |
36 | #ifdef CONFIG_CPU_HAS_SMARTMIPS | |
37 | unsigned long acx; | |
38 | #endif | |
39 | unsigned long cp0_badvaddr; | |
40 | unsigned long cp0_cause; | |
41 | unsigned long cp0_epc; | |
8f657933 | 42 | #ifdef CONFIG_CPU_CAVIUM_OCTEON |
ac655fb7 DD |
43 | unsigned long long mpl[6]; /* MTM{0-5} */ |
44 | unsigned long long mtp[6]; /* MTP{0-5} */ | |
8f657933 DD |
45 | #endif |
46 | } __aligned(8); | |
47 | ||
0926bf95 DD |
48 | struct task_struct; |
49 | ||
a79ebea6 AS |
50 | extern int ptrace_getregs(struct task_struct *child, |
51 | struct user_pt_regs __user *data); | |
52 | extern int ptrace_setregs(struct task_struct *child, | |
53 | struct user_pt_regs __user *data); | |
d302d05c RB |
54 | |
55 | extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data); | |
56 | extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data); | |
57 | ||
0926bf95 DD |
58 | extern int ptrace_get_watch_regs(struct task_struct *child, |
59 | struct pt_watch_regs __user *addr); | |
60 | extern int ptrace_set_watch_regs(struct task_struct *child, | |
61 | struct pt_watch_regs __user *addr); | |
62 | ||
1da177e4 LT |
63 | /* |
64 | * Does the process account for user or for system time? | |
65 | */ | |
66 | #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER) | |
67 | ||
d7e7528b EP |
68 | static inline int is_syscall_success(struct pt_regs *regs) |
69 | { | |
70 | return !regs->regs[7]; | |
71 | } | |
72 | ||
73 | static inline long regs_return_value(struct pt_regs *regs) | |
74 | { | |
75 | if (is_syscall_success(regs)) | |
76 | return regs->regs[2]; | |
77 | else | |
78 | return -regs->regs[2]; | |
79 | } | |
80 | ||
1da177e4 LT |
81 | #define instruction_pointer(regs) ((regs)->cp0_epc) |
82 | #define profile_pc(regs) instruction_pointer(regs) | |
83 | ||
4c21b8fd | 84 | extern asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall); |
8b659a39 | 85 | extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); |
1da177e4 | 86 | |
ff2d8b19 | 87 | extern void die(const char *, struct pt_regs *) __noreturn; |
2d911e9a | 88 | |
ce384d83 | 89 | static inline void die_if_kernel(const char *str, struct pt_regs *regs) |
2d911e9a RB |
90 | { |
91 | if (unlikely(!user_mode(regs))) | |
92 | die(str, regs); | |
93 | } | |
94 | ||
baf9ff74 RB |
95 | #define current_pt_regs() \ |
96 | ({ \ | |
97 | unsigned long sp = (unsigned long)__builtin_frame_address(0); \ | |
98 | (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \ | |
99 | }) | |
100 | ||
c0ff3c53 RB |
101 | /* Helpers for working with the user stack pointer */ |
102 | ||
103 | static inline unsigned long user_stack_pointer(struct pt_regs *regs) | |
104 | { | |
105 | return regs->regs[29]; | |
106 | } | |
107 | ||
108 | static inline void user_stack_pointer_set(struct pt_regs *regs, | |
109 | unsigned long val) | |
110 | { | |
111 | regs->regs[29] = val; | |
112 | } | |
113 | ||
1da177e4 | 114 | #endif /* _ASM_PTRACE_H */ |