ptrace.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI__SPARC_PTRACE_H
  3. #define _UAPI__SPARC_PTRACE_H
  4. #if defined(__sparc__) && defined(__arch64__)
  5. /* 64 bit sparc */
  6. #include <asm/pstate.h>
  7. /* This struct defines the way the registers are stored on the
  8. * stack during a system call and basically all traps.
  9. */
  10. /* This magic value must have the low 9 bits clear,
  11. * as that is where we encode the %tt value, see below.
  12. */
  13. #define PT_REGS_MAGIC 0x57ac6c00
  14. #ifndef __ASSEMBLY__
  15. #include <linux/types.h>
  16. struct pt_regs {
  17. unsigned long u_regs[16]; /* globals and ins */
  18. unsigned long tstate;
  19. unsigned long tpc;
  20. unsigned long tnpc;
  21. unsigned int y;
  22. /* We encode a magic number, PT_REGS_MAGIC, along
  23. * with the %tt (trap type) register value at trap
  24. * entry time. The magic number allows us to identify
  25. * accurately a trap stack frame in the stack
  26. * unwinder, and the %tt value allows us to test
  27. * things like "in a system call" etc. for an arbitray
  28. * process.
  29. *
  30. * The PT_REGS_MAGIC is chosen such that it can be
  31. * loaded completely using just a sethi instruction.
  32. */
  33. unsigned int magic;
  34. };
  35. struct pt_regs32 {
  36. unsigned int psr;
  37. unsigned int pc;
  38. unsigned int npc;
  39. unsigned int y;
  40. unsigned int u_regs[16]; /* globals and ins */
  41. };
  42. /* A V9 register window */
  43. struct reg_window {
  44. unsigned long locals[8];
  45. unsigned long ins[8];
  46. };
  47. /* A 32-bit register window. */
  48. struct reg_window32 {
  49. unsigned int locals[8];
  50. unsigned int ins[8];
  51. };
  52. /* A V9 Sparc stack frame */
  53. struct sparc_stackf {
  54. unsigned long locals[8];
  55. unsigned long ins[6];
  56. struct sparc_stackf *fp;
  57. unsigned long callers_pc;
  58. char *structptr;
  59. unsigned long xargs[6];
  60. unsigned long xxargs[1];
  61. };
  62. /* A 32-bit Sparc stack frame */
  63. struct sparc_stackf32 {
  64. unsigned int locals[8];
  65. unsigned int ins[6];
  66. unsigned int fp;
  67. unsigned int callers_pc;
  68. unsigned int structptr;
  69. unsigned int xargs[6];
  70. unsigned int xxargs[1];
  71. };
  72. struct sparc_trapf {
  73. unsigned long locals[8];
  74. unsigned long ins[8];
  75. unsigned long _unused;
  76. struct pt_regs *regs;
  77. };
  78. #endif /* (!__ASSEMBLY__) */
  79. #else
  80. /* 32 bit sparc */
  81. #include <asm/psr.h>
  82. /* This struct defines the way the registers are stored on the
  83. * stack during a system call and basically all traps.
  84. */
  85. #ifndef __ASSEMBLY__
  86. #include <linux/types.h>
  87. struct pt_regs {
  88. unsigned long psr;
  89. unsigned long pc;
  90. unsigned long npc;
  91. unsigned long y;
  92. unsigned long u_regs[16]; /* globals and ins */
  93. };
  94. /* A 32-bit register window. */
  95. struct reg_window32 {
  96. unsigned long locals[8];
  97. unsigned long ins[8];
  98. };
  99. /* A Sparc stack frame */
  100. struct sparc_stackf {
  101. unsigned long locals[8];
  102. unsigned long ins[6];
  103. struct sparc_stackf *fp;
  104. unsigned long callers_pc;
  105. char *structptr;
  106. unsigned long xargs[6];
  107. unsigned long xxargs[1];
  108. };
  109. #endif /* (!__ASSEMBLY__) */
  110. #endif /* (defined(__sparc__) && defined(__arch64__))*/
  111. #ifndef __ASSEMBLY__
  112. #define TRACEREG_SZ sizeof(struct pt_regs)
  113. #define STACKFRAME_SZ sizeof(struct sparc_stackf)
  114. #define TRACEREG32_SZ sizeof(struct pt_regs32)
  115. #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
  116. #endif /* (!__ASSEMBLY__) */
  117. #define UREG_G0 0
  118. #define UREG_G1 1
  119. #define UREG_G2 2
  120. #define UREG_G3 3
  121. #define UREG_G4 4
  122. #define UREG_G5 5
  123. #define UREG_G6 6
  124. #define UREG_G7 7
  125. #define UREG_I0 8
  126. #define UREG_I1 9
  127. #define UREG_I2 10
  128. #define UREG_I3 11
  129. #define UREG_I4 12
  130. #define UREG_I5 13
  131. #define UREG_I6 14
  132. #define UREG_I7 15
  133. #define UREG_FP UREG_I6
  134. #define UREG_RETPC UREG_I7
  135. #if defined(__sparc__) && defined(__arch64__)
  136. /* 64 bit sparc */
  137. #ifndef __ASSEMBLY__
  138. #else /* __ASSEMBLY__ */
  139. /* For assembly code. */
  140. #define TRACEREG_SZ 0xa0
  141. #define STACKFRAME_SZ 0xc0
  142. #define TRACEREG32_SZ 0x50
  143. #define STACKFRAME32_SZ 0x60
  144. #endif /* __ASSEMBLY__ */
  145. #else /* (defined(__sparc__) && defined(__arch64__)) */
  146. /* 32 bit sparc */
  147. #ifndef __ASSEMBLY__
  148. #else /* (!__ASSEMBLY__) */
  149. /* For assembly code. */
  150. #define TRACEREG_SZ 0x50
  151. #define STACKFRAME_SZ 0x60
  152. #endif /* (!__ASSEMBLY__) */
  153. #endif /* (defined(__sparc__) && defined(__arch64__)) */
  154. /* These are for pt_regs. */
  155. #define PT_V9_G0 0x00
  156. #define PT_V9_G1 0x08
  157. #define PT_V9_G2 0x10
  158. #define PT_V9_G3 0x18
  159. #define PT_V9_G4 0x20
  160. #define PT_V9_G5 0x28
  161. #define PT_V9_G6 0x30
  162. #define PT_V9_G7 0x38
  163. #define PT_V9_I0 0x40
  164. #define PT_V9_I1 0x48
  165. #define PT_V9_I2 0x50
  166. #define PT_V9_I3 0x58
  167. #define PT_V9_I4 0x60
  168. #define PT_V9_I5 0x68
  169. #define PT_V9_I6 0x70
  170. #define PT_V9_FP PT_V9_I6
  171. #define PT_V9_I7 0x78
  172. #define PT_V9_TSTATE 0x80
  173. #define PT_V9_TPC 0x88
  174. #define PT_V9_TNPC 0x90
  175. #define PT_V9_Y 0x98
  176. #define PT_V9_MAGIC 0x9c
  177. #define PT_TSTATE PT_V9_TSTATE
  178. #define PT_TPC PT_V9_TPC
  179. #define PT_TNPC PT_V9_TNPC
  180. /* These for pt_regs32. */
  181. #define PT_PSR 0x0
  182. #define PT_PC 0x4
  183. #define PT_NPC 0x8
  184. #define PT_Y 0xc
  185. #define PT_G0 0x10
  186. #define PT_WIM PT_G0
  187. #define PT_G1 0x14
  188. #define PT_G2 0x18
  189. #define PT_G3 0x1c
  190. #define PT_G4 0x20
  191. #define PT_G5 0x24
  192. #define PT_G6 0x28
  193. #define PT_G7 0x2c
  194. #define PT_I0 0x30
  195. #define PT_I1 0x34
  196. #define PT_I2 0x38
  197. #define PT_I3 0x3c
  198. #define PT_I4 0x40
  199. #define PT_I5 0x44
  200. #define PT_I6 0x48
  201. #define PT_FP PT_I6
  202. #define PT_I7 0x4c
  203. /* Reg_window offsets */
  204. #define RW_V9_L0 0x00
  205. #define RW_V9_L1 0x08
  206. #define RW_V9_L2 0x10
  207. #define RW_V9_L3 0x18
  208. #define RW_V9_L4 0x20
  209. #define RW_V9_L5 0x28
  210. #define RW_V9_L6 0x30
  211. #define RW_V9_L7 0x38
  212. #define RW_V9_I0 0x40
  213. #define RW_V9_I1 0x48
  214. #define RW_V9_I2 0x50
  215. #define RW_V9_I3 0x58
  216. #define RW_V9_I4 0x60
  217. #define RW_V9_I5 0x68
  218. #define RW_V9_I6 0x70
  219. #define RW_V9_I7 0x78
  220. #define RW_L0 0x00
  221. #define RW_L1 0x04
  222. #define RW_L2 0x08
  223. #define RW_L3 0x0c
  224. #define RW_L4 0x10
  225. #define RW_L5 0x14
  226. #define RW_L6 0x18
  227. #define RW_L7 0x1c
  228. #define RW_I0 0x20
  229. #define RW_I1 0x24
  230. #define RW_I2 0x28
  231. #define RW_I3 0x2c
  232. #define RW_I4 0x30
  233. #define RW_I5 0x34
  234. #define RW_I6 0x38
  235. #define RW_I7 0x3c
  236. /* Stack_frame offsets */
  237. #define SF_V9_L0 0x00
  238. #define SF_V9_L1 0x08
  239. #define SF_V9_L2 0x10
  240. #define SF_V9_L3 0x18
  241. #define SF_V9_L4 0x20
  242. #define SF_V9_L5 0x28
  243. #define SF_V9_L6 0x30
  244. #define SF_V9_L7 0x38
  245. #define SF_V9_I0 0x40
  246. #define SF_V9_I1 0x48
  247. #define SF_V9_I2 0x50
  248. #define SF_V9_I3 0x58
  249. #define SF_V9_I4 0x60
  250. #define SF_V9_I5 0x68
  251. #define SF_V9_FP 0x70
  252. #define SF_V9_PC 0x78
  253. #define SF_V9_RETP 0x80
  254. #define SF_V9_XARG0 0x88
  255. #define SF_V9_XARG1 0x90
  256. #define SF_V9_XARG2 0x98
  257. #define SF_V9_XARG3 0xa0
  258. #define SF_V9_XARG4 0xa8
  259. #define SF_V9_XARG5 0xb0
  260. #define SF_V9_XXARG 0xb8
  261. #define SF_L0 0x00
  262. #define SF_L1 0x04
  263. #define SF_L2 0x08
  264. #define SF_L3 0x0c
  265. #define SF_L4 0x10
  266. #define SF_L5 0x14
  267. #define SF_L6 0x18
  268. #define SF_L7 0x1c
  269. #define SF_I0 0x20
  270. #define SF_I1 0x24
  271. #define SF_I2 0x28
  272. #define SF_I3 0x2c
  273. #define SF_I4 0x30
  274. #define SF_I5 0x34
  275. #define SF_FP 0x38
  276. #define SF_PC 0x3c
  277. #define SF_RETP 0x40
  278. #define SF_XARG0 0x44
  279. #define SF_XARG1 0x48
  280. #define SF_XARG2 0x4c
  281. #define SF_XARG3 0x50
  282. #define SF_XARG4 0x54
  283. #define SF_XARG5 0x58
  284. #define SF_XXARG 0x5c
  285. /* Stuff for the ptrace system call */
  286. #define PTRACE_SPARC_DETACH 11
  287. #define PTRACE_GETREGS 12
  288. #define PTRACE_SETREGS 13
  289. #define PTRACE_GETFPREGS 14
  290. #define PTRACE_SETFPREGS 15
  291. #define PTRACE_READDATA 16
  292. #define PTRACE_WRITEDATA 17
  293. #define PTRACE_READTEXT 18
  294. #define PTRACE_WRITETEXT 19
  295. #define PTRACE_GETFPAREGS 20
  296. #define PTRACE_SETFPAREGS 21
  297. /* There are for debugging 64-bit processes, either from a 32 or 64 bit
  298. * parent. Thus their complements are for debugging 32-bit processes only.
  299. */
  300. #define PTRACE_GETREGS64 22
  301. #define PTRACE_SETREGS64 23
  302. /* PTRACE_SYSCALL is 24 */
  303. #define PTRACE_GETFPREGS64 25
  304. #define PTRACE_SETFPREGS64 26
  305. #endif /* _UAPI__SPARC_PTRACE_H */