* ld-srec/srec.exp: Add setup_xfail for i960 COFF targets.
[deliverable/binutils-gdb.git] / gdb / sh3-rom.c
1 /* Remote target glue for the Hitachi SH-3 ROM monitor.
2 Copyright 1995 Free Software Foundation, Inc.
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
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #include "defs.h"
21 #include "gdbcore.h"
22 #include "target.h"
23 #include "monitor.h"
24 #include "serial.h"
25 #include "srec.h"
26
27 static void sh3_open PARAMS ((char *args, int from_tty));
28
29 static void
30 sh3_supply_register (regname, regnamelen, val, vallen)
31 char *regname;
32 int regnamelen;
33 char *val;
34 int vallen;
35 {
36 int numregs;
37 int regno;
38
39 numregs = 1;
40 regno = -1;
41
42 if (regnamelen == 2)
43 switch (regname[0])
44 {
45 case 'S':
46 if (regname[1] == 'R')
47 regno = SR_REGNUM;
48 break;
49 case 'P':
50 if (regname[1] == 'C')
51 regno = PC_REGNUM;
52 else if (regname[1] == 'R')
53 regno = PR_REGNUM;
54 break;
55 }
56 else if (regnamelen == 3)
57 switch (regname[0])
58 {
59 case 'G':
60 case 'V':
61 if (regname[1] == 'B' && regname[2] == 'R')
62 if (regname[0] == 'G')
63 regno = VBR_REGNUM;
64 else
65 regno = GBR_REGNUM;
66 break;
67 #if 0
68 case 'S':
69 if (regname[1] == 'S' && regname[2] == 'R')
70 regno = SSR_REGNUM;
71 else if (regname[1] == 'P' && regname[2] == 'C')
72 regno = SPC_REGNUM;
73 break;
74 #endif
75 }
76 else if (regnamelen == 4)
77 switch (regname[0])
78 {
79 case 'M':
80 if (regname[1] == 'A' && regname[2] == 'C')
81 if (regname[3] == 'H')
82 regno = MACH_REGNUM;
83 else if (regname[3] == 'L')
84 regno = MACL_REGNUM;
85 break;
86 case 'R':
87 if (regname[1] == '0' && regname[2] == '-' && regname[3] == '7')
88 {
89 regno = R0_REGNUM;
90 numregs = 8;
91 }
92 }
93 else if (regnamelen == 5)
94 if (regname[1] == '8' && regname[2] == '-' && regname[3] == '1'
95 && regname[4] =='5')
96 {
97 regno = R0_REGNUM + 8;
98 numregs = 8;
99 }
100
101 if (regno >= 0)
102 while (numregs-- > 0)
103 val = monitor_supply_register (regno++, val);
104 }
105
106 static void
107 sh3_load (desc, file, hashmark)
108 serial_t desc;
109 char *file;
110 int hashmark;
111 {
112 monitor_printf ("il;s:x\r");
113 monitor_expect ("\005", NULL, 0); /* Look for ENQ */
114 SERIAL_WRITE (desc, "\006", 1); /* Send ACK */
115 monitor_expect ("LO x\r", NULL, 0); /* Look for filename */
116
117 load_srec (desc, file, 80, SREC_ALL, hashmark);
118
119 monitor_expect ("\005", NULL, 0); /* Look for ENQ */
120 SERIAL_WRITE (desc, "\006", 1); /* Send ACK */
121 monitor_expect_prompt (NULL, 0);
122 }
123
124 /* This array of registers need to match the indexes used by GDB.
125 This exists because the various ROM monitors use different strings
126 than does GDB, and don't necessarily support all the registers
127 either. So, typing "info reg sp" becomes a "r30". */
128
129 static char *sh3_regnames[NUM_REGS] = {
130 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
131 "R8", "R9", "R10","R11","R12","R13","R14","R15",
132 "PC", "PR", "GBR","VBR","MACH","MACL","SR",NULL,
133 NULL, NULL, NULL, NULL};
134
135 /* Define the monitor command strings. Since these are passed directly
136 through to a printf style function, we may include formatting
137 strings. We also need a CR or LF on the end. */
138
139 static struct target_ops sh3_ops;
140
141 static char *sh3_inits[] = {"\003", NULL}; /* Exits sub-command mode & download cmds */
142
143 static struct monitor_ops sh3_cmds =
144 {
145 MO_CLR_BREAK_USES_ADDR
146 | MO_GETMEM_READ_SINGLE, /* flags */
147 sh3_inits, /* monitor init string */
148 "g\r", /* continue command */
149 "s\r", /* single step */
150 "\003", /* Interrupt program */
151 "b %x\r", /* set a breakpoint */
152 "b -%x\r", /* clear a breakpoint */
153 "b -\r", /* clear all breakpoints */
154 "f %x @%x %x\r", /* fill (start len val) */
155 {
156 "m %x %x\r", /* setmem.cmdb (addr, value) */
157 "m %x %x;w\r", /* setmem.cmdw (addr, value) */
158 "m %x %x;l\r", /* setmem.cmdl (addr, value) */
159 NULL, /* setmem.cmdll (addr, value) */
160 NULL, /* setreg.resp_delim */
161 NULL, /* setreg.term */
162 NULL, /* setreg.term_cmd */
163 },
164 {
165 "m %x\r", /* getmem.cmdb (addr, len) */
166 "m %x;w\r", /* getmem.cmdw (addr, len) */
167 "m %x;l\r", /* getmem.cmdl (addr, len) */
168 NULL, /* getmem.cmdll (addr, len) */
169 "^ [0-9A-F]+ ", /* getmem.resp_delim */
170 "? ", /* getmem.term */
171 ".\r", /* getmem.term_cmd */
172 },
173 {
174 ".%s %x\r", /* setreg.cmd (name, value) */
175 NULL, /* setreg.resp_delim */
176 NULL, /* setreg.term */
177 NULL /* setreg.term_cmd */
178 },
179 {
180 ".%s\r", /* getreg.cmd (name) */
181 "=", /* getreg.resp_delim */
182 "? ", /* getreg.term */
183 ".\r" /* getreg.term_cmd */
184 },
185 "r\r", /* dump_registers */
186 /* register_pattern */
187 "\\(\\w+\\)=\\([0-9a-fA-F]+\\( +[0-9a-fA-F]+\\b\\)*\\)",
188 sh3_supply_register, /* supply_register */
189 sh3_load, /* load_routine */
190 NULL, /* download command */
191 NULL, /* Load response */
192 "\n:", /* monitor command prompt */
193 "\r", /* end-of-line terminator */
194 ".\r", /* optional command terminator */
195 &sh3_ops, /* target operations */
196 SERIAL_1_STOPBITS, /* number of stop bits */
197 sh3_regnames, /* registers names */
198 MONITOR_OPS_MAGIC /* magic */
199 };
200
201 static void
202 sh3_open (args, from_tty)
203 char *args;
204 int from_tty;
205 {
206 monitor_open (args, &sh3_cmds, from_tty);
207 }
208
209 void
210 _initialize_sh3 ()
211 {
212 init_monitor_ops (&sh3_ops);
213
214 sh3_ops.to_shortname = "sh3";
215 sh3_ops.to_longname = "Hitachi SH-3 rom monitor";
216 sh3_ops.to_doc = "Debug on a Hitachi eval board running the SH-3 rom monitor.\n\
217 Specify the serial device it is connected to (e.g. /dev/ttya).";
218 sh3_ops.to_open = sh3_open;
219
220 add_target (&sh3_ops);
221 }
This page took 0.03454 seconds and 4 git commands to generate.