Commit | Line | Data |
---|---|---|
f3ec38d5 SR |
1 | #ifndef __SPARC_PTRACE_H |
2 | #define __SPARC_PTRACE_H | |
3 | ||
54579826 | 4 | #include <uapi/asm/ptrace.h> |
f3ec38d5 SR |
5 | |
6 | #if defined(__sparc__) && defined(__arch64__) | |
f3ec38d5 SR |
7 | #ifndef __ASSEMBLY__ |
8 | ||
f3ec38d5 | 9 | #include <linux/threads.h> |
7f55ba9c | 10 | #include <asm/switch_to.h> |
f3ec38d5 SR |
11 | |
12 | static inline int pt_regs_trap_type(struct pt_regs *regs) | |
13 | { | |
14 | return regs->magic & 0x1ff; | |
15 | } | |
16 | ||
17 | static inline bool pt_regs_is_syscall(struct pt_regs *regs) | |
18 | { | |
19 | return (regs->tstate & TSTATE_SYSCALL); | |
20 | } | |
21 | ||
22 | static inline bool pt_regs_clear_syscall(struct pt_regs *regs) | |
23 | { | |
24 | return (regs->tstate &= ~TSTATE_SYSCALL); | |
25 | } | |
26 | ||
27 | #define arch_ptrace_stop_needed(exit_code, info) \ | |
28 | ({ flush_user_windows(); \ | |
29 | get_thread_wsaved() != 0; \ | |
30 | }) | |
31 | ||
32 | #define arch_ptrace_stop(exit_code, info) \ | |
33 | synchronize_user_stack() | |
34 | ||
35 | struct global_reg_snapshot { | |
36 | unsigned long tstate; | |
37 | unsigned long tpc; | |
38 | unsigned long tnpc; | |
39 | unsigned long o7; | |
40 | unsigned long i7; | |
41 | unsigned long rpc; | |
42 | struct thread_info *thread; | |
43 | unsigned long pad1; | |
44 | }; | |
45 | extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS]; | |
46 | ||
47 | #define force_successful_syscall_return() \ | |
48 | do { current_thread_info()->syscall_noerror = 1; \ | |
49 | } while (0) | |
50 | #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) | |
51 | #define instruction_pointer(regs) ((regs)->tpc) | |
33d8881a | 52 | #define instruction_pointer_set(regs, val) ((regs)->tpc = (val)) |
f3ec38d5 | 53 | #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP]) |
d7e7528b EP |
54 | static inline int is_syscall_success(struct pt_regs *regs) |
55 | { | |
56 | return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)); | |
57 | } | |
58 | ||
59 | static inline long regs_return_value(struct pt_regs *regs) | |
60 | { | |
61 | return regs->u_regs[UREG_I0]; | |
62 | } | |
f3ec38d5 SR |
63 | #ifdef CONFIG_SMP |
64 | extern unsigned long profile_pc(struct pt_regs *); | |
65 | #else | |
66 | #define profile_pc(regs) instruction_pointer(regs) | |
1da177e4 | 67 | #endif |
f3ec38d5 | 68 | #else /* __ASSEMBLY__ */ |
f3ec38d5 | 69 | #endif /* __ASSEMBLY__ */ |
f3ec38d5 | 70 | #else /* (defined(__sparc__) && defined(__arch64__)) */ |
f3ec38d5 | 71 | #ifndef __ASSEMBLY__ |
bde4d8b2 | 72 | #include <asm/switch_to.h> |
f3ec38d5 | 73 | |
f3ec38d5 SR |
74 | static inline bool pt_regs_is_syscall(struct pt_regs *regs) |
75 | { | |
76 | return (regs->psr & PSR_SYSCALL); | |
77 | } | |
78 | ||
79 | static inline bool pt_regs_clear_syscall(struct pt_regs *regs) | |
80 | { | |
81 | return (regs->psr &= ~PSR_SYSCALL); | |
82 | } | |
83 | ||
84 | #define arch_ptrace_stop_needed(exit_code, info) \ | |
85 | ({ flush_user_windows(); \ | |
86 | current_thread_info()->w_saved != 0; \ | |
87 | }) | |
88 | ||
89 | #define arch_ptrace_stop(exit_code, info) \ | |
90 | synchronize_user_stack() | |
91 | ||
92 | #define user_mode(regs) (!((regs)->psr & PSR_PS)) | |
93 | #define instruction_pointer(regs) ((regs)->pc) | |
94 | #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP]) | |
95 | unsigned long profile_pc(struct pt_regs *); | |
f3ec38d5 | 96 | #else /* (!__ASSEMBLY__) */ |
f3ec38d5 | 97 | #endif /* (!__ASSEMBLY__) */ |
f3ec38d5 | 98 | #endif /* (defined(__sparc__) && defined(__arch64__)) */ |
f3ec38d5 | 99 | #define STACK_BIAS 2047 |
f3ec38d5 SR |
100 | |
101 | /* global_reg_snapshot offsets */ | |
102 | #define GR_SNAP_TSTATE 0x00 | |
103 | #define GR_SNAP_TPC 0x08 | |
104 | #define GR_SNAP_TNPC 0x10 | |
105 | #define GR_SNAP_O7 0x18 | |
106 | #define GR_SNAP_I7 0x20 | |
107 | #define GR_SNAP_RPC 0x28 | |
108 | #define GR_SNAP_THREAD 0x30 | |
109 | #define GR_SNAP_PAD1 0x38 | |
110 | ||
f3ec38d5 | 111 | #endif /* !(__SPARC_PTRACE_H) */ |