1 /* Remote debugging interface for Hitachi HMS Monitor Version 1.0
2 Copyright 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by Steve Chamberlain
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 static void hms_open PARAMS ((char *args, int from_tty));
31 hms_supply_register (regname, regnamelen, val, vallen)
41 if (regname[0] != 'P')
43 /* We scan off all the registers in one go */
45 val = monitor_supply_register (PC_REGNUM, val);
46 /* Skip the ccr string */
47 while (*val != '=' && *val)
50 val = monitor_supply_register (CCR_REGNUM, val + 1);
52 /* Skip up to rest of regs */
53 while (*val != '=' && *val)
56 for (regno = 0; regno < 7; regno++)
58 val = monitor_supply_register (regno, val + 1);
63 * This array of registers needs to match the indexes used by GDB. The
64 * whole reason this exists is because the various ROM monitors use
65 * different names than GDB does, and don't support all the
66 * registers either. So, typing "info reg sp" becomes a "r30".
69 static char *hms_regnames[NUM_REGS] =
71 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "CCR", "PC"
75 * Define the monitor command strings. Since these are passed directly
76 * through to a printf style function, we need can include formatting
77 * strings. We also need a CR or LF on the end.
80 static struct target_ops hms_ops;
82 static char *hms_inits[] =
83 {"\003", /* Resets the prompt, and clears repeated cmds */
86 static struct monitor_ops hms_cmds =
88 MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_GETMEM_NEEDS_RANGE,
89 hms_inits, /* Init strings */
90 "g\r", /* continue command */
91 "s\r", /* single step */
92 "\003", /* ^C interrupts the program */
93 "b %x\r", /* set a breakpoint */
94 "b - %x\r", /* clear a breakpoint */
95 "b -\r", /* clear all breakpoints */
96 "f %x %x %x\r", /* fill (start end val) */
98 "m.b %x=%x\r", /* setmem.cmdb (addr, value) */
99 "m.w %x=%x\r", /* setmem.cmdw (addr, value) */
100 NULL, /* setmem.cmdl (addr, value) */
101 NULL, /* setmem.cmdll (addr, value) */
102 NULL, /* setreg.resp_delim */
103 NULL, /* setreg.term */
104 NULL, /* setreg.term_cmd */
107 "m.b %x %x\r", /* getmem.cmdb (addr, addr) */
108 "m.w %x %x\r", /* getmem.cmdw (addr, addr) */
109 NULL, /* getmem.cmdl (addr, addr) */
110 NULL, /* getmem.cmdll (addr, addr) */
111 ": ", /* getmem.resp_delim */
112 ">", /* getmem.term */
113 "\003", /* getmem.term_cmd */
116 "r %s=%x\r", /* setreg.cmd (name, value) */
117 NULL, /* setreg.resp_delim */
118 NULL, /* setreg.term */
119 NULL /* setreg.term_cmd */
122 "r %s\r", /* getreg.cmd (name) */
123 " (", /* getreg.resp_delim */
124 ":", /* getreg.term */
125 "\003", /* getreg.term_cmd */
127 "r\r", /* dump_registers */
128 "\\(\\w+\\)=\\([0-9a-fA-F]+\\)", /* register_pattern */
129 hms_supply_register, /* supply_register */
130 NULL, /* load_routine (defaults to SRECs) */
131 "tl\r", /* download command */
132 NULL, /* load response */
133 ">", /* monitor command prompt */
134 "\r", /* end-of-command delimitor */
135 NULL, /* optional command terminator */
136 &hms_ops, /* target operations */
137 SERIAL_1_STOPBITS, /* number of stop bits */
138 hms_regnames, /* registers names */
139 MONITOR_OPS_MAGIC /* magic */
143 hms_open (args, from_tty)
147 monitor_open (args, &hms_cmds, from_tty);
150 int write_dos_tick_delay;
153 _initialize_remote_hms ()
155 init_monitor_ops (&hms_ops);
157 hms_ops.to_shortname = "hms";
158 hms_ops.to_longname = "Hitachi Microsystems H8/300 debug monitor";
159 hms_ops.to_doc = "Debug via the HMS monitor.\n\
160 Specify the serial device it is connected to (e.g. /dev/ttya).";
161 hms_ops.to_open = hms_open;
162 /* By trial and error I've found that this delay doesn't break things */
163 write_dos_tick_delay = 1;
164 add_target (&hms_ops);
169 /* This is kept here because we used to support the H8/500 in this module,
170 and I haven't done the H8/500 yet */
172 #include "inferior.h"
175 #include "gdb_string.h"
181 #include "terminal.h"
185 #include "remote-utils.h"
186 /* External data declarations */
187 extern int stop_soon_quietly; /* for wait_for_inferior */
189 /* Forward data declarations */
190 extern struct target_ops hms_ops; /* Forward declaration */
192 /* Forward function declarations */
193 static void hms_fetch_registers ();
194 static int hms_store_registers ();
195 static void hms_close ();
196 static int hms_clear_breakpoints ();
198 extern struct target_ops hms_ops;
199 static void hms_drain ();
200 static void add_commands ();
201 static void remove_commands ();
203 static int quiet = 1; /* FIXME - can be removed after Dec '94 */
207 /***********************************************************************
208 * I/O stuff stolen from remote-eb.c
209 ***********************************************************************/
211 static int timeout = 2;
213 static const char *dev_name;
215 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
216 hms_open knows that we don't have a file open when the program
219 static int before = 0xdead;
220 static int is_open = 0;
221 static int after = 0xdead;
227 printf ("OUTCH! \n");
230 error ("remote device not open");
237 /* Read a character from the remote system, doing all the fancy
244 buf = SERIAL_READCHAR (desc, timeout);
246 if (buf == SERIAL_TIMEOUT)
248 hms_write (".\r\n", 3);
249 error ("Timeout reading from remote system.");
251 if (buf == SERIAL_ERROR)
253 error ("Serial port error!");
256 if (!quiet || remote_debug)
257 printf_unfiltered ("%c", buf);
267 int b = SERIAL_READCHAR (desc, 0);
268 if (b == SERIAL_TIMEOUT)
278 buf = SERIAL_READCHAR (desc, timeout);
279 if (buf == SERIAL_TIMEOUT)
281 if (!quiet || remote_debug)
282 printf_unfiltered ("%c", buf);
288 /* Keep discarding input from the remote system, until STRING is found.
289 Let the user break out immediately. */
318 /* Keep discarding input until we see the hms prompt.
320 The convention for dealing with the prompt is that you
322 o *then* wait for the prompt.
324 Thus the last thing that a procedure does with the serial line
325 will be an expect_prompt(). Exception: hms_resume does not
326 wait for the prompt, because the terminal is being handed over
327 to the inferior. However, the next thing which happens after that
328 is a hms_wait which does wait for the prompt.
329 Note that this includes abnormal exit, e.g. error(). This is
330 necessary to prevent getting into states from which we can't
338 /* Get a hex digit from the remote system & return its value.
339 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
341 get_hex_digit (ignore_space)
349 if (ch >= '0' && ch <= '9')
351 else if (ch >= 'A' && ch <= 'F')
352 return ch - 'A' + 10;
353 else if (ch >= 'a' && ch <= 'f')
354 return ch - 'a' + 10;
355 else if (ch == ' ' && ignore_space)
360 error ("Invalid hex digit from remote system.");
365 /* Get a byte from hms_desc and put it in *BYT. Accept any number
373 val = get_hex_digit (1) << 4;
374 val |= get_hex_digit (0);
378 /* Read a 32-bit hex word from the hms, preceded by a space */
386 for (j = 0; j < 8; j++)
387 val = (val << 4) + get_hex_digit (j == 0);
391 /* Called when SIGALRM signal sent due to alarm() timeout. */
393 /* Number of SIGTRAPs we need to simulate. That is, the next
394 NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
395 SIGTRAP without actually waiting for anything. */
397 static int need_artificial_trap = 0;
400 hms_kill (arg, from_tty)
407 /* This is called not only when we first attach, but also when the
408 user types "run" after having attached. */
410 hms_create_inferior (execfile, args, env)
419 error ("Can't pass arguments to remote hms process.");
421 if (execfile == 0 || exec_bfd == 0)
422 error ("No exec file specified");
424 entry_pt = (int) bfd_get_start_address (exec_bfd);
427 hms_kill (NULL, NULL);
428 hms_clear_breakpoints ();
429 init_wait_for_inferior ();
433 insert_breakpoints (); /* Needed to get correct instruction in cache */
434 proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
437 /* Open a connection to a remote debugger.
438 NAME is the filename used for communication, then a space,
446 while (*s && !isspace (*s))
467 while (*s && !isspace (*s))
473 copy = xmalloc (len + 1);
474 memcpy (copy, word, len);
480 static int baudrate = 9600;
487 /* Put this port into NORMAL mode, send the 'normal' character */
489 hms_write ("\001", 1); /* Control A */
490 hms_write ("\r\n", 2); /* Cr */
494 ok = SERIAL_READCHAR (desc, timeout);
501 if (readchar_nofail () == 'r')
504 /* Not the right baudrate, or the board's not on */
510 if (!SERIAL_SETBAUDRATE (desc, baudrate))
511 error ("Can't set baudrate");
516 /* Close out all files and local state before this target loses control. */
522 /* Clear any break points */
524 hms_clear_breakpoints ();
525 sleep (1); /* Let any output make it all the way back */
528 SERIAL_WRITE (desc, "R\r\n", 3);
534 /* Terminate the open connection to the remote debugger. Use this
535 when you want to detach and do something else with your gdb. */ void
536 hms_detach (args, from_tty)
542 hms_clear_breakpoints ();
545 pop_target (); /* calls hms_close to do the real work
548 printf_filtered ("Ending remote %s debugging\n",
552 /* Tell the remote machine to resume. */
555 hms_resume (pid, step, sig)
565 /* Force the next hms_wait to return a trap. Not doing anything
566 about I/O from the target means that the user has to type "continue"
567 to see any. FIXME, this should be fixed. */
568 need_artificial_trap = 1;
577 /* Wait until the remote machine stops, then return, storing status in
578 STATUS just as `wait' would. */
581 hms_wait (pid, status)
583 struct target_waitstatus *status;
585 /* Strings to look for. '?' means match any single character. Note
586 that with the algorithm we use, the initial character of the string
587 cannot recur in the string, or we will not find some cases of the
588 string in the input. */
590 static char bpt[] = "At breakpoint:";
592 /* It would be tempting to look for "\n[__exit + 0x8]\n" but that
593 requires loading symbols with "yc i" and even if we did do that we
594 don't know that the file has symbols. */
595 static char exitmsg[] = "HMS>";
599 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.
603 /* Current position in swallowed. */
604 char *swallowed_p = swallowed;
608 int old_timeout = timeout;
610 old_immediate_quit = immediate_quit;
611 int swallowed_cr = 0;
613 status->kind = TARGET_WAITKIND_EXITED;
614 status->value.integer = 0;
616 if (need_artificial_trap != 0)
619 TARGET_WAITKIND_STOPPED;
620 status->value.sig = TARGET_SIGNAL_TRAP;
621 need_artificial_trap--;
625 timeout = 5; /* Don't time out for a while - user program is running.
627 immediate_quit = 1; /* Helps ability to QUIT */
630 QUIT; /* Let user quit and leave process running */
647 (ch == *ep || *ep == '?')
667 /* Print out any characters which have been swallowed. */
668 for (p = swallowed; p < swallowed_p; ++p)
669 putchar_unfiltered (*p);
670 swallowed_p = swallowed;
672 if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
674 putchar_unfiltered (ch);
683 status->kind = TARGET_WAITKIND_STOPPED;
684 status->value.sig = TARGET_SIGNAL_TRAP;
689 status->kind = TARGET_WAITKIND_EXITED;
690 status->value.integer =
694 timeout = old_timeout;
695 immediate_quit = old_immediate_quit;
700 /* Return the name of register number REGNO in the form input and
703 Returns a pointer to a static buffer containing the answer. */
714 /* Read the remote registers. */
717 gethex (length, start, ok)
727 if (*start >= 'a' && *start <= 'f')
729 result += *start - 'a' + 10;
731 else if (*start >= 'A' &&
734 result += *start - 'A' + 10;
737 (*start >= '0' && *start <= '9')
739 result += *start - '0';
749 timed_read (buf, n, timeout)
776 SERIAL_WRITE (desc, a, l);
778 if (!quiet || remote_debug)
780 printf_unfiltered ("<");
781 for (i = 0; i < l; i++)
783 printf_unfiltered ("%c", a[i]);
785 printf_unfiltered (">");
792 hms_write (s, strlen (s));
793 hms_write ("\r\n", 2);
796 #ifdef GDB_TARGET_IS_H8500
798 /* H8/500 monitor reg dump looks like:
801 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
802 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
808 supply_val (n, size, ptr, segptr)
819 raw[0] = gethex (2, ptr, &ok);
820 raw[1] = gethex (2, ptr + 2, &ok);
821 supply_register (n, raw);
824 raw[0] = gethex (2, ptr, &ok);
825 supply_register (n, raw);
829 int v = gethex (4, ptr, &ok);
830 v |= gethex (2, segptr, &ok) << 16;
832 raw[1] = (v >> 16) & 0xff;
833 raw[2] = (v >> 8) & 0xff;
834 raw[3] = (v >> 0) & 0xff;
835 supply_register (n, raw);
841 hms_fetch_register (dummy)
844 #define REGREPLY_SIZE 108
845 char linebuf[REGREPLY_SIZE + 1];
850 LONGEST reg[NUM_REGS];
858 s = timed_read (linebuf + 1, REGREPLY_SIZE, 1);
860 linebuf[REGREPLY_SIZE] = 0;
862 if (linebuf[3] == 'P' &&
865 linebuf[105] == 'H' &&
866 linebuf[106] == 'M' &&
873 -------1---------2---------3---------4---------5-----
874 345678901234567890123456789012345678901234567890123456
875 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
876 ---6---------7---------8---------9--------10----
877 789012345678901234567890123456789012345678901234
878 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
886 supply_val (PC_REGNUM, 4, linebuf + 6, linebuf + 29);
888 supply_val (CCR_REGNUM, 2, linebuf + 14);
889 supply_val (SEG_C_REGNUM, 1, linebuf + 29);
890 supply_val (SEG_D_REGNUM, 1, linebuf + 35);
891 supply_val (SEG_E_REGNUM, 1, linebuf + 41);
892 supply_val (SEG_T_REGNUM, 1, linebuf + 47);
893 for (i = 0; i < 8; i++)
900 char *src = linebuf + 64 + 5 * i;
901 char *segsrc = linebuf + sr[i];
902 supply_val (R0_REGNUM + i, 2, src);
903 supply_val (PR0_REGNUM + i, 4, src, segsrc);
916 #ifdef GDB_TARGET_IS_H8300
918 hms_fetch_register (dummy)
921 #define REGREPLY_SIZE 79
922 char linebuf[REGREPLY_SIZE + 1];
927 unsigned LONGEST reg[NUM_REGS];
935 s = timed_read (linebuf, 1, 1);
937 while (linebuf[0] != 'r')
938 s = timed_read (linebuf, 1, 1);
940 s = timed_read (linebuf + 1, REGREPLY_SIZE - 1, 1);
942 linebuf[REGREPLY_SIZE] = 0;
944 if (linebuf[0] == 'r' &&
948 linebuf[75] == 'H' &&
949 linebuf[76] == 'M' &&
953 PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
954 5436789012345678901234567890123456789012345678901234567890123456789012
959 reg[PC_REGNUM] = gethex (4, linebuf + 6, &gottok);
960 reg[CCR_REGNUM] = gethex (2, linebuf + 15, &gottok);
961 for (i = 0; i < 8; i++)
963 reg[i] = gethex (4, linebuf + 34 + 5 * i, &gottok);
968 for (i = 0; i < NUM_REGS; i++)
973 swapped[0] = (reg[i]) >> 8;
975 supply_register (i, swapped);
979 /* Store register REGNO, or all if REGNO == -1.
980 Return errno value. */
982 hms_store_register (regno)
987 for (regno = 0; regno < NUM_REGS; regno++)
989 hms_store_register (regno);
994 char *name = get_reg_name (regno);
996 /* Some regs dont really exist */
997 if (!(name[0] == 'p' && name[1] == 'r')
998 && !(name[0] == 'c' && name[1] == 'y')
999 && !(name[0] == 't' && name[1] == 'i')
1000 && !(name[0] == 'i' && name[1] == 'n'))
1002 sprintf (buffer, "r %s=%x", name, read_register (regno));
1003 hms_write_cr (buffer);
1010 /* Get ready to modify the registers array. On machines which store
1011 individual registers, this doesn't need to do anything. On machines
1012 which store all the registers in one fell swoop, this makes sure
1013 that registers contains all the registers from the program being
1017 hms_prepare_to_store ()
1019 /* Do nothing, since we can store individual regs */
1023 translate_addr (addr)
1033 hms_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1038 struct target_ops *target; /* ignored */
1045 hms_write_inferior_memory (memaddr, myaddr, len)
1047 unsigned char *myaddr;
1063 thisgo = len - done;
1067 sprintf (ptr, "M.B %4x =", memaddr + done);
1069 for (idx = 0; idx < thisgo; idx++)
1071 sprintf (ptr, "%2x ", myaddr[idx + done]);
1074 hms_write_cr (buffer);
1083 char *file = "nothing";
1086 file = bfd_get_filename (exec_bfd);
1090 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
1092 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
1094 printf_filtered ("\ton an H8/300 processor.\n");
1097 /* Copy LEN bytes of data from debugger memory at MYADDR
1098 to inferior's memory at MEMADDR. Returns errno value.
1099 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1102 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1103 at debugger address MYADDR. Returns errno value. */
1105 hms_read_inferior_memory (memaddr, myaddr, len)
1110 /* Align to nearest low 16 bits */
1113 CORE_ADDR start = memaddr;
1114 CORE_ADDR end = memaddr + len - 1;
1119 AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
1120 012345678901234567890123456789012345678901234567890123456789012345
1130 sprintf (buffer, "m %4x %4x", start & 0xffff, end & 0xffff);
1133 hms_write_cr (buffer);
1134 /* drop the echo and newline */
1135 for (i = 0; i < 13; i++)
1138 /* Grab the lines as they come out and fill the area */
1149 buffer[0] = readchar ();
1150 while (buffer[0] == '\r'
1151 || buffer[0] == '\n')
1152 buffer[0] = readchar ();
1154 if (buffer[0] == 'M')
1157 for (i = 1; i < 50; i++)
1159 buffer[i] = readchar ();
1161 /* sometimes we loose characters in the ascii representation of the
1162 data. I don't know where. So just scan for the end of line */
1164 while (i != '\n' && i != '\r')
1167 /* Now parse the line */
1169 addr = gethex (4, buffer, &ok);
1171 for (p = 0; p < 16; p += 2)
1173 byte[p] = gethex (2, buffer + idx, &ok);
1174 byte[p + 1] = gethex (2, buffer + idx + 2, &ok);
1178 for (p = 0; p < 16; p++)
1180 if (addr + p >= memaddr &&
1181 addr + p < memaddr + len)
1183 myaddr[(addr + p) - memaddr] = byte[p];
1189 #ifdef GDB_TARGET_IS_H8500
1192 #ifdef GDB_TARGET_IS_H8300
1203 #define MAX_BREAKS 16
1204 static int num_brkpts = 0;
1206 hms_insert_breakpoint (addr, save)
1208 char *save; /* Throw away, let hms save instructions */
1212 if (num_brkpts < MAX_BREAKS)
1217 sprintf (buffer, "b %x", addr & 0xffff);
1218 hms_write_cr (buffer);
1224 fprintf_filtered (gdb_stderr,
1225 "Too many break points, break point not installed\n");
1231 hms_remove_breakpoint (addr, save)
1233 char *save; /* Throw away, let hms save instructions */
1240 sprintf (buffer, "b - %x", addr & 0xffff);
1241 hms_write_cr (buffer);
1248 /* Clear the hmss notion of what the break points are */
1250 hms_clear_breakpoints ()
1255 hms_write_cr ("b -");
1263 hms_clear_breakpoints ();
1264 unpush_target (&hms_ops);
1265 generic_mourn_inferior ();
1268 /* Put a command string, in args, out to the hms. The hms is assumed to
1269 be in raw mode, all writing/reading done through desc.
1270 Ouput from the hms is placed on the users terminal until the
1271 prompt from the hms is seen.
1272 FIXME: Can't handle commands that take input. */
1275 hms_com (args, fromtty)
1284 /* Clear all input so only command relative output is displayed */
1286 hms_write_cr (args);
1287 /* hms_write ("\030", 1); */
1292 hms_open (name, from_tty)
1305 dev_name = strdup (name);
1307 if (!(desc = SERIAL_OPEN (dev_name)))
1308 perror_with_name ((char *) dev_name);
1312 push_target (&hms_ops);
1313 dcache_ptr = dcache_init (hms_read_inferior_memory,
1314 hms_write_inferior_memory);
1316 /* Hello? Are you there? */
1317 SERIAL_WRITE (desc, "\r\n", 2);
1320 /* Clear any break points */
1321 hms_clear_breakpoints ();
1323 printf_filtered ("Connected to remote board running HMS monitor.\n");
1328 /* Define the target subroutine names */
1330 struct target_ops hms_ops =
1332 "hms", "Remote HMS monitor",
1333 "Use the H8 evaluation board running the HMS monitor connected\n\
1336 hms_open, hms_close,
1337 0, hms_detach, hms_resume, hms_wait, /* attach */
1338 hms_fetch_register, hms_store_register,
1339 hms_prepare_to_store,
1340 hms_xfer_inferior_memory,
1342 hms_insert_breakpoint, hms_remove_breakpoint, /* Breakpoints */
1343 0, 0, 0, 0, 0, /* Terminal handling */
1344 hms_kill, /* FIXME, kill */
1346 0, /* lookup_symbol */
1347 hms_create_inferior, /* create_inferior */
1348 hms_mourn, /* mourn_inferior FIXME */
1350 0, /* notice_signals */
1352 process_stratum, 0, /* next */
1353 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
1354 0, 0, /* Section pointers */
1355 OPS_MAGIC, /* Always the last thing */
1358 hms_quiet () /* FIXME - this routine can be removed after Dec '94 */
1362 printf_filtered ("Snoop disabled\n");
1364 printf_filtered ("Snoop enabled\n");
1366 printf_filtered ("`snoop' is obsolete, please use `set remotedebug'.\n");
1374 dev_name = get_word (&s);
1387 int newrate = atoi (s);
1390 if (SERIAL_SETBAUDRATE (desc, newrate))
1391 error ("Can't use %d baud\n", newrate);
1393 printf_filtered ("Checking target is in sync\n");
1395 printf_filtered ("Sending commands to set target to %d\n",
1398 sprintf (buffer, "tm %d. N 8 1", baudrate);
1399 hms_write_cr (buffer);
1403 /***********************************************************************/
1406 hms_drain (args, fromtty)
1413 c = SERIAL_READCHAR (desc, 1);
1414 if (c == SERIAL_TIMEOUT)
1416 if (c == SERIAL_ERROR)
1418 if (c > ' ' && c < 127)
1419 printf ("%c", c & 0xff);
1421 printf ("<%x>", c & 0xff);
1429 add_com ("hms_drain", class_obscure, hms_drain,
1430 "Drain pending hms text buffers.");
1436 extern struct cmd_list_element *cmdlist;
1437 delete_cmd ("hms-drain", &cmdlist);
1442 _initialize_remote_hms ()
1444 add_target (&hms_ops);
1446 add_com ("hms <command>", class_obscure, hms_com,
1447 "Send a command to the HMS monitor.");
1449 /* FIXME - hms_quiet and `snoop' can be removed after Dec '94 */
1450 add_com ("snoop", class_obscure, hms_quiet,
1451 "Show what commands are going to the monitor (OBSOLETE - see 'set remotedebug')");
1453 add_com ("device", class_obscure, hms_device,
1454 "Set the terminal line for HMS communications");
1456 add_com ("speed", class_obscure, hms_speed,
1457 "Set the terminal line speed for HMS communications");