blob: 5334e86ccad670cc36f7d6870493375aeb3aa479 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Mundtfa5da2f2007-03-08 17:27:37 +090020#include <asm/cacheflush.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/* Same as pt_regs but has vbr in place of syscall_nr */
23struct kgdb_regs {
24 unsigned long regs[16];
25 unsigned long pc;
26 unsigned long pr;
27 unsigned long sr;
28 unsigned long gbr;
29 unsigned long mach;
30 unsigned long macl;
31 unsigned long vbr;
32};
33
34/* State info */
35extern char kgdb_in_gdb_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037extern char in_nmi; /* Debounce flag to prevent NMI reentry*/
38
39/* SCI */
40extern int kgdb_portnum;
41extern int kgdb_baud;
42extern char kgdb_parity;
43extern char kgdb_bits;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45/* Init and interface stuff */
46extern int kgdb_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern int (*kgdb_getchar)(void);
48extern void (*kgdb_putchar)(int);
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050/* Trap functions */
Paul Mundtfa5da2f2007-03-08 17:27:37 +090051typedef void (kgdb_debug_hook_t)(struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052typedef void (kgdb_bus_error_hook_t)(void);
53extern kgdb_debug_hook_t *kgdb_debug_hook;
54extern kgdb_bus_error_hook_t *kgdb_bus_err_hook;
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* Console */
Paul Mundta90f3542007-10-03 17:13:34 +090057struct console;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058void kgdb_console_write(struct console *co, const char *s, unsigned count);
Paul Mundtfa5da2f2007-03-08 17:27:37 +090059extern int kgdb_console_setup(struct console *, char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61/* Prototypes for jmp fns */
62#define _JBLEN 9
63typedef int jmp_buf[_JBLEN];
64extern void longjmp(jmp_buf __jmpb, int __retval);
65extern int setjmp(jmp_buf __jmpb);
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* Forced breakpoint */
Paul Mundta90f3542007-10-03 17:13:34 +090068#define breakpoint() __asm__ __volatile__("trapa #0x3c")
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70/* KGDB should be able to flush all kernel text space */
71#if defined(CONFIG_CPU_SH4)
72#define kgdb_flush_icache_range(start, end) \
73{ \
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 __flush_purge_region((void*)(start), (int)(end) - (int)(start));\
75 flush_icache_range((start), (end)); \
76}
77#else
78#define kgdb_flush_icache_range(start, end) do { } while (0)
79#endif
80
Paul Mundt56e8d7b2006-09-27 16:24:55 +090081/* Taken from sh-stub.c of GDB 4.18 */
82static const char hexchars[] = "0123456789abcdef";
83
84/* Get high hex bits */
85static inline char highhex(const int x)
86{
87 return hexchars[(x >> 4) & 0xf];
88}
89
90/* Get low hex bits */
91static inline char lowhex(const int x)
92{
93 return hexchars[x & 0xf];
94}
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#endif