blob: 12a9c569a2d2714ce612984bdadb8fdea6e0ca04 [file] [log] [blame]
Daniel Hellstrom9d7c6b22008-03-28 09:47:00 +01001/* Contain the Stack frame layout on interrupt. pt_regs.
2 * taken from the SPARC port of Linux (ptrace.h).
3 *
4 * (C) Copyright 2007
5 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 *
22 */
23
24#ifndef __SPARC_PTRACE_H__
25#define __SPARC_PTRACE_H__
26
27#include <asm/psr.h>
28
29/* This struct defines the way the registers are stored on the
30 * stack during a system call and basically all traps.
31 */
32
33#ifndef __ASSEMBLY__
34
35struct pt_regs {
36 unsigned long psr;
37 unsigned long pc;
38 unsigned long npc;
39 unsigned long y;
40 unsigned long u_regs[16]; /* globals and ins */
41};
42
43#define UREG_G0 0
44#define UREG_G1 1
45#define UREG_G2 2
46#define UREG_G3 3
47#define UREG_G4 4
48#define UREG_G5 5
49#define UREG_G6 6
50#define UREG_G7 7
51#define UREG_I0 8
52#define UREG_I1 9
53#define UREG_I2 10
54#define UREG_I3 11
55#define UREG_I4 12
56#define UREG_I5 13
57#define UREG_I6 14
58#define UREG_I7 15
59#define UREG_WIM UREG_G0
60#define UREG_FADDR UREG_G0
61#define UREG_FP UREG_I6
62#define UREG_RETPC UREG_I7
63
64/* A register window */
65struct reg_window {
66 unsigned long locals[8];
67 unsigned long ins[8];
68};
69
70/* A Sparc stack frame */
71struct sparc_stackf {
72 unsigned long locals[8];
73 unsigned long ins[6];
74 struct sparc_stackf *fp;
75 unsigned long callers_pc;
76 char *structptr;
77 unsigned long xargs[6];
78 unsigned long xxargs[1];
79};
80
81#define TRACEREG_SZ sizeof(struct pt_regs)
82#define STACKFRAME_SZ sizeof(struct sparc_stackf)
83
84#else /* __ASSEMBLY__ */
85/* For assembly code. */
86#define TRACEREG_SZ 0x50
87#define STACKFRAME_SZ 0x60
88#endif
89
90/*
91 * The asm_offsets.h is a generated file, so we cannot include it.
92 * It may be OK for glibc headers, but it's utterly pointless for C code.
93 * The assembly code using those offsets has to include it explicitly.
94 */
95/* #include <asm/asm_offsets.h> */
96
97/* These are for pt_regs. */
98#define PT_PSR 0x0
99#define PT_PC 0x4
100#define PT_NPC 0x8
101#define PT_Y 0xc
102#define PT_G0 0x10
103#define PT_WIM PT_G0
104#define PT_G1 0x14
105#define PT_G2 0x18
106#define PT_G3 0x1c
107#define PT_G4 0x20
108#define PT_G5 0x24
109#define PT_G6 0x28
110#define PT_G7 0x2c
111#define PT_I0 0x30
112#define PT_I1 0x34
113#define PT_I2 0x38
114#define PT_I3 0x3c
115#define PT_I4 0x40
116#define PT_I5 0x44
117#define PT_I6 0x48
118#define PT_FP PT_I6
119#define PT_I7 0x4c
120
121/* Reg_window offsets */
122#define RW_L0 0x00
123#define RW_L1 0x04
124#define RW_L2 0x08
125#define RW_L3 0x0c
126#define RW_L4 0x10
127#define RW_L5 0x14
128#define RW_L6 0x18
129#define RW_L7 0x1c
130#define RW_I0 0x20
131#define RW_I1 0x24
132#define RW_I2 0x28
133#define RW_I3 0x2c
134#define RW_I4 0x30
135#define RW_I5 0x34
136#define RW_I6 0x38
137#define RW_I7 0x3c
138
139/* Stack_frame offsets */
140#define SF_L0 0x00
141#define SF_L1 0x04
142#define SF_L2 0x08
143#define SF_L3 0x0c
144#define SF_L4 0x10
145#define SF_L5 0x14
146#define SF_L6 0x18
147#define SF_L7 0x1c
148#define SF_I0 0x20
149#define SF_I1 0x24
150#define SF_I2 0x28
151#define SF_I3 0x2c
152#define SF_I4 0x30
153#define SF_I5 0x34
154#define SF_FP 0x38
155#define SF_PC 0x3c
156#define SF_RETP 0x40
157#define SF_XARG0 0x44
158#define SF_XARG1 0x48
159#define SF_XARG2 0x4c
160#define SF_XARG3 0x50
161#define SF_XARG4 0x54
162#define SF_XARG5 0x58
163#define SF_XXARG 0x5c
164
165/* Stuff for the ptrace system call */
166#define PTRACE_SUNATTACH 10
167#define PTRACE_SUNDETACH 11
168#define PTRACE_GETREGS 12
169#define PTRACE_SETREGS 13
170#define PTRACE_GETFPREGS 14
171#define PTRACE_SETFPREGS 15
172#define PTRACE_READDATA 16
173#define PTRACE_WRITEDATA 17
174#define PTRACE_READTEXT 18
175#define PTRACE_WRITETEXT 19
176#define PTRACE_GETFPAREGS 20
177#define PTRACE_SETFPAREGS 21
178
179#define PTRACE_GETUCODE 29 /* stupid bsd-ism */
180
181#endif /* !(_SPARC_PTRACE_H) */