Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * May be copied or modified under the terms of the GNU General Public |
| 3 | * License. See linux/COPYING for more information. |
| 4 | * |
| 5 | * Based on original code by Glenn Engel, Jim Kingdon, |
| 6 | * David Grothe <dave@gcom.com>, Tigran Aivazian, <tigran@sco.com> and |
| 7 | * Amit S. Kale <akale@veritas.com> |
| 8 | * |
| 9 | * Super-H port based on sh-stub.c (Ben Lee and Steve Chamberlain) by |
| 10 | * Henry Bell <henry.bell@st.com> |
| 11 | * |
| 12 | * Header file for low-level support for remote debug using GDB. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #ifndef __KGDB_H |
| 17 | #define __KGDB_H |
| 18 | |
| 19 | #include <asm/ptrace.h> |
Paul Mundt | fa5da2f | 2007-03-08 17:27:37 +0900 | [diff] [blame] | 20 | #include <asm/cacheflush.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | struct console; |
| 23 | |
| 24 | /* Same as pt_regs but has vbr in place of syscall_nr */ |
| 25 | struct kgdb_regs { |
| 26 | unsigned long regs[16]; |
| 27 | unsigned long pc; |
| 28 | unsigned long pr; |
| 29 | unsigned long sr; |
| 30 | unsigned long gbr; |
| 31 | unsigned long mach; |
| 32 | unsigned long macl; |
| 33 | unsigned long vbr; |
| 34 | }; |
| 35 | |
| 36 | /* State info */ |
| 37 | extern char kgdb_in_gdb_mode; |
| 38 | extern int kgdb_done_init; |
| 39 | extern int kgdb_enabled; |
| 40 | extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */ |
| 41 | extern int kgdb_halt; /* Execute initial breakpoint at startup */ |
| 42 | extern char in_nmi; /* Debounce flag to prevent NMI reentry*/ |
| 43 | |
| 44 | /* SCI */ |
| 45 | extern int kgdb_portnum; |
| 46 | extern int kgdb_baud; |
| 47 | extern char kgdb_parity; |
| 48 | extern char kgdb_bits; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /* Init and interface stuff */ |
| 51 | extern int kgdb_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | extern int (*kgdb_getchar)(void); |
| 53 | extern void (*kgdb_putchar)(int); |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | /* Trap functions */ |
Paul Mundt | fa5da2f | 2007-03-08 17:27:37 +0900 | [diff] [blame] | 56 | typedef void (kgdb_debug_hook_t)(struct pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | typedef void (kgdb_bus_error_hook_t)(void); |
| 58 | extern kgdb_debug_hook_t *kgdb_debug_hook; |
| 59 | extern kgdb_bus_error_hook_t *kgdb_bus_err_hook; |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | /* Console */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | void kgdb_console_write(struct console *co, const char *s, unsigned count); |
Paul Mundt | fa5da2f | 2007-03-08 17:27:37 +0900 | [diff] [blame] | 63 | extern int kgdb_console_setup(struct console *, char *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | /* Prototypes for jmp fns */ |
| 66 | #define _JBLEN 9 |
| 67 | typedef int jmp_buf[_JBLEN]; |
| 68 | extern void longjmp(jmp_buf __jmpb, int __retval); |
| 69 | extern int setjmp(jmp_buf __jmpb); |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | /* Forced breakpoint */ |
Paul Mundt | fa5da2f | 2007-03-08 17:27:37 +0900 | [diff] [blame] | 72 | #define breakpoint() \ |
Paul Mundt | f413d0d | 2006-12-13 17:40:05 +0900 | [diff] [blame] | 73 | do { \ |
| 74 | if (kgdb_enabled) \ |
| 75 | __asm__ __volatile__("trapa #0x3c"); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } while (0) |
| 77 | |
| 78 | /* KGDB should be able to flush all kernel text space */ |
| 79 | #if defined(CONFIG_CPU_SH4) |
| 80 | #define kgdb_flush_icache_range(start, end) \ |
| 81 | { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | __flush_purge_region((void*)(start), (int)(end) - (int)(start));\ |
| 83 | flush_icache_range((start), (end)); \ |
| 84 | } |
| 85 | #else |
| 86 | #define kgdb_flush_icache_range(start, end) do { } while (0) |
| 87 | #endif |
| 88 | |
Paul Mundt | 56e8d7b | 2006-09-27 16:24:55 +0900 | [diff] [blame] | 89 | /* Taken from sh-stub.c of GDB 4.18 */ |
| 90 | static const char hexchars[] = "0123456789abcdef"; |
| 91 | |
| 92 | /* Get high hex bits */ |
| 93 | static inline char highhex(const int x) |
| 94 | { |
| 95 | return hexchars[(x >> 4) & 0xf]; |
| 96 | } |
| 97 | |
| 98 | /* Get low hex bits */ |
| 99 | static inline char lowhex(const int x) |
| 100 | { |
| 101 | return hexchars[x & 0xf]; |
| 102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | #endif |