aboutsummaryrefslogtreecommitdiff
path: root/gdb/w89k-rom.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1995-04-17 06:31:39 +0000
committerStu Grossman <grossman@cygnus>1995-04-17 06:31:39 +0000
commit5de0c6486d2a61d7b3b41a130feb546f936473ee (patch)
treecacd2ebe2e17709e6421a51a8aeb17cf6f05d4bc /gdb/w89k-rom.c
parent9ce0322db8511a64d7a8e44da3fa8e6271b1cb2a (diff)
downloadgdb-5de0c6486d2a61d7b3b41a130feb546f936473ee.zip
gdb-5de0c6486d2a61d7b3b41a130feb546f936473ee.tar.gz
gdb-5de0c6486d2a61d7b3b41a130feb546f936473ee.tar.bz2
* monitor.c: Move all xmodem stuff into xmodem.[ch]. Remove
unnecessary remoteloadprotocol and remoteloadtype support. * (expect expect_prompt): Change names to monitor_expect and monitor_expect_prompt. Make them global. * (printf_monitor): Change name to monitor_printf. Make global. * (monitor_read_memory): Flush command echo to avoid parsing ambiguity with CPU32Bug monitor. * (monitor_load): Remove remoteloadprotocol and remoteloadtype support. Call target_ops->load_routine, default to monitor_load_srec. * (monitor_load_srec): Remove everything but S-record support. * monitor.h (monitor_ops): Add load_routine to provide monitor specific download capability. * remote-est.c: Clean up copyrights and comments. * w89k-rom.c: Use new xmodem support. * xmodem.c xmodem.h: New files to support xmodem downloads. * rom68k-rom.c remote-est.c: Fix copyrights, add load_routine entry to monitor_ops. * cpu32bug-rom.c: New file to support Moto BCC debuggers. * config/m68k/est.mt (TDEPFILES): Add cpu32bug.o. * config/pa/hppapro.mt (TDEPFILES): Add xmodem.o.
Diffstat (limited to 'gdb/w89k-rom.c')
-rw-r--r--gdb/w89k-rom.c84
1 files changed, 81 insertions, 3 deletions
diff --git a/gdb/w89k-rom.c b/gdb/w89k-rom.c
index 5023e31..aedd739 100644
--- a/gdb/w89k-rom.c
+++ b/gdb/w89k-rom.c
@@ -24,6 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "target.h"
#include "monitor.h"
#include "serial.h"
+#include "xmodem.h"
static void w89k_open PARAMS ((char *args, int from_tty));
@@ -154,6 +155,82 @@ w89k_supply_register (regname, regnamelen, val, vallen)
val = monitor_supply_register (regno++, val);
}
+static int hashmark = 1; /* flag set by "set hash" */
+
+extern struct monitor_ops w89k_cmds; /* fwd decl */
+
+static void
+w89k_load (desc, file, hashmark)
+ serial_t desc;
+ char *file;
+ int hashmark;
+{
+ bfd *abfd;
+ asection *s;
+ char *buffer;
+ int i;
+
+ buffer = alloca (XMODEM_PACKETSIZE);
+
+ abfd = bfd_openr (file, 0);
+ if (!abfd)
+ {
+ printf_filtered ("Unable to open file %s\n", file);
+ return;
+ }
+
+ if (bfd_check_format (abfd, bfd_object) == 0)
+ {
+ printf_filtered ("File is not an object file\n");
+ return;
+ }
+
+ for (s = abfd->sections; s; s = s->next)
+ if (s->flags & SEC_LOAD)
+ {
+ bfd_size_type section_size;
+
+ printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
+ s->vma + s->_raw_size);
+ gdb_flush (gdb_stdout);
+
+ monitor_printf (w89k_cmds.load, s->vma);
+ if (w89k_cmds.loadresp)
+ monitor_expect (w89k_cmds.loadresp, NULL, 0);
+
+ xmodem_init_xfer (desc);
+
+ section_size = bfd_section_size (abfd, s);
+
+ for (i = 0; i < section_size; i += XMODEM_DATASIZE)
+ {
+ int numbytes;
+
+ numbytes = min (XMODEM_DATASIZE, section_size - i);
+
+ bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
+ numbytes);
+
+ xmodem_send_packet (desc, buffer, numbytes, hashmark);
+
+ if (hashmark)
+ {
+ putchar_unfiltered ('#');
+ gdb_flush (gdb_stdout);
+ }
+ } /* Per-packet (or S-record) loop */
+
+ xmodem_finish_xfer (desc);
+
+ monitor_expect_prompt (NULL, 0);
+
+ putchar_unfiltered ('\n');
+ } /* Loadable sections */
+
+ if (hashmark)
+ putchar_unfiltered ('\n');
+}
+
/*
* Define the monitor command strings. Since these are passed directly
* through to a printf style function, we need can include formatting
@@ -162,7 +239,7 @@ w89k_supply_register (regname, regnamelen, val, vallen)
static struct target_ops w89k_ops;
-static char *w89k_loadtypes[] = {"srec", NULL};
+static char *w89k_loadtypes[] = {"binary", NULL};
static char *w89k_loadprotos[] = {"xmodem", NULL};
static char *w89k_inits[] = {"\r", NULL};
@@ -211,8 +288,9 @@ static struct monitor_ops w89k_cmds =
"r\r", /* dump_registers */
"\\(\\w+\\)\\( +[0-9a-fA-F]+\\b\\)+",
w89k_supply_register, /* supply_register */
- "u\r", /* download command */
- "u\n\r", /* load response */
+ w89k_load, /* load routine */
+ "u %x\r", /* download command */
+ "\r", /* load response */
"ROM>", /* monitor command prompt */
NULL, /* end-of-command delimitor */
NULL, /* optional command terminator */