* dwarf2read.c (read_tag_const_type, read_tag_volatile_type):
[deliverable/binutils-gdb.git] / gdb / mon960-rom.c
CommitLineData
c906108c
SS
1/* Remote target glue for the Intel 960 MON960 ROM monitor.
2 Copyright 1995, 1996 Free Software Foundation, Inc.
3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
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.
c906108c 10
c5aa993b
JM
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.
c906108c 15
c5aa993b
JM
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,
19 Boston, MA 02111-1307, USA. */
c906108c
SS
20
21
22#include "defs.h"
23#include "gdbcore.h"
24#include "target.h"
25#include "monitor.h"
26#include "serial.h"
27#include "srec.h"
28#include "xmodem.h"
29#include "symtab.h"
c5aa993b 30#include "symfile.h" /* for generic_load */
d4f3574e 31#include "inferior.h" /* for write_pc() */
c906108c
SS
32
33#define USE_GENERIC_LOAD
34
35static struct target_ops mon960_ops;
36
a14ed312 37static void mon960_open (char *args, int from_tty);
c906108c
SS
38
39#ifdef USE_GENERIC_LOAD
40
41static void
fba45db2 42mon960_load_gen (char *filename, int from_tty)
c906108c
SS
43{
44 extern int inferior_pid;
45
46 generic_load (filename, from_tty);
47 /* Finally, make the PC point at the start address */
48 if (exec_bfd)
49 write_pc (bfd_get_start_address (exec_bfd));
50
c5aa993b 51 inferior_pid = 0; /* No process now */
c906108c
SS
52}
53
54#else
55
56static void
fba45db2 57mon960_load (serial_t desc, char *file, int hashmark)
c906108c
SS
58{
59 bfd *abfd;
60 asection *s;
61 char *buffer;
62 int i;
63
64 buffer = alloca (XMODEM_PACKETSIZE);
65 abfd = bfd_openr (file, 0);
66 if (!abfd)
67 {
68 printf_filtered ("Unable to open file %s\n", file);
69 return;
70 }
71 if (bfd_check_format (abfd, bfd_object) == 0)
72 {
73 printf_filtered ("File is not an object file\n");
74 return;
75 }
76 for (s = abfd->sections; s; s = s->next)
77 if (s->flags & SEC_LOAD)
78 {
79 bfd_size_type section_size;
80 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
81 s->vma + s->_raw_size);
82 gdb_flush (gdb_stdout);
83 monitor_printf (current_monitor->load, s->vma);
84 if (current_monitor->loadresp)
85 monitor_expect (current_monitor->loadresp, NULL, 0);
86 xmodem_init_xfer (desc);
87 section_size = bfd_section_size (abfd, s);
88 for (i = 0; i < section_size; i += XMODEM_DATASIZE)
89 {
90 int numbytes;
91 numbytes = min (XMODEM_DATASIZE, section_size - i);
92 bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
93 numbytes);
94 xmodem_send_packet (desc, buffer, numbytes, hashmark);
95 if (hashmark)
96 {
97 putchar_unfiltered ('#');
98 gdb_flush (gdb_stdout);
99 }
100 } /* Per-packet (or S-record) loop */
101 xmodem_finish_xfer (desc);
102 monitor_expect_prompt (NULL, 0);
103 putchar_unfiltered ('\n');
104 } /* Loadable sections */
c5aa993b 105 if (hashmark)
c906108c
SS
106 putchar_unfiltered ('\n');
107}
108
109#endif /* USE_GENERIC_LOAD */
110
111/* This array of registers need to match the indexes used by GDB.
112 This exists because the various ROM monitors use different strings
113 than does GDB, and don't necessarily support all the registers
114 either. So, typing "info reg sp" becomes a "r30". */
115
116/* these correspond to the offsets from tm-* files from config directories */
c5aa993b 117/* g0-g14, fp, pfp, sp, rip,r3-15, pc, ac, tc, fp0-3 */
c906108c
SS
118/* NOTE: "ip" is documented as "ir" in the Mon960 UG. */
119/* NOTE: "ir" can't be accessed... but there's an ip and rip. */
c5aa993b
JM
120static char *full_regnames[NUM_REGS] =
121{
122 /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7",
123 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
124 /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
125 /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp",
126 /* 32 */ "pc", "ac", "tc", "ip", "fp0", "fp1", "fp2", "fp3",
127};
c906108c
SS
128
129static char *mon960_regnames[NUM_REGS];
130
131/* Define the monitor command strings. Since these are passed directly
132 through to a printf style function, we may include formatting
133 strings. We also need a CR or LF on the end. */
134
135/* need to pause the monitor for timing reasons, so slow it down */
136
137#if 0
138/* FIXME: this extremely long init string causes MON960 to return two NAKS
139 instead of performing the autobaud recognition, at least when gdb
140 is running on GNU/Linux. The short string below works on Linux, and on
141 SunOS using a tcp serial connection. Must retest on SunOS using a
142 direct serial connection; if that works, get rid of the long string. */
c5aa993b
JM
143static char *mon960_inits[] =
144{"\n\r\r\r\r\r\r\r\r\r\r\r\r\r\r\n\r\n\r\n", NULL};
c906108c 145#else
c5aa993b
JM
146static char *mon960_inits[] =
147{"\r", NULL};
c906108c
SS
148#endif
149
c5aa993b 150static struct monitor_ops mon960_cmds;
c906108c 151
c5aa993b 152static void
c906108c
SS
153init_mon960_cmds (void)
154{
c5aa993b
JM
155 mon960_cmds.flags = MO_CLR_BREAK_USES_ADDR
156 | MO_NO_ECHO_ON_OPEN | MO_SEND_BREAK_ON_STOP | MO_GETMEM_READ_SINGLE; /* flags */
157 mon960_cmds.init = mon960_inits; /* Init strings */
158 mon960_cmds.cont = "go\n\r"; /* continue command */
159 mon960_cmds.step = "st\n\r"; /* single step */
160 mon960_cmds.stop = NULL; /* break interrupts the program */
161 mon960_cmds.set_break = NULL; /* set a breakpoint */
162 mon960_cmds.clr_break = /* can't use "br" because only 2 hw bps are supported */
163 mon960_cmds.clr_all_break = NULL; /* clear a breakpoint - "de" is for hw bps */
c906108c 164 NULL, /* clear all breakpoints */
c5aa993b 165 mon960_cmds.fill = NULL; /* fill (start end val) */
c906108c
SS
166 /* can't use "fi" because it takes words, not bytes */
167 /* can't use "mb", "md" or "mo" because they require interaction */
c5aa993b
JM
168 mon960_cmds.setmem.cmdb = NULL; /* setmem.cmdb (addr, value) */
169 mon960_cmds.setmem.cmdw = NULL; /* setmem.cmdw (addr, value) */
170 mon960_cmds.setmem.cmdl = "md %x %x\n\r"; /* setmem.cmdl (addr, value) */
171 mon960_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
172 mon960_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
173 mon960_cmds.setmem.term = NULL; /* setmem.term */
174 mon960_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
c906108c
SS
175 /* since the parsing of multiple bytes is difficult due to
176 interspersed addresses, we'll only read 1 value at a time,
177 even tho these can handle a count */
c5aa993b
JM
178 mon960_cmds.getmem.cmdb = "db %x\n\r"; /* getmem.cmdb (addr, #bytes) */
179 mon960_cmds.getmem.cmdw = "ds %x\n\r"; /* getmem.cmdw (addr, #swords) */
180 mon960_cmds.getmem.cmdl = "di %x\n\r"; /* getmem.cmdl (addr, #words) */
181 mon960_cmds.getmem.cmdll = "dd %x\n\r"; /* getmem.cmdll (addr, #dwords) */
182 mon960_cmds.getmem.resp_delim = " : "; /* getmem.resp_delim */
183 mon960_cmds.getmem.term = NULL; /* getmem.term */
184 mon960_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
185 mon960_cmds.setreg.cmd = "md %s %x\n\r"; /* setreg.cmd (name, value) */
186 mon960_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
187 mon960_cmds.setreg.term = NULL; /* setreg.term */
188 mon960_cmds.setreg.term_cmd = NULL, /* setreg.term_cmd */
189 mon960_cmds.getreg.cmd = "di %s\n\r"; /* getreg.cmd (name) */
190 mon960_cmds.getreg.resp_delim = " : "; /* getreg.resp_delim */
191 mon960_cmds.getreg.term = NULL; /* getreg.term */
192 mon960_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
193 mon960_cmds.dump_registers = "re\n\r"; /* dump_registers */
194 mon960_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */
195 mon960_cmds.supply_register = NULL; /* supply_register */
c906108c 196#ifdef USE_GENERIC_LOAD
c5aa993b
JM
197 mon960_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
198 mon960_cmds.load = NULL; /* download command */
199 mon960_cmds.loadresp = NULL; /* load response */
c906108c 200#else
c5aa993b
JM
201 mon960_cmds.load_routine = mon960_load; /* load_routine (defaults to SRECs) */
202 mon960_cmds.load = "do\n\r"; /* download command */
203 mon960_cmds.loadresp = "Downloading\n\r"; /* load response */
c906108c 204#endif
c5aa993b
JM
205 mon960_cmds.prompt = "=>"; /* monitor command prompt */
206 mon960_cmds.line_term = "\n\r"; /* end-of-command delimitor */
207 mon960_cmds.cmd_end = NULL; /* optional command terminator */
208 mon960_cmds.target = &mon960_ops; /* target operations */
209 mon960_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
210 mon960_cmds.regnames = mon960_regnames; /* registers names */
c906108c
SS
211 mon960_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
212};
213
214static void
fba45db2 215mon960_open (char *args, int from_tty)
c906108c
SS
216{
217 char buf[64];
218
219 monitor_open (args, &mon960_cmds, from_tty);
220
221 /* Attempt to fetch the value of the first floating point register (fp0).
222 If the monitor returns a string containing the word "Bad" we'll assume
223 this processor has no floating point registers, and nullify the
224 regnames entries that refer to FP registers. */
225
c5aa993b
JM
226 monitor_printf (mon960_cmds.getreg.cmd, full_regnames[FP0_REGNUM]); /* di fp0 */
227 if (monitor_expect_prompt (buf, sizeof (buf)) != -1)
228 if (strstr (buf, "Bad") != NULL)
c906108c
SS
229 {
230 int i;
231
232 for (i = FP0_REGNUM; i < FP0_REGNUM + 4; i++)
c5aa993b 233 mon960_regnames[i] = NULL;
c906108c
SS
234 }
235}
236
237void
fba45db2 238_initialize_mon960 (void)
c906108c 239{
c5aa993b 240 memcpy (mon960_regnames, full_regnames, sizeof (full_regnames));
c906108c
SS
241
242 init_mon960_cmds ();
243
244 init_monitor_ops (&mon960_ops);
245
c5aa993b 246 mon960_ops.to_shortname = "mon960"; /* for the target command */
c906108c
SS
247 mon960_ops.to_longname = "Intel 960 MON960 monitor";
248#ifdef USE_GENERIC_LOAD
c5aa993b 249 mon960_ops.to_load = mon960_load_gen; /* FIXME - should go back and try "do" */
c906108c
SS
250#endif
251 /* use SW breaks; target only supports 2 HW breakpoints */
c5aa993b
JM
252 mon960_ops.to_insert_breakpoint = memory_insert_breakpoint;
253 mon960_ops.to_remove_breakpoint = memory_remove_breakpoint;
c906108c 254
c5aa993b 255 mon960_ops.to_doc =
c906108c
SS
256 "Use an Intel 960 board running the MON960 debug monitor.\n\
257Specify the serial device it is connected to (e.g. /dev/ttya).";
258
259 mon960_ops.to_open = mon960_open;
260 add_target (&mon960_ops);
261}
This page took 0.094361 seconds and 4 git commands to generate.