* remote-sim.h (sim_state, SIM_DESC): New types.
[deliverable/binutils-gdb.git] / gdb / sparclet-rom.c
CommitLineData
012be3ce
DP
1/* Remote target glue for the SPARC Sparclet ROM monitor.
2 Copyright 1995, 1996 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20
21#include "defs.h"
22#include "gdbcore.h"
23#include "target.h"
24#include "monitor.h"
25#include "serial.h"
26#include "srec.h"
27#include "symtab.h"
28#include "symfile.h" /* for generic_load */
29
a7f6f9ed 30#if 0 /* Do we really need all this Unix stuff here? */
012be3ce
DP
31#if !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && !defined (HAVE_SGTTY)
32#define HAVE_SGTTY
33#endif
34
35#ifdef HAVE_SGTTY
36#include <sys/ioctl.h>
37#endif
38
39#include <sys/types.h> /* Needed by file.h on Sys V */
40#include <sys/file.h>
41#include <signal.h>
42#include <sys/stat.h>
a7f6f9ed 43#endif /* Unix stuff */
012be3ce
DP
44
45#define USE_GENERIC_LOAD
46#define USE_SW_BREAKS
47
48static struct target_ops sparclet_ops;
49
50static void sparclet_open PARAMS ((char *args, int from_tty));
51
52#ifdef USE_GENERIC_LOAD
53
54static void
55sparclet_load_gen (filename, from_tty)
56 char *filename;
57 int from_tty;
58{
59 extern int inferior_pid;
60
61 generic_load (filename, from_tty);
62 /* Finally, make the PC point at the start address */
63 if (exec_bfd)
64 write_pc (bfd_get_start_address (exec_bfd));
65
66 inferior_pid = 0; /* No process now */
67}
68
a7f6f9ed
MS
69#endif
70
71#ifdef USE_XMODEM_LOAD
012be3ce
DP
72
73static void
74sparclet_xmodem_load (desc, file, hashmark)
75 serial_t desc;
76 char *file;
77 int hashmark;
78{
79 bfd *abfd;
80 asection *s;
81 char *buffer;
82 int i;
83
84 buffer = alloca (XMODEM_PACKETSIZE);
85 abfd = bfd_openr (file, 0);
86 if (!abfd)
87 {
88 printf_filtered ("Unable to open file %s\n", file);
89 return;
90 }
91 if (bfd_check_format (abfd, bfd_object) == 0)
92 {
93 printf_filtered ("File is not an object file\n");
94 return;
95 }
96 for (s = abfd->sections; s; s = s->next)
97 if (s->flags & SEC_LOAD)
98 {
99 bfd_size_type section_size;
100 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
101 s->vma + s->_raw_size);
102 gdb_flush (gdb_stdout);
103 monitor_printf (current_monitor->load, s->vma);
104 if (current_monitor->loadresp)
105 monitor_expect (current_monitor->loadresp, NULL, 0);
106 xmodem_init_xfer (desc);
107 section_size = bfd_section_size (abfd, s);
108 for (i = 0; i < section_size; i += XMODEM_DATASIZE)
109 {
110 int numbytes;
111 numbytes = min (XMODEM_DATASIZE, section_size - i);
112 bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
113 numbytes);
114 xmodem_send_packet (desc, buffer, numbytes, hashmark);
115 if (hashmark)
116 {
117 putchar_unfiltered ('#');
118 gdb_flush (gdb_stdout);
119 }
120 } /* Per-packet (or S-record) loop */
121 xmodem_finish_xfer (desc);
122 monitor_expect_prompt (NULL, 0);
123 putchar_unfiltered ('\n');
124 } /* Loadable sections */
125 if (hashmark)
126 putchar_unfiltered ('\n');
127}
128
129static void
130sparclet_load (desc, file, hashmark)
131 serial_t desc;
132 char *file;
133 int hashmark;
134{
135???
136}
a7f6f9ed 137#endif /* USE_XMODEM_LOAD */
012be3ce
DP
138
139/* This array of registers need to match the indexes used by GDB.
140 This exists because the various ROM monitors use different strings
141 than does GDB, and don't necessarily support all the registers
142 either. So, typing "info reg sp" becomes a "r30". */
143
144/*PSR 0x00000080 impl ver icc AW LE EE EC EF PIL S PS ET CWP WIM
145 0x0 0x0 0x0 0 0 0 0 0 0x0 1 0 0 0x00 0x2
146 0000010
147 INS LOCALS OUTS GLOBALS
148 0 0x00000000 0x00000000 0x00000000 0x00000000
149 1 0x00000000 0x00000000 0x00000000 0x00000000
150 2 0x00000000 0x00000000 0x00000000 0x00000000
151 3 0x00000000 0x00000000 0x00000000 0x00000000
152 4 0x00000000 0x00000000 0x00000000 0x00000000
153 5 0x00000000 0x00001000 0x00000000 0x00000000
154 6 0x00000000 0x00000000 0x123f0000 0x00000000
155 7 0x00000000 0x00000000 0x00000000 0x00000000
156pc: 0x12010000 0x00000000 unimp
157npc: 0x12010004 0x00001000 unimp 0x1000
158tbr: 0x00000000
159y: 0x00000000
160*/
161/* these correspond to the offsets from tm-* files from config directories */
162
163/* is wim part of psr?? */
164/* monitor wants lower case */
165static char *sparclet_regnames[NUM_REGS] = REGISTER_NAMES;
166
a7f6f9ed
MS
167
168/* Function: sparclet_supply_register
169 Just returns with no action.
170 This function is required, because parse_register_dump (monitor.c)
171 expects to be able to call it. If we don't supply something, it will
172 call a null pointer and core-dump. Since this function does not
173 actually do anything, GDB will request the registers individually. */
174
175static void
176sparclet_supply_register (regname, regnamelen, val, vallen)
177 char *regname;
178 int regnamelen;
179 char *val;
180 int vallen;
181{
182 return;
183}
184
185
186
012be3ce
DP
187/* Define the monitor command strings. Since these are passed directly
188 through to a printf style function, we may include formatting
189 strings. We also need a CR or LF on the end. */
190
191/* need to pause the monitor for timing reasons, so slow it down */
192
193static char *sparclet_inits[] = {"\n\r\r\n", NULL};
194
195static struct monitor_ops sparclet_cmds =
196{
a7f6f9ed
MS
197 MO_CLR_BREAK_USES_ADDR |
198 MO_HEX_PREFIX |
199 MO_NO_ECHO_ON_OPEN |
200 MO_NO_ECHO_ON_SETMEM |
201 MO_RUN_FIRST_TIME |
202 MO_GETMEM_READ_SINGLE, /* flags */
203 sparclet_inits, /* Init strings */
012be3ce
DP
204 "cont\r", /* continue command */
205 "step\r", /* single step */
a7f6f9ed
MS
206 "\r", /* break interrupts the program */
207 "+bp %x\r", /* set a breakpoint */
012be3ce 208 /* can't use "br" because only 2 hw bps are supported */
a7f6f9ed
MS
209 "-bp %x\r", /* clear a breakpoint */
210 "-bp\r", /* clear all breakpoints */
211 "fill %x -n %x -v %x -b\r", /* fill (start length val) */
012be3ce
DP
212 /* can't use "fi" because it takes words, not bytes */
213 {
214 /* ex [addr] [-n count] [-b|-s|-l] default: ex cur -n 1 -b */
a7f6f9ed
MS
215 "ex %x -b\r%x\rq\r", /* setmem.cmdb (addr, value) */
216 "ex %x -s\r%x\rq\r", /* setmem.cmdw (addr, value) */
217 "ex %x -l\r%x\rq\r", /* setmem.cmdl (addr, value) */
012be3ce 218 NULL, /* setmem.cmdll (addr, value) */
a7f6f9ed
MS
219 NULL, /*": " */ /* setmem.resp_delim */
220 NULL, /*"? " */ /* setmem.term */
221 NULL, /*"q\r" */ /* setmem.term_cmd */
012be3ce
DP
222 },
223 {
224 /* since the parsing of multiple bytes is difficult due to
225 interspersed addresses, we'll only read 1 value at a time,
226 even tho these can handle a count */
227 /* we can use -n to set count to read, but may have to parse? */
228 "ex %x -n 1 -b\r", /* getmem.cmdb (addr, #bytes) */
229 "ex %x -n 1 -s\r", /* getmem.cmdw (addr, #swords) */
230 "ex %x -n 1 -l\r", /* getmem.cmdl (addr, #words) */
a7f6f9ed 231 NULL, /* getmem.cmdll (addr, #dwords) */
012be3ce
DP
232 ": ", /* getmem.resp_delim */
233 NULL, /* getmem.term */
234 NULL, /* getmem.term_cmd */
235 },
236 {
237 "reg %s 0x%x\r", /* setreg.cmd (name, value) */
238 NULL, /* setreg.resp_delim */
239 NULL, /* setreg.term */
240 NULL /* setreg.term_cmd */
241 },
242 {
a7f6f9ed
MS
243 "reg %s\r", /* getreg.cmd (name) */
244 " ", /* getreg.resp_delim */
012be3ce
DP
245 NULL, /* getreg.term */
246 NULL, /* getreg.term_cmd */
247 },
248 "reg\r", /* dump_registers */
249 "\\(\\w+\\)=\\([0-9a-fA-F]+\\)", /* register_pattern */
a7f6f9ed 250 sparclet_supply_register, /* supply_register */
012be3ce
DP
251#ifdef USE_GENERIC_LOAD
252 NULL, /* load_routine (defaults to SRECs) */
253 NULL, /* download command */
254 NULL, /* load response */
255#else
a7f6f9ed
MS
256 NULL, /* load_routine (defaults to SRECs) */
257 /* load [c|a] [s | f | r [addr count]] */
258 "load c s\r", /* download command (srecs on console) */
259 "load: ", /* load response */
012be3ce 260#endif
a7f6f9ed 261 "monitor>", /* monitor command prompt */
012be3ce 262 /* yikes! gdb core dumps without this delimitor!! */
a7f6f9ed 263 "\r", /* end-of-command delimitor */
012be3ce 264 NULL, /* optional command terminator */
a7f6f9ed 265 &sparclet_ops, /* target operations */
012be3ce
DP
266 SERIAL_1_STOPBITS, /* number of stop bits */
267 sparclet_regnames, /* registers names */
268 MONITOR_OPS_MAGIC /* magic */
269};
270
271static void
272sparclet_open (args, from_tty)
273 char *args;
274 int from_tty;
275{
276 monitor_open (args, &sparclet_cmds, from_tty);
277}
278
279void
280_initialize_sparclet ()
281{
a7f6f9ed
MS
282 int i;
283
284 for (i = 0; i < NUM_REGS; i++)
285 if (sparclet_regnames[i][0] == 'c' ||
286 sparclet_regnames[i][0] == 'a')
287 sparclet_regnames[i] = 0; /* mon can't report c* or a* regs */
012be3ce 288
a7f6f9ed
MS
289 sparclet_regnames[0] = 0; /* mon won't report %G0 */
290
291 init_monitor_ops (&sparclet_ops);
012be3ce
DP
292 sparclet_ops.to_shortname = "sparclet"; /* for the target command */
293 sparclet_ops.to_longname = "SPARC Sparclet monitor";
294#ifdef USE_GENERIC_LOAD
295 sparclet_ops.to_load = sparclet_load_gen; /* FIXME - should go back and try "do" */
296#endif
297#ifdef USE_SW_BREAKS
298 /* use SW breaks; target only supports 2 HW breakpoints */
299 sparclet_ops.to_insert_breakpoint = memory_insert_breakpoint;
300 sparclet_ops.to_remove_breakpoint = memory_remove_breakpoint;
301#endif
302
303 sparclet_ops.to_doc =
304 "Use a board running the Sparclet debug monitor.\n\
305Specify the serial device it is connected to (e.g. /dev/ttya).";
306
307 sparclet_ops.to_open = sparclet_open;
308 add_target (&sparclet_ops);
309}
310
This page took 0.073114 seconds and 4 git commands to generate.