Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gdb-stub.h
Go to the documentation of this file.
1 /* MN10300 Kernel GDB stub definitions
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells ([email protected])
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 
15 #include <asm/exceptions.h>
16 
17 /*
18  * register ID numbers in GDB remote protocol
19  */
20 
21 #define GDB_REGID_PC 9
22 #define GDB_REGID_FP 7
23 #define GDB_REGID_SP 8
24 
25 /*
26  * virtual stack layout for the GDB exception handler
27  */
28 #define NUMREGS 64
29 
30 #define GDB_FR_D0 (0 * 4)
31 #define GDB_FR_D1 (1 * 4)
32 #define GDB_FR_D2 (2 * 4)
33 #define GDB_FR_D3 (3 * 4)
34 #define GDB_FR_A0 (4 * 4)
35 #define GDB_FR_A1 (5 * 4)
36 #define GDB_FR_A2 (6 * 4)
37 #define GDB_FR_A3 (7 * 4)
38 
39 #define GDB_FR_SP (8 * 4)
40 #define GDB_FR_PC (9 * 4)
41 #define GDB_FR_MDR (10 * 4)
42 #define GDB_FR_EPSW (11 * 4)
43 #define GDB_FR_LIR (12 * 4)
44 #define GDB_FR_LAR (13 * 4)
45 #define GDB_FR_MDRQ (14 * 4)
46 
47 #define GDB_FR_E0 (15 * 4)
48 #define GDB_FR_E1 (16 * 4)
49 #define GDB_FR_E2 (17 * 4)
50 #define GDB_FR_E3 (18 * 4)
51 #define GDB_FR_E4 (19 * 4)
52 #define GDB_FR_E5 (20 * 4)
53 #define GDB_FR_E6 (21 * 4)
54 #define GDB_FR_E7 (22 * 4)
55 
56 #define GDB_FR_SSP (23 * 4)
57 #define GDB_FR_MSP (24 * 4)
58 #define GDB_FR_USP (25 * 4)
59 #define GDB_FR_MCRH (26 * 4)
60 #define GDB_FR_MCRL (27 * 4)
61 #define GDB_FR_MCVF (28 * 4)
62 
63 #define GDB_FR_FPCR (29 * 4)
64 #define GDB_FR_DUMMY0 (30 * 4)
65 #define GDB_FR_DUMMY1 (31 * 4)
66 
67 #define GDB_FR_FS0 (32 * 4)
68 
69 #define GDB_FR_SIZE (NUMREGS * 4)
70 
71 #ifndef __ASSEMBLY__
72 
73 /*
74  * This is the same as above, but for the high-level
75  * part of the GDB stub.
76  */
77 
78 struct gdb_regs {
79  /* saved main processor registers */
80  u32 d0, d1, d2, d3, a0, a1, a2, a3;
82  u32 e0, e1, e2, e3, e4, e5, e6, e7;
84 
85  /* saved floating point registers */
91 };
92 
93 /*
94  * Prototypes
95  */
96 extern void show_registers_only(struct pt_regs *regs);
97 
98 extern asmlinkage void gdbstub_init(void);
99 extern asmlinkage void gdbstub_exit(int status);
100 extern asmlinkage void gdbstub_io_init(void);
101 extern asmlinkage void gdbstub_io_set_baud(unsigned baud);
102 extern asmlinkage int gdbstub_io_rx_char(unsigned char *_ch, int nonblock);
103 extern asmlinkage void gdbstub_io_tx_char(unsigned char ch);
104 extern asmlinkage void gdbstub_io_tx_flush(void);
105 
106 extern asmlinkage void gdbstub_io_rx_handler(void);
107 extern asmlinkage void gdbstub_rx_irq(struct pt_regs *, enum exception_code);
108 extern asmlinkage int gdbstub_intercept(struct pt_regs *, enum exception_code);
109 extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
110 extern asmlinkage void __gdbstub_bug_trap(void);
111 extern asmlinkage void __gdbstub_pause(void);
112 
113 #ifdef CONFIG_MN10300_CACHE_ENABLED
114 extern asmlinkage void gdbstub_purge_cache(void);
115 #else
116 #define gdbstub_purge_cache() do {} while (0)
117 #endif
118 
119 /* Used to prevent crashes in memory access */
120 extern asmlinkage int gdbstub_read_byte(const u8 *, u8 *);
121 extern asmlinkage int gdbstub_read_word(const u8 *, u8 *);
122 extern asmlinkage int gdbstub_read_dword(const u8 *, u8 *);
123 extern asmlinkage int gdbstub_write_byte(u32, u8 *);
124 extern asmlinkage int gdbstub_write_word(u32, u8 *);
125 extern asmlinkage int gdbstub_write_dword(u32, u8 *);
126 
127 extern asmlinkage void gdbstub_read_byte_guard(void);
128 extern asmlinkage void gdbstub_read_byte_cont(void);
129 extern asmlinkage void gdbstub_read_word_guard(void);
130 extern asmlinkage void gdbstub_read_word_cont(void);
131 extern asmlinkage void gdbstub_read_dword_guard(void);
132 extern asmlinkage void gdbstub_read_dword_cont(void);
133 extern asmlinkage void gdbstub_write_byte_guard(void);
134 extern asmlinkage void gdbstub_write_byte_cont(void);
135 extern asmlinkage void gdbstub_write_word_guard(void);
136 extern asmlinkage void gdbstub_write_word_cont(void);
137 extern asmlinkage void gdbstub_write_dword_guard(void);
138 extern asmlinkage void gdbstub_write_dword_cont(void);
139 
141 extern u32 gdbstub_rx_inp;
142 extern u32 gdbstub_rx_outp;
143 extern u8 gdbstub_rx_overflow;
144 extern u8 gdbstub_busy;
145 extern u8 gdbstub_rx_unget;
146 
147 #ifdef CONFIG_GDBSTUB_DEBUGGING
148 extern void gdbstub_printk(const char *fmt, ...)
149  __attribute__((format(printf, 1, 2)));
150 #else
151 static inline __attribute__((format(printf, 1, 2)))
152 void gdbstub_printk(const char *fmt, ...)
153 {
154 }
155 #endif
156 
157 #ifdef CONFIG_GDBSTUB_DEBUG_ENTRY
158 #define gdbstub_entry(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
159 #else
160 #define gdbstub_entry(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
161 #endif
162 
163 #ifdef CONFIG_GDBSTUB_DEBUG_PROTOCOL
164 #define gdbstub_proto(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
165 #else
166 #define gdbstub_proto(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
167 #endif
168 
169 #ifdef CONFIG_GDBSTUB_DEBUG_IO
170 #define gdbstub_io(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
171 #else
172 #define gdbstub_io(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
173 #endif
174 
175 #ifdef CONFIG_GDBSTUB_DEBUG_BREAKPOINT
176 #define gdbstub_bkpt(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
177 #else
178 #define gdbstub_bkpt(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
179 #endif
180 
181 #endif /* !__ASSEMBLY__ */
182 #endif /* _ASM_GDB_STUB_H */