blob: f5495ad82b77bc753b218b3a3498ea089e511134 [file] [log] [blame]
David Howellsb920de12008-02-08 04:19:31 -08001/* MN10300 Kernel GDB stub definitions
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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
78struct gdb_regs {
79 /* saved main processor registers */
80 u32 d0, d1, d2, d3, a0, a1, a2, a3;
81 u32 sp, pc, mdr, epsw, lir, lar, mdrq;
82 u32 e0, e1, e2, e3, e4, e5, e6, e7;
83 u32 ssp, msp, usp, mcrh, mcrl, mcvf;
84
85 /* saved floating point registers */
86 u32 fpcr, _dummy0, _dummy1;
87 u32 fs0, fs1, fs2, fs3, fs4, fs5, fs6, fs7;
88 u32 fs8, fs9, fs10, fs11, fs12, fs13, fs14, fs15;
89 u32 fs16, fs17, fs18, fs19, fs20, fs21, fs22, fs23;
90 u32 fs24, fs25, fs26, fs27, fs28, fs29, fs30, fs31;
91};
92
93/*
94 * Prototypes
95 */
96extern void show_registers_only(struct pt_regs *regs);
97
98extern asmlinkage void gdbstub_init(void);
99extern asmlinkage void gdbstub_exit(int status);
100extern asmlinkage void gdbstub_io_init(void);
101extern asmlinkage void gdbstub_io_set_baud(unsigned baud);
102extern asmlinkage int gdbstub_io_rx_char(unsigned char *_ch, int nonblock);
103extern asmlinkage void gdbstub_io_tx_char(unsigned char ch);
104extern asmlinkage void gdbstub_io_tx_flush(void);
105
106extern asmlinkage void gdbstub_io_rx_handler(void);
107extern asmlinkage void gdbstub_rx_irq(struct pt_regs *, enum exception_code);
108extern asmlinkage int gdbstub_intercept(struct pt_regs *, enum exception_code);
109extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
110extern asmlinkage void __gdbstub_bug_trap(void);
111extern asmlinkage void __gdbstub_pause(void);
David Howellsb920de12008-02-08 04:19:31 -0800112
David Howells344af922010-10-27 17:28:42 +0100113#ifdef CONFIG_MN10300_CACHE_ENABLED
David Howellsb920de12008-02-08 04:19:31 -0800114extern 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 */
120extern asmlinkage int gdbstub_read_byte(const u8 *, u8 *);
121extern asmlinkage int gdbstub_read_word(const u8 *, u8 *);
122extern asmlinkage int gdbstub_read_dword(const u8 *, u8 *);
123extern asmlinkage int gdbstub_write_byte(u32, u8 *);
124extern asmlinkage int gdbstub_write_word(u32, u8 *);
125extern asmlinkage int gdbstub_write_dword(u32, u8 *);
126
127extern asmlinkage void gdbstub_read_byte_guard(void);
128extern asmlinkage void gdbstub_read_byte_cont(void);
129extern asmlinkage void gdbstub_read_word_guard(void);
130extern asmlinkage void gdbstub_read_word_cont(void);
131extern asmlinkage void gdbstub_read_dword_guard(void);
132extern asmlinkage void gdbstub_read_dword_cont(void);
133extern asmlinkage void gdbstub_write_byte_guard(void);
134extern asmlinkage void gdbstub_write_byte_cont(void);
135extern asmlinkage void gdbstub_write_word_guard(void);
136extern asmlinkage void gdbstub_write_word_cont(void);
137extern asmlinkage void gdbstub_write_dword_guard(void);
138extern asmlinkage void gdbstub_write_dword_cont(void);
139
140extern u8 gdbstub_rx_buffer[PAGE_SIZE];
141extern u32 gdbstub_rx_inp;
142extern u32 gdbstub_rx_outp;
143extern u8 gdbstub_rx_overflow;
144extern u8 gdbstub_busy;
145extern u8 gdbstub_rx_unget;
146
147#ifdef CONFIG_GDBSTUB_DEBUGGING
148extern void gdbstub_printk(const char *fmt, ...)
149 __attribute__((format(printf, 1, 2)));
150#else
151static inline __attribute__((format(printf, 1, 2)))
152void 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
David Howells95f45722010-08-12 16:55:02 +0100160#define gdbstub_entry(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
David Howellsb920de12008-02-08 04:19:31 -0800161#endif
162
163#ifdef CONFIG_GDBSTUB_DEBUG_PROTOCOL
164#define gdbstub_proto(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
165#else
David Howells95f45722010-08-12 16:55:02 +0100166#define gdbstub_proto(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
David Howellsb920de12008-02-08 04:19:31 -0800167#endif
168
169#ifdef CONFIG_GDBSTUB_DEBUG_IO
170#define gdbstub_io(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
171#else
David Howells95f45722010-08-12 16:55:02 +0100172#define gdbstub_io(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
David Howellsb920de12008-02-08 04:19:31 -0800173#endif
174
175#ifdef CONFIG_GDBSTUB_DEBUG_BREAKPOINT
176#define gdbstub_bkpt(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__)
177#else
David Howells95f45722010-08-12 16:55:02 +0100178#define gdbstub_bkpt(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
David Howellsb920de12008-02-08 04:19:31 -0800179#endif
180
181#endif /* !__ASSEMBLY__ */
182#endif /* _ASM_GDB_STUB_H */