blob: da43bdc622943bf422a396abba301148151f8f96 [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
35struct 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};
David S. Miller916ca142012-10-16 09:34:01 -070045
46struct global_pmu_snapshot {
47 unsigned long pcr[4];
48 unsigned long pic[4];
49};
50
51union global_cpu_snapshot {
52 struct global_reg_snapshot reg;
53 struct global_pmu_snapshot pmu;
54};
55
56extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080057
58#define force_successful_syscall_return() \
59do { current_thread_info()->syscall_noerror = 1; \
60} while (0)
61#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
62#define instruction_pointer(regs) ((regs)->tpc)
Jason Wessel33d88812011-07-19 15:43:16 -050063#define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080064#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
Eric Parisd7e75282012-01-03 14:23:06 -050065static inline int is_syscall_success(struct pt_regs *regs)
66{
67 return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
68}
69
70static inline long regs_return_value(struct pt_regs *regs)
71{
72 return regs->u_regs[UREG_I0];
73}
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080074#ifdef CONFIG_SMP
75extern unsigned long profile_pc(struct pt_regs *);
76#else
77#define profile_pc(regs) instruction_pointer(regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#endif
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080079#else /* __ASSEMBLY__ */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080080#endif /* __ASSEMBLY__ */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080081#else /* (defined(__sparc__) && defined(__arch64__)) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080082#ifndef __ASSEMBLY__
Sam Ravnborgbde4d8b2012-03-30 15:53:50 +020083#include <asm/switch_to.h>
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080084
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -080085static inline bool pt_regs_is_syscall(struct pt_regs *regs)
86{
87 return (regs->psr & PSR_SYSCALL);
88}
89
90static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
91{
92 return (regs->psr &= ~PSR_SYSCALL);
93}
94
95#define arch_ptrace_stop_needed(exit_code, info) \
96({ flush_user_windows(); \
97 current_thread_info()->w_saved != 0; \
98})
99
100#define arch_ptrace_stop(exit_code, info) \
101 synchronize_user_stack()
102
103#define user_mode(regs) (!((regs)->psr & PSR_PS))
104#define instruction_pointer(regs) ((regs)->pc)
105#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
106unsigned long profile_pc(struct pt_regs *);
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800107#else /* (!__ASSEMBLY__) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800108#endif /* (!__ASSEMBLY__) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800109#endif /* (defined(__sparc__) && defined(__arch64__)) */
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800110#define STACK_BIAS 2047
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800111
112/* global_reg_snapshot offsets */
113#define GR_SNAP_TSTATE 0x00
114#define GR_SNAP_TPC 0x08
115#define GR_SNAP_TNPC 0x10
116#define GR_SNAP_O7 0x18
117#define GR_SNAP_I7 0x20
118#define GR_SNAP_RPC 0x28
119#define GR_SNAP_THREAD 0x30
120#define GR_SNAP_PAD1 0x38
121
Sam Ravnborgf3ec38d2009-01-02 19:42:12 -0800122#endif /* !(__SPARC_PTRACE_H) */