ptrace.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
  9. */
  10. #ifndef __ASM_ARC_PTRACE_H
  11. #define __ASM_ARC_PTRACE_H
  12. #ifdef __KERNEL__
  13. #ifndef __ASSEMBLY__
  14. /* THE pt_regs: Defines how regs are saved during entry into kernel */
  15. struct pt_regs {
  16. /*
  17. * 1 word gutter after reg-file has been saved
  18. * Technically not needed, Since SP always points to a "full" location
  19. * (vs. "empty"). But pt_regs is shared with tools....
  20. */
  21. long res;
  22. /* Real registers */
  23. long bta; /* bta_l1, bta_l2, erbta */
  24. long lp_start;
  25. long lp_end;
  26. long lp_count;
  27. long status32; /* status32_l1, status32_l2, erstatus */
  28. long ret; /* ilink1, ilink2 or eret */
  29. long blink;
  30. long fp;
  31. long r26; /* gp */
  32. long r12;
  33. long r11;
  34. long r10;
  35. long r9;
  36. long r8;
  37. long r7;
  38. long r6;
  39. long r5;
  40. long r4;
  41. long r3;
  42. long r2;
  43. long r1;
  44. long r0;
  45. long sp; /* user/kernel sp depending on where we came from */
  46. long orig_r0;
  47. /*to distinguish bet excp, syscall, irq */
  48. union {
  49. #ifdef CONFIG_CPU_BIG_ENDIAN
  50. /* so that assembly code is same for LE/BE */
  51. unsigned long orig_r8:16, event:16;
  52. #else
  53. unsigned long event:16, orig_r8:16;
  54. #endif
  55. long orig_r8_word;
  56. };
  57. };
  58. /* Callee saved registers - need to be saved only when you are scheduled out */
  59. struct callee_regs {
  60. long res; /* Again this is not needed */
  61. long r25;
  62. long r24;
  63. long r23;
  64. long r22;
  65. long r21;
  66. long r20;
  67. long r19;
  68. long r18;
  69. long r17;
  70. long r16;
  71. long r15;
  72. long r14;
  73. long r13;
  74. };
  75. #define instruction_pointer(regs) ((regs)->ret)
  76. #define profile_pc(regs) instruction_pointer(regs)
  77. /* return 1 if user mode or 0 if kernel mode */
  78. #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
  79. #define user_stack_pointer(regs)\
  80. ({ unsigned int sp; \
  81. if (user_mode(regs)) \
  82. sp = (regs)->sp;\
  83. else \
  84. sp = -1; \
  85. sp; \
  86. })
  87. #define in_syscall(regs) (regs->event & orig_r8_IS_SCALL)
  88. #define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)
  89. #define syscall_wont_restart(regs) (regs->event |= orig_r8_IS_SCALL_RESTARTED)
  90. #define syscall_restartable(regs) !(regs->event & orig_r8_IS_SCALL_RESTARTED)
  91. #define current_pt_regs() \
  92. ({ \
  93. /* open-coded current_thread_info() */ \
  94. register unsigned long sp asm ("sp"); \
  95. unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
  96. (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \
  97. })
  98. static inline long regs_return_value(struct pt_regs *regs)
  99. {
  100. return regs->r0;
  101. }
  102. #endif /* !__ASSEMBLY__ */
  103. #define orig_r8_IS_SCALL 0x0001
  104. #define orig_r8_IS_SCALL_RESTARTED 0x0002
  105. #define orig_r8_IS_BRKPT 0x0004
  106. #define orig_r8_IS_EXCPN 0x0004
  107. #define orig_r8_IS_IRQ1 0x0010
  108. #define orig_r8_IS_IRQ2 0x0020
  109. #endif /* __KERNEL__ */
  110. #ifndef __ASSEMBLY__
  111. /*
  112. * Userspace ABI: Register state needed by
  113. * -ptrace (gdbserver)
  114. * -sigcontext (SA_SIGNINFO signal frame)
  115. *
  116. * This is to decouple pt_regs from user-space ABI, to be able to change it
  117. * w/o affecting the ABI.
  118. * Although the layout (initial padding) is similar to pt_regs to have some
  119. * optimizations when copying pt_regs to/from user_regs_struct.
  120. *
  121. * Also, sigcontext only care about the scratch regs as that is what we really
  122. * save/restore for signal handling.
  123. */
  124. struct user_regs_struct {
  125. struct scratch {
  126. long pad;
  127. long bta, lp_start, lp_end, lp_count;
  128. long status32, ret, blink, fp, gp;
  129. long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
  130. long sp;
  131. } scratch;
  132. struct callee {
  133. long pad;
  134. long r25, r24, r23, r22, r21, r20;
  135. long r19, r18, r17, r16, r15, r14, r13;
  136. } callee;
  137. long efa; /* break pt addr, for break points in delay slots */
  138. long stop_pc; /* give dbg stop_pc directly after checking orig_r8 */
  139. };
  140. #endif /* !__ASSEMBLY__ */
  141. #endif /* __ASM_PTRACE_H */