Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI__SPARC_PTRACE_H
0003 #define _UAPI__SPARC_PTRACE_H
0004 
0005 #if defined(__sparc__) && defined(__arch64__)
0006 /* 64 bit sparc */
0007 #include <asm/pstate.h>
0008 
0009 /* This struct defines the way the registers are stored on the
0010  * stack during a system call and basically all traps.
0011  */
0012 
0013 /* This magic value must have the low 9 bits clear,
0014  * as that is where we encode the %tt value, see below.
0015  */
0016 #define PT_REGS_MAGIC 0x57ac6c00
0017 
0018 #ifndef __ASSEMBLY__
0019 
0020 #include <linux/types.h>
0021 
0022 struct pt_regs {
0023     unsigned long u_regs[16]; /* globals and ins */
0024     unsigned long tstate;
0025     unsigned long tpc;
0026     unsigned long tnpc;
0027     unsigned int y;
0028 
0029     /* We encode a magic number, PT_REGS_MAGIC, along
0030      * with the %tt (trap type) register value at trap
0031      * entry time.  The magic number allows us to identify
0032      * accurately a trap stack frame in the stack
0033      * unwinder, and the %tt value allows us to test
0034      * things like "in a system call" etc. for an arbitray
0035      * process.
0036      *
0037      * The PT_REGS_MAGIC is chosen such that it can be
0038      * loaded completely using just a sethi instruction.
0039      */
0040     unsigned int magic;
0041 };
0042 
0043 struct pt_regs32 {
0044     unsigned int psr;
0045     unsigned int pc;
0046     unsigned int npc;
0047     unsigned int y;
0048     unsigned int u_regs[16]; /* globals and ins */
0049 };
0050 
0051 /* A V9 register window */
0052 struct reg_window {
0053     unsigned long locals[8];
0054     unsigned long ins[8];
0055 };
0056 
0057 /* A 32-bit register window. */
0058 struct reg_window32 {
0059     unsigned int locals[8];
0060     unsigned int ins[8];
0061 };
0062 
0063 /* A V9 Sparc stack frame */
0064 struct sparc_stackf {
0065     unsigned long locals[8];
0066         unsigned long ins[6];
0067     struct sparc_stackf *fp;
0068     unsigned long callers_pc;
0069     char *structptr;
0070     unsigned long xargs[6];
0071     unsigned long xxargs[1];
0072 };
0073 
0074 /* A 32-bit Sparc stack frame */
0075 struct sparc_stackf32 {
0076     unsigned int locals[8];
0077         unsigned int ins[6];
0078     unsigned int fp;
0079     unsigned int callers_pc;
0080     unsigned int structptr;
0081     unsigned int xargs[6];
0082     unsigned int xxargs[1];
0083 };
0084 
0085 struct sparc_trapf {
0086     unsigned long locals[8];
0087     unsigned long ins[8];
0088     unsigned long _unused;
0089     struct pt_regs *regs;
0090 };
0091 #endif /* (!__ASSEMBLY__) */
0092 #else
0093 /* 32 bit sparc */
0094 
0095 #include <asm/psr.h>
0096 
0097 /* This struct defines the way the registers are stored on the
0098  * stack during a system call and basically all traps.
0099  */
0100 #ifndef __ASSEMBLY__
0101 
0102 #include <linux/types.h>
0103 
0104 struct pt_regs {
0105     unsigned long psr;
0106     unsigned long pc;
0107     unsigned long npc;
0108     unsigned long y;
0109     unsigned long u_regs[16]; /* globals and ins */
0110 };
0111 
0112 /* A 32-bit register window. */
0113 struct reg_window32 {
0114     unsigned long locals[8];
0115     unsigned long ins[8];
0116 };
0117 
0118 /* A Sparc stack frame */
0119 struct sparc_stackf {
0120     unsigned long locals[8];
0121         unsigned long ins[6];
0122     struct sparc_stackf *fp;
0123     unsigned long callers_pc;
0124     char *structptr;
0125     unsigned long xargs[6];
0126     unsigned long xxargs[1];
0127 };
0128 #endif /* (!__ASSEMBLY__) */
0129 
0130 #endif /* (defined(__sparc__) && defined(__arch64__))*/
0131 
0132 #ifndef __ASSEMBLY__
0133 
0134 #define TRACEREG_SZ sizeof(struct pt_regs)
0135 #define STACKFRAME_SZ   sizeof(struct sparc_stackf)
0136 
0137 #define TRACEREG32_SZ   sizeof(struct pt_regs32)
0138 #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
0139 
0140 #endif /* (!__ASSEMBLY__) */
0141 
0142 #define UREG_G0        0
0143 #define UREG_G1        1
0144 #define UREG_G2        2
0145 #define UREG_G3        3
0146 #define UREG_G4        4
0147 #define UREG_G5        5
0148 #define UREG_G6        6
0149 #define UREG_G7        7
0150 #define UREG_I0        8
0151 #define UREG_I1        9
0152 #define UREG_I2        10
0153 #define UREG_I3        11
0154 #define UREG_I4        12
0155 #define UREG_I5        13
0156 #define UREG_I6        14
0157 #define UREG_I7        15
0158 #define UREG_FP        UREG_I6
0159 #define UREG_RETPC     UREG_I7
0160 
0161 #if defined(__sparc__) && defined(__arch64__)
0162 /* 64 bit sparc */
0163 
0164 #ifndef __ASSEMBLY__
0165 
0166 
0167 #else /* __ASSEMBLY__ */
0168 /* For assembly code. */
0169 #define TRACEREG_SZ     0xa0
0170 #define STACKFRAME_SZ       0xc0
0171 
0172 #define TRACEREG32_SZ       0x50
0173 #define STACKFRAME32_SZ     0x60
0174 #endif /* __ASSEMBLY__ */
0175 
0176 #else /* (defined(__sparc__) && defined(__arch64__)) */
0177 
0178 /* 32 bit sparc */
0179 
0180 #ifndef __ASSEMBLY__
0181 
0182 
0183 #else /* (!__ASSEMBLY__) */
0184 /* For assembly code. */
0185 #define TRACEREG_SZ       0x50
0186 #define STACKFRAME_SZ     0x60
0187 #endif /* (!__ASSEMBLY__) */
0188 
0189 #endif /* (defined(__sparc__) && defined(__arch64__)) */
0190 
0191 
0192 /* These are for pt_regs. */
0193 #define PT_V9_G0     0x00
0194 #define PT_V9_G1     0x08
0195 #define PT_V9_G2     0x10
0196 #define PT_V9_G3     0x18
0197 #define PT_V9_G4     0x20
0198 #define PT_V9_G5     0x28
0199 #define PT_V9_G6     0x30
0200 #define PT_V9_G7     0x38
0201 #define PT_V9_I0     0x40
0202 #define PT_V9_I1     0x48
0203 #define PT_V9_I2     0x50
0204 #define PT_V9_I3     0x58
0205 #define PT_V9_I4     0x60
0206 #define PT_V9_I5     0x68
0207 #define PT_V9_I6     0x70
0208 #define PT_V9_FP     PT_V9_I6
0209 #define PT_V9_I7     0x78
0210 #define PT_V9_TSTATE 0x80
0211 #define PT_V9_TPC    0x88
0212 #define PT_V9_TNPC   0x90
0213 #define PT_V9_Y      0x98
0214 #define PT_V9_MAGIC  0x9c
0215 #define PT_TSTATE   PT_V9_TSTATE
0216 #define PT_TPC      PT_V9_TPC
0217 #define PT_TNPC     PT_V9_TNPC
0218 
0219 /* These for pt_regs32. */
0220 #define PT_PSR    0x0
0221 #define PT_PC     0x4
0222 #define PT_NPC    0x8
0223 #define PT_Y      0xc
0224 #define PT_G0     0x10
0225 #define PT_WIM    PT_G0
0226 #define PT_G1     0x14
0227 #define PT_G2     0x18
0228 #define PT_G3     0x1c
0229 #define PT_G4     0x20
0230 #define PT_G5     0x24
0231 #define PT_G6     0x28
0232 #define PT_G7     0x2c
0233 #define PT_I0     0x30
0234 #define PT_I1     0x34
0235 #define PT_I2     0x38
0236 #define PT_I3     0x3c
0237 #define PT_I4     0x40
0238 #define PT_I5     0x44
0239 #define PT_I6     0x48
0240 #define PT_FP     PT_I6
0241 #define PT_I7     0x4c
0242 
0243 /* Reg_window offsets */
0244 #define RW_V9_L0     0x00
0245 #define RW_V9_L1     0x08
0246 #define RW_V9_L2     0x10
0247 #define RW_V9_L3     0x18
0248 #define RW_V9_L4     0x20
0249 #define RW_V9_L5     0x28
0250 #define RW_V9_L6     0x30
0251 #define RW_V9_L7     0x38
0252 #define RW_V9_I0     0x40
0253 #define RW_V9_I1     0x48
0254 #define RW_V9_I2     0x50
0255 #define RW_V9_I3     0x58
0256 #define RW_V9_I4     0x60
0257 #define RW_V9_I5     0x68
0258 #define RW_V9_I6     0x70
0259 #define RW_V9_I7     0x78
0260 
0261 #define RW_L0     0x00
0262 #define RW_L1     0x04
0263 #define RW_L2     0x08
0264 #define RW_L3     0x0c
0265 #define RW_L4     0x10
0266 #define RW_L5     0x14
0267 #define RW_L6     0x18
0268 #define RW_L7     0x1c
0269 #define RW_I0     0x20
0270 #define RW_I1     0x24
0271 #define RW_I2     0x28
0272 #define RW_I3     0x2c
0273 #define RW_I4     0x30
0274 #define RW_I5     0x34
0275 #define RW_I6     0x38
0276 #define RW_I7     0x3c
0277 
0278 /* Stack_frame offsets */
0279 #define SF_V9_L0     0x00
0280 #define SF_V9_L1     0x08
0281 #define SF_V9_L2     0x10
0282 #define SF_V9_L3     0x18
0283 #define SF_V9_L4     0x20
0284 #define SF_V9_L5     0x28
0285 #define SF_V9_L6     0x30
0286 #define SF_V9_L7     0x38
0287 #define SF_V9_I0     0x40
0288 #define SF_V9_I1     0x48
0289 #define SF_V9_I2     0x50
0290 #define SF_V9_I3     0x58
0291 #define SF_V9_I4     0x60
0292 #define SF_V9_I5     0x68
0293 #define SF_V9_FP     0x70
0294 #define SF_V9_PC     0x78
0295 #define SF_V9_RETP   0x80
0296 #define SF_V9_XARG0  0x88
0297 #define SF_V9_XARG1  0x90
0298 #define SF_V9_XARG2  0x98
0299 #define SF_V9_XARG3  0xa0
0300 #define SF_V9_XARG4  0xa8
0301 #define SF_V9_XARG5  0xb0
0302 #define SF_V9_XXARG  0xb8
0303 
0304 #define SF_L0     0x00
0305 #define SF_L1     0x04
0306 #define SF_L2     0x08
0307 #define SF_L3     0x0c
0308 #define SF_L4     0x10
0309 #define SF_L5     0x14
0310 #define SF_L6     0x18
0311 #define SF_L7     0x1c
0312 #define SF_I0     0x20
0313 #define SF_I1     0x24
0314 #define SF_I2     0x28
0315 #define SF_I3     0x2c
0316 #define SF_I4     0x30
0317 #define SF_I5     0x34
0318 #define SF_FP     0x38
0319 #define SF_PC     0x3c
0320 #define SF_RETP   0x40
0321 #define SF_XARG0  0x44
0322 #define SF_XARG1  0x48
0323 #define SF_XARG2  0x4c
0324 #define SF_XARG3  0x50
0325 #define SF_XARG4  0x54
0326 #define SF_XARG5  0x58
0327 #define SF_XXARG  0x5c
0328 
0329 
0330 /* Stuff for the ptrace system call */
0331 #define PTRACE_SPARC_DETACH       11
0332 #define PTRACE_GETREGS            12
0333 #define PTRACE_SETREGS            13
0334 #define PTRACE_GETFPREGS          14
0335 #define PTRACE_SETFPREGS          15
0336 #define PTRACE_READDATA           16
0337 #define PTRACE_WRITEDATA          17
0338 #define PTRACE_READTEXT           18
0339 #define PTRACE_WRITETEXT          19
0340 #define PTRACE_GETFPAREGS         20
0341 #define PTRACE_SETFPAREGS         21
0342 
0343 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
0344  * parent.  Thus their complements are for debugging 32-bit processes only.
0345  */
0346 
0347 #define PTRACE_GETREGS64      22
0348 #define PTRACE_SETREGS64      23
0349 /* PTRACE_SYSCALL is 24 */
0350 #define PTRACE_GETFPREGS64    25
0351 #define PTRACE_SETFPREGS64    26
0352 
0353 #endif /* _UAPI__SPARC_PTRACE_H */