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., 675 Mass Ave, Cambridge, MA 02139, 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 "\003r %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 NULL
, /* 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
);
151 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
);
170 /* This is kept here because we used to support the H8/500 in this module,
171 and I haven't done the H8/500 yet */
173 #include "inferior.h"
182 #include "terminal.h"
186 #include "remote-utils.h"
187 /* External data declarations */
188 extern int stop_soon_quietly
; /* for wait_for_inferior */
190 /* Forward data declarations */
191 extern struct target_ops hms_ops
; /* Forward declaration */
193 /* Forward function declarations */
194 static void hms_fetch_registers ();
195 static int hms_store_registers ();
196 static void hms_close ();
197 static int hms_clear_breakpoints ();
199 extern struct target_ops hms_ops
;
200 static void hms_drain ();
201 static void add_commands ();
202 static void remove_commands ();
204 static int quiet
= 1; /* FIXME - can be removed after Dec '94 */
211 /***********************************************************************
212 * I/O stuff stolen from remote-eb.c
213 ***********************************************************************/
215 static int timeout
= 2;
217 static const char *dev_name
;
219 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
220 hms_open knows that we don't have a file open when the program
223 static int before
= 0xdead;
224 static int is_open
= 0;
225 static int after
= 0xdead;
231 printf ("OUTCH! \n");
234 error ("remote device not open");
241 /* Read a character from the remote system, doing all the fancy
248 buf
= SERIAL_READCHAR (desc
, timeout
);
250 if (buf
== SERIAL_TIMEOUT
)
252 hms_write (".\r\n", 3);
253 error ("Timeout reading from remote system.");
255 if (buf
== SERIAL_ERROR
)
257 error ("Serial port error!");
260 if (!quiet
|| remote_debug
)
261 printf_unfiltered ("%c", buf
);
271 int b
= SERIAL_READCHAR (desc
, 0);
272 if (b
== SERIAL_TIMEOUT
)
282 buf
= SERIAL_READCHAR (desc
, timeout
);
283 if (buf
== SERIAL_TIMEOUT
)
285 if (!quiet
|| remote_debug
)
286 printf_unfiltered ("%c", buf
);
292 /* Keep discarding input from the remote system, until STRING is found.
293 Let the user break out immediately. */
322 /* Keep discarding input until we see the hms prompt.
324 The convention for dealing with the prompt is that you
326 o *then* wait for the prompt.
328 Thus the last thing that a procedure does with the serial line
329 will be an expect_prompt(). Exception: hms_resume does not
330 wait for the prompt, because the terminal is being handed over
331 to the inferior. However, the next thing which happens after that
332 is a hms_wait which does wait for the prompt.
333 Note that this includes abnormal exit, e.g. error(). This is
334 necessary to prevent getting into states from which we can't
342 /* Get a hex digit from the remote system & return its value.
343 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
345 get_hex_digit (ignore_space
)
353 if (ch
>= '0' && ch
<= '9')
355 else if (ch
>= 'A' && ch
<= 'F')
356 return ch
- 'A' + 10;
357 else if (ch
>= 'a' && ch
<= 'f')
358 return ch
- 'a' + 10;
359 else if (ch
== ' ' && ignore_space
)
364 error ("Invalid hex digit from remote system.");
369 /* Get a byte from hms_desc and put it in *BYT. Accept any number
377 val
= get_hex_digit (1) << 4;
378 val
|= get_hex_digit (0);
382 /* Read a 32-bit hex word from the hms, preceded by a space */
390 for (j
= 0; j
< 8; j
++)
391 val
= (val
<< 4) + get_hex_digit (j
== 0);
395 /* Called when SIGALRM signal sent due to alarm() timeout. */
397 /* Number of SIGTRAPs we need to simulate. That is, the next
398 NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
399 SIGTRAP without actually waiting for anything. */
401 static int need_artificial_trap
= 0;
404 hms_kill (arg
, from_tty
)
411 /* This is called not only when we first attach, but also when the
412 user types "run" after having attached. */
414 hms_create_inferior (execfile
, args
, env
)
423 error ("Can't pass arguments to remote hms process.");
425 if (execfile
== 0 || exec_bfd
== 0)
426 error ("No exec file specified");
428 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
431 hms_kill (NULL
, NULL
);
432 hms_clear_breakpoints ();
433 init_wait_for_inferior ();
437 insert_breakpoints (); /* Needed to get correct instruction in cache */
438 proceed (entry_pt
, TARGET_SIGNAL_DEFAULT
, 0);
441 /* Open a connection to a remote debugger.
442 NAME is the filename used for communication, then a space,
450 while (*s
&& !isspace (*s
))
471 while (*s
&& !isspace (*s
))
477 copy
= xmalloc (len
+ 1);
478 memcpy (copy
, word
, len
);
484 static int baudrate
= 9600;
491 /* Put this port into NORMAL mode, send the 'normal' character */
493 hms_write ("\001", 1); /* Control A */
494 hms_write ("\r\n", 2); /* Cr */
498 ok
= SERIAL_READCHAR (desc
, timeout
);
505 if (readchar_nofail () == 'r')
508 /* Not the right baudrate, or the board's not on */
514 if (!SERIAL_SETBAUDRATE (desc
, baudrate
))
515 error ("Can't set baudrate");
520 /* Close out all files and local state before this target loses control. */
526 /* Clear any break points */
528 hms_clear_breakpoints ();
529 sleep (1); /* Let any output make it all the way back */
532 SERIAL_WRITE (desc
, "R\r\n", 3);
539 /* Terminate the open connection to the remote debugger. Use this
540 when you want to detach and do something else with your gdb. */ void
541 hms_detach (args
, from_tty
)
547 hms_clear_breakpoints ();
550 pop_target (); /* calls hms_close to do the real work
553 printf_filtered ("Ending remote %s debugging\n",
557 /* Tell the remote machine to resume. */
560 hms_resume (pid
, step
, sig
)
565 dcache_flush (dcache_ptr
);
572 /* Force the next hms_wait to return a trap. Not doing anything
573 about I/O from the target means that the user has to type "continue"
574 to see any. FIXME, this should be fixed. */
575 need_artificial_trap
= 1;
584 /* Wait until the remote machine stops, then return, storing status in
585 STATUS just as `wait' would. */
588 hms_wait (pid
, status
)
590 struct target_waitstatus
*status
;
592 /* Strings to look for. '?' means match any single character. Note
593 that with the algorithm we use, the initial character of the string
594 cannot recur in the string, or we will not find some cases of the
595 string in the input. */
597 static char bpt
[] = "At breakpoint:";
599 /* It would be tempting to look for "\n[__exit + 0x8]\n" but that
600 requires loading symbols with "yc i" and even if we did do that we
601 don't know that the file has symbols. */
602 static char exitmsg
[] = "HMS>";
606 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.
610 /* Current position in swallowed. */
611 char *swallowed_p
= swallowed
;
615 int old_timeout
= timeout
;
617 old_immediate_quit
= immediate_quit
;
618 int swallowed_cr
= 0;
620 status
->kind
= TARGET_WAITKIND_EXITED
;
621 status
->value
.integer
= 0;
623 if (need_artificial_trap
!= 0)
626 TARGET_WAITKIND_STOPPED
;
627 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
628 need_artificial_trap
--;
632 timeout
= 5; /* Don't time out for a while - user program is running.
634 immediate_quit
= 1; /* Helps ability to QUIT */
637 QUIT
; /* Let user quit and leave process running */
654 (ch
== *ep
|| *ep
== '?')
674 /* Print out any characters which have been swallowed. */
675 for (p
= swallowed
; p
< swallowed_p
; ++p
)
676 putchar_unfiltered (*p
);
677 swallowed_p
= swallowed
;
679 if ((ch
!= '\r' && ch
!= '\n') || swallowed_cr
> 10)
681 putchar_unfiltered (ch
);
690 status
->kind
= TARGET_WAITKIND_STOPPED
;
691 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
696 status
->kind
= TARGET_WAITKIND_EXITED
;
697 status
->value
.integer
=
701 timeout
= old_timeout
;
702 immediate_quit
= old_immediate_quit
;
707 /* Return the name of register number REGNO in the form input and
710 Returns a pointer to a static buffer containing the answer. */
721 /* Read the remote registers. */
724 gethex (length
, start
, ok
)
734 if (*start
>= 'a' && *start
<= 'f')
736 result
+= *start
- 'a' + 10;
738 else if (*start
>= 'A' &&
741 result
+= *start
- 'A' + 10;
744 (*start
>= '0' && *start
<= '9')
746 result
+= *start
- '0';
756 timed_read (buf
, n
, timeout
)
783 SERIAL_WRITE (desc
, a
, l
);
785 if (!quiet
|| remote_debug
)
787 printf_unfiltered ("<");
788 for (i
= 0; i
< l
; i
++)
790 printf_unfiltered ("%c", a
[i
]);
792 printf_unfiltered (">");
799 hms_write (s
, strlen (s
));
800 hms_write ("\r\n", 2);
803 #ifdef GDB_TARGET_IS_H8500
805 /* H8/500 monitor reg dump looks like:
808 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
809 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
815 supply_val (n
, size
, ptr
, segptr
)
826 raw
[0] = gethex (2, ptr
, &ok
);
827 raw
[1] = gethex (2, ptr
+ 2, &ok
);
828 supply_register (n
, raw
);
831 raw
[0] = gethex (2, ptr
, &ok
);
832 supply_register (n
, raw
);
836 int v
= gethex (4, ptr
, &ok
);
837 v
|= gethex (2, segptr
, &ok
) << 16;
839 raw
[1] = (v
>> 16) & 0xff;
840 raw
[2] = (v
>> 8) & 0xff;
841 raw
[3] = (v
>> 0) & 0xff;
842 supply_register (n
, raw
);
848 hms_fetch_register (dummy
)
851 #define REGREPLY_SIZE 108
852 char linebuf
[REGREPLY_SIZE
+ 1];
857 LONGEST reg
[NUM_REGS
];
865 s
= timed_read (linebuf
+ 1, REGREPLY_SIZE
, 1);
867 linebuf
[REGREPLY_SIZE
] = 0;
869 if (linebuf
[3] == 'P' &&
872 linebuf
[105] == 'H' &&
873 linebuf
[106] == 'M' &&
880 -------1---------2---------3---------4---------5-----
881 345678901234567890123456789012345678901234567890123456
882 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
883 ---6---------7---------8---------9--------10----
884 789012345678901234567890123456789012345678901234
885 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
893 supply_val (PC_REGNUM
, 4, linebuf
+ 6, linebuf
+ 29);
895 supply_val (CCR_REGNUM
, 2, linebuf
+ 14);
896 supply_val (SEG_C_REGNUM
, 1, linebuf
+ 29);
897 supply_val (SEG_D_REGNUM
, 1, linebuf
+ 35);
898 supply_val (SEG_E_REGNUM
, 1, linebuf
+ 41);
899 supply_val (SEG_T_REGNUM
, 1, linebuf
+ 47);
900 for (i
= 0; i
< 8; i
++)
907 char *src
= linebuf
+ 64 + 5 * i
;
908 char *segsrc
= linebuf
+ sr
[i
];
909 supply_val (R0_REGNUM
+ i
, 2, src
);
910 supply_val (PR0_REGNUM
+ i
, 4, src
, segsrc
);
923 #ifdef GDB_TARGET_IS_H8300
925 hms_fetch_register (dummy
)
928 #define REGREPLY_SIZE 79
929 char linebuf
[REGREPLY_SIZE
+ 1];
934 unsigned LONGEST reg
[NUM_REGS
];
942 s
= timed_read (linebuf
, 1, 1);
944 while (linebuf
[0] != 'r')
945 s
= timed_read (linebuf
, 1, 1);
947 s
= timed_read (linebuf
+ 1, REGREPLY_SIZE
- 1, 1);
949 linebuf
[REGREPLY_SIZE
] = 0;
951 if (linebuf
[0] == 'r' &&
955 linebuf
[75] == 'H' &&
956 linebuf
[76] == 'M' &&
960 PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
961 5436789012345678901234567890123456789012345678901234567890123456789012
966 reg
[PC_REGNUM
] = gethex (4, linebuf
+ 6, &gottok
);
967 reg
[CCR_REGNUM
] = gethex (2, linebuf
+ 15, &gottok
);
968 for (i
= 0; i
< 8; i
++)
970 reg
[i
] = gethex (4, linebuf
+ 34 + 5 * i
, &gottok
);
975 for (i
= 0; i
< NUM_REGS
; i
++)
980 swapped
[0] = (reg
[i
]) >> 8;
982 supply_register (i
, swapped
);
986 /* Store register REGNO, or all if REGNO == -1.
987 Return errno value. */
989 hms_store_register (regno
)
994 for (regno
= 0; regno
< NUM_REGS
; regno
++)
996 hms_store_register (regno
);
1001 char *name
= get_reg_name (regno
);
1003 /* Some regs dont really exist */
1004 if (!(name
[0] == 'p' && name
[1] == 'r')
1005 && !(name
[0] == 'c' && name
[1] == 'y')
1006 && !(name
[0] == 't' && name
[1] == 'i')
1007 && !(name
[0] == 'i' && name
[1] == 'n'))
1009 sprintf (buffer
, "r %s=%x", name
, read_register (regno
));
1010 hms_write_cr (buffer
);
1017 /* Get ready to modify the registers array. On machines which store
1018 individual registers, this doesn't need to do anything. On machines
1019 which store all the registers in one fell swoop, this makes sure
1020 that registers contains all the registers from the program being
1024 hms_prepare_to_store ()
1026 /* Do nothing, since we can store individual regs */
1030 translate_addr (addr
)
1038 /* Read a word from remote address ADDR and return it.
1039 * This goes through the data cache.
1042 hms_fetch_word (addr
)
1045 return dcache_fetch (dcache_ptr
, addr
);
1048 /* Write a word WORD into remote address ADDR.
1049 This goes through the data cache. */
1052 hms_store_word (addr
, word
)
1056 dcache_poke (dcache_ptr
, addr
, word
);
1060 hms_xfer_inferior_memory (memaddr
, myaddr
, len
, write
, target
)
1065 struct target_ops
*target
; /* ignored */
1069 /* Round starting address down to longword boundary. */
1070 register CORE_ADDR addr
;
1072 /* Round ending address up; get number of longwords that makes. */
1075 /* Allocate buffer of that many longwords. */
1076 register int *buffer
;
1079 addr
= memaddr
& -sizeof (int);
1080 count
= (((memaddr
+ len
) - addr
) + sizeof (int) - 1) / sizeof (int);
1082 buffer
= (int *) alloca (count
* sizeof (int));
1086 /* Fill start and end extra bytes of buffer with existing memory data. */
1088 if (addr
!= memaddr
|| len
< (int) sizeof (int))
1090 /* Need part of initial word -- fetch it. */
1091 buffer
[0] = hms_fetch_word (addr
);
1094 if (count
> 1) /* FIXME, avoid if even boundary */
1097 = hms_fetch_word (addr
+ (count
- 1) * sizeof (int));
1100 /* Copy data to be written over corresponding part of buffer */
1102 memcpy ((char *) buffer
+ (memaddr
& (sizeof (int) - 1)), myaddr
, len
);
1104 /* Write the entire buffer. */
1106 for (i
= 0; i
< count
; i
++, addr
+= sizeof (int))
1109 hms_store_word (addr
, buffer
[i
]);
1119 /* Read all the longwords */
1120 for (i
= 0; i
< count
; i
++, addr
+= sizeof (int))
1123 buffer
[i
] = hms_fetch_word (addr
);
1131 /* Copy appropriate bytes out of the buffer. */
1132 memcpy (myaddr
, (char *) buffer
+ (memaddr
& (sizeof (int) - 1)), len
);
1139 hms_write_inferior_memory (memaddr
, myaddr
, len
)
1141 unsigned char *myaddr
;
1157 thisgo
= len
- done
;
1161 sprintf (ptr
, "M.B %4x =", memaddr
+ done
);
1163 for (idx
= 0; idx
< thisgo
; idx
++)
1165 sprintf (ptr
, "%2x ", myaddr
[idx
+ done
]);
1168 hms_write_cr (buffer
);
1177 char *file
= "nothing";
1180 file
= bfd_get_filename (exec_bfd
);
1184 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file
);
1186 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name
, baudrate
, file
);
1188 printf_filtered ("\ton an H8/300 processor.\n");
1191 /* Copy LEN bytes of data from debugger memory at MYADDR
1192 to inferior's memory at MEMADDR. Returns errno value.
1193 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1196 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1197 at debugger address MYADDR. Returns errno value. */
1199 hms_read_inferior_memory (memaddr
, myaddr
, len
)
1204 /* Align to nearest low 16 bits */
1207 CORE_ADDR start
= memaddr
;
1208 CORE_ADDR end
= memaddr
+ len
- 1;
1213 AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
1214 012345678901234567890123456789012345678901234567890123456789012345
1224 sprintf (buffer
, "m %4x %4x", start
& 0xffff, end
& 0xffff);
1227 hms_write_cr (buffer
);
1228 /* drop the echo and newline */
1229 for (i
= 0; i
< 13; i
++)
1232 /* Grab the lines as they come out and fill the area */
1243 buffer
[0] = readchar ();
1244 while (buffer
[0] == '\r'
1245 || buffer
[0] == '\n')
1246 buffer
[0] = readchar ();
1248 if (buffer
[0] == 'M')
1251 for (i
= 1; i
< 50; i
++)
1253 buffer
[i
] = readchar ();
1255 /* sometimes we loose characters in the ascii representation of the
1256 data. I don't know where. So just scan for the end of line */
1258 while (i
!= '\n' && i
!= '\r')
1261 /* Now parse the line */
1263 addr
= gethex (4, buffer
, &ok
);
1265 for (p
= 0; p
< 16; p
+= 2)
1267 byte
[p
] = gethex (2, buffer
+ idx
, &ok
);
1268 byte
[p
+ 1] = gethex (2, buffer
+ idx
+ 2, &ok
);
1272 for (p
= 0; p
< 16; p
++)
1274 if (addr
+ p
>= memaddr
&&
1275 addr
+ p
< memaddr
+ len
)
1277 myaddr
[(addr
+ p
) - memaddr
] = byte
[p
];
1283 #ifdef GDB_TARGET_IS_H8500
1286 #ifdef GDB_TARGET_IS_H8300
1297 #define MAX_BREAKS 16
1298 static int num_brkpts
= 0;
1300 hms_insert_breakpoint (addr
, save
)
1302 char *save
; /* Throw away, let hms save instructions */
1306 if (num_brkpts
< MAX_BREAKS
)
1311 sprintf (buffer
, "b %x", addr
& 0xffff);
1312 hms_write_cr (buffer
);
1318 fprintf_filtered (gdb_stderr
,
1319 "Too many break points, break point not installed\n");
1325 hms_remove_breakpoint (addr
, save
)
1327 char *save
; /* Throw away, let hms save instructions */
1334 sprintf (buffer
, "b - %x", addr
& 0xffff);
1335 hms_write_cr (buffer
);
1342 /* Clear the hmss notion of what the break points are */
1344 hms_clear_breakpoints ()
1349 hms_write_cr ("b -");
1357 hms_clear_breakpoints ();
1358 unpush_target (&hms_ops
);
1359 generic_mourn_inferior ();
1362 /* Put a command string, in args, out to the hms. The hms is assumed to
1363 be in raw mode, all writing/reading done through desc.
1364 Ouput from the hms is placed on the users terminal until the
1365 prompt from the hms is seen.
1366 FIXME: Can't handle commands that take input. */
1369 hms_com (args
, fromtty
)
1378 /* Clear all input so only command relative output is displayed */
1380 hms_write_cr (args
);
1381 /* hms_write ("\030", 1); */
1386 hms_open (name
, from_tty
)
1399 dev_name
= strdup (name
);
1401 if (!(desc
= SERIAL_OPEN (dev_name
)))
1402 perror_with_name ((char *) dev_name
);
1406 push_target (&hms_ops
);
1407 dcache_ptr
= dcache_init (hms_read_inferior_memory
,
1408 hms_write_inferior_memory
);
1410 /* Hello? Are you there? */
1411 SERIAL_WRITE (desc
, "\r\n", 2);
1414 /* Clear any break points */
1415 hms_clear_breakpoints ();
1417 printf_filtered ("Connected to remote board running HMS monitor.\n");
1422 /* Define the target subroutine names */
1424 struct target_ops hms_ops
=
1426 "hms", "Remote HMS monitor",
1427 "Use the H8 evaluation board running the HMS monitor connected\n\
1430 hms_open
, hms_close
,
1431 0, hms_detach
, hms_resume
, hms_wait
, /* attach */
1432 hms_fetch_register
, hms_store_register
,
1433 hms_prepare_to_store
,
1434 hms_xfer_inferior_memory
,
1436 hms_insert_breakpoint
, hms_remove_breakpoint
, /* Breakpoints */
1437 0, 0, 0, 0, 0, /* Terminal handling */
1438 hms_kill
, /* FIXME, kill */
1440 0, /* lookup_symbol */
1441 hms_create_inferior
, /* create_inferior */
1442 hms_mourn
, /* mourn_inferior FIXME */
1444 0, /* notice_signals */
1446 process_stratum
, 0, /* next */
1447 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
1448 0, 0, /* Section pointers */
1449 OPS_MAGIC
, /* Always the last thing */
1452 hms_quiet () /* FIXME - this routine can be removed after Dec '94 */
1456 printf_filtered ("Snoop disabled\n");
1458 printf_filtered ("Snoop enabled\n");
1460 printf_filtered ("`snoop' is obsolete, please use `set remotedebug'.\n");
1468 dev_name
= get_word (&s
);
1481 int newrate
= atoi (s
);
1484 if (SERIAL_SETBAUDRATE (desc
, newrate
))
1485 error ("Can't use %d baud\n", newrate
);
1487 printf_filtered ("Checking target is in sync\n");
1489 printf_filtered ("Sending commands to set target to %d\n",
1492 sprintf (buffer
, "tm %d. N 8 1", baudrate
);
1493 hms_write_cr (buffer
);
1497 /***********************************************************************/
1500 hms_drain (args
, fromtty
)
1507 c
= SERIAL_READCHAR (desc
, 1);
1508 if (c
== SERIAL_TIMEOUT
)
1510 if (c
== SERIAL_ERROR
)
1512 if (c
> ' ' && c
< 127)
1513 printf ("%c", c
& 0xff);
1515 printf ("<%x>", c
& 0xff);
1523 add_com ("hms_drain", class_obscure
, hms_drain
,
1524 "Drain pending hms text buffers.");
1530 extern struct cmd_list_element
*cmdlist
;
1531 delete_cmd ("hms-drain", &cmdlist
);
1536 _initialize_remote_hms ()
1538 add_target (&hms_ops
);
1540 add_com ("hms <command>", class_obscure
, hms_com
,
1541 "Send a command to the HMS monitor.");
1543 /* FIXME - hms_quiet and `snoop' can be removed after Dec '94 */
1544 add_com ("snoop", class_obscure
, hms_quiet
,
1545 "Show what commands are going to the monitor (OBSOLETE - see 'set remotedebug')");
1547 add_com ("device", class_obscure
, hms_device
,
1548 "Set the terminal line for HMS communications");
1550 add_com ("speed", class_obscure
, hms_speed
,
1551 "Set the terminal line speed for HMS communications");