1 // OBSOLETE /* Remote debugging interface for Motorola's MVME187BUG monitor, an embedded
2 // OBSOLETE monitor for the m88k.
4 // OBSOLETE Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
5 // OBSOLETE 2002 Free Software Foundation, Inc.
7 // OBSOLETE Contributed by Cygnus Support. Written by K. Richard Pixley.
9 // OBSOLETE This file is part of GDB.
11 // OBSOLETE This program is free software; you can redistribute it and/or modify
12 // OBSOLETE it under the terms of the GNU General Public License as published by
13 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
14 // OBSOLETE (at your option) any later version.
16 // OBSOLETE This program is distributed in the hope that it will be useful,
17 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // OBSOLETE GNU General Public License for more details.
21 // OBSOLETE You should have received a copy of the GNU General Public License
22 // OBSOLETE along with this program; if not, write to the Free Software
23 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
24 // OBSOLETE Boston, MA 02111-1307, USA. */
26 // OBSOLETE #include "defs.h"
27 // OBSOLETE #include "inferior.h"
28 // OBSOLETE #include "gdb_string.h"
29 // OBSOLETE #include "regcache.h"
30 // OBSOLETE #include <ctype.h>
31 // OBSOLETE #include <fcntl.h>
32 // OBSOLETE #include <setjmp.h>
33 // OBSOLETE #include <errno.h>
35 // OBSOLETE #include "terminal.h"
36 // OBSOLETE #include "gdbcore.h"
37 // OBSOLETE #include "gdbcmd.h"
39 // OBSOLETE #include "serial.h"
40 // OBSOLETE #include "remote-utils.h"
42 // OBSOLETE /* External data declarations */
43 // OBSOLETE extern int stop_soon_quietly; /* for wait_for_inferior */
45 // OBSOLETE /* Forward data declarations */
46 // OBSOLETE extern struct target_ops bug_ops; /* Forward declaration */
48 // OBSOLETE /* Forward function declarations */
49 // OBSOLETE static int bug_clear_breakpoints (void);
51 // OBSOLETE static int bug_read_memory (CORE_ADDR memaddr,
52 // OBSOLETE unsigned char *myaddr, int len);
54 // OBSOLETE static int bug_write_memory (CORE_ADDR memaddr,
55 // OBSOLETE unsigned char *myaddr, int len);
57 // OBSOLETE /* This variable is somewhat arbitrary. It's here so that it can be
58 // OBSOLETE set from within a running gdb. */
60 // OBSOLETE static int srec_max_retries = 3;
62 // OBSOLETE /* Each S-record download to the target consists of an S0 header
63 // OBSOLETE record, some number of S3 data records, and one S7 termination
64 // OBSOLETE record. I call this download a "frame". Srec_frame says how many
65 // OBSOLETE bytes will be represented in each frame. */
67 // OBSOLETE #define SREC_SIZE 160
68 // OBSOLETE static int srec_frame = SREC_SIZE;
70 // OBSOLETE /* This variable determines how many bytes will be represented in each
71 // OBSOLETE S3 s-record. */
73 // OBSOLETE static int srec_bytes = 40;
75 // OBSOLETE /* At one point it appeared to me as though the bug monitor could not
76 // OBSOLETE really be expected to receive two sequential characters at 9600
77 // OBSOLETE baud reliably. Echo-pacing is an attempt to force data across the
78 // OBSOLETE line even in this condition. Specifically, in echo-pace mode, each
79 // OBSOLETE character is sent one at a time and we look for the echo before
80 // OBSOLETE sending the next. This is excruciatingly slow. */
82 // OBSOLETE static int srec_echo_pace = 0;
84 // OBSOLETE /* How long to wait after an srec for a possible error message.
85 // OBSOLETE Similar to the above, I tried sleeping after sending each S3 record
86 // OBSOLETE in hopes that I might actually see error messages from the bug
87 // OBSOLETE monitor. This might actually work if we were to use sleep
88 // OBSOLETE intervals smaller than 1 second. */
90 // OBSOLETE static int srec_sleep = 0;
92 // OBSOLETE /* Every srec_noise records, flub the checksum. This is a debugging
93 // OBSOLETE feature. Set the variable to something other than 1 in order to
94 // OBSOLETE inject *deliberate* checksum errors. One might do this if one
95 // OBSOLETE wanted to test error handling and recovery. */
97 // OBSOLETE static int srec_noise = 0;
99 // OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */
101 // OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next
102 // OBSOLETE NEED_ARTIFICIAL_TRAP calls to bug_wait should just return
103 // OBSOLETE SIGTRAP without actually waiting for anything. */
105 // OBSOLETE static int need_artificial_trap = 0;
108 // OBSOLETE * Download a file specified in 'args', to the bug.
111 // OBSOLETE static void
112 // OBSOLETE bug_load (char *args, int fromtty)
114 // OBSOLETE bfd *abfd;
115 // OBSOLETE asection *s;
116 // OBSOLETE char buffer[1024];
118 // OBSOLETE sr_check_open ();
120 // OBSOLETE inferior_ptid = null_ptid;
121 // OBSOLETE abfd = bfd_openr (args, 0);
122 // OBSOLETE if (!abfd)
124 // OBSOLETE printf_filtered ("Unable to open file %s\n", args);
128 // OBSOLETE if (bfd_check_format (abfd, bfd_object) == 0)
130 // OBSOLETE printf_filtered ("File is not an object file\n");
134 // OBSOLETE s = abfd->sections;
135 // OBSOLETE while (s != (asection *) NULL)
137 // OBSOLETE srec_frame = SREC_SIZE;
138 // OBSOLETE if (s->flags & SEC_LOAD)
142 // OBSOLETE char *buffer = xmalloc (srec_frame);
144 // OBSOLETE printf_filtered ("%s\t: 0x%4lx .. 0x%4lx ", s->name, s->vma, s->vma + s->_raw_size);
145 // OBSOLETE gdb_flush (gdb_stdout);
146 // OBSOLETE for (i = 0; i < s->_raw_size; i += srec_frame)
148 // OBSOLETE if (srec_frame > s->_raw_size - i)
149 // OBSOLETE srec_frame = s->_raw_size - i;
151 // OBSOLETE bfd_get_section_contents (abfd, s, buffer, i, srec_frame);
152 // OBSOLETE bug_write_memory (s->vma + i, buffer, srec_frame);
153 // OBSOLETE printf_filtered ("*");
154 // OBSOLETE gdb_flush (gdb_stdout);
156 // OBSOLETE printf_filtered ("\n");
157 // OBSOLETE xfree (buffer);
159 // OBSOLETE s = s->next;
161 // OBSOLETE sprintf (buffer, "rs ip %lx", (unsigned long) abfd->start_address);
162 // OBSOLETE sr_write_cr (buffer);
163 // OBSOLETE gr_expect_prompt ();
167 // OBSOLETE static char *
168 // OBSOLETE get_word (char **p)
170 // OBSOLETE char *s = *p;
171 // OBSOLETE char *word;
172 // OBSOLETE char *copy;
173 // OBSOLETE size_t len;
175 // OBSOLETE while (isspace (*s))
178 // OBSOLETE word = s;
182 // OBSOLETE while (*s && !isspace (*s))
188 // OBSOLETE copy = xmalloc (len + 1);
189 // OBSOLETE memcpy (copy, word, len);
190 // OBSOLETE copy[len] = 0;
192 // OBSOLETE return copy;
196 // OBSOLETE static struct gr_settings bug_settings =
198 // OBSOLETE "Bug>", /* prompt */
199 // OBSOLETE &bug_ops, /* ops */
200 // OBSOLETE bug_clear_breakpoints, /* clear_all_breakpoints */
201 // OBSOLETE gr_generic_checkin, /* checkin */
204 // OBSOLETE static char *cpu_check_strings[] =
207 // OBSOLETE "Invalid Register",
210 // OBSOLETE static void
211 // OBSOLETE bug_open (char *args, int from_tty)
213 // OBSOLETE if (args == NULL)
214 // OBSOLETE args = "";
216 // OBSOLETE gr_open (args, from_tty, &bug_settings);
217 // OBSOLETE /* decide *now* whether we are on an 88100 or an 88110 */
218 // OBSOLETE sr_write_cr ("rs cr06");
219 // OBSOLETE sr_expect ("rs cr06");
221 // OBSOLETE switch (gr_multi_scan (cpu_check_strings, 0))
223 // OBSOLETE case 0: /* this is an m88100 */
224 // OBSOLETE target_is_m88110 = 0;
226 // OBSOLETE case 1: /* this is an m88110 */
227 // OBSOLETE target_is_m88110 = 1;
230 // OBSOLETE internal_error (__FILE__, __LINE__, "failed internal consistency check");
234 // OBSOLETE /* Tell the remote machine to resume. */
237 // OBSOLETE bug_resume (ptid_t ptid, int step, enum target_signal sig)
239 // OBSOLETE if (step)
241 // OBSOLETE sr_write_cr ("t");
243 // OBSOLETE /* Force the next bug_wait to return a trap. Not doing anything
244 // OBSOLETE about I/O from the target means that the user has to type
245 // OBSOLETE "continue" to see any. FIXME, this should be fixed. */
246 // OBSOLETE need_artificial_trap = 1;
249 // OBSOLETE sr_write_cr ("g");
254 // OBSOLETE /* Wait until the remote machine stops, then return,
255 // OBSOLETE storing status in STATUS just as `wait' would. */
257 // OBSOLETE static char *wait_strings[] =
259 // OBSOLETE "At Breakpoint",
260 // OBSOLETE "Exception: Data Access Fault (Local Bus Timeout)",
261 // OBSOLETE "\r8??\?-Bug>", /* The '\?' avoids creating a trigraph */
262 // OBSOLETE "\r197-Bug>",
267 // OBSOLETE bug_wait (ptid_t ptid, struct target_waitstatus *status)
269 // OBSOLETE int old_timeout = sr_get_timeout ();
270 // OBSOLETE int old_immediate_quit = immediate_quit;
272 // OBSOLETE status->kind = TARGET_WAITKIND_EXITED;
273 // OBSOLETE status->value.integer = 0;
275 // OBSOLETE /* read off leftovers from resume so that the rest can be passed
276 // OBSOLETE back out as stdout. */
277 // OBSOLETE if (need_artificial_trap == 0)
279 // OBSOLETE sr_expect ("Effective address: ");
280 // OBSOLETE (void) sr_get_hex_word ();
281 // OBSOLETE sr_expect ("\r\n");
284 // OBSOLETE sr_set_timeout (-1); /* Don't time out -- user program is running. */
285 // OBSOLETE immediate_quit = 1; /* Helps ability to QUIT */
287 // OBSOLETE switch (gr_multi_scan (wait_strings, need_artificial_trap == 0))
289 // OBSOLETE case 0: /* breakpoint case */
290 // OBSOLETE status->kind = TARGET_WAITKIND_STOPPED;
291 // OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP;
292 // OBSOLETE /* user output from the target can be discarded here. (?) */
293 // OBSOLETE gr_expect_prompt ();
296 // OBSOLETE case 1: /* bus error */
297 // OBSOLETE status->kind = TARGET_WAITKIND_STOPPED;
298 // OBSOLETE status->value.sig = TARGET_SIGNAL_BUS;
299 // OBSOLETE /* user output from the target can be discarded here. (?) */
300 // OBSOLETE gr_expect_prompt ();
303 // OBSOLETE case 2: /* normal case */
305 // OBSOLETE if (need_artificial_trap != 0)
307 // OBSOLETE /* stepping */
308 // OBSOLETE status->kind = TARGET_WAITKIND_STOPPED;
309 // OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP;
310 // OBSOLETE need_artificial_trap--;
315 // OBSOLETE /* exit case */
316 // OBSOLETE status->kind = TARGET_WAITKIND_EXITED;
317 // OBSOLETE status->value.integer = 0;
321 // OBSOLETE case -1: /* trouble */
323 // OBSOLETE fprintf_filtered (gdb_stderr,
324 // OBSOLETE "Trouble reading target during wait\n");
328 // OBSOLETE sr_set_timeout (old_timeout);
329 // OBSOLETE immediate_quit = old_immediate_quit;
330 // OBSOLETE return inferior_ptid;
333 // OBSOLETE /* Return the name of register number REGNO
334 // OBSOLETE in the form input and output by bug.
336 // OBSOLETE Returns a pointer to a static buffer containing the answer. */
337 // OBSOLETE static char *
338 // OBSOLETE get_reg_name (int regno)
340 // OBSOLETE static char *rn[] =
342 // OBSOLETE "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07",
343 // OBSOLETE "r08", "r09", "r10", "r11", "r12", "r13", "r14", "r15",
344 // OBSOLETE "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
345 // OBSOLETE "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
347 // OBSOLETE /* these get confusing because we omit a few and switch some ordering around. */
349 // OBSOLETE "cr01", /* 32 = psr */
350 // OBSOLETE "fcr62", /* 33 = fpsr */
351 // OBSOLETE "fcr63", /* 34 = fpcr */
352 // OBSOLETE "ip", /* this is something of a cheat. */
353 // OBSOLETE /* 35 = sxip */
354 // OBSOLETE "cr05", /* 36 = snip */
355 // OBSOLETE "cr06", /* 37 = sfip */
357 // OBSOLETE "x00", "x01", "x02", "x03", "x04", "x05", "x06", "x07",
358 // OBSOLETE "x08", "x09", "x10", "x11", "x12", "x13", "x14", "x15",
359 // OBSOLETE "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
360 // OBSOLETE "x24", "x25", "x26", "x27", "x28", "x29", "x30", "x31",
363 // OBSOLETE return rn[regno];
366 // OBSOLETE #if 0 /* not currently used */
367 // OBSOLETE /* Read from remote while the input matches STRING. Return zero on
368 // OBSOLETE success, -1 on failure. */
370 // OBSOLETE static int
371 // OBSOLETE bug_scan (char *s)
375 // OBSOLETE while (*s)
377 // OBSOLETE c = sr_readchar ();
378 // OBSOLETE if (c != *s++)
380 // OBSOLETE fflush (stdout);
381 // OBSOLETE printf ("\nNext character is '%c' - %d and s is \"%s\".\n", c, c, --s);
382 // OBSOLETE return (-1);
386 // OBSOLETE return (0);
388 // OBSOLETE #endif /* never */
390 // OBSOLETE static int
391 // OBSOLETE bug_srec_write_cr (char *s)
393 // OBSOLETE char *p = s;
395 // OBSOLETE if (srec_echo_pace)
396 // OBSOLETE for (p = s; *p; ++p)
398 // OBSOLETE if (sr_get_debug () > 0)
399 // OBSOLETE printf ("%c", *p);
402 // OBSOLETE serial_write (sr_get_desc (), p, 1);
403 // OBSOLETE while (sr_pollchar () != *p);
407 // OBSOLETE sr_write_cr (s);
408 // OBSOLETE /* return(bug_scan (s) || bug_scan ("\n")); */
411 // OBSOLETE return (0);
414 // OBSOLETE /* Store register REGNO, or all if REGNO == -1. */
416 // OBSOLETE static void
417 // OBSOLETE bug_fetch_register (int regno)
419 // OBSOLETE sr_check_open ();
421 // OBSOLETE if (regno == -1)
425 // OBSOLETE for (i = 0; i < NUM_REGS; ++i)
426 // OBSOLETE bug_fetch_register (i);
428 // OBSOLETE else if (target_is_m88110 && regno == SFIP_REGNUM)
430 // OBSOLETE /* m88110 has no sfip. */
431 // OBSOLETE long l = 0;
432 // OBSOLETE supply_register (regno, (char *) &l);
434 // OBSOLETE else if (regno < XFP_REGNUM)
436 // OBSOLETE char buffer[MAX_REGISTER_RAW_SIZE];
438 // OBSOLETE sr_write ("rs ", 3);
439 // OBSOLETE sr_write_cr (get_reg_name (regno));
440 // OBSOLETE sr_expect ("=");
441 // OBSOLETE store_unsigned_integer (buffer, REGISTER_RAW_SIZE (regno),
442 // OBSOLETE sr_get_hex_word ());
443 // OBSOLETE gr_expect_prompt ();
444 // OBSOLETE supply_register (regno, buffer);
448 // OBSOLETE /* Float register so we need to parse a strange data format. */
450 // OBSOLETE unsigned char fpreg_buf[10];
452 // OBSOLETE sr_write ("rs ", 3);
453 // OBSOLETE sr_write (get_reg_name (regno), strlen (get_reg_name (regno)));
454 // OBSOLETE sr_write_cr (";d");
455 // OBSOLETE sr_expect ("rs");
456 // OBSOLETE sr_expect (get_reg_name (regno));
457 // OBSOLETE sr_expect (";d");
458 // OBSOLETE sr_expect ("=");
460 // OBSOLETE /* sign */
461 // OBSOLETE p = sr_get_hex_digit (1);
462 // OBSOLETE fpreg_buf[0] = p << 7;
464 // OBSOLETE /* exponent */
465 // OBSOLETE sr_expect ("_");
466 // OBSOLETE p = sr_get_hex_digit (1);
467 // OBSOLETE fpreg_buf[0] += (p << 4);
468 // OBSOLETE fpreg_buf[0] += sr_get_hex_digit (1);
470 // OBSOLETE fpreg_buf[1] = sr_get_hex_digit (1) << 4;
472 // OBSOLETE /* fraction */
473 // OBSOLETE sr_expect ("_");
474 // OBSOLETE fpreg_buf[1] += sr_get_hex_digit (1);
476 // OBSOLETE fpreg_buf[2] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
477 // OBSOLETE fpreg_buf[3] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
478 // OBSOLETE fpreg_buf[4] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
479 // OBSOLETE fpreg_buf[5] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
480 // OBSOLETE fpreg_buf[6] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
481 // OBSOLETE fpreg_buf[7] = (sr_get_hex_digit (1) << 4) + sr_get_hex_digit (1);
482 // OBSOLETE fpreg_buf[8] = 0;
483 // OBSOLETE fpreg_buf[9] = 0;
485 // OBSOLETE gr_expect_prompt ();
486 // OBSOLETE supply_register (regno, fpreg_buf);
492 // OBSOLETE /* Store register REGNO, or all if REGNO == -1. */
494 // OBSOLETE static void
495 // OBSOLETE bug_store_register (int regno)
497 // OBSOLETE char buffer[1024];
498 // OBSOLETE sr_check_open ();
500 // OBSOLETE if (regno == -1)
504 // OBSOLETE for (i = 0; i < NUM_REGS; ++i)
505 // OBSOLETE bug_store_register (i);
509 // OBSOLETE char *regname;
511 // OBSOLETE regname = get_reg_name (regno);
513 // OBSOLETE if (target_is_m88110 && regno == SFIP_REGNUM)
515 // OBSOLETE else if (regno < XFP_REGNUM)
516 // OBSOLETE sprintf (buffer, "rs %s %08lx",
518 // OBSOLETE (long) read_register (regno));
521 // OBSOLETE unsigned char *fpreg_buf =
522 // OBSOLETE (unsigned char *) ®isters[REGISTER_BYTE (regno)];
524 // OBSOLETE sprintf (buffer, "rs %s %1x_%02x%1x_%1x%02x%02x%02x%02x%02x%02x;d",
526 // OBSOLETE /* sign */
527 // OBSOLETE (fpreg_buf[0] >> 7) & 0xf,
528 // OBSOLETE /* exponent */
529 // OBSOLETE fpreg_buf[0] & 0x7f,
530 // OBSOLETE (fpreg_buf[1] >> 8) & 0xf,
531 // OBSOLETE /* fraction */
532 // OBSOLETE fpreg_buf[1] & 0xf,
533 // OBSOLETE fpreg_buf[2],
534 // OBSOLETE fpreg_buf[3],
535 // OBSOLETE fpreg_buf[4],
536 // OBSOLETE fpreg_buf[5],
537 // OBSOLETE fpreg_buf[6],
538 // OBSOLETE fpreg_buf[7]);
541 // OBSOLETE sr_write_cr (buffer);
542 // OBSOLETE gr_expect_prompt ();
548 // OBSOLETE /* Transfer LEN bytes between GDB address MYADDR and target address
549 // OBSOLETE MEMADDR. If WRITE is non-zero, transfer them to the target,
550 // OBSOLETE otherwise transfer them from the target. TARGET is unused.
552 // OBSOLETE Returns the number of bytes transferred. */
555 // OBSOLETE bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
556 // OBSOLETE struct mem_attrib *attrib, struct target_ops *target)
560 // OBSOLETE if (len <= 0)
561 // OBSOLETE return 0;
563 // OBSOLETE if (write)
564 // OBSOLETE res = bug_write_memory (memaddr, myaddr, len);
566 // OBSOLETE res = bug_read_memory (memaddr, myaddr, len);
568 // OBSOLETE return res;
571 // OBSOLETE static void
572 // OBSOLETE start_load (void)
574 // OBSOLETE char *command;
576 // OBSOLETE command = (srec_echo_pace ? "lo 0 ;x" : "lo 0");
578 // OBSOLETE sr_write_cr (command);
579 // OBSOLETE sr_expect (command);
580 // OBSOLETE sr_expect ("\r\n");
581 // OBSOLETE bug_srec_write_cr ("S0030000FC");
585 // OBSOLETE /* This is an extremely vulnerable and fragile function. I've made
586 // OBSOLETE considerable attempts to make this deterministic, but I've
587 // OBSOLETE certainly forgotten something. The trouble is that S-records are
588 // OBSOLETE only a partial file format, not a protocol. Worse, apparently the
589 // OBSOLETE m88k bug monitor does not run in real time while receiving
590 // OBSOLETE S-records. Hence, we must pay excruciating attention to when and
591 // OBSOLETE where error messages are returned, and what has actually been sent.
593 // OBSOLETE Each call represents a chunk of memory to be sent to the target.
594 // OBSOLETE We break that chunk into an S0 header record, some number of S3
595 // OBSOLETE data records each containing srec_bytes, and an S7 termination
596 // OBSOLETE record. */
598 // OBSOLETE static char *srecord_strings[] =
600 // OBSOLETE "S-RECORD",
605 // OBSOLETE static int
606 // OBSOLETE bug_write_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
608 // OBSOLETE int done;
609 // OBSOLETE int checksum;
611 // OBSOLETE int retries;
612 // OBSOLETE char *buffer = alloca ((srec_bytes + 8) << 1);
614 // OBSOLETE retries = 0;
618 // OBSOLETE done = 0;
620 // OBSOLETE if (retries > srec_max_retries)
621 // OBSOLETE return (-1);
623 // OBSOLETE if (retries > 0)
625 // OBSOLETE if (sr_get_debug () > 0)
626 // OBSOLETE printf ("\n<retrying...>\n");
628 // OBSOLETE /* This gr_expect_prompt call is extremely important. Without
629 // OBSOLETE it, we will tend to resend our packet so fast that it
630 // OBSOLETE will arrive before the bug monitor is ready to receive
631 // OBSOLETE it. This would lead to a very ugly resend loop. */
633 // OBSOLETE gr_expect_prompt ();
636 // OBSOLETE start_load ();
638 // OBSOLETE while (done < len)
640 // OBSOLETE int thisgo;
642 // OBSOLETE char *buf = buffer;
643 // OBSOLETE CORE_ADDR address;
645 // OBSOLETE checksum = 0;
646 // OBSOLETE thisgo = len - done;
647 // OBSOLETE if (thisgo > srec_bytes)
648 // OBSOLETE thisgo = srec_bytes;
650 // OBSOLETE address = memaddr + done;
651 // OBSOLETE sprintf (buf, "S3%02X%08lX", thisgo + 4 + 1, (long) address);
652 // OBSOLETE buf += 12;
654 // OBSOLETE checksum += (thisgo + 4 + 1
655 // OBSOLETE + (address & 0xff)
656 // OBSOLETE + ((address >> 8) & 0xff)
657 // OBSOLETE + ((address >> 16) & 0xff)
658 // OBSOLETE + ((address >> 24) & 0xff));
660 // OBSOLETE for (idx = 0; idx < thisgo; idx++)
662 // OBSOLETE sprintf (buf, "%02X", myaddr[idx + done]);
663 // OBSOLETE checksum += myaddr[idx + done];
664 // OBSOLETE buf += 2;
667 // OBSOLETE if (srec_noise > 0)
669 // OBSOLETE /* FIXME-NOW: insert a deliberate error every now and then.
670 // OBSOLETE This is intended for testing/debugging the error handling
671 // OBSOLETE stuff. */
672 // OBSOLETE static int counter = 0;
673 // OBSOLETE if (++counter > srec_noise)
675 // OBSOLETE counter = 0;
676 // OBSOLETE ++checksum;
680 // OBSOLETE sprintf (buf, "%02X", ~checksum & 0xff);
681 // OBSOLETE bug_srec_write_cr (buffer);
683 // OBSOLETE if (srec_sleep != 0)
684 // OBSOLETE sleep (srec_sleep);
686 // OBSOLETE /* This pollchar is probably redundant to the gr_multi_scan
687 // OBSOLETE below. Trouble is, we can't be sure when or where an
688 // OBSOLETE error message will appear. Apparently, when running at
689 // OBSOLETE full speed from a typical sun4, error messages tend to
690 // OBSOLETE appear to arrive only *after* the s7 record. */
692 // OBSOLETE if ((x = sr_pollchar ()) != 0)
694 // OBSOLETE if (sr_get_debug () > 0)
695 // OBSOLETE printf ("\n<retrying...>\n");
697 // OBSOLETE ++retries;
699 // OBSOLETE /* flush any remaining input and verify that we are back
700 // OBSOLETE at the prompt level. */
701 // OBSOLETE gr_expect_prompt ();
702 // OBSOLETE /* start all over again. */
703 // OBSOLETE start_load ();
704 // OBSOLETE done = 0;
705 // OBSOLETE continue;
708 // OBSOLETE done += thisgo;
711 // OBSOLETE bug_srec_write_cr ("S7060000000000F9");
712 // OBSOLETE ++retries;
714 // OBSOLETE /* Having finished the load, we need to figure out whether we
715 // OBSOLETE had any errors. */
717 // OBSOLETE while (gr_multi_scan (srecord_strings, 0) == 0);;
719 // OBSOLETE return (0);
722 // OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR
723 // OBSOLETE to inferior's memory at MEMADDR. Returns errno value.
724 // OBSOLETE * sb/sh instructions don't work on unaligned addresses, when TU=1.
727 // OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result
728 // OBSOLETE at debugger address MYADDR. Returns errno value. */
729 // OBSOLETE static int
730 // OBSOLETE bug_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
732 // OBSOLETE char request[100];
733 // OBSOLETE char *buffer;
735 // OBSOLETE char type;
736 // OBSOLETE char size;
737 // OBSOLETE unsigned char c;
738 // OBSOLETE unsigned int inaddr;
739 // OBSOLETE unsigned int checksum;
741 // OBSOLETE sprintf (request, "du 0 %lx:&%d", (long) memaddr, len);
742 // OBSOLETE sr_write_cr (request);
744 // OBSOLETE p = buffer = alloca (len);
746 // OBSOLETE /* scan up through the header */
747 // OBSOLETE sr_expect ("S0030000FC");
749 // OBSOLETE while (p < buffer + len)
751 // OBSOLETE /* scan off any white space. */
752 // OBSOLETE while (sr_readchar () != 'S');;
754 // OBSOLETE /* what kind of s-rec? */
755 // OBSOLETE type = sr_readchar ();
757 // OBSOLETE /* scan record size */
758 // OBSOLETE sr_get_hex_byte (&size);
759 // OBSOLETE checksum = size;
761 // OBSOLETE inaddr = 0;
763 // OBSOLETE switch (type)
765 // OBSOLETE case '7':
766 // OBSOLETE case '8':
767 // OBSOLETE case '9':
768 // OBSOLETE goto done;
770 // OBSOLETE case '3':
771 // OBSOLETE sr_get_hex_byte (&c);
772 // OBSOLETE inaddr = (inaddr << 8) + c;
773 // OBSOLETE checksum += c;
775 // OBSOLETE /* intentional fall through */
776 // OBSOLETE case '2':
777 // OBSOLETE sr_get_hex_byte (&c);
778 // OBSOLETE inaddr = (inaddr << 8) + c;
779 // OBSOLETE checksum += c;
781 // OBSOLETE /* intentional fall through */
782 // OBSOLETE case '1':
783 // OBSOLETE sr_get_hex_byte (&c);
784 // OBSOLETE inaddr = (inaddr << 8) + c;
785 // OBSOLETE checksum += c;
787 // OBSOLETE sr_get_hex_byte (&c);
788 // OBSOLETE inaddr = (inaddr << 8) + c;
789 // OBSOLETE checksum += c;
794 // OBSOLETE /* bonk */
795 // OBSOLETE error ("reading s-records.");
798 // OBSOLETE if (inaddr < memaddr
799 // OBSOLETE || (memaddr + len) < (inaddr + size))
800 // OBSOLETE error ("srec out of memory range.");
802 // OBSOLETE if (p != buffer + inaddr - memaddr)
803 // OBSOLETE error ("srec out of sequence.");
805 // OBSOLETE for (; size; --size, ++p)
807 // OBSOLETE sr_get_hex_byte (p);
808 // OBSOLETE checksum += *p;
811 // OBSOLETE sr_get_hex_byte (&c);
812 // OBSOLETE if (c != (~checksum & 0xff))
813 // OBSOLETE error ("bad s-rec checksum");
817 // OBSOLETE gr_expect_prompt ();
818 // OBSOLETE if (p != buffer + len)
819 // OBSOLETE return (1);
821 // OBSOLETE memcpy (myaddr, buffer, len);
822 // OBSOLETE return (0);
825 // OBSOLETE #define MAX_BREAKS 16
826 // OBSOLETE static int num_brkpts = 0;
828 // OBSOLETE /* Insert a breakpoint at ADDR. SAVE is normally the address of the
829 // OBSOLETE pattern buffer where the instruction that the breakpoint overwrites
830 // OBSOLETE is saved. It is unused here since the bug is responsible for
831 // OBSOLETE saving/restoring the original instruction. */
833 // OBSOLETE static int
834 // OBSOLETE bug_insert_breakpoint (CORE_ADDR addr, char *save)
836 // OBSOLETE sr_check_open ();
838 // OBSOLETE if (num_brkpts < MAX_BREAKS)
840 // OBSOLETE char buffer[100];
842 // OBSOLETE num_brkpts++;
843 // OBSOLETE sprintf (buffer, "br %lx", (long) addr);
844 // OBSOLETE sr_write_cr (buffer);
845 // OBSOLETE gr_expect_prompt ();
846 // OBSOLETE return (0);
850 // OBSOLETE fprintf_filtered (gdb_stderr,
851 // OBSOLETE "Too many break points, break point not installed\n");
852 // OBSOLETE return (1);
857 // OBSOLETE /* Remove a breakpoint at ADDR. SAVE is normally the previously
858 // OBSOLETE saved pattern, but is unused here since the bug is responsible
859 // OBSOLETE for saving/restoring instructions. */
861 // OBSOLETE static int
862 // OBSOLETE bug_remove_breakpoint (CORE_ADDR addr, char *save)
864 // OBSOLETE if (num_brkpts > 0)
866 // OBSOLETE char buffer[100];
868 // OBSOLETE num_brkpts--;
869 // OBSOLETE sprintf (buffer, "nobr %lx", (long) addr);
870 // OBSOLETE sr_write_cr (buffer);
871 // OBSOLETE gr_expect_prompt ();
874 // OBSOLETE return (0);
877 // OBSOLETE /* Clear the bugs notion of what the break points are */
878 // OBSOLETE static int
879 // OBSOLETE bug_clear_breakpoints (void)
882 // OBSOLETE if (sr_is_open ())
884 // OBSOLETE sr_write_cr ("nobr");
885 // OBSOLETE sr_expect ("nobr");
886 // OBSOLETE gr_expect_prompt ();
888 // OBSOLETE num_brkpts = 0;
889 // OBSOLETE return (0);
892 // OBSOLETE struct target_ops bug_ops;
894 // OBSOLETE static void
895 // OBSOLETE init_bug_ops (void)
897 // OBSOLETE bug_ops.to_shortname = "bug";
898 // OBSOLETE "Remote BUG monitor",
899 // OBSOLETE bug_ops.to_longname = "Use the mvme187 board running the BUG monitor connected by a serial line.";
900 // OBSOLETE bug_ops.to_doc = " ";
901 // OBSOLETE bug_ops.to_open = bug_open;
902 // OBSOLETE bug_ops.to_close = gr_close;
903 // OBSOLETE bug_ops.to_attach = 0;
904 // OBSOLETE bug_ops.to_post_attach = NULL;
905 // OBSOLETE bug_ops.to_require_attach = NULL;
906 // OBSOLETE bug_ops.to_detach = gr_detach;
907 // OBSOLETE bug_ops.to_require_detach = NULL;
908 // OBSOLETE bug_ops.to_resume = bug_resume;
909 // OBSOLETE bug_ops.to_wait = bug_wait;
910 // OBSOLETE bug_ops.to_post_wait = NULL;
911 // OBSOLETE bug_ops.to_fetch_registers = bug_fetch_register;
912 // OBSOLETE bug_ops.to_store_registers = bug_store_register;
913 // OBSOLETE bug_ops.to_prepare_to_store = gr_prepare_to_store;
914 // OBSOLETE bug_ops.to_xfer_memory = bug_xfer_memory;
915 // OBSOLETE bug_ops.to_files_info = gr_files_info;
916 // OBSOLETE bug_ops.to_insert_breakpoint = bug_insert_breakpoint;
917 // OBSOLETE bug_ops.to_remove_breakpoint = bug_remove_breakpoint;
918 // OBSOLETE bug_ops.to_terminal_init = 0;
919 // OBSOLETE bug_ops.to_terminal_inferior = 0;
920 // OBSOLETE bug_ops.to_terminal_ours_for_output = 0;
921 // OBSOLETE bug_ops.to_terminal_ours = 0;
922 // OBSOLETE bug_ops.to_terminal_info = 0;
923 // OBSOLETE bug_ops.to_kill = gr_kill;
924 // OBSOLETE bug_ops.to_load = bug_load;
925 // OBSOLETE bug_ops.to_lookup_symbol = 0;
926 // OBSOLETE bug_ops.to_create_inferior = gr_create_inferior;
927 // OBSOLETE bug_ops.to_post_startup_inferior = NULL;
928 // OBSOLETE bug_ops.to_acknowledge_created_inferior = NULL;
929 // OBSOLETE bug_ops.to_clone_and_follow_inferior = NULL;
930 // OBSOLETE bug_ops.to_post_follow_inferior_by_clone = NULL;
931 // OBSOLETE bug_ops.to_insert_fork_catchpoint = NULL;
932 // OBSOLETE bug_ops.to_remove_fork_catchpoint = NULL;
933 // OBSOLETE bug_ops.to_insert_vfork_catchpoint = NULL;
934 // OBSOLETE bug_ops.to_remove_vfork_catchpoint = NULL;
935 // OBSOLETE bug_ops.to_has_forked = NULL;
936 // OBSOLETE bug_ops.to_has_vforked = NULL;
937 // OBSOLETE bug_ops.to_can_follow_vfork_prior_to_exec = NULL;
938 // OBSOLETE bug_ops.to_post_follow_vfork = NULL;
939 // OBSOLETE bug_ops.to_insert_exec_catchpoint = NULL;
940 // OBSOLETE bug_ops.to_remove_exec_catchpoint = NULL;
941 // OBSOLETE bug_ops.to_has_execd = NULL;
942 // OBSOLETE bug_ops.to_reported_exec_events_per_exec_call = NULL;
943 // OBSOLETE bug_ops.to_has_exited = NULL;
944 // OBSOLETE bug_ops.to_mourn_inferior = gr_mourn;
945 // OBSOLETE bug_ops.to_can_run = 0;
946 // OBSOLETE bug_ops.to_notice_signals = 0;
947 // OBSOLETE bug_ops.to_thread_alive = 0;
948 // OBSOLETE bug_ops.to_stop = 0;
949 // OBSOLETE bug_ops.to_pid_to_exec_file = NULL;
950 // OBSOLETE bug_ops.to_stratum = process_stratum;
951 // OBSOLETE bug_ops.DONT_USE = 0;
952 // OBSOLETE bug_ops.to_has_all_memory = 1;
953 // OBSOLETE bug_ops.to_has_memory = 1;
954 // OBSOLETE bug_ops.to_has_stack = 1;
955 // OBSOLETE bug_ops.to_has_registers = 0;
956 // OBSOLETE bug_ops.to_has_execution = 0;
957 // OBSOLETE bug_ops.to_sections = 0;
958 // OBSOLETE bug_ops.to_sections_end = 0;
959 // OBSOLETE bug_ops.to_magic = OPS_MAGIC; /* Always the last thing */
960 // OBSOLETE } /* init_bug_ops */
963 // OBSOLETE _initialize_remote_bug (void)
965 // OBSOLETE init_bug_ops ();
966 // OBSOLETE add_target (&bug_ops);
968 // OBSOLETE add_show_from_set
969 // OBSOLETE (add_set_cmd ("srec-bytes", class_support, var_uinteger,
970 // OBSOLETE (char *) &srec_bytes,
972 // OBSOLETE Set the number of bytes represented in each S-record.\n\
973 // OBSOLETE This affects the communication protocol with the remote target.",
974 // OBSOLETE &setlist),
975 // OBSOLETE &showlist);
977 // OBSOLETE add_show_from_set
978 // OBSOLETE (add_set_cmd ("srec-max-retries", class_support, var_uinteger,
979 // OBSOLETE (char *) &srec_max_retries,
981 // OBSOLETE Set the number of retries for shipping S-records.\n\
982 // OBSOLETE This affects the communication protocol with the remote target.",
983 // OBSOLETE &setlist),
984 // OBSOLETE &showlist);
987 // OBSOLETE /* This needs to set SREC_SIZE, not srec_frame which gets changed at the
988 // OBSOLETE end of a download. But do we need the option at all? */
989 // OBSOLETE add_show_from_set
990 // OBSOLETE (add_set_cmd ("srec-frame", class_support, var_uinteger,
991 // OBSOLETE (char *) &srec_frame,
993 // OBSOLETE Set the number of bytes in an S-record frame.\n\
994 // OBSOLETE This affects the communication protocol with the remote target.",
995 // OBSOLETE &setlist),
996 // OBSOLETE &showlist);
997 // OBSOLETE #endif /* 0 */
999 // OBSOLETE add_show_from_set
1000 // OBSOLETE (add_set_cmd ("srec-noise", class_support, var_zinteger,
1001 // OBSOLETE (char *) &srec_noise,
1003 // OBSOLETE Set number of S-record to send before deliberately flubbing a checksum.\n\
1004 // OBSOLETE Zero means flub none at all. This affects the communication protocol\n\
1005 // OBSOLETE with the remote target.",
1006 // OBSOLETE &setlist),
1007 // OBSOLETE &showlist);
1009 // OBSOLETE add_show_from_set
1010 // OBSOLETE (add_set_cmd ("srec-sleep", class_support, var_zinteger,
1011 // OBSOLETE (char *) &srec_sleep,
1013 // OBSOLETE Set number of seconds to sleep after an S-record for a possible error message to arrive.\n\
1014 // OBSOLETE This affects the communication protocol with the remote target.",
1015 // OBSOLETE &setlist),
1016 // OBSOLETE &showlist);
1018 // OBSOLETE add_show_from_set
1019 // OBSOLETE (add_set_cmd ("srec-echo-pace", class_support, var_boolean,
1020 // OBSOLETE (char *) &srec_echo_pace,
1022 // OBSOLETE Set echo-verification.\n\
1023 // OBSOLETE When on, use verification by echo when downloading S-records. This is\n\
1024 // OBSOLETE much slower, but generally more reliable.",
1025 // OBSOLETE &setlist),
1026 // OBSOLETE &showlist);
This page took 0.051037 seconds and 4 git commands to generate.