gdb-stub.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1995 Andreas Busse
  7. * Copyright (C) 2003 Ralf Baechle
  8. */
  9. #ifndef _ASM_GDB_STUB_H
  10. #define _ASM_GDB_STUB_H
  11. /*
  12. * important register numbers
  13. */
  14. #define REG_EPC 37
  15. #define REG_FP 72
  16. #define REG_SP 29
  17. /*
  18. * Stack layout for the GDB exception handler
  19. * Derived from the stack layout described in asm-mips/stackframe.h
  20. *
  21. * The first PTRSIZE*6 bytes are argument save space for C subroutines.
  22. */
  23. #define NUMREGS 90
  24. #define GDB_FR_REG0 (PTRSIZE*6) /* 0 */
  25. #define GDB_FR_REG1 ((GDB_FR_REG0) + LONGSIZE) /* 1 */
  26. #define GDB_FR_REG2 ((GDB_FR_REG1) + LONGSIZE) /* 2 */
  27. #define GDB_FR_REG3 ((GDB_FR_REG2) + LONGSIZE) /* 3 */
  28. #define GDB_FR_REG4 ((GDB_FR_REG3) + LONGSIZE) /* 4 */
  29. #define GDB_FR_REG5 ((GDB_FR_REG4) + LONGSIZE) /* 5 */
  30. #define GDB_FR_REG6 ((GDB_FR_REG5) + LONGSIZE) /* 6 */
  31. #define GDB_FR_REG7 ((GDB_FR_REG6) + LONGSIZE) /* 7 */
  32. #define GDB_FR_REG8 ((GDB_FR_REG7) + LONGSIZE) /* 8 */
  33. #define GDB_FR_REG9 ((GDB_FR_REG8) + LONGSIZE) /* 9 */
  34. #define GDB_FR_REG10 ((GDB_FR_REG9) + LONGSIZE) /* 10 */
  35. #define GDB_FR_REG11 ((GDB_FR_REG10) + LONGSIZE) /* 11 */
  36. #define GDB_FR_REG12 ((GDB_FR_REG11) + LONGSIZE) /* 12 */
  37. #define GDB_FR_REG13 ((GDB_FR_REG12) + LONGSIZE) /* 13 */
  38. #define GDB_FR_REG14 ((GDB_FR_REG13) + LONGSIZE) /* 14 */
  39. #define GDB_FR_REG15 ((GDB_FR_REG14) + LONGSIZE) /* 15 */
  40. #define GDB_FR_REG16 ((GDB_FR_REG15) + LONGSIZE) /* 16 */
  41. #define GDB_FR_REG17 ((GDB_FR_REG16) + LONGSIZE) /* 17 */
  42. #define GDB_FR_REG18 ((GDB_FR_REG17) + LONGSIZE) /* 18 */
  43. #define GDB_FR_REG19 ((GDB_FR_REG18) + LONGSIZE) /* 19 */
  44. #define GDB_FR_REG20 ((GDB_FR_REG19) + LONGSIZE) /* 20 */
  45. #define GDB_FR_REG21 ((GDB_FR_REG20) + LONGSIZE) /* 21 */
  46. #define GDB_FR_REG22 ((GDB_FR_REG21) + LONGSIZE) /* 22 */
  47. #define GDB_FR_REG23 ((GDB_FR_REG22) + LONGSIZE) /* 23 */
  48. #define GDB_FR_REG24 ((GDB_FR_REG23) + LONGSIZE) /* 24 */
  49. #define GDB_FR_REG25 ((GDB_FR_REG24) + LONGSIZE) /* 25 */
  50. #define GDB_FR_REG26 ((GDB_FR_REG25) + LONGSIZE) /* 26 */
  51. #define GDB_FR_REG27 ((GDB_FR_REG26) + LONGSIZE) /* 27 */
  52. #define GDB_FR_REG28 ((GDB_FR_REG27) + LONGSIZE) /* 28 */
  53. #define GDB_FR_REG29 ((GDB_FR_REG28) + LONGSIZE) /* 29 */
  54. #define GDB_FR_REG30 ((GDB_FR_REG29) + LONGSIZE) /* 30 */
  55. #define GDB_FR_REG31 ((GDB_FR_REG30) + LONGSIZE) /* 31 */
  56. /*
  57. * Saved special registers
  58. */
  59. #define GDB_FR_STATUS ((GDB_FR_REG31) + LONGSIZE) /* 32 */
  60. #define GDB_FR_LO ((GDB_FR_STATUS) + LONGSIZE) /* 33 */
  61. #define GDB_FR_HI ((GDB_FR_LO) + LONGSIZE) /* 34 */
  62. #define GDB_FR_BADVADDR ((GDB_FR_HI) + LONGSIZE) /* 35 */
  63. #define GDB_FR_CAUSE ((GDB_FR_BADVADDR) + LONGSIZE) /* 36 */
  64. #define GDB_FR_EPC ((GDB_FR_CAUSE) + LONGSIZE) /* 37 */
  65. /*
  66. * Saved floating point registers
  67. */
  68. #define GDB_FR_FPR0 ((GDB_FR_EPC) + LONGSIZE) /* 38 */
  69. #define GDB_FR_FPR1 ((GDB_FR_FPR0) + LONGSIZE) /* 39 */
  70. #define GDB_FR_FPR2 ((GDB_FR_FPR1) + LONGSIZE) /* 40 */
  71. #define GDB_FR_FPR3 ((GDB_FR_FPR2) + LONGSIZE) /* 41 */
  72. #define GDB_FR_FPR4 ((GDB_FR_FPR3) + LONGSIZE) /* 42 */
  73. #define GDB_FR_FPR5 ((GDB_FR_FPR4) + LONGSIZE) /* 43 */
  74. #define GDB_FR_FPR6 ((GDB_FR_FPR5) + LONGSIZE) /* 44 */
  75. #define GDB_FR_FPR7 ((GDB_FR_FPR6) + LONGSIZE) /* 45 */
  76. #define GDB_FR_FPR8 ((GDB_FR_FPR7) + LONGSIZE) /* 46 */
  77. #define GDB_FR_FPR9 ((GDB_FR_FPR8) + LONGSIZE) /* 47 */
  78. #define GDB_FR_FPR10 ((GDB_FR_FPR9) + LONGSIZE) /* 48 */
  79. #define GDB_FR_FPR11 ((GDB_FR_FPR10) + LONGSIZE) /* 49 */
  80. #define GDB_FR_FPR12 ((GDB_FR_FPR11) + LONGSIZE) /* 50 */
  81. #define GDB_FR_FPR13 ((GDB_FR_FPR12) + LONGSIZE) /* 51 */
  82. #define GDB_FR_FPR14 ((GDB_FR_FPR13) + LONGSIZE) /* 52 */
  83. #define GDB_FR_FPR15 ((GDB_FR_FPR14) + LONGSIZE) /* 53 */
  84. #define GDB_FR_FPR16 ((GDB_FR_FPR15) + LONGSIZE) /* 54 */
  85. #define GDB_FR_FPR17 ((GDB_FR_FPR16) + LONGSIZE) /* 55 */
  86. #define GDB_FR_FPR18 ((GDB_FR_FPR17) + LONGSIZE) /* 56 */
  87. #define GDB_FR_FPR19 ((GDB_FR_FPR18) + LONGSIZE) /* 57 */
  88. #define GDB_FR_FPR20 ((GDB_FR_FPR19) + LONGSIZE) /* 58 */
  89. #define GDB_FR_FPR21 ((GDB_FR_FPR20) + LONGSIZE) /* 59 */
  90. #define GDB_FR_FPR22 ((GDB_FR_FPR21) + LONGSIZE) /* 60 */
  91. #define GDB_FR_FPR23 ((GDB_FR_FPR22) + LONGSIZE) /* 61 */
  92. #define GDB_FR_FPR24 ((GDB_FR_FPR23) + LONGSIZE) /* 62 */
  93. #define GDB_FR_FPR25 ((GDB_FR_FPR24) + LONGSIZE) /* 63 */
  94. #define GDB_FR_FPR26 ((GDB_FR_FPR25) + LONGSIZE) /* 64 */
  95. #define GDB_FR_FPR27 ((GDB_FR_FPR26) + LONGSIZE) /* 65 */
  96. #define GDB_FR_FPR28 ((GDB_FR_FPR27) + LONGSIZE) /* 66 */
  97. #define GDB_FR_FPR29 ((GDB_FR_FPR28) + LONGSIZE) /* 67 */
  98. #define GDB_FR_FPR30 ((GDB_FR_FPR29) + LONGSIZE) /* 68 */
  99. #define GDB_FR_FPR31 ((GDB_FR_FPR30) + LONGSIZE) /* 69 */
  100. #define GDB_FR_FSR ((GDB_FR_FPR31) + LONGSIZE) /* 70 */
  101. #define GDB_FR_FIR ((GDB_FR_FSR) + LONGSIZE) /* 71 */
  102. #define GDB_FR_FRP ((GDB_FR_FIR) + LONGSIZE) /* 72 */
  103. #define GDB_FR_DUMMY ((GDB_FR_FRP) + LONGSIZE) /* 73, unused ??? */
  104. /*
  105. * Again, CP0 registers
  106. */
  107. #define GDB_FR_CP0_INDEX ((GDB_FR_DUMMY) + LONGSIZE) /* 74 */
  108. #define GDB_FR_CP0_RANDOM ((GDB_FR_CP0_INDEX) + LONGSIZE) /* 75 */
  109. #define GDB_FR_CP0_ENTRYLO0 ((GDB_FR_CP0_RANDOM) + LONGSIZE)/* 76 */
  110. #define GDB_FR_CP0_ENTRYLO1 ((GDB_FR_CP0_ENTRYLO0) + LONGSIZE)/* 77 */
  111. #define GDB_FR_CP0_CONTEXT ((GDB_FR_CP0_ENTRYLO1) + LONGSIZE)/* 78 */
  112. #define GDB_FR_CP0_PAGEMASK ((GDB_FR_CP0_CONTEXT) + LONGSIZE)/* 79 */
  113. #define GDB_FR_CP0_WIRED ((GDB_FR_CP0_PAGEMASK) + LONGSIZE)/* 80 */
  114. #define GDB_FR_CP0_REG7 ((GDB_FR_CP0_WIRED) + LONGSIZE) /* 81 */
  115. #define GDB_FR_CP0_REG8 ((GDB_FR_CP0_REG7) + LONGSIZE) /* 82 */
  116. #define GDB_FR_CP0_REG9 ((GDB_FR_CP0_REG8) + LONGSIZE) /* 83 */
  117. #define GDB_FR_CP0_ENTRYHI ((GDB_FR_CP0_REG9) + LONGSIZE) /* 84 */
  118. #define GDB_FR_CP0_REG11 ((GDB_FR_CP0_ENTRYHI) + LONGSIZE)/* 85 */
  119. #define GDB_FR_CP0_REG12 ((GDB_FR_CP0_REG11) + LONGSIZE) /* 86 */
  120. #define GDB_FR_CP0_REG13 ((GDB_FR_CP0_REG12) + LONGSIZE) /* 87 */
  121. #define GDB_FR_CP0_REG14 ((GDB_FR_CP0_REG13) + LONGSIZE) /* 88 */
  122. #define GDB_FR_CP0_PRID ((GDB_FR_CP0_REG14) + LONGSIZE) /* 89 */
  123. #define GDB_FR_SIZE ((((GDB_FR_CP0_PRID) + LONGSIZE) + (PTRSIZE-1)) & ~(PTRSIZE-1))
  124. #ifndef __ASSEMBLY__
  125. /*
  126. * This is the same as above, but for the high-level
  127. * part of the GDB stub.
  128. */
  129. struct gdb_regs {
  130. /*
  131. * Pad bytes for argument save space on the stack
  132. * 24/48 Bytes for 32/64 bit code
  133. */
  134. unsigned long pad0[6];
  135. /*
  136. * saved main processor registers
  137. */
  138. long reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7;
  139. long reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15;
  140. long reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23;
  141. long reg24, reg25, reg26, reg27, reg28, reg29, reg30, reg31;
  142. /*
  143. * Saved special registers
  144. */
  145. long cp0_status;
  146. long lo;
  147. long hi;
  148. long cp0_badvaddr;
  149. long cp0_cause;
  150. long cp0_epc;
  151. /*
  152. * Saved floating point registers
  153. */
  154. long fpr0, fpr1, fpr2, fpr3, fpr4, fpr5, fpr6, fpr7;
  155. long fpr8, fpr9, fpr10, fpr11, fpr12, fpr13, fpr14, fpr15;
  156. long fpr16, fpr17, fpr18, fpr19, fpr20, fpr21, fpr22, fpr23;
  157. long fpr24, fpr25, fpr26, fpr27, fpr28, fpr29, fpr30, fpr31;
  158. long cp1_fsr;
  159. long cp1_fir;
  160. /*
  161. * Frame pointer
  162. */
  163. long frame_ptr;
  164. long dummy; /* unused */
  165. /*
  166. * saved cp0 registers
  167. */
  168. long cp0_index;
  169. long cp0_random;
  170. long cp0_entrylo0;
  171. long cp0_entrylo1;
  172. long cp0_context;
  173. long cp0_pagemask;
  174. long cp0_wired;
  175. long cp0_reg7;
  176. long cp0_reg8;
  177. long cp0_reg9;
  178. long cp0_entryhi;
  179. long cp0_reg11;
  180. long cp0_reg12;
  181. long cp0_reg13;
  182. long cp0_reg14;
  183. long cp0_prid;
  184. };
  185. /*
  186. * Prototypes
  187. */
  188. extern int kgdb_enabled;
  189. void set_debug_traps(void);
  190. void set_async_breakpoint(unsigned long *epc);
  191. #endif /* !__ASSEMBLY__ */
  192. #endif /* _ASM_GDB_STUB_H */