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));
30 hms_supply_register (regname, regnamelen, val, vallen)
40 if (regname[0] != 'P')
42 /* We scan off all the registers in one go */
44 val = monitor_supply_register (PC_REGNUM, val);
45 /* Skip the ccr string */
46 while (*val != '=' && *val)
49 val = monitor_supply_register (CCR_REGNUM, val + 1);
51 /* Skip up to rest of regs */
52 while (*val != '=' && *val)
55 for (regno = 0; regno < 7; regno++)
57 val = monitor_supply_register (regno, val + 1);
62 * This array of registers needs to match the indexes used by GDB. The
63 * whole reason this exists is because the various ROM monitors use
64 * different names than GDB does, and don't support all the
65 * registers either. So, typing "info reg sp" becomes a "r30".
68 static char *hms_regnames[NUM_REGS] =
70 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "CCR", "PC"
74 * Define the monitor command strings. Since these are passed directly
75 * through to a printf style function, we need can include formatting
76 * strings. We also need a CR or LF on the end.
79 static struct target_ops hms_ops;
81 static char *hms_inits[] =
82 {"\003", /* Resets the prompt, and clears repeated cmds */
85 static struct monitor_ops hms_cmds ;
86 static void init_hms_cmds(void)
88 hms_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_GETMEM_NEEDS_RANGE;
89 hms_cmds.init = hms_inits; /* Init strings */
90 hms_cmds.cont = "g\r"; /* continue command */
91 hms_cmds.step = "s\r"; /* single step */
92 hms_cmds.stop = "\003"; /* ^C interrupts the program */
93 hms_cmds.set_break = "b %x\r"; /* set a breakpoint */
94 hms_cmds.clr_break = "b - %x\r"; /* clear a breakpoint */
95 hms_cmds.clr_all_break = "b -\r"; /* clear all breakpoints */
96 hms_cmds.fill = "f %x %x %x\r"; /* fill (start end val) */
97 hms_cmds.setmem.cmdb = "m.b %x=%x\r"; /* setmem.cmdb (addr, value) */
98 hms_cmds.setmem.cmdw = "m.w %x=%x\r"; /* setmem.cmdw (addr, value) */
99 hms_cmds.setmem.cmdl = NULL; /* setmem.cmdl (addr, value) */
100 hms_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
101 hms_cmds.setmem.resp_delim = NULL;/* setreg.resp_delim */
102 hms_cmds.setmem.term = NULL; /* setreg.term */
103 hms_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */
104 hms_cmds.getmem.cmdb = "m.b %x %x\r"; /* getmem.cmdb (addr, addr) */
105 hms_cmds.getmem.cmdw = "m.w %x %x\r"; /* getmem.cmdw (addr, addr) */
106 hms_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, addr) */
107 hms_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr) */
108 hms_cmds.getmem.resp_delim = ": ";/* getmem.resp_delim */
109 hms_cmds.getmem.term = ">"; /* getmem.term */
110 hms_cmds.getmem.term_cmd = "\003";/* getmem.term_cmd */
111 hms_cmds.setreg.cmd = "r %s=%x\r";/* setreg.cmd (name, value) */
112 hms_cmds.setreg.resp_delim = NULL;/* setreg.resp_delim */
113 hms_cmds.setreg.term = NULL; /* setreg.term */
114 hms_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
115 hms_cmds.getreg.cmd = "r %s\r"; /* getreg.cmd (name) */
116 hms_cmds.getreg.resp_delim = " (";/* getreg.resp_delim */
117 hms_cmds.getreg.term = ":"; /* getreg.term */
118 hms_cmds.getreg.term_cmd = "\003";/* getreg.term_cmd */
119 hms_cmds.dump_registers = "r\r"; /* dump_registers */
120 hms_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */
121 hms_cmds.supply_register = hms_supply_register; /* supply_register */
122 hms_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
123 hms_cmds.load = "tl\r"; /* download command */
124 hms_cmds.loadresp = NULL; /* load response */
125 hms_cmds.prompt = ">"; /* monitor command prompt */
126 hms_cmds.line_term = "\r"; /* end-of-command delimitor */
127 hms_cmds.cmd_end = NULL; /* optional command terminator */
128 hms_cmds.target = &hms_ops; /* target operations */
129 hms_cmds.stopbits = SERIAL_1_STOPBITS;/* number of stop bits */
130 hms_cmds.regnames = hms_regnames; /* registers names */
131 hms_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
132 } /* init_hms-cmds */
135 hms_open (args, from_tty)
139 monitor_open (args, &hms_cmds, from_tty);
142 int write_dos_tick_delay;
145 _initialize_remote_hms ()
148 init_monitor_ops (&hms_ops);
150 hms_ops.to_shortname = "hms";
151 hms_ops.to_longname = "Hitachi Microsystems H8/300 debug monitor";
152 hms_ops.to_doc = "Debug via the HMS monitor.\n\
153 Specify the serial device it is connected to (e.g. /dev/ttya).";
154 hms_ops.to_open = hms_open;
155 /* By trial and error I've found that this delay doesn't break things */
156 write_dos_tick_delay = 1;
157 add_target (&hms_ops);
162 /* This is kept here because we used to support the H8/500 in this module,
163 and I haven't done the H8/500 yet */
165 #include "inferior.h"
168 #include "gdb_string.h"
174 #include "terminal.h"
178 #include "remote-utils.h"
179 /* External data declarations */
180 extern int stop_soon_quietly; /* for wait_for_inferior */
182 /* Forward data declarations */
183 extern struct target_ops hms_ops; /* Forward declaration */
185 /* Forward function declarations */
186 static void hms_fetch_registers ();
187 static int hms_store_registers ();
188 static void hms_close ();
189 static int hms_clear_breakpoints ();
191 extern struct target_ops hms_ops;
192 static void hms_drain ();
193 static void add_commands ();
194 static void remove_commands ();
196 static int quiet = 1; /* FIXME - can be removed after Dec '94 */
200 /***********************************************************************
201 * I/O stuff stolen from remote-eb.c
202 ***********************************************************************/
204 static int timeout = 2;
206 static const char *dev_name;
208 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
209 hms_open knows that we don't have a file open when the program
212 static int before = 0xdead;
213 static int is_open = 0;
214 static int after = 0xdead;
220 printf ("OUTCH! \n");
223 error ("remote device not open");
230 /* Read a character from the remote system, doing all the fancy
237 buf = SERIAL_READCHAR (desc, timeout);
239 if (buf == SERIAL_TIMEOUT)
241 hms_write (".\r\n", 3);
242 error ("Timeout reading from remote system.");
244 if (buf == SERIAL_ERROR)
246 error ("Serial port error!");
249 if (!quiet || remote_debug)
250 printf_unfiltered ("%c", buf);
260 int b = SERIAL_READCHAR (desc, 0);
261 if (b == SERIAL_TIMEOUT)
271 buf = SERIAL_READCHAR (desc, timeout);
272 if (buf == SERIAL_TIMEOUT)
274 if (!quiet || remote_debug)
275 printf_unfiltered ("%c", buf);
281 /* Keep discarding input from the remote system, until STRING is found.
282 Let the user break out immediately. */
311 /* Keep discarding input until we see the hms prompt.
313 The convention for dealing with the prompt is that you
315 o *then* wait for the prompt.
317 Thus the last thing that a procedure does with the serial line
318 will be an expect_prompt(). Exception: hms_resume does not
319 wait for the prompt, because the terminal is being handed over
320 to the inferior. However, the next thing which happens after that
321 is a hms_wait which does wait for the prompt.
322 Note that this includes abnormal exit, e.g. error(). This is
323 necessary to prevent getting into states from which we can't
331 /* Get a hex digit from the remote system & return its value.
332 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
334 get_hex_digit (ignore_space)
342 if (ch >= '0' && ch <= '9')
344 else if (ch >= 'A' && ch <= 'F')
345 return ch - 'A' + 10;
346 else if (ch >= 'a' && ch <= 'f')
347 return ch - 'a' + 10;
348 else if (ch == ' ' && ignore_space)
353 error ("Invalid hex digit from remote system.");
358 /* Get a byte from hms_desc and put it in *BYT. Accept any number
366 val = get_hex_digit (1) << 4;
367 val |= get_hex_digit (0);
371 /* Read a 32-bit hex word from the hms, preceded by a space */
379 for (j = 0; j < 8; j++)
380 val = (val << 4) + get_hex_digit (j == 0);
384 /* Called when SIGALRM signal sent due to alarm() timeout. */
386 /* Number of SIGTRAPs we need to simulate. That is, the next
387 NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
388 SIGTRAP without actually waiting for anything. */
390 static int need_artificial_trap = 0;
393 hms_kill (arg, from_tty)
400 /* This is called not only when we first attach, but also when the
401 user types "run" after having attached. */
403 hms_create_inferior (execfile, args, env)
412 error ("Can't pass arguments to remote hms process.");
414 if (execfile == 0 || exec_bfd == 0)
415 error ("No executable file specified");
417 entry_pt = (int) bfd_get_start_address (exec_bfd);
420 hms_kill (NULL, NULL);
421 hms_clear_breakpoints ();
422 init_wait_for_inferior ();
426 insert_breakpoints (); /* Needed to get correct instruction in cache */
427 proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
430 /* Open a connection to a remote debugger.
431 NAME is the filename used for communication, then a space,
439 while (*s && !isspace (*s))
460 while (*s && !isspace (*s))
466 copy = xmalloc (len + 1);
467 memcpy (copy, word, len);
473 static int baudrate = 9600;
480 /* Put this port into NORMAL mode, send the 'normal' character */
482 hms_write ("\001", 1); /* Control A */
483 hms_write ("\r\n", 2); /* Cr */
487 ok = SERIAL_READCHAR (desc, timeout);
494 if (readchar_nofail () == 'r')
497 /* Not the right baudrate, or the board's not on */
503 if (!SERIAL_SETBAUDRATE (desc, baudrate))
504 error ("Can't set baudrate");
509 /* Close out all files and local state before this target loses control. */
515 /* Clear any break points */
517 hms_clear_breakpoints ();
518 sleep (1); /* Let any output make it all the way back */
521 SERIAL_WRITE (desc, "R\r\n", 3);
527 /* Terminate the open connection to the remote debugger. Use this
528 when you want to detach and do something else with your gdb. */ void
529 hms_detach (args, from_tty)
535 hms_clear_breakpoints ();
538 pop_target (); /* calls hms_close to do the real work
541 printf_filtered ("Ending remote %s debugging\n",
545 /* Tell the remote machine to resume. */
548 hms_resume (pid, step, sig)
558 /* Force the next hms_wait to return a trap. Not doing anything
559 about I/O from the target means that the user has to type "continue"
560 to see any. FIXME, this should be fixed. */
561 need_artificial_trap = 1;
570 /* Wait until the remote machine stops, then return, storing status in
571 STATUS just as `wait' would. */
574 hms_wait (pid, status)
576 struct target_waitstatus *status;
578 /* Strings to look for. '?' means match any single character. Note
579 that with the algorithm we use, the initial character of the string
580 cannot recur in the string, or we will not find some cases of the
581 string in the input. */
583 static char bpt[] = "At breakpoint:";
585 /* It would be tempting to look for "\n[__exit + 0x8]\n" but that
586 requires loading symbols with "yc i" and even if we did do that we
587 don't know that the file has symbols. */
588 static char exitmsg[] = "HMS>";
592 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.
596 /* Current position in swallowed. */
597 char *swallowed_p = swallowed;
601 int old_timeout = timeout;
603 old_immediate_quit = immediate_quit;
604 int swallowed_cr = 0;
606 status->kind = TARGET_WAITKIND_EXITED;
607 status->value.integer = 0;
609 if (need_artificial_trap != 0)
612 TARGET_WAITKIND_STOPPED;
613 status->value.sig = TARGET_SIGNAL_TRAP;
614 need_artificial_trap--;
618 timeout = 5; /* Don't time out for a while - user program is running.
620 immediate_quit = 1; /* Helps ability to QUIT */
623 QUIT; /* Let user quit and leave process running */
640 (ch == *ep || *ep == '?')
660 /* Print out any characters which have been swallowed. */
661 for (p = swallowed; p < swallowed_p; ++p)
662 putchar_unfiltered (*p);
663 swallowed_p = swallowed;
665 if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
667 putchar_unfiltered (ch);
676 status->kind = TARGET_WAITKIND_STOPPED;
677 status->value.sig = TARGET_SIGNAL_TRAP;
682 status->kind = TARGET_WAITKIND_EXITED;
683 status->value.integer =
687 timeout = old_timeout;
688 immediate_quit = old_immediate_quit;
693 /* Return the name of register number REGNO in the form input and
696 Returns a pointer to a static buffer containing the answer. */
707 /* Read the remote registers. */
710 gethex (length, start, ok)
720 if (*start >= 'a' && *start <= 'f')
722 result += *start - 'a' + 10;
724 else if (*start >= 'A' &&
727 result += *start - 'A' + 10;
730 (*start >= '0' && *start <= '9')
732 result += *start - '0';
742 timed_read (buf, n, timeout)
769 SERIAL_WRITE (desc, a, l);
771 if (!quiet || remote_debug)
773 printf_unfiltered ("<");
774 for (i = 0; i < l; i++)
776 printf_unfiltered ("%c", a[i]);
778 printf_unfiltered (">");
785 hms_write (s, strlen (s));
786 hms_write ("\r\n", 2);
789 #ifdef GDB_TARGET_IS_H8500
791 /* H8/500 monitor reg dump looks like:
794 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
795 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
801 supply_val (n, size, ptr, segptr)
812 raw[0] = gethex (2, ptr, &ok);
813 raw[1] = gethex (2, ptr + 2, &ok);
814 supply_register (n, raw);
817 raw[0] = gethex (2, ptr, &ok);
818 supply_register (n, raw);
822 int v = gethex (4, ptr, &ok);
823 v |= gethex (2, segptr, &ok) << 16;
825 raw[1] = (v >> 16) & 0xff;
826 raw[2] = (v >> 8) & 0xff;
827 raw[3] = (v >> 0) & 0xff;
828 supply_register (n, raw);
834 hms_fetch_register (dummy)
837 #define REGREPLY_SIZE 108
838 char linebuf[REGREPLY_SIZE + 1];
843 LONGEST reg[NUM_REGS];
851 s = timed_read (linebuf + 1, REGREPLY_SIZE, 1);
853 linebuf[REGREPLY_SIZE] = 0;
855 if (linebuf[3] == 'P' &&
858 linebuf[105] == 'H' &&
859 linebuf[106] == 'M' &&
866 -------1---------2---------3---------4---------5-----
867 345678901234567890123456789012345678901234567890123456
868 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
869 ---6---------7---------8---------9--------10----
870 789012345678901234567890123456789012345678901234
871 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
879 supply_val (PC_REGNUM, 4, linebuf + 6, linebuf + 29);
881 supply_val (CCR_REGNUM, 2, linebuf + 14);
882 supply_val (SEG_C_REGNUM, 1, linebuf + 29);
883 supply_val (SEG_D_REGNUM, 1, linebuf + 35);
884 supply_val (SEG_E_REGNUM, 1, linebuf + 41);
885 supply_val (SEG_T_REGNUM, 1, linebuf + 47);
886 for (i = 0; i < 8; i++)
893 char *src = linebuf + 64 + 5 * i;
894 char *segsrc = linebuf + sr[i];
895 supply_val (R0_REGNUM + i, 2, src);
896 supply_val (PR0_REGNUM + i, 4, src, segsrc);
909 #ifdef GDB_TARGET_IS_H8300
911 hms_fetch_register (dummy)
914 #define REGREPLY_SIZE 79
915 char linebuf[REGREPLY_SIZE + 1];
920 ULONGEST reg[NUM_REGS];
928 s = timed_read (linebuf, 1, 1);
930 while (linebuf[0] != 'r')
931 s = timed_read (linebuf, 1, 1);
933 s = timed_read (linebuf + 1, REGREPLY_SIZE - 1, 1);
935 linebuf[REGREPLY_SIZE] = 0;
937 if (linebuf[0] == 'r' &&
941 linebuf[75] == 'H' &&
942 linebuf[76] == 'M' &&
946 PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
947 5436789012345678901234567890123456789012345678901234567890123456789012
952 reg[PC_REGNUM] = gethex (4, linebuf + 6, &gottok);
953 reg[CCR_REGNUM] = gethex (2, linebuf + 15, &gottok);
954 for (i = 0; i < 8; i++)
956 reg[i] = gethex (4, linebuf + 34 + 5 * i, &gottok);
961 for (i = 0; i < NUM_REGS; i++)
966 swapped[0] = (reg[i]) >> 8;
968 supply_register (i, swapped);
972 /* Store register REGNO, or all if REGNO == -1.
973 Return errno value. */
975 hms_store_register (regno)
980 for (regno = 0; regno < NUM_REGS; regno++)
982 hms_store_register (regno);
987 char *name = get_reg_name (regno);
989 /* Some regs dont really exist */
990 if (!(name[0] == 'p' && name[1] == 'r')
991 && !(name[0] == 'c' && name[1] == 'y')
992 && !(name[0] == 't' && name[1] == 'i')
993 && !(name[0] == 'i' && name[1] == 'n'))
995 sprintf (buffer, "r %s=%x", name, read_register (regno));
996 hms_write_cr (buffer);
1003 /* Get ready to modify the registers array. On machines which store
1004 individual registers, this doesn't need to do anything. On machines
1005 which store all the registers in one fell swoop, this makes sure
1006 that registers contains all the registers from the program being
1010 hms_prepare_to_store ()
1012 /* Do nothing, since we can store individual regs */
1016 translate_addr (addr)
1026 hms_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1031 struct target_ops *target; /* ignored */
1038 hms_write_inferior_memory (memaddr, myaddr, len)
1040 unsigned char *myaddr;
1056 thisgo = len - done;
1060 sprintf (ptr, "M.B %4x =", memaddr + done);
1062 for (idx = 0; idx < thisgo; idx++)
1064 sprintf (ptr, "%2x ", myaddr[idx + done]);
1067 hms_write_cr (buffer);
1076 char *file = "nothing";
1079 file = bfd_get_filename (exec_bfd);
1083 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
1085 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
1087 printf_filtered ("\ton an H8/300 processor.\n");
1090 /* Copy LEN bytes of data from debugger memory at MYADDR
1091 to inferior's memory at MEMADDR. Returns errno value.
1092 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1095 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1096 at debugger address MYADDR. Returns errno value. */
1098 hms_read_inferior_memory (memaddr, myaddr, len)
1103 /* Align to nearest low 16 bits */
1106 CORE_ADDR start = memaddr;
1107 CORE_ADDR end = memaddr + len - 1;
1112 AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
1113 012345678901234567890123456789012345678901234567890123456789012345
1123 sprintf (buffer, "m %4x %4x", start & 0xffff, end & 0xffff);
1126 hms_write_cr (buffer);
1127 /* drop the echo and newline */
1128 for (i = 0; i < 13; i++)
1131 /* Grab the lines as they come out and fill the area */
1142 buffer[0] = readchar ();
1143 while (buffer[0] == '\r'
1144 || buffer[0] == '\n')
1145 buffer[0] = readchar ();
1147 if (buffer[0] == 'M')
1150 for (i = 1; i < 50; i++)
1152 buffer[i] = readchar ();
1154 /* sometimes we loose characters in the ascii representation of the
1155 data. I don't know where. So just scan for the end of line */
1157 while (i != '\n' && i != '\r')
1160 /* Now parse the line */
1162 addr = gethex (4, buffer, &ok);
1164 for (p = 0; p < 16; p += 2)
1166 byte[p] = gethex (2, buffer + idx, &ok);
1167 byte[p + 1] = gethex (2, buffer + idx + 2, &ok);
1171 for (p = 0; p < 16; p++)
1173 if (addr + p >= memaddr &&
1174 addr + p < memaddr + len)
1176 myaddr[(addr + p) - memaddr] = byte[p];
1182 #ifdef GDB_TARGET_IS_H8500
1185 #ifdef GDB_TARGET_IS_H8300
1196 #define MAX_BREAKS 16
1197 static int num_brkpts = 0;
1199 hms_insert_breakpoint (addr, save)
1201 char *save; /* Throw away, let hms save instructions */
1205 if (num_brkpts < MAX_BREAKS)
1210 sprintf (buffer, "b %x", addr & 0xffff);
1211 hms_write_cr (buffer);
1217 fprintf_filtered (gdb_stderr,
1218 "Too many break points, break point not installed\n");
1224 hms_remove_breakpoint (addr, save)
1226 char *save; /* Throw away, let hms save instructions */
1233 sprintf (buffer, "b - %x", addr & 0xffff);
1234 hms_write_cr (buffer);
1241 /* Clear the hmss notion of what the break points are */
1243 hms_clear_breakpoints ()
1248 hms_write_cr ("b -");
1256 hms_clear_breakpoints ();
1257 unpush_target (&hms_ops);
1258 generic_mourn_inferior ();
1261 /* Put a command string, in args, out to the hms. The hms is assumed to
1262 be in raw mode, all writing/reading done through desc.
1263 Ouput from the hms is placed on the users terminal until the
1264 prompt from the hms is seen.
1265 FIXME: Can't handle commands that take input. */
1268 hms_com (args, fromtty)
1277 /* Clear all input so only command relative output is displayed */
1279 hms_write_cr (args);
1280 /* hms_write ("\030", 1); */
1285 hms_open (name, from_tty)
1298 dev_name = strdup (name);
1300 if (!(desc = SERIAL_OPEN (dev_name)))
1301 perror_with_name ((char *) dev_name);
1305 push_target (&hms_ops);
1306 dcache_ptr = dcache_init (hms_read_inferior_memory,
1307 hms_write_inferior_memory);
1309 /* Hello? Are you there? */
1310 SERIAL_WRITE (desc, "\r\n", 2);
1313 /* Clear any break points */
1314 hms_clear_breakpoints ();
1316 printf_filtered ("Connected to remote board running HMS monitor.\n");
1321 /* Define the target subroutine names */
1323 struct target_ops hms_ops ;
1324 static void init_hms_ops(void)
1326 hms_ops.to_shortname = "hms";
1327 hms_ops.to_longname = "Remote HMS monitor";
1328 hms_ops.to_doc = "Use the H8 evaluation board running the HMS monitor connected\n\
1330 hms_ops.to_open = hms_open;
1331 hms_ops.to_close = hms_close;
1332 hms_ops.to_attach = 0;
1333 hms_ops.to_detach = hms_detach;
1334 hms_ops.to_resume = hms_resume;
1335 hms_ops.to_wait = hms_wait;
1336 hms_ops.to_fetch_registers = hms_fetch_register;
1337 hms_ops.to_store_registers = hms_store_register;
1338 hms_ops.to_prepare_to_store = hms_prepare_to_store;
1339 hms_ops.to_xfer_memory = hms_xfer_inferior_memory;
1340 hms_ops.to_files_info = hms_files_info;
1341 hms_ops.to_insert_breakpoint = hms_insert_breakpoint;
1342 hms_ops.to_remove_breakpoint = hms_remove_breakpoint;
1343 hms_ops.to_terminal_init = 0;
1344 hms_ops.to_terminal_inferior = 0;
1345 hms_ops.to_terminal_ours_for_output = 0;
1346 hms_ops.to_terminal_ours = 0;
1347 hms_ops.to_terminal_info = 0;
1348 hms_ops.to_kill = hms_kill;
1349 hms_ops.to_load = generic_load;
1350 hms_ops.to_lookup_symbol = 0;
1351 hms_ops.to_create_inferior = hms_create_inferior;
1352 hms_ops.to_mourn_inferior = hms_mourn;
1353 hms_ops.to_can_run = 0;
1354 hms_ops.to_notice_signals = 0;
1355 hms_ops.to_thread_alive = 0;
1356 hms_ops.to_stop = 0;
1357 hms_ops.to_stratum = process_stratum;
1358 hms_ops.DONT_USE = 0;
1359 hms_ops.to_has_all_memory = 1;
1360 hms_ops.to_has_memory = 1;
1361 hms_ops.to_has_stack = 1;
1362 hms_ops.to_has_registers = 1;
1363 hms_ops.to_has_execution = 1;
1364 hms_ops.to_sections = 0;
1365 hms_ops.to_sections_end = 0;
1366 hms_ops.to_magic = OPS_MAGIC;
1369 hms_quiet () /* FIXME - this routine can be removed after Dec '94 */
1373 printf_filtered ("Snoop disabled\n");
1375 printf_filtered ("Snoop enabled\n");
1377 printf_filtered ("`snoop' is obsolete, please use `set remotedebug'.\n");
1385 dev_name = get_word (&s);
1398 int newrate = atoi (s);
1401 if (SERIAL_SETBAUDRATE (desc, newrate))
1402 error ("Can't use %d baud\n", newrate);
1404 printf_filtered ("Checking target is in sync\n");
1406 printf_filtered ("Sending commands to set target to %d\n",
1409 sprintf (buffer, "tm %d. N 8 1", baudrate);
1410 hms_write_cr (buffer);
1414 /***********************************************************************/
1417 hms_drain (args, fromtty)
1424 c = SERIAL_READCHAR (desc, 1);
1425 if (c == SERIAL_TIMEOUT)
1427 if (c == SERIAL_ERROR)
1429 if (c > ' ' && c < 127)
1430 printf ("%c", c & 0xff);
1432 printf ("<%x>", c & 0xff);
1440 add_com ("hms_drain", class_obscure, hms_drain,
1441 "Drain pending hms text buffers.");
1447 extern struct cmd_list_element *cmdlist;
1448 delete_cmd ("hms-drain", &cmdlist);
1453 _initialize_remote_hms ()
1456 add_target (&hms_ops);
1458 add_com ("hms <command>", class_obscure, hms_com,
1459 "Send a command to the HMS monitor.");
1461 /* FIXME - hms_quiet and `snoop' can be removed after Dec '94 */
1462 add_com ("snoop", class_obscure, hms_quiet,
1463 "Show what commands are going to the monitor (OBSOLETE - see 'set remotedebug')");
1465 add_com ("device", class_obscure, hms_device,
1466 "Set the terminal line for HMS communications");
1468 add_com ("speed", class_obscure, hms_speed,
1469 "Set the terminal line speed for HMS communications");