ptrace.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2012 Regents of the University of California
  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,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _ASM_RISCV_PTRACE_H
  14. #define _ASM_RISCV_PTRACE_H
  15. #include <uapi/asm/ptrace.h>
  16. #include <asm/csr.h>
  17. #ifndef __ASSEMBLY__
  18. struct pt_regs {
  19. unsigned long sepc;
  20. unsigned long ra;
  21. unsigned long sp;
  22. unsigned long gp;
  23. unsigned long tp;
  24. unsigned long t0;
  25. unsigned long t1;
  26. unsigned long t2;
  27. unsigned long s0;
  28. unsigned long s1;
  29. unsigned long a0;
  30. unsigned long a1;
  31. unsigned long a2;
  32. unsigned long a3;
  33. unsigned long a4;
  34. unsigned long a5;
  35. unsigned long a6;
  36. unsigned long a7;
  37. unsigned long s2;
  38. unsigned long s3;
  39. unsigned long s4;
  40. unsigned long s5;
  41. unsigned long s6;
  42. unsigned long s7;
  43. unsigned long s8;
  44. unsigned long s9;
  45. unsigned long s10;
  46. unsigned long s11;
  47. unsigned long t3;
  48. unsigned long t4;
  49. unsigned long t5;
  50. unsigned long t6;
  51. /* Supervisor CSRs */
  52. unsigned long sstatus;
  53. unsigned long sbadaddr;
  54. unsigned long scause;
  55. /* a0 value before the syscall */
  56. unsigned long orig_a0;
  57. };
  58. #ifdef CONFIG_64BIT
  59. #define REG_FMT "%016lx"
  60. #else
  61. #define REG_FMT "%08lx"
  62. #endif
  63. #define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0)
  64. /* Helpers for working with the instruction pointer */
  65. #define GET_IP(regs) ((regs)->sepc)
  66. #define SET_IP(regs, val) (GET_IP(regs) = (val))
  67. static inline unsigned long instruction_pointer(struct pt_regs *regs)
  68. {
  69. return GET_IP(regs);
  70. }
  71. static inline void instruction_pointer_set(struct pt_regs *regs,
  72. unsigned long val)
  73. {
  74. SET_IP(regs, val);
  75. }
  76. #define profile_pc(regs) instruction_pointer(regs)
  77. /* Helpers for working with the user stack pointer */
  78. #define GET_USP(regs) ((regs)->sp)
  79. #define SET_USP(regs, val) (GET_USP(regs) = (val))
  80. static inline unsigned long user_stack_pointer(struct pt_regs *regs)
  81. {
  82. return GET_USP(regs);
  83. }
  84. static inline void user_stack_pointer_set(struct pt_regs *regs,
  85. unsigned long val)
  86. {
  87. SET_USP(regs, val);
  88. }
  89. /* Helpers for working with the frame pointer */
  90. #define GET_FP(regs) ((regs)->s0)
  91. #define SET_FP(regs, val) (GET_FP(regs) = (val))
  92. static inline unsigned long frame_pointer(struct pt_regs *regs)
  93. {
  94. return GET_FP(regs);
  95. }
  96. static inline void frame_pointer_set(struct pt_regs *regs,
  97. unsigned long val)
  98. {
  99. SET_FP(regs, val);
  100. }
  101. #endif /* __ASSEMBLY__ */
  102. #endif /* _ASM_RISCV_PTRACE_H */