summaryrefslogtreecommitdiffstats
path: root/arch/mn10300/include/asm/gdb-stub.h
blob: f5495ad82b77bc753b218b3a3498ea089e511134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* MN10300 Kernel GDB stub definitions
 *
 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 * - Derived from asm-mips/gdb-stub.h (c) 1995 Andreas Busse
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public Licence
 * as published by the Free Software Foundation; either version
 * 2 of the Licence, or (at your option) any later version.
 */
#ifndef _ASM_GDB_STUB_H
#define _ASM_GDB_STUB_H

#include <asm/exceptions.h>

/*
 * register ID numbers in GDB remote protocol
 */

#define GDB_REGID_PC		9
#define GDB_REGID_FP		7
#define GDB_REGID_SP		8

/*
 * virtual stack layout for the GDB exception handler
 */
#define NUMREGS			64

#define GDB_FR_D0		(0 * 4)
#define GDB_FR_D1		(1 * 4)
#define GDB_FR_D2		(2 * 4)
#define GDB_FR_D3		(3 * 4)
#define GDB_FR_A0		(4 * 4)
#define GDB_FR_A1		(5 * 4)
#define GDB_FR_A2		(6 * 4)
#define GDB_FR_A3		(7 * 4)

#define GDB_FR_SP		(8 * 4)
#define GDB_FR_PC		(9 * 4)
#define GDB_FR_MDR		(10 * 4)
#define GDB_FR_EPSW		(11 * 4)
#define GDB_FR_LIR		(12 * 4)
#define GDB_FR_LAR		(13 * 4)
#define GDB_FR_MDRQ		(14 * 4)

#define GDB_FR_E0		(15 * 4)
#define GDB_FR_E1		(16 * 4)
#define GDB_FR_E2		(17 * 4)
#define GDB_FR_E3		(18 * 4)
#define GDB_FR_E4		(19 * 4)
#define GDB_FR_E5		(20 * 4)
#define GDB_FR_E6		(21 * 4)
#define GDB_FR_E7		(22 * 4)

#define GDB_FR_SSP		(23 * 4)
#define GDB_FR_MSP		(24 * 4)
#define GDB_FR_USP		(25 * 4)
#define GDB_FR_MCRH		(26 * 4)
#define GDB_FR_MCRL		(27 * 4)
#define GDB_FR_MCVF		(28 * 4)

#define GDB_FR_FPCR		(29 * 4)
#define GDB_FR_DUMMY0		(30 * 4)
#define GDB_FR_DUMMY1		(31 * 4)

#define GDB_FR_FS0		(32 * 4)

#define GDB_FR_SIZE		(NUMREGS * 4)

#ifndef __ASSEMBLY__

/*
 * This is the same as above, but for the high-level
 * part of the GDB stub.
 */

struct gdb_regs {
	/* saved main processor registers */
	u32	d0, d1, d2, d3, a0, a1, a2, a3;
	u32	sp, pc, mdr, epsw, lir, lar, mdrq;
	u32	e0, e1, e2, e3, e4, e5, e6, e7;
	u32	ssp, msp, usp, mcrh, mcrl, mcvf;

	/* saved floating point registers */
	u32	fpcr, _dummy0, _dummy1;
	u32	fs0,  fs1,  fs2,  fs3,  fs4,  fs5,  fs6,  fs7;
	u32	fs8,  fs9,  fs10, fs11, fs12, fs13, fs14, fs15;
	u32	fs16, fs17, fs18, fs19, fs20, fs21, fs22, fs23;
	u32	fs24, fs25, fs26, fs27, fs28, fs29, fs30, fs31;
};

/*
 * Prototypes
 */
extern void show_registers_only(struct pt_regs *regs);

extern asmlinkage void gdbstub_init(void);
extern asmlinkage void gdbstub_exit(int status);
extern asmlinkage void gdbstub_io_init(void);
extern asmlinkage void gdbstub_io_set_baud(unsigned baud);
extern asmlinkage int  gdbstub_io_rx_char(unsigned char *_ch, int nonblock);
extern asmlinkage void gdbstub_io_tx_char(unsigned char ch);
extern asmlinkage void gdbstub_io_tx_flush(void);

extern asmlinkage void gdbstub_io_rx_handler(void);
extern asmlinkage void gdbstub_rx_irq(struct pt_regs *, enum exception_code);
extern asmlinkage int  gdbstub_intercept(struct pt_regs *, enum exception_code);
extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
extern asmlinkage void __gdbstub_bug_trap(void);
extern asmlinkage void __gdbstub_pause(void);

#ifdef CONFIG_MN10300_CACHE_ENABLED
extern asmlinkage void gdbstub_purge_cache(void);
#else
#define gdbstub_purge_cache()	do {} while (0)
#endif

/* Used to prevent crashes in memory access */
extern asmlinkage int  gdbstub_read_byte(const u8 *, u8 *);
extern asmlinkage int  gdbstub_read_word(const u8 *, u8 *);
extern asmlinkage int  gdbstub_read_dword(const u8 *, u8 *);
extern asmlinkage int  gdbstub_write_byte(u32, u8 *);
extern asmlinkage int  gdbstub_write_word(u32, u8 *);
extern asmlinkage int  gdbstub_write_dword(u32, u8 *);

extern asmlinkage void gdbstub_read_byte_guard(void);
extern asmlinkage void gdbstub_read_byte_cont(void);
extern asmlinkage void gdbstub_read_word_guard(void);
extern asmlinkage void gdbstub_read_word_cont(void);
extern asmlinkage void gdbstub_read_dword_guard(void);
extern asmlinkage void gdbstub_read_dword_cont(void);
extern asmlinkage void gdbstub_write_byte_guard(void);
extern asmlinkage void gdbstub_write_byte_cont(void);
extern asmlinkage void gdbstub_write_word_guard(void);
extern asmlinkage void gdbstub_write_word_cont(void);
extern asmlinkage void gdbstub_write_dword_guard(void);
extern asmlinkage void gdbstub_write_dword_cont(void);

extern u8	gdbstub_rx_buffer[PAGE_SIZE];
extern u32	gdbstub_rx_inp;
extern u32	gdbstub_rx_outp;
extern u8	gdbstub_rx_overflow;
extern u8	gdbstub_busy;
extern u8	gdbstub_rx_unget;

#ifdef CONFIG_GDBSTUB_DEBUGGING
extern void gdbstub_printk(const char *fmt, ...)
	__attribute__((format(printf, 1, 2)));
#else
static inline __attribute__((format(printf, 1, 2)))
void gdbstub_printk(const char *fmt, ...)
{
}
#endif

#ifdef CONFIG_GDBSTUB_DEBUG_ENTRY
#define gdbstub_entry(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
#else
#define gdbstub_entry(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
#endif

#ifdef CONFIG_GDBSTUB_DEBUG_PROTOCOL
#define gdbstub_proto(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
#else
#define gdbstub_proto(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
#endif

#ifdef CONFIG_GDBSTUB_DEBUG_IO
#define gdbstub_io(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
#else
#define gdbstub_io(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
#endif

#ifdef CONFIG_GDBSTUB_DEBUG_BREAKPOINT
#define gdbstub_bkpt(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
#else
#define gdbstub_bkpt(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
#endif

#endif /* !__ASSEMBLY__ */
#endif /* _ASM_GDB_STUB_H */