Merge branches 'x86/apic', 'x86/cleanups', 'x86/cpufeature', 'x86/crashdump', 'x86...
[linux-2.6-block.git] / arch / sparc / include / asm / ptrace_32.h
CommitLineData
f5e706ad
SR
1#ifndef _SPARC_PTRACE_H
2#define _SPARC_PTRACE_H
3
4#include <asm/psr.h>
5
6/* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
8 */
9
10#ifndef __ASSEMBLY__
11
12#include <linux/types.h>
13
14struct pt_regs {
15 unsigned long psr;
16 unsigned long pc;
17 unsigned long npc;
18 unsigned long y;
19 unsigned long u_regs[16]; /* globals and ins */
20};
21
22#define UREG_G0 0
23#define UREG_G1 1
24#define UREG_G2 2
25#define UREG_G3 3
26#define UREG_G4 4
27#define UREG_G5 5
28#define UREG_G6 6
29#define UREG_G7 7
30#define UREG_I0 8
31#define UREG_I1 9
32#define UREG_I2 10
33#define UREG_I3 11
34#define UREG_I4 12
35#define UREG_I5 13
36#define UREG_I6 14
37#define UREG_I7 15
38#define UREG_WIM UREG_G0
39#define UREG_FADDR UREG_G0
40#define UREG_FP UREG_I6
41#define UREG_RETPC UREG_I7
42
f5e706ad
SR
43/* A register window */
44struct reg_window {
45 unsigned long locals[8];
46 unsigned long ins[8];
47};
48
49/* A Sparc stack frame */
50struct sparc_stackf {
51 unsigned long locals[8];
52 unsigned long ins[6];
53 struct sparc_stackf *fp;
54 unsigned long callers_pc;
55 char *structptr;
56 unsigned long xargs[6];
57 unsigned long xxargs[1];
58};
59
60#define TRACEREG_SZ sizeof(struct pt_regs)
61#define STACKFRAME_SZ sizeof(struct sparc_stackf)
62
63#ifdef __KERNEL__
64
878a5535
DM
65#include <asm/system.h>
66
6717c282
DM
67static inline bool pt_regs_is_syscall(struct pt_regs *regs)
68{
69 return (regs->psr & PSR_SYSCALL);
70}
71
72static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
73{
74 return (regs->psr &= ~PSR_SYSCALL);
75}
76
878a5535
DM
77#define arch_ptrace_stop_needed(exit_code, info) \
78({ flush_user_windows(); \
79 current_thread_info()->w_saved != 0; \
80})
81
82#define arch_ptrace_stop(exit_code, info) \
83 synchronize_user_stack()
84
f5e706ad
SR
85#define user_mode(regs) (!((regs)->psr & PSR_PS))
86#define instruction_pointer(regs) ((regs)->pc)
ac76cfd0 87#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
f5e706ad
SR
88unsigned long profile_pc(struct pt_regs *);
89extern void show_regs(struct pt_regs *);
90#endif
91
92#else /* __ASSEMBLY__ */
93/* For assembly code. */
94#define TRACEREG_SZ 0x50
95#define STACKFRAME_SZ 0x60
96#endif
97
98/*
99 * The asm-offsets.h is a generated file, so we cannot include it.
100 * It may be OK for glibc headers, but it's utterly pointless for C code.
101 * The assembly code using those offsets has to include it explicitly.
102 */
103/* #include <asm/asm-offsets.h> */
104
105/* These are for pt_regs. */
106#define PT_PSR 0x0
107#define PT_PC 0x4
108#define PT_NPC 0x8
109#define PT_Y 0xc
110#define PT_G0 0x10
111#define PT_WIM PT_G0
112#define PT_G1 0x14
113#define PT_G2 0x18
114#define PT_G3 0x1c
115#define PT_G4 0x20
116#define PT_G5 0x24
117#define PT_G6 0x28
118#define PT_G7 0x2c
119#define PT_I0 0x30
120#define PT_I1 0x34
121#define PT_I2 0x38
122#define PT_I3 0x3c
123#define PT_I4 0x40
124#define PT_I5 0x44
125#define PT_I6 0x48
126#define PT_FP PT_I6
127#define PT_I7 0x4c
128
129/* Reg_window offsets */
130#define RW_L0 0x00
131#define RW_L1 0x04
132#define RW_L2 0x08
133#define RW_L3 0x0c
134#define RW_L4 0x10
135#define RW_L5 0x14
136#define RW_L6 0x18
137#define RW_L7 0x1c
138#define RW_I0 0x20
139#define RW_I1 0x24
140#define RW_I2 0x28
141#define RW_I3 0x2c
142#define RW_I4 0x30
143#define RW_I5 0x34
144#define RW_I6 0x38
145#define RW_I7 0x3c
146
147/* Stack_frame offsets */
148#define SF_L0 0x00
149#define SF_L1 0x04
150#define SF_L2 0x08
151#define SF_L3 0x0c
152#define SF_L4 0x10
153#define SF_L5 0x14
154#define SF_L6 0x18
155#define SF_L7 0x1c
156#define SF_I0 0x20
157#define SF_I1 0x24
158#define SF_I2 0x28
159#define SF_I3 0x2c
160#define SF_I4 0x30
161#define SF_I5 0x34
162#define SF_FP 0x38
163#define SF_PC 0x3c
164#define SF_RETP 0x40
165#define SF_XARG0 0x44
166#define SF_XARG1 0x48
167#define SF_XARG2 0x4c
168#define SF_XARG3 0x50
169#define SF_XARG4 0x54
170#define SF_XARG5 0x58
171#define SF_XXARG 0x5c
172
173/* Stuff for the ptrace system call */
174#define PTRACE_SPARC_DETACH 11
175#define PTRACE_GETREGS 12
176#define PTRACE_SETREGS 13
177#define PTRACE_GETFPREGS 14
178#define PTRACE_SETFPREGS 15
179#define PTRACE_READDATA 16
180#define PTRACE_WRITEDATA 17
181#define PTRACE_READTEXT 18
182#define PTRACE_WRITETEXT 19
183#define PTRACE_GETFPAREGS 20
184#define PTRACE_SETFPAREGS 21
185
186#endif /* !(_SPARC_PTRACE_H) */