gdb-stub.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* MN10300 Kernel GDB stub definitions
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. * - Derived from asm-mips/gdb-stub.h (c) 1995 Andreas Busse
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public Licence
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the Licence, or (at your option) any later version.
  11. */
  12. #ifndef _ASM_GDB_STUB_H
  13. #define _ASM_GDB_STUB_H
  14. #include <asm/exceptions.h>
  15. /*
  16. * register ID numbers in GDB remote protocol
  17. */
  18. #define GDB_REGID_PC 9
  19. #define GDB_REGID_FP 7
  20. #define GDB_REGID_SP 8
  21. /*
  22. * virtual stack layout for the GDB exception handler
  23. */
  24. #define NUMREGS 64
  25. #define GDB_FR_D0 (0 * 4)
  26. #define GDB_FR_D1 (1 * 4)
  27. #define GDB_FR_D2 (2 * 4)
  28. #define GDB_FR_D3 (3 * 4)
  29. #define GDB_FR_A0 (4 * 4)
  30. #define GDB_FR_A1 (5 * 4)
  31. #define GDB_FR_A2 (6 * 4)
  32. #define GDB_FR_A3 (7 * 4)
  33. #define GDB_FR_SP (8 * 4)
  34. #define GDB_FR_PC (9 * 4)
  35. #define GDB_FR_MDR (10 * 4)
  36. #define GDB_FR_EPSW (11 * 4)
  37. #define GDB_FR_LIR (12 * 4)
  38. #define GDB_FR_LAR (13 * 4)
  39. #define GDB_FR_MDRQ (14 * 4)
  40. #define GDB_FR_E0 (15 * 4)
  41. #define GDB_FR_E1 (16 * 4)
  42. #define GDB_FR_E2 (17 * 4)
  43. #define GDB_FR_E3 (18 * 4)
  44. #define GDB_FR_E4 (19 * 4)
  45. #define GDB_FR_E5 (20 * 4)
  46. #define GDB_FR_E6 (21 * 4)
  47. #define GDB_FR_E7 (22 * 4)
  48. #define GDB_FR_SSP (23 * 4)
  49. #define GDB_FR_MSP (24 * 4)
  50. #define GDB_FR_USP (25 * 4)
  51. #define GDB_FR_MCRH (26 * 4)
  52. #define GDB_FR_MCRL (27 * 4)
  53. #define GDB_FR_MCVF (28 * 4)
  54. #define GDB_FR_FPCR (29 * 4)
  55. #define GDB_FR_DUMMY0 (30 * 4)
  56. #define GDB_FR_DUMMY1 (31 * 4)
  57. #define GDB_FR_FS0 (32 * 4)
  58. #define GDB_FR_SIZE (NUMREGS * 4)
  59. #ifndef __ASSEMBLY__
  60. /*
  61. * This is the same as above, but for the high-level
  62. * part of the GDB stub.
  63. */
  64. struct gdb_regs {
  65. /* saved main processor registers */
  66. u32 d0, d1, d2, d3, a0, a1, a2, a3;
  67. u32 sp, pc, mdr, epsw, lir, lar, mdrq;
  68. u32 e0, e1, e2, e3, e4, e5, e6, e7;
  69. u32 ssp, msp, usp, mcrh, mcrl, mcvf;
  70. /* saved floating point registers */
  71. u32 fpcr, _dummy0, _dummy1;
  72. u32 fs0, fs1, fs2, fs3, fs4, fs5, fs6, fs7;
  73. u32 fs8, fs9, fs10, fs11, fs12, fs13, fs14, fs15;
  74. u32 fs16, fs17, fs18, fs19, fs20, fs21, fs22, fs23;
  75. u32 fs24, fs25, fs26, fs27, fs28, fs29, fs30, fs31;
  76. };
  77. /*
  78. * Prototypes
  79. */
  80. extern void show_registers_only(struct pt_regs *regs);
  81. extern asmlinkage void gdbstub_init(void);
  82. extern asmlinkage void gdbstub_exit(int status);
  83. extern asmlinkage void gdbstub_io_init(void);
  84. extern asmlinkage void gdbstub_io_set_baud(unsigned baud);
  85. extern asmlinkage int gdbstub_io_rx_char(unsigned char *_ch, int nonblock);
  86. extern asmlinkage void gdbstub_io_tx_char(unsigned char ch);
  87. extern asmlinkage void gdbstub_io_tx_flush(void);
  88. extern asmlinkage void gdbstub_io_rx_handler(void);
  89. extern asmlinkage void gdbstub_rx_irq(struct pt_regs *, enum exception_code);
  90. extern asmlinkage int gdbstub_intercept(struct pt_regs *, enum exception_code);
  91. extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
  92. extern asmlinkage void __gdbstub_bug_trap(void);
  93. extern asmlinkage void __gdbstub_pause(void);
  94. #ifdef CONFIG_MN10300_CACHE_ENABLED
  95. extern asmlinkage void gdbstub_purge_cache(void);
  96. #else
  97. #define gdbstub_purge_cache() do {} while (0)
  98. #endif
  99. /* Used to prevent crashes in memory access */
  100. extern asmlinkage int gdbstub_read_byte(const u8 *, u8 *);
  101. extern asmlinkage int gdbstub_read_word(const u8 *, u8 *);
  102. extern asmlinkage int gdbstub_read_dword(const u8 *, u8 *);
  103. extern asmlinkage int gdbstub_write_byte(u32, u8 *);
  104. extern asmlinkage int gdbstub_write_word(u32, u8 *);
  105. extern asmlinkage int gdbstub_write_dword(u32, u8 *);
  106. extern asmlinkage void gdbstub_read_byte_guard(void);
  107. extern asmlinkage void gdbstub_read_byte_cont(void);
  108. extern asmlinkage void gdbstub_read_word_guard(void);
  109. extern asmlinkage void gdbstub_read_word_cont(void);
  110. extern asmlinkage void gdbstub_read_dword_guard(void);
  111. extern asmlinkage void gdbstub_read_dword_cont(void);
  112. extern asmlinkage void gdbstub_write_byte_guard(void);
  113. extern asmlinkage void gdbstub_write_byte_cont(void);
  114. extern asmlinkage void gdbstub_write_word_guard(void);
  115. extern asmlinkage void gdbstub_write_word_cont(void);
  116. extern asmlinkage void gdbstub_write_dword_guard(void);
  117. extern asmlinkage void gdbstub_write_dword_cont(void);
  118. extern u8 gdbstub_rx_buffer[PAGE_SIZE];
  119. extern u32 gdbstub_rx_inp;
  120. extern u32 gdbstub_rx_outp;
  121. extern u8 gdbstub_rx_overflow;
  122. extern u8 gdbstub_busy;
  123. extern u8 gdbstub_rx_unget;
  124. #ifdef CONFIG_GDBSTUB_DEBUGGING
  125. extern void gdbstub_printk(const char *fmt, ...)
  126. __attribute__((format(printf, 1, 2)));
  127. #else
  128. static inline __attribute__((format(printf, 1, 2)))
  129. void gdbstub_printk(const char *fmt, ...)
  130. {
  131. }
  132. #endif
  133. #ifdef CONFIG_GDBSTUB_DEBUG_ENTRY
  134. #define gdbstub_entry(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
  135. #else
  136. #define gdbstub_entry(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
  137. #endif
  138. #ifdef CONFIG_GDBSTUB_DEBUG_PROTOCOL
  139. #define gdbstub_proto(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
  140. #else
  141. #define gdbstub_proto(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
  142. #endif
  143. #ifdef CONFIG_GDBSTUB_DEBUG_IO
  144. #define gdbstub_io(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
  145. #else
  146. #define gdbstub_io(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
  147. #endif
  148. #ifdef CONFIG_GDBSTUB_DEBUG_BREAKPOINT
  149. #define gdbstub_bkpt(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
  150. #else
  151. #define gdbstub_bkpt(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
  152. #endif
  153. #endif /* !__ASSEMBLY__ */
  154. #endif /* _ASM_GDB_STUB_H */