blob: 4bc8cb187d119a8d66bff3995b9f7add0d79e09d [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>
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/* Same as pt_regs but has vbr in place of syscall_nr */
22struct kgdb_regs {
23 unsigned long regs[16];
24 unsigned long pc;
25 unsigned long pr;
26 unsigned long sr;
27 unsigned long gbr;
28 unsigned long mach;
29 unsigned long macl;
30 unsigned long vbr;
31};
32
33/* State info */
34extern char kgdb_in_gdb_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036extern char in_nmi; /* Debounce flag to prevent NMI reentry*/
37
38/* SCI */
39extern int kgdb_portnum;
40extern int kgdb_baud;
41extern char kgdb_parity;
42extern char kgdb_bits;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44/* Init and interface stuff */
45extern int kgdb_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046extern int (*kgdb_getchar)(void);
47extern void (*kgdb_putchar)(int);
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049/* Trap functions */
Paul Mundtfa5da2f2007-03-08 17:27:37 +090050typedef void (kgdb_debug_hook_t)(struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051typedef void (kgdb_bus_error_hook_t)(void);
52extern kgdb_debug_hook_t *kgdb_debug_hook;
53extern kgdb_bus_error_hook_t *kgdb_bus_err_hook;
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055/* Console */
Paul Mundta90f3542007-10-03 17:13:34 +090056struct console;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057void kgdb_console_write(struct console *co, const char *s, unsigned count);
Paul Mundtfa5da2f2007-03-08 17:27:37 +090058extern int kgdb_console_setup(struct console *, char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60/* Prototypes for jmp fns */
61#define _JBLEN 9
62typedef int jmp_buf[_JBLEN];
63extern void longjmp(jmp_buf __jmpb, int __retval);
64extern int setjmp(jmp_buf __jmpb);
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066/* Forced breakpoint */
Paul Mundta90f3542007-10-03 17:13:34 +090067#define breakpoint() __asm__ __volatile__("trapa #0x3c")
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Paul Mundt56e8d7b2006-09-27 16:24:55 +090069/* Taken from sh-stub.c of GDB 4.18 */
70static const char hexchars[] = "0123456789abcdef";
71
72/* Get high hex bits */
73static inline char highhex(const int x)
74{
75 return hexchars[(x >> 4) & 0xf];
76}
77
78/* Get low hex bits */
79static inline char lowhex(const int x)
80{
81 return hexchars[x & 0xf];
82}
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#endif