ptrace.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_PTRACE_H
  15. #define _ASM_TILE_PTRACE_H
  16. #include <arch/chip.h>
  17. #include <arch/abi.h>
  18. /* These must match struct pt_regs, below. */
  19. #if CHIP_WORD_SIZE() == 32
  20. #define PTREGS_OFFSET_REG(n) ((n)*4)
  21. #else
  22. #define PTREGS_OFFSET_REG(n) ((n)*8)
  23. #endif
  24. #define PTREGS_OFFSET_BASE 0
  25. #define PTREGS_OFFSET_TP PTREGS_OFFSET_REG(53)
  26. #define PTREGS_OFFSET_SP PTREGS_OFFSET_REG(54)
  27. #define PTREGS_OFFSET_LR PTREGS_OFFSET_REG(55)
  28. #define PTREGS_NR_GPRS 56
  29. #define PTREGS_OFFSET_PC PTREGS_OFFSET_REG(56)
  30. #define PTREGS_OFFSET_EX1 PTREGS_OFFSET_REG(57)
  31. #define PTREGS_OFFSET_FAULTNUM PTREGS_OFFSET_REG(58)
  32. #define PTREGS_OFFSET_ORIG_R0 PTREGS_OFFSET_REG(59)
  33. #define PTREGS_OFFSET_FLAGS PTREGS_OFFSET_REG(60)
  34. #if CHIP_HAS_CMPEXCH()
  35. #define PTREGS_OFFSET_CMPEXCH PTREGS_OFFSET_REG(61)
  36. #endif
  37. #define PTREGS_SIZE PTREGS_OFFSET_REG(64)
  38. #ifndef __ASSEMBLY__
  39. #ifdef __KERNEL__
  40. /* Benefit from consistent use of "long" on all chips. */
  41. typedef unsigned long pt_reg_t;
  42. #else
  43. /* Provide appropriate length type to userspace regardless of -m32/-m64. */
  44. typedef uint_reg_t pt_reg_t;
  45. #endif
  46. /*
  47. * This struct defines the way the registers are stored on the stack during a
  48. * system call or exception. "struct sigcontext" has the same shape.
  49. */
  50. struct pt_regs {
  51. /* Saved main processor registers; 56..63 are special. */
  52. /* tp, sp, and lr must immediately follow regs[] for aliasing. */
  53. pt_reg_t regs[53];
  54. pt_reg_t tp; /* aliases regs[TREG_TP] */
  55. pt_reg_t sp; /* aliases regs[TREG_SP] */
  56. pt_reg_t lr; /* aliases regs[TREG_LR] */
  57. /* Saved special registers. */
  58. pt_reg_t pc; /* stored in EX_CONTEXT_K_0 */
  59. pt_reg_t ex1; /* stored in EX_CONTEXT_K_1 (PL and ICS bit) */
  60. pt_reg_t faultnum; /* fault number (INT_SWINT_1 for syscall) */
  61. pt_reg_t orig_r0; /* r0 at syscall entry, else zero */
  62. pt_reg_t flags; /* flags (see below) */
  63. #if !CHIP_HAS_CMPEXCH()
  64. pt_reg_t pad[3];
  65. #else
  66. pt_reg_t cmpexch; /* value of CMPEXCH_VALUE SPR at interrupt */
  67. pt_reg_t pad[2];
  68. #endif
  69. };
  70. #endif /* __ASSEMBLY__ */
  71. #define PTRACE_GETREGS 12
  72. #define PTRACE_SETREGS 13
  73. #define PTRACE_GETFPREGS 14
  74. #define PTRACE_SETFPREGS 15
  75. /* Support TILE-specific ptrace options, with events starting at 16. */
  76. #define PTRACE_O_TRACEMIGRATE 0x00010000
  77. #define PTRACE_EVENT_MIGRATE 16
  78. #ifdef __KERNEL__
  79. #define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE)
  80. #define PT_TRACE_MIGRATE 0x00080000
  81. #define PT_TRACE_MASK_TILE (PT_TRACE_MIGRATE)
  82. #endif
  83. #ifdef __KERNEL__
  84. /* Flag bits in pt_regs.flags */
  85. #define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */
  86. #define PT_FLAGS_CALLER_SAVES 2 /* caller-save registers are valid */
  87. #define PT_FLAGS_RESTORE_REGS 4 /* restore callee-save regs on return */
  88. #ifndef __ASSEMBLY__
  89. #define instruction_pointer(regs) ((regs)->pc)
  90. #define profile_pc(regs) instruction_pointer(regs)
  91. /* Does the process account for user or for system time? */
  92. #define user_mode(regs) (EX1_PL((regs)->ex1) == USER_PL)
  93. /* Fill in a struct pt_regs with the current kernel registers. */
  94. struct pt_regs *get_pt_regs(struct pt_regs *);
  95. /* Trace the current syscall. */
  96. extern void do_syscall_trace(void);
  97. extern void show_regs(struct pt_regs *);
  98. #define arch_has_single_step() (1)
  99. /*
  100. * A structure for all single-stepper state.
  101. *
  102. * Also update defines in assembler section if it changes
  103. */
  104. struct single_step_state {
  105. /* the page to which we will write hacked-up bundles */
  106. void __user *buffer;
  107. union {
  108. int flags;
  109. struct {
  110. unsigned long is_enabled:1, update:1, update_reg:6;
  111. };
  112. };
  113. unsigned long orig_pc; /* the original PC */
  114. unsigned long next_pc; /* return PC if no branch (PC + 1) */
  115. unsigned long branch_next_pc; /* return PC if we did branch/jump */
  116. unsigned long update_value; /* value to restore to update_target */
  117. };
  118. /* Single-step the instruction at regs->pc */
  119. extern void single_step_once(struct pt_regs *regs);
  120. /* Clean up after execve(). */
  121. extern void single_step_execve(void);
  122. struct task_struct;
  123. extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
  124. int error_code);
  125. #ifdef __tilegx__
  126. /* We need this since sigval_t has a user pointer in it, for GETSIGINFO etc. */
  127. #define __ARCH_WANT_COMPAT_SYS_PTRACE
  128. #endif
  129. #endif /* !__ASSEMBLY__ */
  130. #define SINGLESTEP_STATE_MASK_IS_ENABLED 0x1
  131. #define SINGLESTEP_STATE_MASK_UPDATE 0x2
  132. #define SINGLESTEP_STATE_TARGET_LB 2
  133. #define SINGLESTEP_STATE_TARGET_UB 7
  134. #endif /* !__KERNEL__ */
  135. #endif /* _ASM_TILE_PTRACE_H */