1 /* Remote target glue for the Hitachi SH-3 ROM monitor.
2 Copyright 1995 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 static void sh3_open PARAMS ((char *args, int from_tty));
29 sh3_supply_register (regname, regnamelen, val, vallen)
45 if (regname[1] == 'R')
49 if (regname[1] == 'C')
51 else if (regname[1] == 'R')
55 else if (regnamelen == 3)
60 if (regname[1] == 'B' && regname[2] == 'R')
61 if (regname[0] == 'G')
68 if (regname[1] == 'S' && regname[2] == 'R')
70 else if (regname[1] == 'P' && regname[2] == 'C')
75 else if (regnamelen == 4)
79 if (regname[1] == 'A' && regname[2] == 'C')
80 if (regname[3] == 'H')
82 else if (regname[3] == 'L')
86 if (regname[1] == '0' && regname[2] == '-' && regname[3] == '7')
92 else if (regnamelen == 5)
93 if (regname[1] == '8' && regname[2] == '-' && regname[3] == '1'
96 regno = R0_REGNUM + 8;
101 while (numregs-- > 0)
102 val = monitor_supply_register (regno++, val);
105 /* This array of registers need to match the indexes used by GDB.
106 This exists because the various ROM monitors use different strings
107 than does GDB, and don't necessarily support all the registers
108 either. So, typing "info reg sp" becomes a "r30". */
110 static char *sh3_regnames[NUM_REGS] = {
111 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
112 "R8", "R9", "R10","R11","R12","R13","R14","R15",
113 "PC", "PR", "GBR","VBR","MACH","MACL","SR",NULL,
114 NULL, NULL, NULL, NULL};
116 /* Define the monitor command strings. Since these are passed directly
117 through to a printf style function, we may include formatting
118 strings. We also need a CR or LF on the end. */
120 static struct target_ops sh3_ops;
122 static char *sh3_inits[] = {"\003", NULL}; /* Exits sub-command mode & download cmds */
124 static struct monitor_ops sh3_cmds =
126 MO_CLR_BREAK_USES_ADDR
127 | MO_GETMEM_READ_SINGLE, /* flags */
128 sh3_inits, /* monitor init string */
129 "g\r", /* continue command */
130 "s\r", /* single step */
131 "\003", /* Interrupt program */
132 "b %x\r", /* set a breakpoint */
133 "b -%x\r", /* clear a breakpoint */
134 "b -\r", /* clear all breakpoints */
135 "f %x @%x %x\r", /* fill (start len val) */
137 "m %x %x\r", /* setmem.cmdb (addr, value) */
138 "m %x %x;w\r", /* setmem.cmdw (addr, value) */
139 "m %x %x;l\r", /* setmem.cmdl (addr, value) */
140 NULL, /* setmem.cmdll (addr, value) */
141 NULL, /* setreg.resp_delim */
142 NULL, /* setreg.term */
143 NULL, /* setreg.term_cmd */
146 "m %x\r", /* getmem.cmdb (addr, len) */
147 "m %x;w\r", /* getmem.cmdw (addr, len) */
148 "m %x;l\r", /* getmem.cmdl (addr, len) */
149 NULL, /* getmem.cmdll (addr, len) */
150 "^ [0-9A-F]+ ", /* getmem.resp_delim */
151 "? ", /* getmem.term */
152 ".\r", /* getmem.term_cmd */
155 ".%s %x\r", /* setreg.cmd (name, value) */
156 NULL, /* setreg.resp_delim */
157 NULL, /* setreg.term */
158 NULL /* setreg.term_cmd */
161 ".%s\r", /* getreg.cmd (name) */
162 "=", /* getreg.resp_delim */
163 "? ", /* getreg.term */
164 ".\r" /* getreg.term_cmd */
166 "r\r", /* dump_registers */
167 /* register_pattern */
168 "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
169 sh3_supply_register, /* supply_register */
170 NULL, /* load_routine (defaults to SRECs) */
171 "il;s:x\r\006", /* download command */
172 NULL, /* Load response */
173 "\n:", /* monitor command prompt */
174 "\r", /* end-of-line terminator */
175 ".\r", /* optional command terminator */
176 &sh3_ops, /* target operations */
177 SERIAL_1_STOPBITS, /* number of stop bits */
178 sh3_regnames, /* registers names */
179 MONITOR_OPS_MAGIC /* magic */
183 sh3_open (args, from_tty)
187 monitor_open (args, &sh3_cmds, from_tty);
193 init_monitor_ops (&sh3_ops);
195 sh3_ops.to_shortname = "sh3";
196 sh3_ops.to_longname = "Hitachi SH-3 rom monitor";
197 sh3_ops.to_doc = "Debug on a Hitachi eval board running the SH-3 rom monitor.\n\
198 Specify the serial device it is connected to (e.g. /dev/ttya).";
199 sh3_ops.to_open = sh3_open;
201 add_target (&sh3_ops);