ptrace.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Copyright (C) 2001 PPC64 Team, IBM Corp
  3. *
  4. * This struct defines the way the registers are stored on the
  5. * kernel stack during a system call or other kernel entry.
  6. *
  7. * this should only contain volatile regs
  8. * since we can keep non-volatile in the thread_struct
  9. * should set this up when only volatiles are saved
  10. * by intr code.
  11. *
  12. * Since this is going on the stack, *CARE MUST BE TAKEN* to insure
  13. * that the overall structure is a multiple of 16 bytes in length.
  14. *
  15. * Note that the offsets of the fields in this struct correspond with
  16. * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c.
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version
  21. * 2 of the License, or (at your option) any later version.
  22. */
  23. #ifndef _UAPI_ASM_POWERPC_PTRACE_H
  24. #define _UAPI_ASM_POWERPC_PTRACE_H
  25. #include <linux/types.h>
  26. #ifndef __ASSEMBLY__
  27. struct pt_regs {
  28. unsigned long gpr[32];
  29. unsigned long nip;
  30. unsigned long msr;
  31. unsigned long orig_gpr3; /* Used for restarting system calls */
  32. unsigned long ctr;
  33. unsigned long link;
  34. unsigned long xer;
  35. unsigned long ccr;
  36. #ifdef __powerpc64__
  37. unsigned long softe; /* Soft enabled/disabled */
  38. #else
  39. unsigned long mq; /* 601 only (not used at present) */
  40. /* Used on APUS to hold IPL value. */
  41. #endif
  42. unsigned long trap; /* Reason for being here */
  43. /* N.B. for critical exceptions on 4xx, the dar and dsisr
  44. fields are overloaded to hold srr0 and srr1. */
  45. unsigned long dar; /* Fault registers */
  46. unsigned long dsisr; /* on 4xx/Book-E used for ESR */
  47. unsigned long result; /* Result of a system call */
  48. };
  49. #endif /* __ASSEMBLY__ */
  50. /*
  51. * Offsets used by 'ptrace' system call interface.
  52. * These can't be changed without breaking binary compatibility
  53. * with MkLinux, etc.
  54. */
  55. #define PT_R0 0
  56. #define PT_R1 1
  57. #define PT_R2 2
  58. #define PT_R3 3
  59. #define PT_R4 4
  60. #define PT_R5 5
  61. #define PT_R6 6
  62. #define PT_R7 7
  63. #define PT_R8 8
  64. #define PT_R9 9
  65. #define PT_R10 10
  66. #define PT_R11 11
  67. #define PT_R12 12
  68. #define PT_R13 13
  69. #define PT_R14 14
  70. #define PT_R15 15
  71. #define PT_R16 16
  72. #define PT_R17 17
  73. #define PT_R18 18
  74. #define PT_R19 19
  75. #define PT_R20 20
  76. #define PT_R21 21
  77. #define PT_R22 22
  78. #define PT_R23 23
  79. #define PT_R24 24
  80. #define PT_R25 25
  81. #define PT_R26 26
  82. #define PT_R27 27
  83. #define PT_R28 28
  84. #define PT_R29 29
  85. #define PT_R30 30
  86. #define PT_R31 31
  87. #define PT_NIP 32
  88. #define PT_MSR 33
  89. #define PT_ORIG_R3 34
  90. #define PT_CTR 35
  91. #define PT_LNK 36
  92. #define PT_XER 37
  93. #define PT_CCR 38
  94. #ifndef __powerpc64__
  95. #define PT_MQ 39
  96. #else
  97. #define PT_SOFTE 39
  98. #endif
  99. #define PT_TRAP 40
  100. #define PT_DAR 41
  101. #define PT_DSISR 42
  102. #define PT_RESULT 43
  103. #define PT_DSCR 44
  104. #define PT_REGS_COUNT 44
  105. #define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
  106. #ifndef __powerpc64__
  107. #define PT_FPR31 (PT_FPR0 + 2*31)
  108. #define PT_FPSCR (PT_FPR0 + 2*32 + 1)
  109. #else /* __powerpc64__ */
  110. #define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
  111. #define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
  112. #define PT_VSCR (PT_VR0 + 32*2 + 1)
  113. #define PT_VRSAVE (PT_VR0 + 33*2)
  114. /*
  115. * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
  116. */
  117. #define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
  118. #define PT_VSR31 (PT_VSR0 + 2*31)
  119. #endif /* __powerpc64__ */
  120. /*
  121. * Get/set all the altivec registers v0..v31, vscr, vrsave, in one go.
  122. * The transfer totals 34 quadword. Quadwords 0-31 contain the
  123. * corresponding vector registers. Quadword 32 contains the vscr as the
  124. * last word (offset 12) within that quadword. Quadword 33 contains the
  125. * vrsave as the first word (offset 0) within the quadword.
  126. *
  127. * This definition of the VMX state is compatible with the current PPC32
  128. * ptrace interface. This allows signal handling and ptrace to use the same
  129. * structures. This also simplifies the implementation of a bi-arch
  130. * (combined (32- and 64-bit) gdb.
  131. */
  132. #define PTRACE_GETVRREGS 0x12
  133. #define PTRACE_SETVRREGS 0x13
  134. /* Get/set all the upper 32-bits of the SPE registers, accumulator, and
  135. * spefscr, in one go */
  136. #define PTRACE_GETEVRREGS 0x14
  137. #define PTRACE_SETEVRREGS 0x15
  138. /* Get the first 32 128bit VSX registers */
  139. #define PTRACE_GETVSRREGS 0x1b
  140. #define PTRACE_SETVSRREGS 0x1c
  141. /*
  142. * Get or set a debug register. The first 16 are DABR registers and the
  143. * second 16 are IABR registers.
  144. */
  145. #define PTRACE_GET_DEBUGREG 0x19
  146. #define PTRACE_SET_DEBUGREG 0x1a
  147. /* (new) PTRACE requests using the same numbers as x86 and the same
  148. * argument ordering. Additionally, they support more registers too
  149. */
  150. #define PTRACE_GETREGS 0xc
  151. #define PTRACE_SETREGS 0xd
  152. #define PTRACE_GETFPREGS 0xe
  153. #define PTRACE_SETFPREGS 0xf
  154. #define PTRACE_GETREGS64 0x16
  155. #define PTRACE_SETREGS64 0x17
  156. /* Calls to trace a 64bit program from a 32bit program */
  157. #define PPC_PTRACE_PEEKTEXT_3264 0x95
  158. #define PPC_PTRACE_PEEKDATA_3264 0x94
  159. #define PPC_PTRACE_POKETEXT_3264 0x93
  160. #define PPC_PTRACE_POKEDATA_3264 0x92
  161. #define PPC_PTRACE_PEEKUSR_3264 0x91
  162. #define PPC_PTRACE_POKEUSR_3264 0x90
  163. #define PTRACE_SINGLEBLOCK 0x100 /* resume execution until next branch */
  164. #define PPC_PTRACE_GETHWDBGINFO 0x89
  165. #define PPC_PTRACE_SETHWDEBUG 0x88
  166. #define PPC_PTRACE_DELHWDEBUG 0x87
  167. #ifndef __ASSEMBLY__
  168. struct ppc_debug_info {
  169. __u32 version; /* Only version 1 exists to date */
  170. __u32 num_instruction_bps;
  171. __u32 num_data_bps;
  172. __u32 num_condition_regs;
  173. __u32 data_bp_alignment;
  174. __u32 sizeof_condition; /* size of the DVC register */
  175. __u64 features;
  176. };
  177. #endif /* __ASSEMBLY__ */
  178. /*
  179. * features will have bits indication whether there is support for:
  180. */
  181. #define PPC_DEBUG_FEATURE_INSN_BP_RANGE 0x0000000000000001
  182. #define PPC_DEBUG_FEATURE_INSN_BP_MASK 0x0000000000000002
  183. #define PPC_DEBUG_FEATURE_DATA_BP_RANGE 0x0000000000000004
  184. #define PPC_DEBUG_FEATURE_DATA_BP_MASK 0x0000000000000008
  185. #define PPC_DEBUG_FEATURE_DATA_BP_DAWR 0x0000000000000010
  186. #ifndef __ASSEMBLY__
  187. struct ppc_hw_breakpoint {
  188. __u32 version; /* currently, version must be 1 */
  189. __u32 trigger_type; /* only some combinations allowed */
  190. __u32 addr_mode; /* address match mode */
  191. __u32 condition_mode; /* break/watchpoint condition flags */
  192. __u64 addr; /* break/watchpoint address */
  193. __u64 addr2; /* range end or mask */
  194. __u64 condition_value; /* contents of the DVC register */
  195. };
  196. #endif /* __ASSEMBLY__ */
  197. /*
  198. * Trigger Type
  199. */
  200. #define PPC_BREAKPOINT_TRIGGER_EXECUTE 0x00000001
  201. #define PPC_BREAKPOINT_TRIGGER_READ 0x00000002
  202. #define PPC_BREAKPOINT_TRIGGER_WRITE 0x00000004
  203. #define PPC_BREAKPOINT_TRIGGER_RW \
  204. (PPC_BREAKPOINT_TRIGGER_READ | PPC_BREAKPOINT_TRIGGER_WRITE)
  205. /*
  206. * Address Mode
  207. */
  208. #define PPC_BREAKPOINT_MODE_EXACT 0x00000000
  209. #define PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE 0x00000001
  210. #define PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE 0x00000002
  211. #define PPC_BREAKPOINT_MODE_MASK 0x00000003
  212. /*
  213. * Condition Mode
  214. */
  215. #define PPC_BREAKPOINT_CONDITION_MODE 0x00000003
  216. #define PPC_BREAKPOINT_CONDITION_NONE 0x00000000
  217. #define PPC_BREAKPOINT_CONDITION_AND 0x00000001
  218. #define PPC_BREAKPOINT_CONDITION_EXACT PPC_BREAKPOINT_CONDITION_AND
  219. #define PPC_BREAKPOINT_CONDITION_OR 0x00000002
  220. #define PPC_BREAKPOINT_CONDITION_AND_OR 0x00000003
  221. #define PPC_BREAKPOINT_CONDITION_BE_ALL 0x00ff0000
  222. #define PPC_BREAKPOINT_CONDITION_BE_SHIFT 16
  223. #define PPC_BREAKPOINT_CONDITION_BE(n) \
  224. (1<<((n)+PPC_BREAKPOINT_CONDITION_BE_SHIFT))
  225. #endif /* _UAPI_ASM_POWERPC_PTRACE_H */