Commit | Line | Data |
---|---|---|
d108166f SS |
1 | /* Remote target glue for the ROM68K ROM monitor. |
2 | Copyright 1988, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
50e183a2 RS |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
6c9638b4 | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
50e183a2 | 19 | |
06b8f5e4 RS |
20 | #include "defs.h" |
21 | #include "gdbcore.h" | |
22 | #include "target.h" | |
23 | #include "monitor.h" | |
1265e2d8 | 24 | #include "serial.h" |
06b8f5e4 | 25 | |
5de0c648 | 26 | static void rom68k_open PARAMS ((char *args, int from_tty)); |
2081365f SG |
27 | |
28 | static void | |
29 | rom68k_supply_register (regname, regnamelen, val, vallen) | |
30 | char *regname; | |
31 | int regnamelen; | |
32 | char *val; | |
33 | int vallen; | |
34 | { | |
35 | int numregs; | |
36 | int regno; | |
37 | ||
38 | numregs = 1; | |
39 | regno = -1; | |
40 | ||
41 | if (regnamelen == 2) | |
5de0c648 SG |
42 | switch (regname[0]) |
43 | { | |
44 | case 'S': | |
45 | if (regname[1] == 'R') | |
46 | regno = PS_REGNUM; | |
47 | break; | |
48 | case 'P': | |
49 | if (regname[1] == 'C') | |
50 | regno = PC_REGNUM; | |
51 | break; | |
52 | case 'D': | |
53 | if (regname[1] != 'R') | |
d108166f | 54 | break; |
5de0c648 SG |
55 | regno = D0_REGNUM; |
56 | numregs = 8; | |
57 | break; | |
58 | case 'A': | |
59 | if (regname[1] != 'R') | |
d108166f | 60 | break; |
5de0c648 SG |
61 | regno = A0_REGNUM; |
62 | numregs = 7; | |
63 | break; | |
64 | } | |
2081365f | 65 | else if (regnamelen == 3) |
5de0c648 SG |
66 | switch (regname[0]) |
67 | { | |
68 | case 'I': | |
69 | if (regname[1] == 'S' && regname[2] == 'P') | |
70 | regno = SP_REGNUM; | |
71 | } | |
2081365f SG |
72 | |
73 | if (regno >= 0) | |
74 | while (numregs-- > 0) | |
75 | val = monitor_supply_register (regno++, val); | |
76 | } | |
06b8f5e4 | 77 | |
d108166f SS |
78 | /* This array of registers need to match the indexes used by GDB. |
79 | This exists because the various ROM monitors use different strings | |
80 | than does GDB, and don't necessarily support all the registers | |
81 | either. So, typing "info reg sp" becomes a "r30". */ | |
82 | ||
1265e2d8 SG |
83 | static char *rom68k_regnames[NUM_REGS] = { |
84 | "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", | |
85 | "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP", | |
86 | "SR", "PC" }; | |
06b8f5e4 | 87 | |
d108166f SS |
88 | /* Define the monitor command strings. Since these are passed directly |
89 | through to a printf style function, we may include formatting | |
90 | strings. We also need a CR or LF on the end. */ | |
06b8f5e4 | 91 | |
32fa4b59 | 92 | static struct target_ops rom68k_ops; |
06b8f5e4 | 93 | |
a706069f SG |
94 | static char *rom68k_inits[] = {".\r\r", NULL}; /* Exits pm/pr & download cmds */ |
95 | ||
1265e2d8 SG |
96 | static struct monitor_ops rom68k_cmds = |
97 | { | |
a706069f SG |
98 | 0, /* flags */ |
99 | rom68k_inits, /* monitor init string */ | |
100 | "go\r", /* continue command */ | |
101 | "st\r", /* single step */ | |
102 | NULL, /* No way to interrupt program */ | |
1265e2d8 SG |
103 | "db %x\r", /* set a breakpoint */ |
104 | "cb %x\r", /* clear a breakpoint */ | |
a706069f SG |
105 | "cb *\r", /* clear all breakpoints */ |
106 | "fm %x %x %x\r", /* fill (start len val) */ | |
06b8f5e4 | 107 | { |
a706069f SG |
108 | "pm %x %x\r", /* setmem.cmdb (addr, value) */ |
109 | "pm.w %x %x\r", /* setmem.cmdw (addr, value) */ | |
110 | "pm.l %x %x\r", /* setmem.cmdl (addr, value) */ | |
111 | NULL, /* setmem.cmdll (addr, value) */ | |
1265e2d8 SG |
112 | NULL, /* setreg.resp_delim */ |
113 | NULL, /* setreg.term */ | |
114 | NULL, /* setreg.term_cmd */ | |
06b8f5e4 RS |
115 | }, |
116 | { | |
a706069f SG |
117 | "dm %x %x\r", /* getmem.cmdb (addr, len) */ |
118 | "dm.w %x %x\r", /* getmem.cmdw (addr, len) */ | |
119 | "dm.l %x %x\r", /* getmem.cmdl (addr, len) */ | |
120 | NULL, /* getmem.cmdll (addr, len) */ | |
1265e2d8 SG |
121 | " ", /* getmem.resp_delim */ |
122 | NULL, /* getmem.term */ | |
123 | NULL, /* getmem.term_cmd */ | |
06b8f5e4 RS |
124 | }, |
125 | { | |
1265e2d8 SG |
126 | "pr %s %x\r", /* setreg.cmd (name, value) */ |
127 | NULL, /* setreg.resp_delim */ | |
128 | NULL, /* setreg.term */ | |
129 | NULL /* setreg.term_cmd */ | |
06b8f5e4 RS |
130 | }, |
131 | { | |
1265e2d8 SG |
132 | "pr %s\r", /* getreg.cmd (name) */ |
133 | ": ", /* getreg.resp_delim */ | |
134 | "= ", /* getreg.term */ | |
135 | ".\r" /* getreg.term_cmd */ | |
06b8f5e4 | 136 | }, |
a706069f | 137 | "dr\r", /* dump_registers */ |
2081365f SG |
138 | /* register_pattern */ |
139 | "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)", | |
140 | rom68k_supply_register, /* supply_register */ | |
5de0c648 | 141 | NULL, /* load_routine (defaults to SRECs) */ |
1265e2d8 | 142 | "dc\r", /* download command */ |
a706069f | 143 | "Waiting for S-records from host... ", /* Load response */ |
eba08643 | 144 | "ROM68K :-> ", /* monitor command prompt */ |
511ffbf2 | 145 | "\r", /* end-of-line terminator */ |
1265e2d8 SG |
146 | ".\r", /* optional command terminator */ |
147 | &rom68k_ops, /* target operations */ | |
1265e2d8 | 148 | SERIAL_1_STOPBITS, /* number of stop bits */ |
a706069f SG |
149 | rom68k_regnames, /* registers names */ |
150 | MONITOR_OPS_MAGIC /* magic */ | |
d108166f | 151 | }; |
06b8f5e4 | 152 | |
d108166f SS |
153 | static void |
154 | rom68k_open (args, from_tty) | |
06b8f5e4 RS |
155 | char *args; |
156 | int from_tty; | |
157 | { | |
1265e2d8 | 158 | monitor_open (args, &rom68k_cmds, from_tty); |
06b8f5e4 RS |
159 | } |
160 | ||
161 | void | |
162 | _initialize_rom68k () | |
163 | { | |
32fa4b59 SG |
164 | init_monitor_ops (&rom68k_ops); |
165 | ||
166 | rom68k_ops.to_shortname = "rom68k"; | |
167 | rom68k_ops.to_longname = "Rom68k debug monitor for the IDP Eval board"; | |
168 | rom68k_ops.to_doc = "Debug on a Motorola IDP eval board running the ROM68K monitor.\n\ | |
169 | Specify the serial device it is connected to (e.g. /dev/ttya)."; | |
170 | rom68k_ops.to_open = rom68k_open; | |
171 | ||
06b8f5e4 | 172 | add_target (&rom68k_ops); |
06b8f5e4 | 173 | } |