2003-07-21 Andrew Cagney <cagney@redhat.com>
[binutils-gdb.git] / gdb / m32r-rom.c
1 /* Remote debugging interface to m32r and mon2000 ROM monitors for GDB,
2 the GNU debugger.
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001
4 Free Software Foundation, Inc.
5
6 Adapted by Michael Snyder of Cygnus Support.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 /* This module defines communication with the Renesas m32r monitor */
26
27 #include "defs.h"
28 #include "gdbcore.h"
29 #include "target.h"
30 #include "monitor.h"
31 #include "serial.h"
32 #include "symtab.h"
33 #include "command.h"
34 #include "gdbcmd.h"
35 #include "symfile.h" /* for generic load */
36 #include <time.h> /* for time_t */
37 #include "gdb_string.h"
38 #include "objfiles.h" /* for ALL_OBJFILES etc. */
39 #include "inferior.h" /* for write_pc() */
40 #include <ctype.h>
41 #include "regcache.h"
42
43 extern void report_transfer_performance (unsigned long, time_t, time_t);
44
45 /*
46 * All this stuff just to get my host computer's IP address!
47 */
48 #include <sys/types.h>
49 #include <netdb.h> /* for hostent */
50 #include <netinet/in.h> /* for struct in_addr */
51 #if 1
52 #include <arpa/inet.h> /* for inet_ntoa */
53 #endif
54
55 static char *board_addr; /* user-settable IP address for M32R-EVA */
56 static char *server_addr; /* user-settable IP address for gdb host */
57 static char *download_path; /* user-settable path for SREC files */
58
59
60 /* REGNUM */
61 #define PSW_REGNUM 16
62 #define SPI_REGNUM 18
63 #define SPU_REGNUM 19
64 #define ACCL_REGNUM 22
65 #define ACCH_REGNUM 23
66
67
68 /*
69 * Function: m32r_load_1 (helper function)
70 */
71
72 static void
73 m32r_load_section (bfd *abfd, asection *s, void *obj)
74 {
75 unsigned int *data_count = obj;
76 if (s->flags & SEC_LOAD)
77 {
78 bfd_size_type section_size = bfd_section_size (abfd, s);
79 bfd_vma section_base = bfd_section_lma (abfd, s);
80 unsigned int buffer, i;
81
82 *data_count += section_size;
83
84 printf_filtered ("Loading section %s, size 0x%lx lma ",
85 bfd_section_name (abfd, s), section_size);
86 print_address_numeric (section_base, 1, gdb_stdout);
87 printf_filtered ("\n");
88 gdb_flush (gdb_stdout);
89 monitor_printf ("%s mw\r", paddr_nz (section_base));
90 for (i = 0; i < section_size; i += 4)
91 {
92 QUIT;
93 monitor_expect (" -> ", NULL, 0);
94 bfd_get_section_contents (abfd, s, (char *) &buffer, i, 4);
95 monitor_printf ("%x\n", buffer);
96 }
97 monitor_expect (" -> ", NULL, 0);
98 monitor_printf ("q\n");
99 monitor_expect_prompt (NULL, 0);
100 }
101 }
102
103 static int
104 m32r_load_1 (void *dummy)
105 {
106 int data_count = 0;
107
108 bfd_map_over_sections ((bfd *) dummy, m32r_load_section, &data_count);
109 return data_count;
110 }
111
112 /*
113 * Function: m32r_load (an alternate way to load)
114 */
115
116 static void
117 m32r_load (char *filename, int from_tty)
118 {
119 bfd *abfd;
120 asection *s;
121 unsigned int i, data_count = 0;
122 time_t start_time, end_time; /* for timing of download */
123
124 if (filename == NULL || filename[0] == 0)
125 filename = get_exec_file (1);
126
127 abfd = bfd_openr (filename, 0);
128 if (!abfd)
129 error ("Unable to open file %s\n", filename);
130 if (bfd_check_format (abfd, bfd_object) == 0)
131 error ("File is not an object file\n");
132 start_time = time (NULL);
133 #if 0
134 for (s = abfd->sections; s; s = s->next)
135 if (s->flags & SEC_LOAD)
136 {
137 bfd_size_type section_size = bfd_section_size (abfd, s);
138 bfd_vma section_base = bfd_section_vma (abfd, s);
139 unsigned int buffer;
140
141 data_count += section_size;
142
143 printf_filtered ("Loading section %s, size 0x%lx vma ",
144 bfd_section_name (abfd, s), section_size);
145 print_address_numeric (section_base, 1, gdb_stdout);
146 printf_filtered ("\n");
147 gdb_flush (gdb_stdout);
148 monitor_printf ("%x mw\r", section_base);
149 for (i = 0; i < section_size; i += 4)
150 {
151 monitor_expect (" -> ", NULL, 0);
152 bfd_get_section_contents (abfd, s, (char *) &buffer, i, 4);
153 monitor_printf ("%x\n", buffer);
154 }
155 monitor_expect (" -> ", NULL, 0);
156 monitor_printf ("q\n");
157 monitor_expect_prompt (NULL, 0);
158 }
159 #else
160 if (!(catch_errors (m32r_load_1, abfd, "Load aborted!\n", RETURN_MASK_ALL)))
161 {
162 monitor_printf ("q\n");
163 return;
164 }
165 #endif
166 end_time = time (NULL);
167 printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd));
168 report_transfer_performance (data_count, start_time, end_time);
169
170 /* Finally, make the PC point at the start address */
171 if (exec_bfd)
172 write_pc (bfd_get_start_address (exec_bfd));
173
174 inferior_ptid = null_ptid; /* No process now */
175
176 /* This is necessary because many things were based on the PC at the
177 time that we attached to the monitor, which is no longer valid
178 now that we have loaded new code (and just changed the PC).
179 Another way to do this might be to call normal_stop, except that
180 the stack may not be valid, and things would get horribly
181 confused... */
182
183 clear_symtab_users ();
184 }
185
186 static void
187 m32r_load_gen (char *filename, int from_tty)
188 {
189 generic_load (filename, from_tty);
190 }
191
192 static void m32r_open (char *args, int from_tty);
193 static void mon2000_open (char *args, int from_tty);
194
195 /* This array of registers needs to match the indexes used by GDB. The
196 whole reason this exists is because the various ROM monitors use
197 different names than GDB does, and don't support all the registers
198 either. So, typing "info reg sp" becomes an "A7". */
199
200 static char *m32r_regnames[] =
201 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
202 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
203 "psw", "cbr", "spi", "spu", "bpc", "pc", "accl", "acch",
204 };
205
206 static void
207 m32r_supply_register (char *regname, int regnamelen, char *val, int vallen)
208 {
209 int regno;
210 int num_regs = sizeof (m32r_regnames) / sizeof (m32r_regnames[0]);
211
212 for (regno = 0; regno < num_regs; regno++)
213 if (strncmp (regname, m32r_regnames[regno], regnamelen) == 0)
214 break;
215
216 if (regno >= num_regs)
217 return; /* no match */
218
219 if (regno == ACCL_REGNUM)
220 { /* special handling for 64-bit acc reg */
221 monitor_supply_register (ACCH_REGNUM, val);
222 val = strchr (val, ':'); /* skip past ':' to get 2nd word */
223 if (val != NULL)
224 monitor_supply_register (ACCL_REGNUM, val + 1);
225 }
226 else
227 {
228 monitor_supply_register (regno, val);
229 if (regno == PSW_REGNUM)
230 {
231 unsigned long psw = strtoul (val, NULL, 16);
232 char *zero = "00000000", *one = "00000001";
233
234 #ifdef SM_REGNUM
235 /* Stack mode bit */
236 monitor_supply_register (SM_REGNUM, (psw & 0x80) ? one : zero);
237 #endif
238 #ifdef BSM_REGNUM
239 /* Backup stack mode bit */
240 monitor_supply_register (BSM_REGNUM, (psw & 0x8000) ? one : zero);
241 #endif
242 #ifdef IE_REGNUM
243 /* Interrupt enable bit */
244 monitor_supply_register (IE_REGNUM, (psw & 0x40) ? one : zero);
245 #endif
246 #ifdef BIE_REGNUM
247 /* Backup interrupt enable bit */
248 monitor_supply_register (BIE_REGNUM, (psw & 0x4000) ? one : zero);
249 #endif
250 #ifdef COND_REGNUM
251 /* Condition bit (carry etc.) */
252 monitor_supply_register (COND_REGNUM, (psw & 0x1) ? one : zero);
253 #endif
254 #ifdef CBR_REGNUM
255 monitor_supply_register (CBR_REGNUM, (psw & 0x1) ? one : zero);
256 #endif
257 #ifdef BPC_REGNUM
258 monitor_supply_register (BPC_REGNUM, zero); /* KLUDGE: (???????) */
259 #endif
260 #ifdef BCARRY_REGNUM
261 monitor_supply_register (BCARRY_REGNUM, zero); /* KLUDGE: (??????) */
262 #endif
263 }
264
265 if (regno == SPI_REGNUM || regno == SPU_REGNUM)
266 { /* special handling for stack pointer (spu or spi) */
267 unsigned long stackmode = read_register (PSW_REGNUM) & 0x80;
268
269 if (regno == SPI_REGNUM && !stackmode) /* SP == SPI */
270 monitor_supply_register (SP_REGNUM, val);
271 else if (regno == SPU_REGNUM && stackmode) /* SP == SPU */
272 monitor_supply_register (SP_REGNUM, val);
273 }
274 }
275 }
276
277 /* m32r RevC board monitor */
278
279 static struct target_ops m32r_ops;
280
281 static char *m32r_inits[] = { "\r", NULL };
282
283 static struct monitor_ops m32r_cmds;
284
285 static void
286 init_m32r_cmds (void)
287 {
288 m32r_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_REGISTER_VALUE_FIRST;
289 m32r_cmds.init = m32r_inits; /* Init strings */
290 m32r_cmds.cont = "go\r"; /* continue command */
291 m32r_cmds.step = "step\r"; /* single step */
292 m32r_cmds.stop = NULL; /* interrupt command */
293 m32r_cmds.set_break = "%x +bp\r"; /* set a breakpoint */
294 m32r_cmds.clr_break = "%x -bp\r"; /* clear a breakpoint */
295 m32r_cmds.clr_all_break = "bpoff\r"; /* clear all breakpoints */
296 m32r_cmds.fill = "%x %x %x fill\r"; /* fill (start length val) */
297 m32r_cmds.setmem.cmdb = "%x 1 %x fill\r"; /* setmem.cmdb (addr, value) */
298 m32r_cmds.setmem.cmdw = "%x 1 %x fillh\r"; /* setmem.cmdw (addr, value) */
299 m32r_cmds.setmem.cmdl = "%x 1 %x fillw\r"; /* setmem.cmdl (addr, value) */
300 m32r_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
301 m32r_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
302 m32r_cmds.setmem.term = NULL; /* setmem.term */
303 m32r_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
304 m32r_cmds.getmem.cmdb = "%x %x dump\r"; /* getmem.cmdb (addr, len) */
305 m32r_cmds.getmem.cmdw = NULL; /* getmem.cmdw (addr, len) */
306 m32r_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, len) */
307 m32r_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
308 m32r_cmds.getmem.resp_delim = ": "; /* getmem.resp_delim */
309 m32r_cmds.getmem.term = NULL; /* getmem.term */
310 m32r_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
311 m32r_cmds.setreg.cmd = "%x to %%%s\r"; /* setreg.cmd (name, value) */
312 m32r_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
313 m32r_cmds.setreg.term = NULL; /* setreg.term */
314 m32r_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
315 m32r_cmds.getreg.cmd = NULL; /* getreg.cmd (name) */
316 m32r_cmds.getreg.resp_delim = NULL; /* getreg.resp_delim */
317 m32r_cmds.getreg.term = NULL; /* getreg.term */
318 m32r_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
319 m32r_cmds.dump_registers = ".reg\r"; /* dump_registers */
320 m32r_cmds.register_pattern = "\\(\\w+\\) += \\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
321 m32r_cmds.supply_register = m32r_supply_register; /* supply_register */
322 m32r_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
323 m32r_cmds.load = NULL; /* download command */
324 m32r_cmds.loadresp = NULL; /* load response */
325 m32r_cmds.prompt = "ok "; /* monitor command prompt */
326 m32r_cmds.line_term = "\r"; /* end-of-line terminator */
327 m32r_cmds.cmd_end = NULL; /* optional command terminator */
328 m32r_cmds.target = &m32r_ops; /* target operations */
329 m32r_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
330 m32r_cmds.regnames = m32r_regnames; /* registers names */
331 m32r_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
332 } /* init_m32r_cmds */
333
334 static void
335 m32r_open (char *args, int from_tty)
336 {
337 monitor_open (args, &m32r_cmds, from_tty);
338 }
339
340 /* Mon2000 monitor (MSA2000 board) */
341
342 static struct target_ops mon2000_ops;
343 static struct monitor_ops mon2000_cmds;
344
345 static void
346 init_mon2000_cmds (void)
347 {
348 mon2000_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_REGISTER_VALUE_FIRST;
349 mon2000_cmds.init = m32r_inits; /* Init strings */
350 mon2000_cmds.cont = "go\r"; /* continue command */
351 mon2000_cmds.step = "step\r"; /* single step */
352 mon2000_cmds.stop = NULL; /* interrupt command */
353 mon2000_cmds.set_break = "%x +bp\r"; /* set a breakpoint */
354 mon2000_cmds.clr_break = "%x -bp\r"; /* clear a breakpoint */
355 mon2000_cmds.clr_all_break = "bpoff\r"; /* clear all breakpoints */
356 mon2000_cmds.fill = "%x %x %x fill\r"; /* fill (start length val) */
357 mon2000_cmds.setmem.cmdb = "%x 1 %x fill\r"; /* setmem.cmdb (addr, value) */
358 mon2000_cmds.setmem.cmdw = "%x 1 %x fillh\r"; /* setmem.cmdw (addr, value) */
359 mon2000_cmds.setmem.cmdl = "%x 1 %x fillw\r"; /* setmem.cmdl (addr, value) */
360 mon2000_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
361 mon2000_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
362 mon2000_cmds.setmem.term = NULL; /* setmem.term */
363 mon2000_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
364 mon2000_cmds.getmem.cmdb = "%x %x dump\r"; /* getmem.cmdb (addr, len) */
365 mon2000_cmds.getmem.cmdw = NULL; /* getmem.cmdw (addr, len) */
366 mon2000_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, len) */
367 mon2000_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
368 mon2000_cmds.getmem.resp_delim = ": "; /* getmem.resp_delim */
369 mon2000_cmds.getmem.term = NULL; /* getmem.term */
370 mon2000_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
371 mon2000_cmds.setreg.cmd = "%x to %%%s\r"; /* setreg.cmd (name, value) */
372 mon2000_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
373 mon2000_cmds.setreg.term = NULL; /* setreg.term */
374 mon2000_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
375 mon2000_cmds.getreg.cmd = NULL; /* getreg.cmd (name) */
376 mon2000_cmds.getreg.resp_delim = NULL; /* getreg.resp_delim */
377 mon2000_cmds.getreg.term = NULL; /* getreg.term */
378 mon2000_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
379 mon2000_cmds.dump_registers = ".reg\r"; /* dump_registers */
380 mon2000_cmds.register_pattern = "\\(\\w+\\) += \\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
381 mon2000_cmds.supply_register = m32r_supply_register; /* supply_register */
382 mon2000_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
383 mon2000_cmds.load = NULL; /* download command */
384 mon2000_cmds.loadresp = NULL; /* load response */
385 mon2000_cmds.prompt = "Mon2000>"; /* monitor command prompt */
386 mon2000_cmds.line_term = "\r"; /* end-of-line terminator */
387 mon2000_cmds.cmd_end = NULL; /* optional command terminator */
388 mon2000_cmds.target = &mon2000_ops; /* target operations */
389 mon2000_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
390 mon2000_cmds.regnames = m32r_regnames; /* registers names */
391 mon2000_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
392 } /* init_mon2000_cmds */
393
394 static void
395 mon2000_open (char *args, int from_tty)
396 {
397 monitor_open (args, &mon2000_cmds, from_tty);
398 }
399
400 /* Function: set_board_address
401 Tell the BootOne monitor what it's ethernet IP address is. */
402
403 static void
404 m32r_set_board_address (char *args, int from_tty)
405 {
406 int resp_len;
407 char buf[1024];
408
409 if (args && *args)
410 {
411 monitor_printf ("ulip %s\n", args);
412 resp_len = monitor_expect_prompt (buf, sizeof (buf));
413 /* now parse the result for success */
414 }
415 else
416 error ("Requires argument (IP address for M32R-EVA board)");
417 }
418
419 /* Function: set_server_address
420 Tell the BootOne monitor what gdb's ethernet IP address is. */
421
422 static void
423 m32r_set_server_address (char *args, int from_tty)
424 {
425 int resp_len;
426 char buf[1024];
427
428 if (args && *args)
429 {
430 monitor_printf ("uhip %s\n", args);
431 resp_len = monitor_expect_prompt (buf, sizeof (buf));
432 /* now parse the result for success */
433 }
434 else
435 error ("Requires argument (IP address of GDB's host computer)");
436 }
437
438 /* Function: set_download_path
439 Tell the BootOne monitor the default path for downloadable SREC files. */
440
441 static void
442 m32r_set_download_path (char *args, int from_tty)
443 {
444 int resp_len;
445 char buf[1024];
446
447 if (args && *args)
448 {
449 monitor_printf ("up %s\n", args);
450 resp_len = monitor_expect_prompt (buf, sizeof (buf));
451 /* now parse the result for success */
452 }
453 else
454 error ("Requires argument (default path for downloadable SREC files)");
455 }
456
457 static void
458 m32r_upload_command (char *args, int from_tty)
459 {
460 bfd *abfd;
461 asection *s;
462 time_t start_time, end_time; /* for timing of download */
463 int resp_len, data_count = 0;
464 char buf[1024];
465 struct hostent *hostent;
466 struct in_addr inet_addr;
467
468 /* first check to see if there's an ethernet port! */
469 monitor_printf ("ust\r");
470 resp_len = monitor_expect_prompt (buf, sizeof (buf));
471 if (!strchr (buf, ':'))
472 error ("No ethernet connection!");
473
474 if (board_addr == 0)
475 {
476 /* scan second colon in the output from the "ust" command */
477 char *myIPaddress = strchr (strchr (buf, ':') + 1, ':') + 1;
478
479 while (isspace (*myIPaddress))
480 myIPaddress++;
481
482 if (!strncmp (myIPaddress, "0.0.", 4)) /* empty */
483 error
484 ("Please use 'set board-address' to set the M32R-EVA board's IP address.");
485 if (strchr (myIPaddress, '('))
486 *(strchr (myIPaddress, '(')) = '\0'; /* delete trailing junk */
487 board_addr = xstrdup (myIPaddress);
488 }
489 if (server_addr == 0)
490 {
491 buf[0] = 0;
492 gethostname (buf, sizeof (buf));
493 if (buf[0] != 0)
494 hostent = gethostbyname (buf);
495 if (hostent != 0)
496 {
497 #if 1
498 memcpy (&inet_addr.s_addr, hostent->h_addr,
499 sizeof (inet_addr.s_addr));
500 server_addr = (char *) inet_ntoa (inet_addr);
501 #else
502 server_addr = (char *) inet_ntoa (hostent->h_addr);
503 #endif
504 }
505 if (server_addr == 0) /* failed? */
506 error
507 ("Need to know gdb host computer's IP address (use 'set server-address')");
508 }
509
510 if (args == 0 || args[0] == 0) /* no args: upload the current file */
511 args = get_exec_file (1);
512
513 if (args[0] != '/' && download_path == 0)
514 {
515 if (current_directory)
516 download_path = xstrdup (current_directory);
517 else
518 error
519 ("Need to know default download path (use 'set download-path')");
520 }
521
522 start_time = time (NULL);
523 monitor_printf ("uhip %s\r", server_addr);
524 resp_len = monitor_expect_prompt (buf, sizeof (buf)); /* parse result? */
525 monitor_printf ("ulip %s\r", board_addr);
526 resp_len = monitor_expect_prompt (buf, sizeof (buf)); /* parse result? */
527 if (args[0] != '/')
528 monitor_printf ("up %s\r", download_path); /* use default path */
529 else
530 monitor_printf ("up\r"); /* rooted filename/path */
531 resp_len = monitor_expect_prompt (buf, sizeof (buf)); /* parse result? */
532
533 if (strrchr (args, '.') && !strcmp (strrchr (args, '.'), ".srec"))
534 monitor_printf ("ul %s\r", args);
535 else /* add ".srec" suffix */
536 monitor_printf ("ul %s.srec\r", args);
537 resp_len = monitor_expect_prompt (buf, sizeof (buf)); /* parse result? */
538
539 if (buf[0] == 0 || strstr (buf, "complete") == 0)
540 error
541 ("Upload file not found: %s.srec\nCheck IP addresses and download path.",
542 args);
543 else
544 printf_filtered (" -- Ethernet load complete.\n");
545
546 end_time = time (NULL);
547 abfd = bfd_openr (args, 0);
548 if (abfd != NULL)
549 { /* Download is done -- print section statistics */
550 if (bfd_check_format (abfd, bfd_object) == 0)
551 {
552 printf_filtered ("File is not an object file\n");
553 }
554 for (s = abfd->sections; s; s = s->next)
555 if (s->flags & SEC_LOAD)
556 {
557 bfd_size_type section_size = bfd_section_size (abfd, s);
558 bfd_vma section_base = bfd_section_lma (abfd, s);
559 unsigned int buffer;
560
561 data_count += section_size;
562
563 printf_filtered ("Loading section %s, size 0x%lx lma ",
564 bfd_section_name (abfd, s), section_size);
565 print_address_numeric (section_base, 1, gdb_stdout);
566 printf_filtered ("\n");
567 gdb_flush (gdb_stdout);
568 }
569 /* Finally, make the PC point at the start address */
570 write_pc (bfd_get_start_address (abfd));
571 report_transfer_performance (data_count, start_time, end_time);
572 printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd));
573 }
574 inferior_ptid = null_ptid; /* No process now */
575
576 /* This is necessary because many things were based on the PC at the
577 time that we attached to the monitor, which is no longer valid
578 now that we have loaded new code (and just changed the PC).
579 Another way to do this might be to call normal_stop, except that
580 the stack may not be valid, and things would get horribly
581 confused... */
582
583 clear_symtab_users ();
584 }
585
586 void
587 _initialize_m32r_rom (void)
588 {
589 /* Initialize m32r RevC monitor target */
590 init_m32r_cmds ();
591 init_monitor_ops (&m32r_ops);
592
593 m32r_ops.to_shortname = "m32r";
594 m32r_ops.to_longname = "m32r monitor";
595 m32r_ops.to_load = m32r_load_gen; /* monitor lacks a download command */
596 m32r_ops.to_doc = "Debug via the m32r monitor.\n\
597 Specify the serial device it is connected to (e.g. /dev/ttya).";
598 m32r_ops.to_open = m32r_open;
599 add_target (&m32r_ops);
600
601 /* Initialize mon2000 monitor target */
602 init_mon2000_cmds ();
603 init_monitor_ops (&mon2000_ops);
604
605 mon2000_ops.to_shortname = "mon2000";
606 mon2000_ops.to_longname = "Mon2000 monitor";
607 mon2000_ops.to_load = m32r_load_gen; /* monitor lacks a download command */
608 mon2000_ops.to_doc = "Debug via the Mon2000 monitor.\n\
609 Specify the serial device it is connected to (e.g. /dev/ttya).";
610 mon2000_ops.to_open = mon2000_open;
611 add_target (&mon2000_ops);
612
613 add_show_from_set
614 (add_set_cmd ("download-path", class_obscure, var_string,
615 (char *) &download_path,
616 "Set the default path for downloadable SREC files.",
617 &setlist), &showlist);
618
619 add_show_from_set
620 (add_set_cmd ("board-address", class_obscure, var_string,
621 (char *) &board_addr,
622 "Set IP address for M32R-EVA target board.",
623 &setlist), &showlist);
624
625 add_show_from_set
626 (add_set_cmd ("server-address", class_obscure, var_string,
627 (char *) &server_addr,
628 "Set IP address for download server (GDB's host computer).",
629 &setlist), &showlist);
630
631 add_com ("upload", class_obscure, m32r_upload_command,
632 "Upload the srec file via the monitor's Ethernet upload capability.");
633
634 add_com ("tload", class_obscure, m32r_load, "test upload command.");
635 }