]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/remote-est.c
* cpu32bug-rom.c monitor.h op50-rom.c remote-est.c rom68k-rom.c
[thirdparty/binutils-gdb.git] / gdb / remote-est.c
1 /* Remote debugging interface for EST-300 ICE, for GDB
2 Copyright 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5 Written by Steve Chamberlain for Cygnus Support.
6 Re-written by Stu Grossman of Cygnus Support
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23
24 #include "defs.h"
25 #include "gdbcore.h"
26 #include "target.h"
27 #include "monitor.h"
28 #include "serial.h"
29
30 static void est_open PARAMS ((char *args, int from_tty));
31
32 static void
33 est_supply_register (regname, regnamelen, val, vallen)
34 char *regname;
35 int regnamelen;
36 char *val;
37 int vallen;
38 {
39 int regno;
40
41 if (regnamelen != 2)
42 return;
43
44 switch (regname[0])
45 {
46 case 'S':
47 if (regname[1] != 'R')
48 return;
49 regno = PS_REGNUM;
50 break;
51 case 'P':
52 if (regname[1] != 'C')
53 return;
54 regno = PC_REGNUM;
55 break;
56 case 'D':
57 if (regname[1] < '0' || regname[1] > '7')
58 return;
59 regno = regname[1] - '0' + D0_REGNUM;
60 break;
61 case 'A':
62 if (regname[1] < '0' || regname[1] > '7')
63 return;
64 regno = regname[1] - '0' + A0_REGNUM;
65 break;
66 default:
67 return;
68 }
69
70 monitor_supply_register (regno, val);
71 }
72
73 /*
74 * This array of registers needs to match the indexes used by GDB. The
75 * whole reason this exists is because the various ROM monitors use
76 * different names than GDB does, and don't support all the
77 * registers either. So, typing "info reg sp" becomes a "r30".
78 */
79
80 static char *est_regnames[NUM_REGS] =
81 {
82 "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
83 "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
84 "SR", "PC",
85 };
86
87 /*
88 * Define the monitor command strings. Since these are passed directly
89 * through to a printf style function, we need can include formatting
90 * strings. We also need a CR or LF on the end.
91 */
92
93 static struct target_ops est_ops;
94
95 static char *est_inits[] = {"he\r", /* Resets the prompt, and clears repeated cmds */
96 NULL};
97
98 static struct monitor_ops est_cmds =
99 {
100 MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_NEED_REGDUMP_AFTER_CONT,
101 est_inits, /* Init strings */
102 "go\r", /* continue command */
103 "sidr\r", /* single step */
104 "\003", /* ^C interrupts the program */
105 "sb %x\r", /* set a breakpoint */
106 "rb %x\r", /* clear a breakpoint */
107 "rb\r", /* clear all breakpoints */
108 "bfb %x %x %x\r", /* fill (start end val) */
109 {
110 "smb %x %x\r", /* setmem.cmdb (addr, value) */
111 "smw %x %x\r", /* setmem.cmdw (addr, value) */
112 "sml %x %x\r", /* setmem.cmdl (addr, value) */
113 NULL, /* setmem.cmdll (addr, value) */
114 NULL, /* setreg.resp_delim */
115 NULL, /* setreg.term */
116 NULL, /* setreg.term_cmd */
117 },
118 {
119 "dmb %x %x\r", /* getmem.cmdb (addr, len) */
120 "dmw %x %x\r", /* getmem.cmdw (addr, len) */
121 "dml %x %x\r", /* getmem.cmdl (addr, len) */
122 NULL, /* getmem.cmdll (addr, len) */
123 ": ", /* getmem.resp_delim */
124 NULL, /* getmem.term */
125 NULL, /* getmem.term_cmd */
126 },
127 {
128 "sr %s %x\r", /* setreg.cmd (name, value) */
129 NULL, /* setreg.resp_delim */
130 NULL, /* setreg.term */
131 NULL /* setreg.term_cmd */
132 },
133 {
134 "dr %s\r", /* getreg.cmd (name) */
135 " = ", /* getreg.resp_delim */
136 NULL, /* getreg.term */
137 NULL /* getreg.term_cmd */
138 },
139 "dr\r", /* dump_registers */
140 "\\(\\w+\\) = \\([0-9a-fA-F]+\\)", /* register_pattern */
141 est_supply_register, /* supply_register */
142 NULL, /* load_routine (defaults to SRECs) */
143 "dl\r", /* download command */
144 "+", /* load response */
145 ">BKM>", /* monitor command prompt */
146 NULL, /* end-of-command delimitor */
147 NULL, /* optional command terminator */
148 &est_ops, /* target operations */
149 SERIAL_1_STOPBITS, /* number of stop bits */
150 est_regnames, /* registers names */
151 MONITOR_OPS_MAGIC /* magic */
152 };
153
154 void
155 est_open(args, from_tty)
156 char *args;
157 int from_tty;
158 {
159 monitor_open (args, &est_cmds, from_tty);
160 }
161
162 void
163 _initialize_est ()
164 {
165 init_monitor_ops (&est_ops);
166
167 est_ops.to_shortname = "est";
168 est_ops.to_longname = "EST background debug monitor";
169 est_ops.to_doc = "Debug via the EST BDM.\n\
170 Specify the serial device it is connected to (e.g. /dev/ttya).";
171 est_ops.to_open = est_open;
172
173 add_target (&est_ops);
174 }