ptrace.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* 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. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __SPARC_PTRACE_H__
  10. #define __SPARC_PTRACE_H__
  11. #include <asm/psr.h>
  12. /* This struct defines the way the registers are stored on the
  13. * stack during a system call and basically all traps.
  14. */
  15. #ifndef __ASSEMBLY__
  16. struct pt_regs {
  17. unsigned long psr;
  18. unsigned long pc;
  19. unsigned long npc;
  20. unsigned long y;
  21. unsigned long u_regs[16]; /* globals and ins */
  22. };
  23. #define UREG_G0 0
  24. #define UREG_G1 1
  25. #define UREG_G2 2
  26. #define UREG_G3 3
  27. #define UREG_G4 4
  28. #define UREG_G5 5
  29. #define UREG_G6 6
  30. #define UREG_G7 7
  31. #define UREG_I0 8
  32. #define UREG_I1 9
  33. #define UREG_I2 10
  34. #define UREG_I3 11
  35. #define UREG_I4 12
  36. #define UREG_I5 13
  37. #define UREG_I6 14
  38. #define UREG_I7 15
  39. #define UREG_WIM UREG_G0
  40. #define UREG_FADDR UREG_G0
  41. #define UREG_FP UREG_I6
  42. #define UREG_RETPC UREG_I7
  43. /* A register window */
  44. struct reg_window {
  45. unsigned long locals[8];
  46. unsigned long ins[8];
  47. };
  48. /* A Sparc stack frame */
  49. struct sparc_stackf {
  50. unsigned long locals[8];
  51. unsigned long ins[6];
  52. struct sparc_stackf *fp;
  53. unsigned long callers_pc;
  54. char *structptr;
  55. unsigned long xargs[6];
  56. unsigned long xxargs[1];
  57. };
  58. #define TRACEREG_SZ sizeof(struct pt_regs)
  59. #define STACKFRAME_SZ sizeof(struct sparc_stackf)
  60. #else /* __ASSEMBLY__ */
  61. /* For assembly code. */
  62. #define TRACEREG_SZ 0x50
  63. #define STACKFRAME_SZ 0x60
  64. #endif
  65. /*
  66. * The asm_offsets.h is a generated file, so we cannot include it.
  67. * It may be OK for glibc headers, but it's utterly pointless for C code.
  68. * The assembly code using those offsets has to include it explicitly.
  69. */
  70. /* #include <asm/asm_offsets.h> */
  71. /* These are for pt_regs. */
  72. #define PT_PSR 0x0
  73. #define PT_PC 0x4
  74. #define PT_NPC 0x8
  75. #define PT_Y 0xc
  76. #define PT_G0 0x10
  77. #define PT_WIM PT_G0
  78. #define PT_G1 0x14
  79. #define PT_G2 0x18
  80. #define PT_G3 0x1c
  81. #define PT_G4 0x20
  82. #define PT_G5 0x24
  83. #define PT_G6 0x28
  84. #define PT_G7 0x2c
  85. #define PT_I0 0x30
  86. #define PT_I1 0x34
  87. #define PT_I2 0x38
  88. #define PT_I3 0x3c
  89. #define PT_I4 0x40
  90. #define PT_I5 0x44
  91. #define PT_I6 0x48
  92. #define PT_FP PT_I6
  93. #define PT_I7 0x4c
  94. /* Reg_window offsets */
  95. #define RW_L0 0x00
  96. #define RW_L1 0x04
  97. #define RW_L2 0x08
  98. #define RW_L3 0x0c
  99. #define RW_L4 0x10
  100. #define RW_L5 0x14
  101. #define RW_L6 0x18
  102. #define RW_L7 0x1c
  103. #define RW_I0 0x20
  104. #define RW_I1 0x24
  105. #define RW_I2 0x28
  106. #define RW_I3 0x2c
  107. #define RW_I4 0x30
  108. #define RW_I5 0x34
  109. #define RW_I6 0x38
  110. #define RW_I7 0x3c
  111. /* Stack_frame offsets */
  112. #define SF_L0 0x00
  113. #define SF_L1 0x04
  114. #define SF_L2 0x08
  115. #define SF_L3 0x0c
  116. #define SF_L4 0x10
  117. #define SF_L5 0x14
  118. #define SF_L6 0x18
  119. #define SF_L7 0x1c
  120. #define SF_I0 0x20
  121. #define SF_I1 0x24
  122. #define SF_I2 0x28
  123. #define SF_I3 0x2c
  124. #define SF_I4 0x30
  125. #define SF_I5 0x34
  126. #define SF_FP 0x38
  127. #define SF_PC 0x3c
  128. #define SF_RETP 0x40
  129. #define SF_XARG0 0x44
  130. #define SF_XARG1 0x48
  131. #define SF_XARG2 0x4c
  132. #define SF_XARG3 0x50
  133. #define SF_XARG4 0x54
  134. #define SF_XARG5 0x58
  135. #define SF_XXARG 0x5c
  136. /* Stuff for the ptrace system call */
  137. #define PTRACE_SUNATTACH 10
  138. #define PTRACE_SUNDETACH 11
  139. #define PTRACE_GETREGS 12
  140. #define PTRACE_SETREGS 13
  141. #define PTRACE_GETFPREGS 14
  142. #define PTRACE_SETFPREGS 15
  143. #define PTRACE_READDATA 16
  144. #define PTRACE_WRITEDATA 17
  145. #define PTRACE_READTEXT 18
  146. #define PTRACE_WRITETEXT 19
  147. #define PTRACE_GETFPAREGS 20
  148. #define PTRACE_SETFPAREGS 21
  149. #define PTRACE_GETUCODE 29 /* stupid bsd-ism */
  150. #endif /* !(_SPARC_PTRACE_H) */