ptrace.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2017 Microsemi Corporation.
  3. * Copyright (c) 2017 Padmarao Begari <Padmarao.Begari@microsemi.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef __ASM_RISCV_PTRACE_H
  10. #define __ASM_RISCV_PTRACE_H
  11. struct pt_regs {
  12. unsigned long sepc;
  13. unsigned long ra;
  14. unsigned long sp;
  15. unsigned long gp;
  16. unsigned long tp;
  17. unsigned long t0;
  18. unsigned long t1;
  19. unsigned long t2;
  20. unsigned long s0;
  21. unsigned long s1;
  22. unsigned long a0;
  23. unsigned long a1;
  24. unsigned long a2;
  25. unsigned long a3;
  26. unsigned long a4;
  27. unsigned long a5;
  28. unsigned long a6;
  29. unsigned long a7;
  30. unsigned long s2;
  31. unsigned long s3;
  32. unsigned long s4;
  33. unsigned long s5;
  34. unsigned long s6;
  35. unsigned long s7;
  36. unsigned long s8;
  37. unsigned long s9;
  38. unsigned long s10;
  39. unsigned long s11;
  40. unsigned long t3;
  41. unsigned long t4;
  42. unsigned long t5;
  43. unsigned long t6;
  44. /* Supervisor CSRs */
  45. unsigned long sstatus;
  46. unsigned long sbadaddr;
  47. unsigned long scause;
  48. };
  49. #ifdef CONFIG_64BIT
  50. #define REG_FMT "%016lx"
  51. #else
  52. #define REG_FMT "%08lx"
  53. #endif
  54. #define user_mode(regs) (((regs)->sstatus & SR_PS) == 0)
  55. /* Helpers for working with the instruction pointer */
  56. #define GET_IP(regs) ((regs)->sepc)
  57. #define SET_IP(regs, val) (GET_IP(regs) = (val))
  58. static inline unsigned long instruction_pointer(struct pt_regs *regs)
  59. {
  60. return GET_IP(regs);
  61. }
  62. static inline void instruction_pointer_set(struct pt_regs *regs, ulong val)
  63. {
  64. SET_IP(regs, val);
  65. }
  66. #define profile_pc(regs) instruction_pointer(regs)
  67. /* Helpers for working with the user stack pointer */
  68. #define GET_USP(regs) ((regs)->sp)
  69. #define SET_USP(regs, val) (GET_USP(regs) = (val))
  70. static inline unsigned long user_stack_pointer(struct pt_regs *regs)
  71. {
  72. return GET_USP(regs);
  73. }
  74. static inline void user_stack_pointer_set(struct pt_regs *regs, ulong val)
  75. {
  76. SET_USP(regs, val);
  77. }
  78. /* Helpers for working with the frame pointer */
  79. #define GET_FP(regs) ((regs)->s0)
  80. #define SET_FP(regs, val) (GET_FP(regs) = (val))
  81. static inline unsigned long frame_pointer(struct pt_regs *regs)
  82. {
  83. return GET_FP(regs);
  84. }
  85. static inline void frame_pointer_set(struct pt_regs *regs, ulong val)
  86. {
  87. SET_FP(regs, val);
  88. }
  89. #endif /* __ASM_RISCV_PTRACE_H */