ptrace.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef __SPARC_PTRACE_H
  2. #define __SPARC_PTRACE_H
  3. #include <uapi/asm/ptrace.h>
  4. #if defined(__sparc__) && defined(__arch64__)
  5. #ifndef __ASSEMBLY__
  6. #include <linux/threads.h>
  7. #include <asm/switch_to.h>
  8. static inline int pt_regs_trap_type(struct pt_regs *regs)
  9. {
  10. return regs->magic & 0x1ff;
  11. }
  12. static inline bool pt_regs_is_syscall(struct pt_regs *regs)
  13. {
  14. return (regs->tstate & TSTATE_SYSCALL);
  15. }
  16. static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
  17. {
  18. return (regs->tstate &= ~TSTATE_SYSCALL);
  19. }
  20. #define arch_ptrace_stop_needed(exit_code, info) \
  21. ({ flush_user_windows(); \
  22. get_thread_wsaved() != 0; \
  23. })
  24. #define arch_ptrace_stop(exit_code, info) \
  25. synchronize_user_stack()
  26. struct global_reg_snapshot {
  27. unsigned long tstate;
  28. unsigned long tpc;
  29. unsigned long tnpc;
  30. unsigned long o7;
  31. unsigned long i7;
  32. unsigned long rpc;
  33. struct thread_info *thread;
  34. unsigned long pad1;
  35. };
  36. extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
  37. #define force_successful_syscall_return() \
  38. do { current_thread_info()->syscall_noerror = 1; \
  39. } while (0)
  40. #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
  41. #define instruction_pointer(regs) ((regs)->tpc)
  42. #define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
  43. #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
  44. static inline int is_syscall_success(struct pt_regs *regs)
  45. {
  46. return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
  47. }
  48. static inline long regs_return_value(struct pt_regs *regs)
  49. {
  50. return regs->u_regs[UREG_I0];
  51. }
  52. #ifdef CONFIG_SMP
  53. extern unsigned long profile_pc(struct pt_regs *);
  54. #else
  55. #define profile_pc(regs) instruction_pointer(regs)
  56. #endif
  57. #else /* __ASSEMBLY__ */
  58. #endif /* __ASSEMBLY__ */
  59. #else /* (defined(__sparc__) && defined(__arch64__)) */
  60. #ifndef __ASSEMBLY__
  61. #include <asm/switch_to.h>
  62. static inline bool pt_regs_is_syscall(struct pt_regs *regs)
  63. {
  64. return (regs->psr & PSR_SYSCALL);
  65. }
  66. static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
  67. {
  68. return (regs->psr &= ~PSR_SYSCALL);
  69. }
  70. #define arch_ptrace_stop_needed(exit_code, info) \
  71. ({ flush_user_windows(); \
  72. current_thread_info()->w_saved != 0; \
  73. })
  74. #define arch_ptrace_stop(exit_code, info) \
  75. synchronize_user_stack()
  76. #define user_mode(regs) (!((regs)->psr & PSR_PS))
  77. #define instruction_pointer(regs) ((regs)->pc)
  78. #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
  79. unsigned long profile_pc(struct pt_regs *);
  80. #else /* (!__ASSEMBLY__) */
  81. #endif /* (!__ASSEMBLY__) */
  82. #endif /* (defined(__sparc__) && defined(__arch64__)) */
  83. #define STACK_BIAS 2047
  84. /* global_reg_snapshot offsets */
  85. #define GR_SNAP_TSTATE 0x00
  86. #define GR_SNAP_TPC 0x08
  87. #define GR_SNAP_TNPC 0x10
  88. #define GR_SNAP_O7 0x18
  89. #define GR_SNAP_I7 0x20
  90. #define GR_SNAP_RPC 0x28
  91. #define GR_SNAP_THREAD 0x30
  92. #define GR_SNAP_PAD1 0x38
  93. #endif /* !(__SPARC_PTRACE_H) */