Tweak to match output of autoconf 2.9 with same cygnus local patch as
[deliverable/binutils-gdb.git] / gdb / mon960-rom.c
CommitLineData
2e665cd3
DP
1/* Remote target glue for the Intel 960 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 "xmodem.h"
28
29#if !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && !defined (HAVE_SGTTY)
30#define HAVE_SGTTY
31#endif
32
33#ifdef HAVE_SGTTY
34#include <sys/ioctl.h>
35#endif
36
37#include <sys/types.h> /* Needed by file.h on Sys V */
38#include <sys/file.h>
39#include <signal.h>
40#include <sys/stat.h>
41
42#define USE_GENERIC_LOAD
43
44int quiet = 0; /* 1 => stifle unnecessary messages */
45serial_t mon960_serial;
46char *mon960_ttyname; /* name of tty to talk to mon960 on, or null */
47static struct monitor_ops mon960_cmds;
48
49#ifdef USE_GENERIC_LOAD
50extern void generic_load PARAMS ((char* filename, int from_tty));
51#endif
52static void mon960_open PARAMS ((char *args, int from_tty));
53
54#ifdef USE_GENERIC_LOAD
55static void
56mon960_load_gen (filename, from_tty)
57 char *filename;
58 int from_tty;
59{
60 extern int inferior_pid;
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
69#else
70static void
71mon960_load (desc, file, hashmark)
72 serial_t desc;
73 char *file;
74 int hashmark;
75{
76 bfd *abfd;
77 asection *s;
78 char *buffer;
79 int i;
80
81 buffer = alloca (XMODEM_PACKETSIZE);
82 abfd = bfd_openr (file, 0);
83 if (!abfd)
84 {
85 printf_filtered ("Unable to open file %s\n", file);
86 return;
87 }
88 if (bfd_check_format (abfd, bfd_object) == 0)
89 {
90 printf_filtered ("File is not an object file\n");
91 return;
92 }
93 for (s = abfd->sections; s; s = s->next)
94 if (s->flags & SEC_LOAD)
95 {
96 bfd_size_type section_size;
97 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
98 s->vma + s->_raw_size);
99 gdb_flush (gdb_stdout);
100 monitor_printf (mon960_cmds.load, s->vma);
101 if (mon960_cmds.loadresp)
102 monitor_expect (mon960_cmds.loadresp, NULL, 0);
103 xmodem_init_xfer (desc);
104 section_size = bfd_section_size (abfd, s);
105 for (i = 0; i < section_size; i += XMODEM_DATASIZE)
106 {
107 int numbytes;
108 numbytes = min (XMODEM_DATASIZE, section_size - i);
109 bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
110 numbytes);
111 xmodem_send_packet (desc, buffer, numbytes, hashmark);
112 if (hashmark)
113 {
114 putchar_unfiltered ('#');
115 gdb_flush (gdb_stdout);
116 }
117 } /* Per-packet (or S-record) loop */
118 xmodem_finish_xfer (desc);
119 monitor_expect_prompt (NULL, 0);
120 putchar_unfiltered ('\n');
121 } /* Loadable sections */
122 if (hashmark)
123 putchar_unfiltered ('\n');
124}
125#endif
126
127/* This array of registers need to match the indexes used by GDB.
128 This exists because the various ROM monitors use different strings
129 than does GDB, and don't necessarily support all the registers
130 either. So, typing "info reg sp" becomes a "r30". */
131
132/* these correspond to the offsets from tm-* files from config directories */
133/* g0-g14, fp, pfp, sp, rip,r3-15, pc, ac, tc, fp0-3 */
134/* NOTE: "ip" is documented as "ir" in the Mon960 UG. */
135/* NOTE: "ir" can't be accessed... but there's an ip and rip. */
136static char *mon960_regnames[NUM_REGS] = {
137 /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", \
138 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\
139 /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \
140 /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \
141 /* 32 */ "pc", "ac", "tc", "ip", "fp0", "fp1", "fp2", "fp3",\
142 };
143
144/* Define the monitor command strings. Since these are passed directly
145 through to a printf style function, we may include formatting
146 strings. We also need a CR or LF on the end. */
147
148static struct target_ops mon960_ops;
149
150/* need to pause the monitor for timing reasons, so slow it down */
151static char *mon960_inits[] = {"\n\r\r\r\r\r\r\r\r\r\r\r\r\r\r\n\r\n\r\n", NULL}; /* Exits sub-command mode & download cmds */
152
153static struct monitor_ops mon960_cmds =
154{
155 MO_CLR_BREAK_USES_ADDR
156 | MO_NO_ECHO_ON_OPEN
157 | MO_SEND_BREAK_ON_STOP
158 | MO_GETMEM_READ_SINGLE, /* flags */
159 mon960_inits, /* Init strings */
160 "go\n\r", /* continue command */
161 "st\n\r", /* single step */
162 "\n\r", /* break interrupts the program */
163 NULL, /* set a breakpoint */
164 /* can't use "br" because only 2 hw bps are supported */
165 NULL, /* clear a breakpoint - "de" is for hw bps */
166 NULL, /* clear all breakpoints */
167 NULL, /* fill (start end val) */
168 /* can't use "fi" because it takes words, not bytes */
169 {
170 /* can't use "mb", "md" or "mo" because they require interaction */
171 NULL, /* setmem.cmdb (addr, value) */
172 "md %x %x\n\r", /* setmem.cmdw (addr, value) */
173 NULL, /* setmem.cmdl (addr, value) */
174 NULL, /* setmem.cmdll (addr, value) */
175 NULL, /* setmem.resp_delim */
176 NULL, /* setmem.term */
177 NULL, /* setmem.term_cmd */
178 },
179 {
180 /* since the parsing of multiple bytes is difficult due to
181 interspersed addresses, we'll only read 1 value at a time,
182 even tho these can handle a count */
183 "db %x\n\r", /* getmem.cmdb (addr, #bytes) */
184 "ds %x\n\r", /* getmem.cmdw (addr, #swords) */
185 "di %x\n\r", /* getmem.cmdl (addr, #words) */
186 "dd %x\n\r", /* getmem.cmdll (addr, #dwords) */
187 " : ", /* getmem.resp_delim */
188 NULL, /* getmem.term */
189 NULL, /* getmem.term_cmd */
190 },
191 {
192 "md %s %x\n\r", /* setreg.cmd (name, value) */
193 NULL, /* setreg.resp_delim */
194 NULL, /* setreg.term */
195 NULL /* setreg.term_cmd */
196 },
197 {
198 "di %s\n\r", /* getreg.cmd (name) */
199 " : ", /* getreg.resp_delim */
200 NULL, /* getreg.term */
201 NULL, /* getreg.term_cmd */
202 },
203 "re\n\r", /* dump_registers */
204 "\\(\\w+\\)=\\([0-9a-fA-F]+\\)", /* register_pattern */
205 NULL, /* supply_register */
206#ifdef USE_GENERIC_LOAD
207 NULL, /* load_routine (defaults to SRECs) */
208 NULL, /* download command */
209 NULL, /* load response */
210#else
211 mon960_load, /* load_routine (defaults to SRECs) */
212 "do\n\r", /* download command */
213 "Downloading\n\r", /* load response */
214#endif
215 "=>", /* monitor command prompt */
216 "\n\r", /* end-of-command delimitor */
217 NULL, /* optional command terminator */
218 &mon960_ops, /* target operations */
219 SERIAL_1_STOPBITS, /* number of stop bits */
220 mon960_regnames, /* registers names */
221 MONITOR_OPS_MAGIC /* magic */
222};
223
224/* invoked from monitor.c - opens the serial port */
225static void
226mon960_open (args, from_tty)
227 char *args;
228 int from_tty;
229{
230 char *serial_port_name = args;
231 if (args)
232 {
233 char *cursor = serial_port_name = strsave (args);
234
235 while (*cursor && *cursor != ' ')
236 cursor++;
237
238 if (*cursor)
239 *cursor++ = 0;
240
241 while (*cursor == ' ')
242 cursor++;
243
244 }
245 monitor_open (serial_port_name, &mon960_cmds, from_tty);
246}
247
248
249void
250_initialize_mon960 ()
251{
252 init_monitor_ops (&mon960_ops);
253
254 mon960_ops.to_shortname = "mon960"; /* for the target command */
255 mon960_ops.to_longname = "Intel 960 rom monitor";
256#ifdef USE_GENERIC_LOAD
257 mon960_ops.to_load = mon960_load_gen; /* FIXME - should go back and try "do" */
258#endif
259 /* use SW breaks; target only supports 2 HW breakpoints */
260 mon960_ops.to_insert_breakpoint = memory_insert_breakpoint;
261 mon960_ops.to_remove_breakpoint = memory_remove_breakpoint;
262
263 mon960_ops.to_doc =
264 "Debug on an Intel 960 eval board running the Mon960 rom monitor.\n"
265 "Specify the serial device it is connected to (e.g. /dev/ttya).";
266
267 mon960_ops.to_open = mon960_open;
268 add_target (&mon960_ops);
269}
270
This page took 0.03349 seconds and 4 git commands to generate.