blob: 7a4075003e7639a6aff1b48a0063cdada1e58540 [file] [log] [blame]
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -08001#ifndef __SPARC_PTRACE_H
2#define __SPARC_PTRACE_H
3
David Howells54579822012-10-09 09:47:43 +01004#include <uapi/asm/ptrace.h>
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -08005
6#if defined(__sparc__) && defined(__arch64__)
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -08007#ifndef __ASSEMBLY__
8
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -08009#include <linux/threads.h>
Stephen Rothwell7f55ba92012-03-29 22:39:57 -070010#include <asm/switch_to.h>
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080011
12static inline int pt_regs_trap_type(struct pt_regs *regs)
13{
14 return regs->magic & 0x1ff;
15}
16
17static inline bool pt_regs_is_syscall(struct pt_regs *regs)
18{
19 return (regs->tstate & TSTATE_SYSCALL);
20}
21
22static 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
Al Viro1918c7f2012-10-05 22:37:01 -040035#define current_pt_regs() \
36 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
37
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080038struct global_reg_snapshot {
39 unsigned long tstate;
40 unsigned long tpc;
41 unsigned long tnpc;
42 unsigned long o7;
43 unsigned long i7;
44 unsigned long rpc;
45 struct thread_info *thread;
46 unsigned long pad1;
47};
48extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
49
Al Virodff933d2012-09-26 01:21:14 -040050#define force_successful_syscall_return() set_thread_noerror(1)
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080051#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
52#define instruction_pointer(regs) ((regs)->tpc)
Jason Wessel33d88812011-07-19 15:43:16 -050053#define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080054#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
Eric Parisd7e75282012-01-03 14:23:06 -050055static inline int is_syscall_success(struct pt_regs *regs)
56{
57 return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
58}
59
60static inline long regs_return_value(struct pt_regs *regs)
61{
62 return regs->u_regs[UREG_I0];
63}
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080064#ifdef CONFIG_SMP
65extern unsigned long profile_pc(struct pt_regs *);
66#else
67#define profile_pc(regs) instruction_pointer(regs)
Sam Ravnborga439fe52008-07-27 23:00:59 +020068#endif
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080069#else /* __ASSEMBLY__ */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080070#endif /* __ASSEMBLY__ */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080071#else /* (defined(__sparc__) && defined(__arch64__)) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080072#ifndef __ASSEMBLY__
Sam Ravnborgbde4d8b2012-03-30 15:53:50 +020073#include <asm/switch_to.h>
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080074
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080075static inline bool pt_regs_is_syscall(struct pt_regs *regs)
76{
77 return (regs->psr & PSR_SYSCALL);
78}
79
80static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
81{
82 return (regs->psr &= ~PSR_SYSCALL);
83}
84
85#define arch_ptrace_stop_needed(exit_code, info) \
86({ flush_user_windows(); \
87 current_thread_info()->w_saved != 0; \
88})
89
90#define arch_ptrace_stop(exit_code, info) \
91 synchronize_user_stack()
92
93#define user_mode(regs) (!((regs)->psr & PSR_PS))
94#define instruction_pointer(regs) ((regs)->pc)
95#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
96unsigned long profile_pc(struct pt_regs *);
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080097#else /* (!__ASSEMBLY__) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080098#endif /* (!__ASSEMBLY__) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080099#endif /* (defined(__sparc__) && defined(__arch64__)) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800100#define STACK_BIAS 2047
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800101
102/* global_reg_snapshot offsets */
103#define GR_SNAP_TSTATE 0x00
104#define GR_SNAP_TPC 0x08
105#define GR_SNAP_TNPC 0x10
106#define GR_SNAP_O7 0x18
107#define GR_SNAP_I7 0x20
108#define GR_SNAP_RPC 0x28
109#define GR_SNAP_THREAD 0x30
110#define GR_SNAP_PAD1 0x38
111
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800112#endif /* !(__SPARC_PTRACE_H) */