]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/w89k-rom.c
* monitor.c: make_xmodem_packet and print_xmodem_packet go away.
[thirdparty/binutils-gdb.git] / gdb / w89k-rom.c
1 /* Remote target glue for the WinBond ROM monitor running on the "Cougar"
2 W89k eval board.
3
4 Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 #include "defs.h"
23 #include "gdbcore.h"
24 #include "target.h"
25 #include "monitor.h"
26 #include "serial.h"
27
28 static void w89k_open PARAMS ((char *args, int from_tty));
29
30 /*
31 * this array of registers need to match the indexes used by GDB. The
32 * whole reason this exists is cause the various ROM monitors use
33 * different strings than GDB does, and doesn't support all the
34 * registers either. So, typing "info reg sp" becomes a "r30".
35 */
36 static char *w89k_regnames[NUM_REGS] =
37 {
38 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
39 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
40 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
41 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
42 "SAR", "PC", NULL, NULL, NULL, "EIEM", "IIR", "IVA",
43 "IOR", "IPSW", NULL, NULL, NULL, NULL, NULL,
44 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45 "CCR", NULL, NULL, "TR0", "TR1",
46 };
47
48 static void
49 w89k_supply_register (regname, regnamelen, val, vallen)
50 char *regname;
51 int regnamelen;
52 char *val;
53 int vallen;
54 {
55 int numregs;
56 int regno;
57
58 numregs = 1;
59 regno = -1;
60
61 if (regnamelen == 2)
62 switch (regname[0])
63 {
64 case 'r':
65 numregs = 4;
66 switch (regname[1])
67 {
68 case '0':
69 regno = R0_REGNUM;
70 break;
71 case '4':
72 regno = R0_REGNUM + 4;
73 break;
74 case '8':
75 regno = R0_REGNUM + 8;
76 break;
77 }
78 break;
79 case 'P':
80 if (regname[1] == 'C')
81 regno = PC_REGNUM;
82 break;
83 }
84 else if (regnamelen == 3)
85 switch (regname[0])
86 {
87 case 'r':
88 numregs = 4;
89 if (regname[1] == '1' && regname[2] == '2')
90 regno = R0_REGNUM + 12;
91 else if (regname[1] == '1' && regname[2] == '6')
92 regno = R0_REGNUM + 16;
93 else if (regname[1] == '2' && regname[2] == '0')
94 regno = R0_REGNUM + 20;
95 else if (regname[1] == '2' && regname[2] == '4')
96 regno = R0_REGNUM + 24;
97 else if (regname[1] == '2' && regname[2] == '8')
98 regno = R0_REGNUM + 28;
99 break;
100 case 'R':
101 if (regname[1] == 'C' && regname[2] == 'R')
102 regno = RCR_REGNUM;
103 break;
104 case 'C':
105 if (regname[1] == 'C' && regname[2] == 'R')
106 regno = CCR_REGNUM;
107 break;
108 case 'S':
109 if (regname[1] == 'A' && regname[2] == 'R')
110 regno = SAR_REGNUM;
111 break;
112 case 'I':
113 if (regname[1] == 'I' && regname[2] == 'R')
114 regno = IIR_REGNUM;
115 else if (regname[1] == 'O' && regname[2] == 'R')
116 regno = IOR_REGNUM;
117 break;
118 case 'T':
119 numregs = 4;
120 if (regname[1] == 'R')
121 if (regname[2] == '0')
122 regno = TR0_REGNUM;
123 else if (regname[2] == '4')
124 regno = TR0_REGNUM + 4;
125 break;
126 }
127 else if (regnamelen == 4)
128 switch (regname[0])
129 {
130 case 'E':
131 if (regname[1] == 'I')
132 if (regname[2] == 'E' && regname[3] == 'M')
133 regno = EIEM_REGNUM;
134 break;
135 case 'I':
136 if (regname[1] == 'P' && regname[2] == 'S' && regname[3] == 'W')
137 regno = IPSW_REGNUM;
138 break;
139 }
140 else if (regnamelen == 5)
141 switch (regname[0])
142 {
143 case 'I':
144 if (regname[1] == 'A'
145 && regname[2] == 'O'
146 && regname[3] == 'Q'
147 && regname[4] == 'B')
148 regno = PCOQ_TAIL_REGNUM;
149 break;
150 }
151
152 if (regno >= 0)
153 while (numregs-- > 0)
154 val = monitor_supply_register (regno++, val);
155 }
156
157 /*
158 * Define the monitor command strings. Since these are passed directly
159 * through to a printf style function, we need can include formatting
160 * strings. We also need a CR or LF on the end.
161 */
162
163 static struct target_ops w89k_ops;
164
165 static char *w89k_loadtypes[] = {"srec", NULL};
166 static char *w89k_loadprotos[] = {"xmodem", NULL};
167
168 static char *w89k_inits[] = {"\r", NULL};
169
170 static struct monitor_ops w89k_cmds =
171 {
172 MO_GETMEM_NEEDS_RANGE|MO_FILL_USES_ADDR, /* flags */
173 w89k_inits, /* Init strings */
174 "g\r", /* continue command */
175 "t\r", /* single step */
176 NULL, /* Interrupt char */
177 "bp %x\r", /* set a breakpoint */
178 "bc %x\r", /* clear a breakpoint */
179 "bc *\r", /* clear all breakpoints */
180 "f %x %x %x\r", /* memory fill cmd */
181 {
182 "eb %x %x\r", /* setmem.cmdb (addr, value) */
183 "eh %x %x\r", /* setmem.cmdw (addr, value) */
184 "ew %x %x\r", /* setmem.cmdl (addr, value) */
185 NULL, /* setmem.cmdll (addr, value) */
186 NULL, /* setreg.resp_delim */
187 NULL, /* setreg.term */
188 NULL, /* setreg.term_cmd */
189 },
190 {
191 "db %x %x\r", /* getmem.cmdb (startaddr, endaddr) */
192 "dh %x %x\r", /* getmem.cmdw (startaddr, endaddr) */
193 "dw %x %x\r", /* getmem.cmdl (startaddr, endaddr) */
194 NULL, /* getmem.cmdll (startaddr, endaddr) */
195 " ", /* getmem.resp_delim */
196 NULL, /* getmem.term */
197 NULL, /* getmem.term_cmd */
198 },
199 {
200 "r %s %x\r", /* setreg.cmd (name, value) */
201 NULL, /* setreg.resp_delim */
202 NULL, /* setreg.term */
203 NULL, /* setreg.term_cmd */
204 },
205 {
206 "r %s\r", /* getreg.cmd (name) */
207 "\r", /* getreg.resp_delim */
208 NULL, /* getreg.term */
209 NULL, /* getreg.term_cmd */
210 },
211 "r\r", /* dump_registers */
212 "\\(\\w+\\)\\( +[0-9a-fA-F]+\\b\\)+",
213 w89k_supply_register, /* supply_register */
214 "u\r", /* download command */
215 "u\n\r", /* load response */
216 "ROM>", /* monitor command prompt */
217 NULL, /* end-of-command delimitor */
218 NULL, /* optional command terminator */
219 &w89k_ops, /* target operations */
220 w89k_loadtypes, /* loadtypes */
221 w89k_loadprotos, /* loadprotos */
222 "9600", /* supported baud rates */
223 SERIAL_1_STOPBITS, /* number of stop bits */
224 w89k_regnames, /* register names */
225 MONITOR_OPS_MAGIC /* magic */
226 };
227
228 void
229 w89k_open(args, from_tty)
230 char *args;
231 int from_tty;
232 {
233 monitor_open (args, &w89k_cmds, from_tty);
234 }
235
236 void
237 _initialize_w89k ()
238 {
239 init_monitor_ops (&w89k_ops);
240
241 w89k_ops.to_shortname = "w89k";
242 w89k_ops.to_longname = "WinBond's debug monitor for the W89k Eval board";
243 w89k_ops.to_doc = "Debug on a WinBond W89K eval board.\n\
244 Specify the serial device it is connected to (e.g. /dev/ttya).";
245 w89k_ops.to_open = w89k_open;
246
247 add_target (&w89k_ops);
248 }