1 /* Remote debugging interface for Motorola's MVME187BUG monitor, an embedded
4 Copyright 1992, 1993 Free Software Foundation, Inc.
5 Contributed by Cygnus Support. Written by K. Richard Pixley.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
45 /* External data declarations */
46 extern int stop_soon_quietly; /* for wait_for_inferior */
48 /* Forward data declarations */
49 extern struct target_ops bug_ops; /* Forward declaration */
51 /* Forward function declarations */
52 static void bug_close ();
53 static int bug_clear_breakpoints ();
54 static void bug_write_cr();
58 static int bug_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
59 static int bug_write_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
63 static int bug_read_inferior_memory ();
64 static int bug_write_inferior_memory ();
66 #endif /* not __STDC__ */
68 /* To be silent, or to loudly echo all input and output to and from
73 /* This is the serial descriptor to our target. */
75 static serial_t desc = NULL;
77 /* This variable is somewhat arbitrary. It's here so that it can be
78 set from within a running gdb. */
80 static int srec_max_retries = 3;
82 /* Each S-record download to the target consists of an S0 header
83 record, some number of S3 data records, and one S7 termination
84 record. I call this download a "frame". Srec_frame says how many
85 bytes will be represented in each frame. */
87 static int srec_frame = 160;
89 /* This variable determines how many bytes will be represented in each
92 static int srec_bytes = 40;
94 /* At one point it appeared to me as though the bug monitor could not
95 really be expected to receive two sequential characters at 9600
96 baud reliably. Echo-pacing is an attempt to force data across the
97 line even in this condition. Specifically, in echo-pace mode, each
98 character is sent one at a time and we look for the echo before
99 sending the next. This is excruciatingly slow. */
101 static int srec_echo_pace = 0;
103 /* How long to wait after an srec for a possible error message.
104 Similar to the above, I tried sleeping after sending each S3 record
105 in hopes that I might actually see error messages from the bug
106 monitor. This might actually work if we were to use sleep
107 intervals smaller than 1 second. */
109 static int srec_sleep = 0;
111 /* Every srec_noise records, flub the checksum. This is a debugging
112 feature. Set the variable to something other than 1 in order to
113 inject *deliberate* checksum errors. One might do this if one
114 wanted to test error handling and recovery. */
116 static int srec_noise = 0;
118 /***********************************************************************/
119 /* Caching stuff stolen from remote-nindy.c */
121 /* The data cache records all the data read from the remote machine
122 since the last time it stopped.
124 Each cache block holds LINE_SIZE bytes of data
125 starting at a multiple-of-LINE_SIZE address. */
127 #define LINE_SIZE_POWER 4
128 #define LINE_SIZE (1<<LINE_SIZE_POWER) /* eg 1<<3 == 8 */
129 #define LINE_SIZE_MASK ((LINE_SIZE-1)) /* eg 7*2+1= 111*/
130 #define DCACHE_SIZE 64 /* Number of cache blocks */
131 #define XFORM(x) ((x&LINE_SIZE_MASK)>>2)
134 struct dcache_block *next, *last;
135 unsigned int addr; /* Address for which data is recorded. */
136 int data[LINE_SIZE / sizeof (int)];
139 struct dcache_block dcache_free, dcache_valid;
141 /* Free all the data cache blocks, thus discarding all cached data. */
146 register struct dcache_block *db;
148 while ((db = dcache_valid.next) != &dcache_valid)
151 insque (db, &dcache_free);
156 * If addr is present in the dcache, return the address of the block
160 struct dcache_block *
164 register struct dcache_block *db;
169 /* Search all cache blocks for one that is at this address. */
170 db = dcache_valid.next;
171 while (db != &dcache_valid)
173 if ((addr & ~LINE_SIZE_MASK) == db->addr)
180 /* Return the int data at address ADDR in dcache block DC. */
183 dcache_value (db, addr)
184 struct dcache_block *db;
189 return (db->data[XFORM (addr)]);
192 /* Get a free cache block, put or keep it on the valid list,
193 and return its address. The caller should store into the block
194 the address and data that it describes, then remque it from the
195 free list and insert it into the valid list. This procedure
196 prevents errors from creeping in if a ninMemGet is interrupted
197 (which used to put garbage blocks in the valid list...). */
199 struct dcache_block *
202 register struct dcache_block *db;
204 if ((db = dcache_free.next) == &dcache_free)
206 /* If we can't get one from the free list, take last valid and put
207 it on the free list. */
208 db = dcache_valid.last;
210 insque (db, &dcache_free);
214 insque (db, &dcache_valid);
218 /* Return the contents of the word at address ADDR in the remote machine,
219 using the data cache. */
225 register struct dcache_block *db;
227 db = dcache_hit (addr);
230 db = dcache_alloc ();
232 bug_read_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
234 db->addr = addr & ~LINE_SIZE_MASK;
235 remque (db); /* Off the free list */
236 insque (db, &dcache_valid); /* On the valid list */
238 return (dcache_value (db, addr));
241 /* Write the word at ADDR both in the data cache and in the remote machine. */
243 dcache_poke (addr, data)
247 register struct dcache_block *db;
249 /* First make sure the word is IN the cache. DB is its cache block. */
250 db = dcache_hit (addr);
253 db = dcache_alloc ();
255 bug_write_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
257 db->addr = addr & ~LINE_SIZE_MASK;
258 remque (db); /* Off the free list */
259 insque (db, &dcache_valid); /* On the valid list */
262 /* Modify the word in the cache. */
263 db->data[XFORM (addr)] = data;
265 /* Send the changed word. */
267 bug_write_inferior_memory (addr, (unsigned char *) &data, 4);
271 /* The cache itself. */
272 struct dcache_block the_cache[DCACHE_SIZE];
274 /* Initialize the data cache. */
279 register struct dcache_block *db;
282 dcache_free.next = dcache_free.last = &dcache_free;
283 dcache_valid.next = dcache_valid.last = &dcache_valid;
284 for (i = 0; i < DCACHE_SIZE; i++, db++)
285 insque (db, &dcache_free);
288 /***********************************************************************
289 * I/O stuff stolen from remote-eb.c
290 ***********************************************************************/
292 /* with a timeout of 2, we time out waiting for the prompt after an
294 static int timeout = 4;
296 static const char *dev_name;
298 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
299 bug_open knows that we don't have a file open when the program
302 static int is_open = 0;
308 error ("remote device not open");
317 /* Read a character from the remote system, doing all the fancy
324 buf = SERIAL_READCHAR (desc, timeout);
326 if (buf == SERIAL_TIMEOUT)
327 error ("Timeout reading from remote system.");
340 buf = SERIAL_READCHAR (desc, timeout);
341 if (buf == SERIAL_TIMEOUT)
347 printf ("<timeout>");
358 buf = SERIAL_READCHAR (desc, 0);
359 if (buf == SERIAL_TIMEOUT)
365 printf ("<empty poll>");
370 /* Keep discarding input from the remote system, until STRING is found.
371 Let the user break out immediately. */
381 if (readchar () == *p)
395 /* Keep discarding input until we see the bug prompt.
397 The convention for dealing with the prompt is that you
399 o *then* wait for the prompt.
401 Thus the last thing that a procedure does with the serial line
402 will be an expect_prompt(). Exception: bug_resume does not
403 wait for the prompt, because the terminal is being handed over
404 to the inferior. However, the next thing which happens after that
405 is a bug_wait which does wait for the prompt.
406 Note that this includes abnormal exit, e.g. error(). This is
407 necessary to prevent getting into states from which we can't
415 /* Get a hex digit from the remote system & return its value.
416 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
418 get_hex_digit (ignore_space)
426 if (ch >= '0' && ch <= '9')
428 else if (ch >= 'A' && ch <= 'F')
429 return ch - 'A' + 10;
430 else if (ch >= 'a' && ch <= 'f')
431 return ch - 'a' + 10;
432 else if (ch != ' ' || !ignore_space)
435 error ("Invalid hex digit from remote system.");
440 /* Get a byte from bug_desc and put it in *BYT. Accept any number
448 val = get_hex_digit (1) << 4;
449 val |= get_hex_digit (0);
453 /* Read a 32-bit hex word from the bug, preceded by a space */
461 for (j = 0; j < 8; j++)
462 val = (val << 4) + get_hex_digit (j == 0);
466 /* Called when SIGALRM signal sent due to alarm() timeout. */
468 /* Number of SIGTRAPs we need to simulate. That is, the next
469 NEED_ARTIFICIAL_TRAP calls to bug_wait should just return
470 SIGTRAP without actually waiting for anything. */
472 static int need_artificial_trap = 0;
475 bug_kill (arg, from_tty)
483 * Download a file specified in 'args', to the bug.
487 bug_load (args, fromtty)
499 abfd = bfd_openr (args, 0);
502 printf_filtered ("Unable to open file %s\n", args);
506 if (bfd_check_format (abfd, bfd_object) == 0)
508 printf_filtered ("File is not an object file\n");
513 while (s != (asection *) NULL)
515 if (s->flags & SEC_LOAD)
519 char *buffer = xmalloc (srec_frame);
521 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, s->vma + s->_raw_size);
523 for (i = 0; i < s->_raw_size; i += srec_frame)
525 if (srec_frame > s->_raw_size - i)
526 srec_frame = s->_raw_size - i;
528 bfd_get_section_contents (abfd, s, buffer, i, srec_frame);
529 bug_write_inferior_memory (s->vma + i, buffer, srec_frame);
530 printf_filtered ("*");
533 printf_filtered ("\n");
538 sprintf (buffer, "rs ip %lx", (unsigned long) abfd->start_address);
539 bug_write_cr (buffer);
543 /* This is called not only when we first attach, but also when the
544 user types "run" after having attached. */
546 bug_create_inferior (execfile, args, env)
554 error ("Can't pass arguments to remote bug process.");
556 if (execfile == 0 || exec_bfd == 0)
557 error ("No exec file specified");
559 entry_pt = (int) bfd_get_start_address (exec_bfd);
562 bug_kill (NULL, NULL);
563 bug_clear_breakpoints ();
564 init_wait_for_inferior ();
568 insert_breakpoints (); /* Needed to get correct instruction in cache */
569 proceed (entry_pt, -1, 0);
588 while (*s && !isspace (*s))
594 copy = xmalloc (len + 1);
595 memcpy (copy, word, len);
601 static int baudrate = 9600;
604 bug_open (name, from_tty)
608 push_target (&bug_ops);
616 dev_name = strdup (name);
618 if (!(desc = SERIAL_OPEN (dev_name)))
619 perror_with_name ((char *) dev_name);
626 /* Hello? Are you there? */
627 SERIAL_WRITE (desc, "\r", 1);
630 /* Clear any break points */
631 bug_clear_breakpoints ();
633 printf_filtered ("Connected to remote 187bug system.\n");
636 /* Close out all files and local state before this target loses control. */
642 /* Clear any break points */
643 bug_clear_breakpoints ();
651 /* Terminate the open connection to the remote debugger.
652 Use this when you want to detach and do something else
655 bug_detach (args, from_tty)
660 bug_clear_breakpoints ();
662 pop_target (); /* calls bug_close to do the real work */
665 printf_filtered ("Ending remote %s debugging\n", target_shortname);
668 /* Tell the remote machine to resume. */
671 bug_resume (pid, step, sig)
680 /* Force the next bug_wait to return a trap. Not doing anything
681 about I/O from the target means that the user has to type
682 "continue" to see any. FIXME, this should be fixed. */
683 need_artificial_trap = 1;
695 /* Strings to look for. '?' means match any single character.
696 Note that with the algorithm we use, the initial character
697 of the string cannot recur in the string, or we will not
698 find some cases of the string in the input. */
703 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */
706 /* Current position in swallowed. */
707 char *swallowed_p = swallowed;
711 int swallowed_cr = 0;
715 QUIT; /* Let user quit and leave process running */
729 if (ch == *pb || *pb == '?')
746 /* Print out any characters which have been swallowed. */
747 for (p = swallowed; p < swallowed_p; ++p)
749 swallowed_p = swallowed;
751 if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
766 /* Wait until the remote machine stops, then return,
767 storing status in STATUS just as `wait' would. */
773 int old_timeout = timeout;
774 int old_immediate_quit = immediate_quit;
776 WSETEXIT ((*status), 0);
778 if (need_artificial_trap != 0)
780 WSETSTOP ((*status), SIGTRAP);
781 need_artificial_trap--;
782 /* user output from the target can be discarded here. (?) */
787 /* read off leftovers from resume */
788 expect("Effective address: ");
789 (void) get_hex_word();
792 timeout = -1; /* Don't time out -- user program is running. */
793 immediate_quit = 1; /* Helps ability to QUIT */
795 if (double_scan("At Breakpoint", "8???-Bug>"))
797 /* breakpoint case */
798 WSETSTOP ((*status), SIGTRAP);
802 WSETEXIT ((*status), 0);
805 timeout = old_timeout;
806 immediate_quit = old_immediate_quit;
810 /* Return the name of register number REGNO
811 in the form input and output by bug.
813 Returns a pointer to a static buffer containing the answer. */
818 static char *rn[] = {
819 "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07",
820 "r08", "r09", "r10", "r11", "r12", "r13", "r14", "r15",
821 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
822 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
824 /* these get confusing because we omit a few and switch some ordering around. */
826 "cr01", /* 32 = psr */
827 "fcr62", /* 33 = fpsr*/
828 "fcr63", /* 34 = fpcr */
829 "ip", /* this is something of a cheat. */
831 "cr05", /* 36 = snip */
832 "cr06", /* 37 = sfip */
845 SERIAL_WRITE (desc, a, l);
848 for (i = 0; i < l; i++)
860 bug_write (s, strlen (s));
865 /* Read from remote while the input matches STRING. Return zero on
866 success, -1 on failure. */
880 printf("\nNext character is '%c' - %d and s is \"%s\".\n", c, c, --s);
889 bug_srec_write_cr (s)
901 SERIAL_WRITE(desc, p, 1);
902 while (readchar_nofail() != *p);
907 /* return(bug_scan (s) || bug_scan ("\n")); */
913 /* Store register REGNO, or all if REGNO == -1. */
916 bug_fetch_register(regno)
919 REGISTER_TYPE regval;
926 for (i = 0; i < NUM_REGS; ++i)
927 bug_fetch_register(i);
932 bug_write_cr(get_reg_name(regno));
934 regval = get_hex_word();
937 /* the following registers contain flag bits in the lower to bit slots.
939 if (regno == PC_REGNUM /* aka sxip */
940 || regno == NPC_REGNUM /* aka snip */
941 || regno == SFIP_REGNUM) /* aka sfip */
944 supply_register(regno, (char *) ®val);
950 /* Store register REGNO, or all if REGNO == -1. */
953 bug_store_register (regno)
963 for (i = 0; i < NUM_REGS; ++i)
964 bug_store_register(i);
970 regname = (get_reg_name(regno));
972 sprintf(buffer, "rs %s %08x",
974 read_register(regno));
976 bug_write_cr(buffer);
983 /* Get ready to modify the registers array. On machines which store
984 individual registers, this doesn't need to do anything. On machines
985 which store all the registers in one fell swoop, this makes sure
986 that registers contains all the registers from the program being
990 bug_prepare_to_store ()
992 /* Do nothing, since we can store individual regs */
995 /* Read a word from remote address ADDR and return it.
996 * This goes through the data cache.
999 bug_fetch_word (addr)
1002 return dcache_fetch (addr);
1005 /* Write a word WORD into remote address ADDR.
1006 This goes through the data cache. */
1009 bug_store_word (addr, word)
1013 dcache_poke (addr, word);
1017 bug_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1022 struct target_ops *target; /* ignored */
1026 /* Round starting address down to longword boundary. */
1027 register CORE_ADDR addr;
1029 /* Round ending address up; get number of longwords that makes. */
1032 /* Allocate buffer of that many longwords. */
1033 register int *buffer;
1035 addr = memaddr & -sizeof (int);
1036 count = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
1038 buffer = (int *) alloca (count * sizeof (int));
1042 /* Fill start and end extra bytes of buffer with existing memory data. */
1044 if (addr != memaddr || len < (int) sizeof (int))
1046 /* Need part of initial word -- fetch it. */
1047 buffer[0] = bug_fetch_word (addr);
1050 if (count > 1) /* FIXME, avoid if even boundary */
1053 = bug_fetch_word (addr + (count - 1) * sizeof (int));
1056 /* Copy data to be written over corresponding part of buffer */
1058 bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
1060 /* Write the entire buffer. */
1062 for (i = 0; i < count; i++, addr += sizeof (int))
1065 bug_store_word (addr, buffer[i]);
1076 /* Read all the longwords */
1077 for (i = 0; i < count; i++, addr += sizeof (int))
1080 buffer[i] = bug_fetch_word (addr);
1088 /* Copy appropriate bytes out of the buffer. */
1089 bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
1100 command = (srec_echo_pace ? "lo 0 ;x" : "lo 0");
1102 bug_write_cr (command);
1105 bug_srec_write_cr ("S0030000FC");
1109 /* This is an extremely vulnerable and fragile function. I've made
1110 considerable attempts to make this deterministic, but I've
1111 certainly forgotten something. The trouble is that S-records are
1112 only a partial file format, not a protocol. Worse, apparently the
1113 m88k bug monitor does not run in real time while receiving
1114 S-records. Hence, we must pay excruciating attention to when and
1115 where error messages are returned, and what has actually been sent.
1117 Each call represents a chunk of memory to be sent to the target.
1118 We break that chunk into an S0 header record, some number of S3
1119 data records each containing srec_bytes, and an S7 termination
1123 bug_write_inferior_memory (memaddr, myaddr, len)
1125 unsigned char *myaddr;
1132 char buffer[(srec_bytes + 8) << 1];
1140 if (retries > srec_max_retries)
1146 printf("\n<retrying...>\n");
1148 /* This expect_prompt call is extremely important. Without
1149 it, we will tend to resend our packet so fast that it
1150 will arrive before the bug monitor is ready to receive
1151 it. This would lead to a very ugly resend loop. */
1166 thisgo = len - done;
1167 if (thisgo > srec_bytes)
1168 thisgo = srec_bytes;
1170 address = memaddr + done;
1171 sprintf (buf, "S3%02X%08X", thisgo + 4 + 1, address);
1174 checksum += (thisgo + 4 + 1
1176 + ((address >> 8) & 0xff)
1177 + ((address >> 16) & 0xff)
1178 + ((address >> 24) & 0xff));
1180 for (idx = 0; idx < thisgo; idx++)
1182 sprintf (buf, "%02X", myaddr[idx + done]);
1183 checksum += myaddr[idx + done];
1189 /* FIXME-NOW: insert a deliberate error every now and then.
1190 This is intended for testing/debugging the error handling
1192 static int counter = 0;
1193 if (++counter > srec_noise)
1200 sprintf(buf, "%02X", ~checksum & 0xff);
1201 bug_srec_write_cr (buffer);
1203 if (srec_sleep != 0)
1206 /* This pollchar is probably redundant to the double_scan
1207 below. Trouble is, we can't be sure when or where an
1208 error message will appear. Apparently, when running at
1209 full speed from a typical sun4, error messages tend to
1210 appear to arrive only *after* the s7 record. */
1212 if ((x = pollchar()) != 0)
1215 printf("\n<retrying...>\n");
1219 /* flush any remaining input and verify that we are back
1220 at the prompt level. */
1222 /* start all over again. */
1231 bug_srec_write_cr("S7060000000000F9");
1234 /* Having finished the load, we need to figure out whether we
1236 } while (double_scan("S-RECORD", "8???-Bug>"));;
1244 char *file = "nothing";
1247 file = bfd_get_filename (exec_bfd);
1251 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
1253 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
1255 printf_filtered ("\ton an m88k processor.\n");
1258 /* Copy LEN bytes of data from debugger memory at MYADDR
1259 to inferior's memory at MEMADDR. Returns errno value.
1260 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1263 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1264 at debugger address MYADDR. Returns errno value. */
1266 bug_read_inferior_memory (memaddr, myaddr, len)
1277 unsigned int inaddr;
1278 unsigned int checksum;
1280 sprintf(request, "du 0 %x:&%d", memaddr, len);
1281 bug_write_cr(request);
1283 p = buffer = alloca(len);
1285 /* scan up through the header */
1286 expect("S0030000FC");
1288 while (p < buffer + len)
1290 /* scan off any white space. */
1291 while (readchar() != 'S') ;;
1293 /* what kind of s-rec? */
1296 /* scan record size */
1297 get_hex_byte(&size);
1311 inaddr = (inaddr << 8) + c;
1314 /* intentional fall through */
1317 inaddr = (inaddr << 8) + c;
1320 /* intentional fall through */
1323 inaddr = (inaddr << 8) + c;
1327 inaddr = (inaddr << 8) + c;
1334 error("reading s-records.");
1337 if (inaddr < memaddr
1338 || (memaddr + len) < (inaddr + size))
1339 error("srec out of memory range.");
1341 if (p != buffer + inaddr - memaddr)
1342 error("srec out of sequence.");
1344 for (; size; --size, ++p)
1351 if (c != (~checksum & 0xff))
1352 error("bad s-rec checksum");
1357 if (p != buffer + len)
1360 memcpy(myaddr, buffer, len);
1364 #define MAX_BREAKS 16
1365 static int num_brkpts = 0;
1367 bug_insert_breakpoint (addr, save)
1369 char *save; /* Throw away, let bug save instructions */
1373 if (num_brkpts < MAX_BREAKS)
1378 sprintf (buffer, "br %x", addr);
1379 bug_write_cr (buffer);
1385 fprintf_filtered (stderr,
1386 "Too many break points, break point not installed\n");
1392 bug_remove_breakpoint (addr, save)
1394 char *save; /* Throw away, let bug save instructions */
1401 sprintf (buffer, "nobr %x", addr);
1402 bug_write_cr (buffer);
1409 /* Clear the bugs notion of what the break points are */
1411 bug_clear_breakpoints ()
1416 bug_write_cr ("nobr");
1427 bug_clear_breakpoints ();
1428 generic_mourn_inferior ();
1431 /* Put a command string, in args, out to the bug. The bug is assumed to
1432 be in raw mode, all writing/reading done through desc.
1433 Ouput from the bug is placed on the users terminal until the
1434 prompt from the bug is seen.
1435 FIXME: Can't handle commands that take input. */
1438 bug_com (args, fromtty)
1447 /* Clear all input so only command relative output is displayed */
1449 bug_write_cr (args);
1450 bug_write ("\030", 1);
1455 bug_quiet (args, fromtty)
1461 printf_filtered ("Snoop disabled\n");
1463 printf_filtered ("Snoop enabled\n");
1469 bug_device (args, fromtty)
1474 dev_name = get_word (&args);
1489 int newrate = atoi (s);
1492 if (SERIAL_SETBAUDRATE (desc, newrate))
1493 error ("Can't use %d baud\n", newrate);
1495 printf_filtered ("Checking target is in sync\n");
1497 printf_filtered ("Sending commands to set target to %d\n",
1500 sprintf (buffer, "tm %d. N 8 1", baudrate);
1501 bug_write_cr (buffer);
1506 struct target_ops bug_ops =
1508 "bug", "Remote BUG monitor",
1509 "Use the mvme187 board running the BUG monitor connected\n\
1512 bug_open, bug_close,
1513 0, bug_detach, bug_resume, bug_wait, /* attach */
1514 bug_fetch_register, bug_store_register,
1515 bug_prepare_to_store,
1516 bug_xfer_inferior_memory,
1518 bug_insert_breakpoint, bug_remove_breakpoint, /* Breakpoints */
1519 0, 0, 0, 0, 0, /* Terminal handling */
1520 bug_kill, /* FIXME, kill */
1522 0, /* lookup_symbol */
1523 bug_create_inferior, /* create_inferior */
1524 bug_mourn, /* mourn_inferior FIXME */
1526 0, /* notice_signals */
1527 process_stratum, 0, /* next */
1528 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
1529 0, 0, /* Section pointers */
1530 OPS_MAGIC, /* Always the last thing */
1534 _initialize_remote_bug ()
1536 add_target (&bug_ops);
1538 add_com ("bug <command>", class_obscure, bug_com,
1539 "Send a command to the BUG monitor.");
1540 add_com ("snoop", class_obscure, bug_quiet,
1541 "Show what commands are going to the monitor");
1543 add_com ("device", class_obscure, bug_device,
1544 "Set the terminal line for BUG communications");
1547 add_com ("speed", class_obscure, bug_speed,
1548 "Set the terminal line speed for BUG communications");
1552 (add_set_cmd ("srec-bytes", class_support, var_uinteger,
1553 (char *) &srec_bytes,
1555 Set the number of bytes represented in each S-record.\n\
1556 This affects the communication protocol with the remote target.",
1561 (add_set_cmd ("srec-max-retries", class_support, var_uinteger,
1562 (char *) &srec_max_retries,
1564 Set the number of retries for shipping S-records.\n\
1565 This affects the communication protocol with the remote target.",
1570 (add_set_cmd ("srec-frame", class_support, var_uinteger,
1571 (char *) &srec_frame,
1573 Set the number of bytes in an S-record frame.\n\
1574 This affects the communication protocol with the remote target.",
1579 (add_set_cmd ("srec-noise", class_support, var_zinteger,
1580 (char *) &srec_noise,
1582 Set number of S-record to send before deliberately flubbing a checksum.\n\
1583 Zero means flub none at all. This affects the communication protocol\n\
1584 with the remote target.",
1589 (add_set_cmd ("srec-sleep", class_support, var_zinteger,
1590 (char *) &srec_sleep,
1592 Set number of seconds to sleep after an S-record for a possible error message to arrive.\n\
1593 This affects the communication protocol with the remote target.",
1598 (add_set_cmd ("srec-echo-pace", class_support, var_boolean,
1599 (char *) &srec_echo_pace,
1601 Set echo-verification.\n\
1602 When on, use verification by echo when downloading S-records. This is\n\
1603 much slower, but generally more reliable.",