1 /* Remote debugging interface for Hitachi HMS Monitor Version 1.0
2 Copyright 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
37 /* External data declarations */
38 extern int stop_soon_quietly; /* for wait_for_inferior */
40 /* Forward data declarations */
41 extern struct target_ops hms_ops; /* Forward declaration */
43 /* Forward function declarations */
44 static void hms_fetch_registers ();
45 static int hms_store_registers ();
46 static void hms_close ();
47 static int hms_clear_breakpoints ();
49 extern struct target_ops hms_ops;
50 static void hms_drain ();
51 static void add_commands ();
52 static void remove_commands ();
59 /***********************************************************************/
60 /* Caching stuff stolen from remote-nindy.c */
62 /* The data cache records all the data read from the remote machine
63 since the last time it stopped.
65 Each cache block holds LINE_SIZE bytes of data
66 starting at a multiple-of-LINE_SIZE address. */
68 #define LINE_SIZE_POWER 4
69 #define LINE_SIZE (1<<LINE_SIZE_POWER) /* eg 1<<3 == 8 */
70 #define LINE_SIZE_MASK ((LINE_SIZE-1)) /* eg 7*2+1= 111*/
71 #define DCACHE_SIZE 64 /* Number of cache blocks */
72 #define XFORM(x) ((x&LINE_SIZE_MASK)>>2)
75 struct dcache_block *next, *last;
76 unsigned int addr; /* Address for which data is recorded. */
77 int data[LINE_SIZE / sizeof (int)];
80 struct dcache_block dcache_free, dcache_valid;
82 /* Free all the data cache blocks, thus discarding all cached data. */
87 register struct dcache_block *db;
89 while ((db = dcache_valid.next) != &dcache_valid)
92 insque (db, &dcache_free);
97 * If addr is present in the dcache, return the address of the block
101 struct dcache_block *
105 register struct dcache_block *db;
110 /* Search all cache blocks for one that is at this address. */
111 db = dcache_valid.next;
112 while (db != &dcache_valid)
114 if ((addr & ~LINE_SIZE_MASK) == db->addr)
121 /* Return the int data at address ADDR in dcache block DC. */
124 dcache_value (db, addr)
125 struct dcache_block *db;
130 return (db->data[XFORM (addr)]);
133 /* Get a free cache block, put or keep it on the valid list,
134 and return its address. The caller should store into the block
135 the address and data that it describes, then remque it from the
136 free list and insert it into the valid list. This procedure
137 prevents errors from creeping in if a ninMemGet is interrupted
138 (which used to put garbage blocks in the valid list...). */
140 struct dcache_block *
143 register struct dcache_block *db;
145 if ((db = dcache_free.next) == &dcache_free)
147 /* If we can't get one from the free list, take last valid and put
148 it on the free list. */
149 db = dcache_valid.last;
151 insque (db, &dcache_free);
155 insque (db, &dcache_valid);
159 /* Return the contents of the word at address ADDR in the remote machine,
160 using the data cache. */
166 register struct dcache_block *db;
168 db = dcache_hit (addr);
171 db = dcache_alloc ();
173 hms_read_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
175 db->addr = addr & ~LINE_SIZE_MASK;
176 remque (db); /* Off the free list */
177 insque (db, &dcache_valid); /* On the valid list */
179 return (dcache_value (db, addr));
182 /* Write the word at ADDR both in the data cache and in the remote machine. */
184 dcache_poke (addr, data)
188 register struct dcache_block *db;
190 /* First make sure the word is IN the cache. DB is its cache block. */
191 db = dcache_hit (addr);
194 db = dcache_alloc ();
196 hms_write_inferior_memory (addr & ~LINE_SIZE_MASK, (unsigned char *) db->data, LINE_SIZE);
198 db->addr = addr & ~LINE_SIZE_MASK;
199 remque (db); /* Off the free list */
200 insque (db, &dcache_valid); /* On the valid list */
203 /* Modify the word in the cache. */
204 db->data[XFORM (addr)] = data;
206 /* Send the changed word. */
208 hms_write_inferior_memory (addr, (unsigned char *) &data, 4);
212 /* The cache itself. */
213 struct dcache_block the_cache[DCACHE_SIZE];
215 /* Initialize the data cache. */
220 register struct dcache_block *db;
223 dcache_free.next = dcache_free.last = &dcache_free;
224 dcache_valid.next = dcache_valid.last = &dcache_valid;
225 for (i = 0; i < DCACHE_SIZE; i++, db++)
226 insque (db, &dcache_free);
229 /***********************************************************************
230 * I/O stuff stolen from remote-eb.c
231 ***********************************************************************/
233 static int timeout = 2;
235 static const char *dev_name;
237 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
238 hms_open knows that we don't have a file open when the program
247 error ("remote device not open");
254 /* Read a character from the remote system, doing all the fancy
261 buf = SERIAL_READCHAR (desc, timeout);
263 if (buf == SERIAL_TIMEOUT)
265 hms_write (".\r\n", 3);
266 error ("Timeout reading from remote system.");
268 if (buf == SERIAL_ERROR)
270 error ("Serial port error!");
274 printf_unfiltered ("%c", buf);
284 buf = SERIAL_READCHAR (desc, timeout);
285 if (buf == SERIAL_TIMEOUT)
288 printf_unfiltered ("%c", buf);
294 /* Keep discarding input from the remote system, until STRING is found.
295 Let the user break out immediately. */
305 if (readchar () == *p)
319 /* Keep discarding input until we see the hms prompt.
321 The convention for dealing with the prompt is that you
323 o *then* wait for the prompt.
325 Thus the last thing that a procedure does with the serial line
326 will be an expect_prompt(). Exception: hms_resume does not
327 wait for the prompt, because the terminal is being handed over
328 to the inferior. However, the next thing which happens after that
329 is a hms_wait which does wait for the prompt.
330 Note that this includes abnormal exit, e.g. error(). This is
331 necessary to prevent getting into states from which we can't
339 /* Get a hex digit from the remote system & return its value.
340 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
342 get_hex_digit (ignore_space)
350 if (ch >= '0' && ch <= '9')
352 else if (ch >= 'A' && ch <= 'F')
353 return ch - 'A' + 10;
354 else if (ch >= 'a' && ch <= 'f')
355 return ch - 'a' + 10;
356 else if (ch == ' ' && ignore_space)
361 error ("Invalid hex digit from remote system.");
366 /* Get a byte from hms_desc and put it in *BYT. Accept any number
374 val = get_hex_digit (1) << 4;
375 val |= get_hex_digit (0);
379 /* Read a 32-bit hex word from the hms, preceded by a space */
387 for (j = 0; j < 8; j++)
388 val = (val << 4) + get_hex_digit (j == 0);
392 /* Called when SIGALRM signal sent due to alarm() timeout. */
394 /* Number of SIGTRAPs we need to simulate. That is, the next
395 NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
396 SIGTRAP without actually waiting for anything. */
398 static int need_artificial_trap = 0;
401 hms_kill (arg, from_tty)
409 * Download a file specified in 'args', to the hms.
412 hms_load (args, fromtty)
425 abfd = bfd_openr (args, gnutarget);
428 printf_filtered ("Unable to open file %s\n", args);
432 if (bfd_check_format (abfd, bfd_object) == 0)
434 printf_filtered ("File is not an object file\n");
439 while (s != (asection *) NULL)
441 if (s->flags & SEC_LOAD)
446 char *buffer = xmalloc (DELTA);
448 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, s->vma + s->_raw_size);
449 for (i = 0; i < s->_raw_size; i += DELTA)
453 if (delta > s->_raw_size - i)
454 delta = s->_raw_size - i;
456 bfd_get_section_contents (abfd, s, buffer, i, delta);
457 hms_write_inferior_memory (s->vma + i, buffer, delta);
458 printf_filtered ("*");
459 gdb_flush (gdb_stdout);
461 printf_filtered ("\n");
466 sprintf (buffer, "r PC=%x", abfd->start_address);
467 hms_write_cr (buffer);
469 /* Turn off all breakpoints */
470 hms_write_cr ("b -");
474 /* This is called not only when we first attach, but also when the
475 user types "run" after having attached. */
477 hms_create_inferior (execfile, args, env)
486 error ("Can't pass arguments to remote hms process.");
488 if (execfile == 0 || exec_bfd == 0)
489 error ("No exec file specified");
491 entry_pt = (int) bfd_get_start_address (exec_bfd);
494 hms_kill (NULL, NULL);
495 hms_clear_breakpoints ();
496 init_wait_for_inferior ();
500 insert_breakpoints (); /* Needed to get correct instruction in cache */
501 proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
504 /* Open a connection to a remote debugger.
505 NAME is the filename used for communication, then a space,
513 while (*s && !isspace (*s))
534 while (*s && !isspace (*s))
540 copy = xmalloc (len + 1);
541 memcpy (copy, word, len);
547 static int baudrate = 9600;
554 /* Put this port into NORMAL mode, send the 'normal' character */
556 hms_write ("\001", 1); /* Control A */
557 hms_write ("\r\n", 2); /* Cr */
561 ok = SERIAL_READCHAR (desc, timeout);
568 if (readchar_nofail () == 'r')
571 /* Not the right baudrate, or the board's not on */
577 if (!SERIAL_SETBAUDRATE (desc, baudrate))
578 error ("Can't set baudrate");
583 hms_open (name, from_tty)
596 dev_name = strdup (name);
598 if (!(desc = SERIAL_OPEN (dev_name)))
599 perror_with_name ((char *) dev_name);
603 push_target (&hms_ops);
606 /* Hello? Are you there? */
607 SERIAL_WRITE (desc, "\r\n", 2);
610 /* Clear any break points */
611 hms_clear_breakpoints ();
613 printf_filtered ("Connected to remote board running HMS monitor.\n");
618 /* Close out all files and local state before this target loses control. */
624 /* Clear any break points */
626 hms_clear_breakpoints ();
627 sleep (1); /* Let any output make it all the way back */
630 SERIAL_WRITE (desc, "R\r\n", 3);
636 /* Terminate the open connection to the remote debugger. Use this
637 when you want to detach and do something else with your gdb. */ void
638 hms_detach (args, from_tty)
644 hms_clear_breakpoints ();
647 pop_target (); /* calls hms_close to do the real work
650 printf_filtered ("Ending remote %s debugging\n",
654 /* Tell the remote machine to resume. */
657 hms_resume (pid, step, sig)
669 /* Force the next hms_wait to return a trap. Not doing anything
670 about I/O from the target means that the user has to type "continue"
671 to see any. FIXME, this should be fixed. */
672 need_artificial_trap = 1;
681 /* Wait until the remote machine stops, then return, storing status in
682 STATUS just as `wait' would. */
685 hms_wait (pid, status)
687 struct target_waitstatus *status;
689 /* Strings to look for. '?' means match any single character. Note
690 that with the algorithm we use, the initial character of the string
691 cannot recur in the string, or we will not find some cases of the
692 string in the input. */
694 static char bpt[] = "At breakpoint:";
696 /* It would be tempting to look for "\n[__exit + 0x8]\n" but that
697 requires loading symbols with "yc i" and even if we did do that we
698 don't know that the file has symbols. */
699 static char exitmsg[] = "HMS>";
703 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.
707 /* Current position in swallowed. */
708 char *swallowed_p = swallowed;
712 int old_timeout = timeout;
714 old_immediate_quit = immediate_quit;
715 int swallowed_cr = 0;
717 status->kind = TARGET_WAITKIND_EXITED;
718 status->value.integer = 0;
720 if (need_artificial_trap != 0)
723 TARGET_WAITKIND_STOPPED;
724 status->value.sig = TARGET_SIGNAL_TRAP;
725 need_artificial_trap--;
729 timeout = 5; /* Don't time out for a while - user program is running.
731 immediate_quit = 1; /* Helps ability to QUIT */
734 QUIT; /* Let user quit and leave process running */
751 (ch == *ep || *ep == '?')
771 /* Print out any characters which have been swallowed. */
772 for (p = swallowed; p < swallowed_p; ++p)
773 putc_unfiltered (*p);
774 swallowed_p = swallowed;
776 if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
778 putc_unfiltered (ch);
787 status->kind = TARGET_WAITKIND_STOPPED;
788 status->value.sig = TARGET_SIGNAL_TRAP;
793 status->kind = TARGET_WAITKIND_EXITED;
794 status->value.integer =
798 timeout = old_timeout;
799 immediate_quit = old_immediate_quit;
804 /* Return the name of register number REGNO in the form input and
807 Returns a pointer to a static buffer containing the answer. */
818 /* Read the remote registers. */
821 gethex (length, start, ok)
831 if (*start >= 'a' && *start <= 'f')
833 result += *start - 'a' + 10;
835 else if (*start >= 'A' &&
838 result += *start - 'A' + 10;
841 (*start >= '0' && *start <= '9')
843 result += *start - '0';
853 timed_read (buf, n, timeout)
880 SERIAL_WRITE (desc, a, l);
884 printf_unfiltered ("<");
885 for (i = 0; i < l; i++)
887 printf_unfiltered ("%c", a[i]);
889 printf_unfiltered (">");
896 hms_write (s, strlen (s));
897 hms_write ("\r\n", 2);
900 #ifdef GDB_TARGET_IS_H8500
902 /* H8/500 monitor reg dump looks like:
905 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
906 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
912 supply_val (n, size, ptr, segptr)
923 raw[0] = gethex (2, ptr, &ok);
924 raw[1] = gethex (2, ptr + 2, &ok);
925 supply_register (n, raw);
928 raw[0] = gethex (2, ptr, &ok);
929 supply_register (n, raw);
933 int v = gethex (4, ptr, &ok);
934 v |= gethex (2, segptr, &ok) << 16;
936 raw[1] = (v >> 16) & 0xff;
937 raw[2] = (v >> 8) & 0xff;
938 raw[3] = (v >> 0) & 0xff;
939 supply_register (n, raw);
945 hms_fetch_register (dummy)
948 #define REGREPLY_SIZE 108
949 char linebuf[REGREPLY_SIZE + 1];
954 LONGEST reg[NUM_REGS];
962 s = timed_read (linebuf + 1, REGREPLY_SIZE, 1);
964 linebuf[REGREPLY_SIZE] = 0;
966 if (linebuf[3] == 'P' &&
969 linebuf[105] == 'H' &&
970 linebuf[106] == 'M' &&
977 -------1---------2---------3---------4---------5-----
978 345678901234567890123456789012345678901234567890123456
979 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
980 ---6---------7---------8---------9--------10----
981 789012345678901234567890123456789012345678901234
982 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
990 supply_val (PC_REGNUM, 4, linebuf + 6, linebuf + 29);
992 supply_val (CCR_REGNUM, 2, linebuf + 14);
993 supply_val (SEG_C_REGNUM, 1, linebuf + 29);
994 supply_val (SEG_D_REGNUM, 1, linebuf + 35);
995 supply_val (SEG_E_REGNUM, 1, linebuf + 41);
996 supply_val (SEG_T_REGNUM, 1, linebuf + 47);
997 for (i = 0; i < 8; i++)
1004 char *src = linebuf + 64 + 5 * i;
1005 char *segsrc = linebuf + sr[i];
1006 supply_val (R0_REGNUM + i, 2, src);
1007 supply_val (PR0_REGNUM + i, 4, src, segsrc);
1020 #ifdef GDB_TARGET_IS_H8300
1022 hms_fetch_register (dummy)
1025 #define REGREPLY_SIZE 79
1026 char linebuf[REGREPLY_SIZE + 1];
1031 unsigned LONGEST reg[NUM_REGS];
1039 s = timed_read (linebuf, 1, 1);
1041 while (linebuf[0] != 'r')
1042 s = timed_read (linebuf, 1, 1);
1044 s = timed_read (linebuf + 1, REGREPLY_SIZE - 1, 1);
1046 linebuf[REGREPLY_SIZE] = 0;
1048 if (linebuf[0] == 'r' &&
1049 linebuf[3] == 'P' &&
1050 linebuf[4] == 'C' &&
1051 linebuf[5] == '=' &&
1052 linebuf[75] == 'H' &&
1053 linebuf[76] == 'M' &&
1057 PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
1058 5436789012345678901234567890123456789012345678901234567890123456789012
1063 reg[PC_REGNUM] = gethex (4, linebuf + 6, &gottok);
1064 reg[CCR_REGNUM] = gethex (2, linebuf + 15, &gottok);
1065 for (i = 0; i < 8; i++)
1067 reg[i] = gethex (4, linebuf + 34 + 5 * i, &gottok);
1072 for (i = 0; i < NUM_REGS; i++)
1076 swapped[1] = reg[i];
1077 swapped[0] = (reg[i]) >> 8;
1079 supply_register (i, swapped);
1083 /* Store register REGNO, or all if REGNO == -1.
1084 Return errno value. */
1086 hms_store_register (regno)
1091 for (regno = 0; regno < NUM_REGS; regno++)
1093 hms_store_register (regno);
1098 char *name = get_reg_name (regno);
1100 /* Some regs dont really exist */
1101 if (!(name[0] == 'p' && name[1] == 'r')
1102 && !(name[0] == 'c' && name[1] == 'y')
1103 && !(name[0] == 't' && name[1] == 'i')
1104 && !(name[0] == 'i' && name[1] == 'n'))
1106 sprintf (buffer, "r %s=%x", name, read_register (regno));
1107 hms_write_cr (buffer);
1114 /* Get ready to modify the registers array. On machines which store
1115 individual registers, this doesn't need to do anything. On machines
1116 which store all the registers in one fell swoop, this makes sure
1117 that registers contains all the registers from the program being
1121 hms_prepare_to_store ()
1123 /* Do nothing, since we can store individual regs */
1127 translate_addr (addr)
1135 /* Read a word from remote address ADDR and return it.
1136 * This goes through the data cache.
1139 hms_fetch_word (addr)
1142 return dcache_fetch (addr);
1145 /* Write a word WORD into remote address ADDR.
1146 This goes through the data cache. */
1149 hms_store_word (addr, word)
1153 dcache_poke (addr, word);
1157 hms_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1162 struct target_ops *target; /* ignored */
1166 /* Round starting address down to longword boundary. */
1167 register CORE_ADDR addr;
1169 /* Round ending address up; get number of longwords that makes. */
1172 /* Allocate buffer of that many longwords. */
1173 register int *buffer;
1176 addr = memaddr & -sizeof (int);
1177 count = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
1179 buffer = (int *) alloca (count * sizeof (int));
1183 /* Fill start and end extra bytes of buffer with existing memory data. */
1185 if (addr != memaddr || len < (int) sizeof (int))
1187 /* Need part of initial word -- fetch it. */
1188 buffer[0] = hms_fetch_word (addr);
1191 if (count > 1) /* FIXME, avoid if even boundary */
1194 = hms_fetch_word (addr + (count - 1) * sizeof (int));
1197 /* Copy data to be written over corresponding part of buffer */
1199 memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
1201 /* Write the entire buffer. */
1203 for (i = 0; i < count; i++, addr += sizeof (int))
1206 hms_store_word (addr, buffer[i]);
1216 /* Read all the longwords */
1217 for (i = 0; i < count; i++, addr += sizeof (int))
1220 buffer[i] = hms_fetch_word (addr);
1228 /* Copy appropriate bytes out of the buffer. */
1229 memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
1236 hms_write_inferior_memory (memaddr, myaddr, len)
1238 unsigned char *myaddr;
1254 thisgo = len - done;
1258 sprintf (ptr, "M.B %4x =", memaddr + done);
1260 for (idx = 0; idx < thisgo; idx++)
1262 sprintf (ptr, "%2x ", myaddr[idx + done]);
1265 hms_write_cr (buffer);
1274 char *file = "nothing";
1277 file = bfd_get_filename (exec_bfd);
1281 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
1283 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
1285 printf_filtered ("\ton an H8/300 processor.\n");
1288 /* Copy LEN bytes of data from debugger memory at MYADDR
1289 to inferior's memory at MEMADDR. Returns errno value.
1290 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1293 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1294 at debugger address MYADDR. Returns errno value. */
1296 hms_read_inferior_memory (memaddr, myaddr, len)
1301 /* Align to nearest low 16 bits */
1304 CORE_ADDR start = memaddr;
1305 CORE_ADDR end = memaddr + len - 1;
1310 AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
1311 012345678901234567890123456789012345678901234567890123456789012345
1321 sprintf (buffer, "m %4x %4x", start & 0xffff, end & 0xffff);
1322 hms_write_cr (buffer);
1323 /* drop the echo and newline*/
1324 for (i = 0; i < 13; i++)
1327 /* Grab the lines as they come out and fill the area */
1338 buffer[0] = readchar ();
1339 if (buffer[0] == 'M')
1341 for (i = 1; i < 66; i++)
1342 buffer[i] = readchar ();
1344 /* Now parse the line */
1346 addr = gethex (4, buffer, &ok);
1348 for (p = 0; p < 16; p += 2)
1350 byte[p] = gethex (2, buffer + idx, &ok);
1351 byte[p + 1] = gethex (2, buffer + idx + 2, &ok);
1356 for (p = 0; p < 16; p++)
1358 if (addr + p >= memaddr &&
1359 addr + p < memaddr + len)
1361 myaddr[(addr + p) - memaddr] = byte[p];
1367 #ifdef GDB_TARGET_IS_H8500
1370 #ifdef GDB_TARGET_IS_H8300
1381 #define MAX_BREAKS 16
1382 static int num_brkpts = 0;
1384 hms_insert_breakpoint (addr, save)
1386 char *save; /* Throw away, let hms save instructions */
1390 if (num_brkpts < MAX_BREAKS)
1395 sprintf (buffer, "b %x", addr & 0xffff);
1396 hms_write_cr (buffer);
1402 fprintf_filtered (gdb_stderr,
1403 "Too many break points, break point not installed\n");
1409 hms_remove_breakpoint (addr, save)
1411 char *save; /* Throw away, let hms save instructions */
1418 sprintf (buffer, "b - %x", addr & 0xffff);
1419 hms_write_cr (buffer);
1426 /* Clear the hmss notion of what the break points are */
1428 hms_clear_breakpoints ()
1433 hms_write_cr ("b -");
1441 hms_clear_breakpoints ();
1442 unpush_target (&hms_ops);
1443 generic_mourn_inferior ();
1446 /* Put a command string, in args, out to the hms. The hms is assumed to
1447 be in raw mode, all writing/reading done through desc.
1448 Ouput from the hms is placed on the users terminal until the
1449 prompt from the hms is seen.
1450 FIXME: Can't handle commands that take input. */
1453 hms_com (args, fromtty)
1462 /* Clear all input so only command relative output is displayed */
1464 hms_write_cr (args);
1465 /* hms_write ("\030", 1);*/
1469 /* Define the target subroutine names */
1471 struct target_ops hms_ops =
1473 "hms", "Remote HMS monitor",
1474 "Use the H8 evaluation board running the HMS monitor connected\n\
1477 hms_open, hms_close,
1478 0, hms_detach, hms_resume, hms_wait, /* attach */
1479 hms_fetch_register, hms_store_register,
1480 hms_prepare_to_store,
1481 hms_xfer_inferior_memory,
1483 hms_insert_breakpoint, hms_remove_breakpoint, /* Breakpoints */
1484 0, 0, 0, 0, 0, /* Terminal handling */
1485 hms_kill, /* FIXME, kill */
1487 0, /* lookup_symbol */
1488 hms_create_inferior, /* create_inferior */
1489 hms_mourn, /* mourn_inferior FIXME */
1491 0, /* notice_signals */
1492 process_stratum, 0, /* next */
1493 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
1494 0, 0, /* Section pointers */
1495 OPS_MAGIC, /* Always the last thing */
1502 printf_filtered ("Snoop disabled\n");
1504 printf_filtered ("Snoop enabled\n");
1513 dev_name = get_word (&s);
1526 int newrate = atoi (s);
1529 if (SERIAL_SETBAUDRATE (desc, newrate))
1530 error ("Can't use %d baud\n", newrate);
1532 printf_filtered ("Checking target is in sync\n");
1534 printf_filtered ("Sending commands to set target to %d\n",
1537 sprintf (buffer, "tm %d. N 8 1", baudrate);
1538 hms_write_cr (buffer);
1542 /***********************************************************************/
1545 hms_drain (args, fromtty)
1553 c = SERIAL_READCHAR (desc, 1);
1554 if (c == SERIAL_TIMEOUT)
1556 if (c == SERIAL_ERROR)
1558 if (c > ' ' && c < 127)
1559 printf ("%c", c & 0xff);
1561 printf ("<%x>", c & 0xff);
1569 add_com ("hmsdrain", class_obscure, hms_drain,
1570 "Drain pending hms text buffers.");
1576 extern struct cmd_list_element *cmdlist;
1577 delete_cmd ("hms-drain", &cmdlist);
1581 _initialize_remote_hms ()
1583 add_target (&hms_ops);
1585 add_com ("hms <command>", class_obscure, hms_com,
1586 "Send a command to the HMS monitor.");
1587 add_com ("snoop", class_obscure, hms_quiet,
1588 "Show what commands are going to the monitor");
1590 add_com ("device", class_obscure, hms_device,
1591 "Set the terminal line for HMS communications");
1593 add_com ("speed", class_obscure, hms_speed,
1594 "Set the terminal line speed for HMS communications");