README.GDBTK is a gdbtk file
[deliverable/binutils-gdb.git] / gdb / w89k-rom.c
CommitLineData
50e183a2 1/* Remote target glue for the WinBond ROM monitor running on the "Cougar"
3da4297e 2 W89k eval board.
50e183a2 3
50e183a2
RS
4 Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
5
6This file is part of GDB.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
e8b73ba7
RS
22#include "defs.h"
23#include "gdbcore.h"
24#include "target.h"
25#include "monitor.h"
3da4297e 26#include "serial.h"
e8b73ba7 27
3da4297e 28static void w89k_open PARAMS ((char *args, int from_tty));
27e889bf
RS
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 */
3da4297e
SG
36static 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",
27e889bf 46};
e8b73ba7 47
7952bce6
SG
48static void
49w89k_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
e8b73ba7
RS
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
3da4297e
SG
163static struct target_ops w89k_ops;
164
7952bce6
SG
165static char *w89k_loadtypes[] = {"srec", NULL};
166static char *w89k_loadprotos[] = {"xmodem", NULL};
e8b73ba7 167
3da4297e 168static char *w89k_inits[] = {"\r", NULL};
1265e2d8
SG
169
170static struct monitor_ops w89k_cmds =
171{
7952bce6 172 MO_GETMEM_NEEDS_RANGE|MO_FILL_USES_ADDR, /* flags */
3da4297e
SG
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 */
7952bce6
SG
179 "bc *\r", /* clear all breakpoints */
180 "f %x %x %x\r", /* memory fill cmd */
51d6a954 181 {
3da4297e
SG
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 */
51d6a954
RS
189 },
190 {
3da4297e
SG
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 */
51d6a954 198 },
e6fa5bd6 199 {
3da4297e
SG
200 "r %s %x\r", /* setreg.cmd (name, value) */
201 NULL, /* setreg.resp_delim */
202 NULL, /* setreg.term */
203 NULL, /* setreg.term_cmd */
27e889bf
RS
204 },
205 {
3da4297e
SG
206 "r %s\r", /* getreg.cmd (name) */
207 "\r", /* getreg.resp_delim */
208 NULL, /* getreg.term */
209 NULL, /* getreg.term_cmd */
27e889bf 210 },
7952bce6
SG
211 "r\r", /* dump_registers */
212 "\\(\\w+\\)\\( +[0-9a-fA-F]+\\b\\)+",
213 w89k_supply_register, /* supply_register */
3da4297e 214 "u\r", /* download command */
7952bce6 215 "u\n\r", /* load response */
3da4297e
SG
216 "ROM>", /* monitor command prompt */
217 NULL, /* end-of-command delimitor */
218 NULL, /* optional command terminator */
219 &w89k_ops, /* target operations */
1265e2d8
SG
220 w89k_loadtypes, /* loadtypes */
221 w89k_loadprotos, /* loadprotos */
3da4297e 222 "9600", /* supported baud rates */
1265e2d8 223 SERIAL_1_STOPBITS, /* number of stop bits */
3da4297e
SG
224 w89k_regnames, /* register names */
225 MONITOR_OPS_MAGIC /* magic */
226 };
e8b73ba7
RS
227
228void
229w89k_open(args, from_tty)
230 char *args;
231 int from_tty;
232{
1265e2d8 233 monitor_open (args, &w89k_cmds, from_tty);
e8b73ba7
RS
234}
235
236void
237_initialize_w89k ()
238{
3da4297e 239 init_monitor_ops (&w89k_ops);
27e889bf 240
3da4297e
SG
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\
244Specify the serial device it is connected to (e.g. /dev/ttya).";
245 w89k_ops.to_open = w89k_open;
246
247 add_target (&w89k_ops);
e8b73ba7 248}
This page took 0.064309 seconds and 4 git commands to generate.