Commit | Line | Data |
---|---|---|
50e183a2 RS |
1 | /* Remote target glue for the rom68k ROM monitor. This was running on a |
2 | Motorola IDP 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 | ||
06b8f5e4 RS |
22 | #include "defs.h" |
23 | #include "gdbcore.h" | |
24 | #include "target.h" | |
25 | #include "monitor.h" | |
1265e2d8 | 26 | #include "serial.h" |
06b8f5e4 | 27 | |
2081365f SG |
28 | static void rom68k_open PARAMS ((char *args, int from_tty)); |
29 | ||
30 | static void | |
31 | rom68k_supply_register (regname, regnamelen, val, vallen) | |
32 | char *regname; | |
33 | int regnamelen; | |
34 | char *val; | |
35 | int vallen; | |
36 | { | |
37 | int numregs; | |
38 | int regno; | |
39 | ||
40 | numregs = 1; | |
41 | regno = -1; | |
42 | ||
43 | if (regnamelen == 2) | |
44 | switch (regname[0]) | |
45 | { | |
46 | case 'S': | |
47 | if (regname[1] == 'R') | |
48 | regno = PS_REGNUM; | |
49 | break; | |
50 | case 'P': | |
51 | if (regname[1] == 'C') | |
52 | regno = PC_REGNUM; | |
53 | break; | |
54 | case 'D': | |
55 | if (regname[1] != 'R') | |
56 | break; | |
57 | regno = D0_REGNUM; | |
58 | numregs = 8; | |
59 | break; | |
60 | case 'A': | |
61 | if (regname[1] != 'R') | |
62 | break; | |
63 | regno = A0_REGNUM; | |
64 | numregs = 7; | |
65 | break; | |
66 | } | |
67 | else if (regnamelen == 3) | |
68 | switch (regname[0]) | |
69 | { | |
70 | case 'I': | |
71 | if (regname[1] == 'S' && regname[2] == 'P') | |
72 | regno = SP_REGNUM; | |
73 | } | |
74 | ||
75 | if (regno >= 0) | |
76 | while (numregs-- > 0) | |
77 | val = monitor_supply_register (regno++, val); | |
78 | } | |
06b8f5e4 RS |
79 | |
80 | /* | |
81 | * this array of registers need to match the indexes used by GDB. The | |
82 | * whole reason this exists is cause the various ROM monitors use | |
83 | * different strings than GDB does, and doesn't support all the | |
84 | * registers either. So, typing "info reg sp" becomes a "r30". | |
85 | */ | |
1265e2d8 SG |
86 | static char *rom68k_regnames[NUM_REGS] = { |
87 | "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", | |
88 | "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP", | |
89 | "SR", "PC" }; | |
06b8f5e4 RS |
90 | |
91 | /* | |
92 | * Define the monitor command strings. Since these are passed directly | |
93 | * through to a printf style function, we need can include formatting | |
94 | * strings. We also need a CR or LF on the end. | |
95 | */ | |
96 | ||
32fa4b59 | 97 | static struct target_ops rom68k_ops; |
06b8f5e4 | 98 | |
7952bce6 | 99 | static char *rom68k_loadtypes[] = {"srec", NULL}; |
1265e2d8 SG |
100 | static char *rom68k_loadprotos[] = {"none", NULL}; |
101 | ||
a706069f SG |
102 | static char *rom68k_inits[] = {".\r\r", NULL}; /* Exits pm/pr & download cmds */ |
103 | ||
1265e2d8 SG |
104 | static struct monitor_ops rom68k_cmds = |
105 | { | |
a706069f SG |
106 | 0, /* flags */ |
107 | rom68k_inits, /* monitor init string */ | |
108 | "go\r", /* continue command */ | |
109 | "st\r", /* single step */ | |
110 | NULL, /* No way to interrupt program */ | |
1265e2d8 SG |
111 | "db %x\r", /* set a breakpoint */ |
112 | "cb %x\r", /* clear a breakpoint */ | |
a706069f SG |
113 | "cb *\r", /* clear all breakpoints */ |
114 | "fm %x %x %x\r", /* fill (start len val) */ | |
06b8f5e4 | 115 | { |
a706069f SG |
116 | "pm %x %x\r", /* setmem.cmdb (addr, value) */ |
117 | "pm.w %x %x\r", /* setmem.cmdw (addr, value) */ | |
118 | "pm.l %x %x\r", /* setmem.cmdl (addr, value) */ | |
119 | NULL, /* setmem.cmdll (addr, value) */ | |
1265e2d8 SG |
120 | NULL, /* setreg.resp_delim */ |
121 | NULL, /* setreg.term */ | |
122 | NULL, /* setreg.term_cmd */ | |
06b8f5e4 RS |
123 | }, |
124 | { | |
a706069f SG |
125 | "dm %x %x\r", /* getmem.cmdb (addr, len) */ |
126 | "dm.w %x %x\r", /* getmem.cmdw (addr, len) */ | |
127 | "dm.l %x %x\r", /* getmem.cmdl (addr, len) */ | |
128 | NULL, /* getmem.cmdll (addr, len) */ | |
1265e2d8 SG |
129 | " ", /* getmem.resp_delim */ |
130 | NULL, /* getmem.term */ | |
131 | NULL, /* getmem.term_cmd */ | |
06b8f5e4 RS |
132 | }, |
133 | { | |
1265e2d8 SG |
134 | "pr %s %x\r", /* setreg.cmd (name, value) */ |
135 | NULL, /* setreg.resp_delim */ | |
136 | NULL, /* setreg.term */ | |
137 | NULL /* setreg.term_cmd */ | |
06b8f5e4 RS |
138 | }, |
139 | { | |
1265e2d8 SG |
140 | "pr %s\r", /* getreg.cmd (name) */ |
141 | ": ", /* getreg.resp_delim */ | |
142 | "= ", /* getreg.term */ | |
143 | ".\r" /* getreg.term_cmd */ | |
06b8f5e4 | 144 | }, |
a706069f | 145 | "dr\r", /* dump_registers */ |
2081365f SG |
146 | /* register_pattern */ |
147 | "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)", | |
148 | rom68k_supply_register, /* supply_register */ | |
1265e2d8 | 149 | "dc\r", /* download command */ |
a706069f | 150 | "Waiting for S-records from host... ", /* Load response */ |
1265e2d8 SG |
151 | "ROM68K :->", /* monitor command prompt */ |
152 | "=", /* end-of-command delimitor */ | |
153 | ".\r", /* optional command terminator */ | |
154 | &rom68k_ops, /* target operations */ | |
155 | rom68k_loadtypes, /* loadtypes */ | |
156 | rom68k_loadprotos, /* loadprotos */ | |
157 | "9600", /* supported baud rates */ | |
158 | SERIAL_1_STOPBITS, /* number of stop bits */ | |
a706069f SG |
159 | rom68k_regnames, /* registers names */ |
160 | MONITOR_OPS_MAGIC /* magic */ | |
1265e2d8 | 161 | }; |
06b8f5e4 RS |
162 | |
163 | void | |
164 | rom68k_open(args, from_tty) | |
165 | char *args; | |
166 | int from_tty; | |
167 | { | |
1265e2d8 | 168 | monitor_open (args, &rom68k_cmds, from_tty); |
06b8f5e4 RS |
169 | } |
170 | ||
171 | void | |
172 | _initialize_rom68k () | |
173 | { | |
32fa4b59 SG |
174 | init_monitor_ops (&rom68k_ops); |
175 | ||
176 | rom68k_ops.to_shortname = "rom68k"; | |
177 | rom68k_ops.to_longname = "Rom68k debug monitor for the IDP Eval board"; | |
178 | rom68k_ops.to_doc = "Debug on a Motorola IDP eval board running the ROM68K monitor.\n\ | |
179 | Specify the serial device it is connected to (e.g. /dev/ttya)."; | |
180 | rom68k_ops.to_open = rom68k_open; | |
181 | ||
06b8f5e4 RS |
182 | add_target (&rom68k_ops); |
183 | ||
184 | /* this is the default, since it's the only baud rate supported by the hardware */ | |
185 | baud_rate = 9600; | |
186 | } |