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,
21 Boston, MA 02111-1307, USA. */
29 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
;
91 hms_cmds
.flags
= MO_CLR_BREAK_USES_ADDR
| MO_FILL_USES_ADDR
| MO_GETMEM_NEEDS_RANGE
;
92 hms_cmds
.init
= hms_inits
; /* Init strings */
93 hms_cmds
.cont
= "g\r"; /* continue command */
94 hms_cmds
.step
= "s\r"; /* single step */
95 hms_cmds
.stop
= "\003"; /* ^C interrupts the program */
96 hms_cmds
.set_break
= "b %x\r"; /* set a breakpoint */
97 hms_cmds
.clr_break
= "b - %x\r"; /* clear a breakpoint */
98 hms_cmds
.clr_all_break
= "b -\r"; /* clear all breakpoints */
99 hms_cmds
.fill
= "f %x %x %x\r"; /* fill (start end val) */
100 hms_cmds
.setmem
.cmdb
= "m.b %x=%x\r"; /* setmem.cmdb (addr, value) */
101 hms_cmds
.setmem
.cmdw
= "m.w %x=%x\r"; /* setmem.cmdw (addr, value) */
102 hms_cmds
.setmem
.cmdl
= NULL
; /* setmem.cmdl (addr, value) */
103 hms_cmds
.setmem
.cmdll
= NULL
; /* setmem.cmdll (addr, value) */
104 hms_cmds
.setmem
.resp_delim
= NULL
; /* setreg.resp_delim */
105 hms_cmds
.setmem
.term
= NULL
; /* setreg.term */
106 hms_cmds
.setmem
.term_cmd
= NULL
; /* setreg.term_cmd */
107 hms_cmds
.getmem
.cmdb
= "m.b %x %x\r"; /* getmem.cmdb (addr, addr) */
108 hms_cmds
.getmem
.cmdw
= "m.w %x %x\r"; /* getmem.cmdw (addr, addr) */
109 hms_cmds
.getmem
.cmdl
= NULL
; /* getmem.cmdl (addr, addr) */
110 hms_cmds
.getmem
.cmdll
= NULL
; /* getmem.cmdll (addr, addr) */
111 hms_cmds
.getmem
.resp_delim
= ": "; /* getmem.resp_delim */
112 hms_cmds
.getmem
.term
= ">"; /* getmem.term */
113 hms_cmds
.getmem
.term_cmd
= "\003"; /* getmem.term_cmd */
114 hms_cmds
.setreg
.cmd
= "r %s=%x\r"; /* setreg.cmd (name, value) */
115 hms_cmds
.setreg
.resp_delim
= NULL
; /* setreg.resp_delim */
116 hms_cmds
.setreg
.term
= NULL
; /* setreg.term */
117 hms_cmds
.setreg
.term_cmd
= NULL
; /* setreg.term_cmd */
118 hms_cmds
.getreg
.cmd
= "r %s\r"; /* getreg.cmd (name) */
119 hms_cmds
.getreg
.resp_delim
= " ("; /* getreg.resp_delim */
120 hms_cmds
.getreg
.term
= ":"; /* getreg.term */
121 hms_cmds
.getreg
.term_cmd
= "\003"; /* getreg.term_cmd */
122 hms_cmds
.dump_registers
= "r\r"; /* dump_registers */
123 hms_cmds
.register_pattern
= "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */
124 hms_cmds
.supply_register
= hms_supply_register
; /* supply_register */
125 hms_cmds
.load_routine
= NULL
; /* load_routine (defaults to SRECs) */
126 hms_cmds
.load
= "tl\r"; /* download command */
127 hms_cmds
.loadresp
= NULL
; /* load response */
128 hms_cmds
.prompt
= ">"; /* monitor command prompt */
129 hms_cmds
.line_term
= "\r"; /* end-of-command delimitor */
130 hms_cmds
.cmd_end
= NULL
; /* optional command terminator */
131 hms_cmds
.target
= &hms_ops
; /* target operations */
132 hms_cmds
.stopbits
= SERIAL_1_STOPBITS
; /* number of stop bits */
133 hms_cmds
.regnames
= hms_regnames
; /* registers names */
134 hms_cmds
.magic
= MONITOR_OPS_MAGIC
; /* magic */
135 } /* init_hms-cmds */
138 hms_open (args
, from_tty
)
142 monitor_open (args
, &hms_cmds
, from_tty
);
145 int write_dos_tick_delay
;
148 _initialize_remote_hms ()
151 init_monitor_ops (&hms_ops
);
153 hms_ops
.to_shortname
= "hms";
154 hms_ops
.to_longname
= "Hitachi Microsystems H8/300 debug monitor";
155 hms_ops
.to_doc
= "Debug via the HMS monitor.\n\
156 Specify the serial device it is connected to (e.g. /dev/ttya).";
157 hms_ops
.to_open
= hms_open
;
158 /* By trial and error I've found that this delay doesn't break things */
159 write_dos_tick_delay
= 1;
160 add_target (&hms_ops
);
164 /* This is kept here because we used to support the H8/500 in this module,
165 and I haven't done the H8/500 yet */
167 #include "inferior.h"
170 #include "gdb_string.h"
176 #include "terminal.h"
180 #include "remote-utils.h"
181 /* External data declarations */
182 extern int stop_soon_quietly
; /* for wait_for_inferior */
184 /* Forward data declarations */
185 extern struct target_ops hms_ops
; /* Forward declaration */
187 /* Forward function declarations */
188 static void hms_fetch_registers ();
189 static int hms_store_registers ();
190 static void hms_close ();
191 static int hms_clear_breakpoints ();
193 extern struct target_ops hms_ops
;
194 static void hms_drain ();
195 static void add_commands ();
196 static void remove_commands ();
198 static int quiet
= 1; /* FIXME - can be removed after Dec '94 */
202 /***********************************************************************
203 * I/O stuff stolen from remote-eb.c
204 ***********************************************************************/
206 static int timeout
= 2;
208 static const char *dev_name
;
210 /* Descriptor for I/O to remote machine. Initialize it to -1 so that
211 hms_open knows that we don't have a file open when the program
214 static int before
= 0xdead;
215 static int is_open
= 0;
216 static int after
= 0xdead;
222 printf ("OUTCH! \n");
225 error ("remote device not open");
232 /* Read a character from the remote system, doing all the fancy
239 buf
= SERIAL_READCHAR (desc
, timeout
);
241 if (buf
== SERIAL_TIMEOUT
)
243 hms_write (".\r\n", 3);
244 error ("Timeout reading from remote system.");
246 if (buf
== SERIAL_ERROR
)
248 error ("Serial port error!");
251 if (!quiet
|| remote_debug
)
252 printf_unfiltered ("%c", buf
);
262 int b
= SERIAL_READCHAR (desc
, 0);
263 if (b
== SERIAL_TIMEOUT
)
273 buf
= SERIAL_READCHAR (desc
, timeout
);
274 if (buf
== SERIAL_TIMEOUT
)
276 if (!quiet
|| remote_debug
)
277 printf_unfiltered ("%c", buf
);
283 /* Keep discarding input from the remote system, until STRING is found.
284 Let the user break out immediately. */
313 /* Keep discarding input until we see the hms prompt.
315 The convention for dealing with the prompt is that you
317 o *then* wait for the prompt.
319 Thus the last thing that a procedure does with the serial line
320 will be an expect_prompt(). Exception: hms_resume does not
321 wait for the prompt, because the terminal is being handed over
322 to the inferior. However, the next thing which happens after that
323 is a hms_wait which does wait for the prompt.
324 Note that this includes abnormal exit, e.g. error(). This is
325 necessary to prevent getting into states from which we can't
333 /* Get a hex digit from the remote system & return its value.
334 If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
336 get_hex_digit (ignore_space
)
344 if (ch
>= '0' && ch
<= '9')
346 else if (ch
>= 'A' && ch
<= 'F')
347 return ch
- 'A' + 10;
348 else if (ch
>= 'a' && ch
<= 'f')
349 return ch
- 'a' + 10;
350 else if (ch
== ' ' && ignore_space
)
355 error ("Invalid hex digit from remote system.");
360 /* Get a byte from hms_desc and put it in *BYT. Accept any number
368 val
= get_hex_digit (1) << 4;
369 val
|= get_hex_digit (0);
373 /* Read a 32-bit hex word from the hms, preceded by a space */
381 for (j
= 0; j
< 8; j
++)
382 val
= (val
<< 4) + get_hex_digit (j
== 0);
386 /* Called when SIGALRM signal sent due to alarm() timeout. */
388 /* Number of SIGTRAPs we need to simulate. That is, the next
389 NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
390 SIGTRAP without actually waiting for anything. */
392 static int need_artificial_trap
= 0;
395 hms_kill (arg
, from_tty
)
402 /* This is called not only when we first attach, but also when the
403 user types "run" after having attached. */
405 hms_create_inferior (execfile
, args
, env
)
414 error ("Can't pass arguments to remote hms process.");
416 if (execfile
== 0 || exec_bfd
== 0)
417 error ("No executable file specified");
419 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
422 hms_kill (NULL
, NULL
);
423 hms_clear_breakpoints ();
424 init_wait_for_inferior ();
428 insert_breakpoints (); /* Needed to get correct instruction in cache */
429 proceed (entry_pt
, TARGET_SIGNAL_DEFAULT
, 0);
432 /* Open a connection to a remote debugger.
433 NAME is the filename used for communication, then a space,
441 while (*s
&& !isspace (*s
))
462 while (*s
&& !isspace (*s
))
468 copy
= xmalloc (len
+ 1);
469 memcpy (copy
, word
, len
);
475 static int baudrate
= 9600;
482 /* Put this port into NORMAL mode, send the 'normal' character */
484 hms_write ("\001", 1); /* Control A */
485 hms_write ("\r\n", 2); /* Cr */
489 ok
= SERIAL_READCHAR (desc
, timeout
);
496 if (readchar_nofail () == 'r')
499 /* Not the right baudrate, or the board's not on */
505 if (!SERIAL_SETBAUDRATE (desc
, baudrate
))
506 error ("Can't set baudrate");
511 /* Close out all files and local state before this target loses control. */
517 /* Clear any break points */
519 hms_clear_breakpoints ();
520 sleep (1); /* Let any output make it all the way back */
523 SERIAL_WRITE (desc
, "R\r\n", 3);
529 /* Terminate the open connection to the remote debugger. Use this
530 when you want to detach and do something else with your gdb. */ void
531 hms_detach (args
, from_tty
)
537 hms_clear_breakpoints ();
540 pop_target (); /* calls hms_close to do the real work
543 printf_filtered ("Ending remote %s debugging\n",
547 /* Tell the remote machine to resume. */
550 hms_resume (pid
, step
, sig
)
560 /* Force the next hms_wait to return a trap. Not doing anything
561 about I/O from the target means that the user has to type "continue"
562 to see any. FIXME, this should be fixed. */
563 need_artificial_trap
= 1;
572 /* Wait until the remote machine stops, then return, storing status in
573 STATUS just as `wait' would. */
576 hms_wait (pid
, status
)
578 struct target_waitstatus
*status
;
580 /* Strings to look for. '?' means match any single character. Note
581 that with the algorithm we use, the initial character of the string
582 cannot recur in the string, or we will not find some cases of the
583 string in the input. */
585 static char bpt
[] = "At breakpoint:";
587 /* It would be tempting to look for "\n[__exit + 0x8]\n" but that
588 requires loading symbols with "yc i" and even if we did do that we
589 don't know that the file has symbols. */
590 static char exitmsg
[] = "HMS>";
594 /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.
598 /* Current position in swallowed. */
599 char *swallowed_p
= swallowed
;
603 int old_timeout
= timeout
;
605 old_immediate_quit
= immediate_quit
;
606 int swallowed_cr
= 0;
608 status
->kind
= TARGET_WAITKIND_EXITED
;
609 status
->value
.integer
= 0;
611 if (need_artificial_trap
!= 0)
614 TARGET_WAITKIND_STOPPED
;
615 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
616 need_artificial_trap
--;
620 timeout
= 5; /* Don't time out for a while - user program is running.
622 immediate_quit
= 1; /* Helps ability to QUIT */
625 QUIT
; /* Let user quit and leave process running */
642 (ch
== *ep
|| *ep
== '?')
662 /* Print out any characters which have been swallowed. */
663 for (p
= swallowed
; p
< swallowed_p
; ++p
)
664 putchar_unfiltered (*p
);
665 swallowed_p
= swallowed
;
667 if ((ch
!= '\r' && ch
!= '\n') || swallowed_cr
> 10)
669 putchar_unfiltered (ch
);
678 status
->kind
= TARGET_WAITKIND_STOPPED
;
679 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
684 status
->kind
= TARGET_WAITKIND_EXITED
;
685 status
->value
.integer
=
689 timeout
= old_timeout
;
690 immediate_quit
= old_immediate_quit
;
695 /* Return the name of register number REGNO in the form input and
698 Returns a pointer to a static buffer containing the answer. */
709 /* Read the remote registers. */
712 gethex (length
, start
, ok
)
722 if (*start
>= 'a' && *start
<= 'f')
724 result
+= *start
- 'a' + 10;
726 else if (*start
>= 'A' &&
729 result
+= *start
- 'A' + 10;
732 (*start
>= '0' && *start
<= '9')
734 result
+= *start
- '0';
744 timed_read (buf
, n
, timeout
)
771 SERIAL_WRITE (desc
, a
, l
);
773 if (!quiet
|| remote_debug
)
775 printf_unfiltered ("<");
776 for (i
= 0; i
< l
; i
++)
778 printf_unfiltered ("%c", a
[i
]);
780 printf_unfiltered (">");
787 hms_write (s
, strlen (s
));
788 hms_write ("\r\n", 2);
791 #ifdef GDB_TARGET_IS_H8500
793 /* H8/500 monitor reg dump looks like:
796 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
797 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
803 supply_val (n
, size
, ptr
, segptr
)
814 raw
[0] = gethex (2, ptr
, &ok
);
815 raw
[1] = gethex (2, ptr
+ 2, &ok
);
816 supply_register (n
, raw
);
819 raw
[0] = gethex (2, ptr
, &ok
);
820 supply_register (n
, raw
);
824 int v
= gethex (4, ptr
, &ok
);
825 v
|= gethex (2, segptr
, &ok
) << 16;
827 raw
[1] = (v
>> 16) & 0xff;
828 raw
[2] = (v
>> 8) & 0xff;
829 raw
[3] = (v
>> 0) & 0xff;
830 supply_register (n
, raw
);
836 hms_fetch_register (dummy
)
839 #define REGREPLY_SIZE 108
840 char linebuf
[REGREPLY_SIZE
+ 1];
845 LONGEST reg
[NUM_REGS
];
853 s
= timed_read (linebuf
+ 1, REGREPLY_SIZE
, 1);
855 linebuf
[REGREPLY_SIZE
] = 0;
857 if (linebuf
[3] == 'P' &&
860 linebuf
[105] == 'H' &&
861 linebuf
[106] == 'M' &&
868 -------1---------2---------3---------4---------5-----
869 345678901234567890123456789012345678901234567890123456
870 PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
871 ---6---------7---------8---------9--------10----
872 789012345678901234567890123456789012345678901234
873 R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
881 supply_val (PC_REGNUM
, 4, linebuf
+ 6, linebuf
+ 29);
883 supply_val (CCR_REGNUM
, 2, linebuf
+ 14);
884 supply_val (SEG_C_REGNUM
, 1, linebuf
+ 29);
885 supply_val (SEG_D_REGNUM
, 1, linebuf
+ 35);
886 supply_val (SEG_E_REGNUM
, 1, linebuf
+ 41);
887 supply_val (SEG_T_REGNUM
, 1, linebuf
+ 47);
888 for (i
= 0; i
< 8; i
++)
895 char *src
= linebuf
+ 64 + 5 * i
;
896 char *segsrc
= linebuf
+ sr
[i
];
897 supply_val (R0_REGNUM
+ i
, 2, src
);
898 supply_val (PR0_REGNUM
+ i
, 4, src
, segsrc
);
911 #ifdef GDB_TARGET_IS_H8300
913 hms_fetch_register (dummy
)
916 #define REGREPLY_SIZE 79
917 char linebuf
[REGREPLY_SIZE
+ 1];
922 ULONGEST reg
[NUM_REGS
];
930 s
= timed_read (linebuf
, 1, 1);
932 while (linebuf
[0] != 'r')
933 s
= timed_read (linebuf
, 1, 1);
935 s
= timed_read (linebuf
+ 1, REGREPLY_SIZE
- 1, 1);
937 linebuf
[REGREPLY_SIZE
] = 0;
939 if (linebuf
[0] == 'r' &&
943 linebuf
[75] == 'H' &&
944 linebuf
[76] == 'M' &&
948 PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
949 5436789012345678901234567890123456789012345678901234567890123456789012
954 reg
[PC_REGNUM
] = gethex (4, linebuf
+ 6, &gottok
);
955 reg
[CCR_REGNUM
] = gethex (2, linebuf
+ 15, &gottok
);
956 for (i
= 0; i
< 8; i
++)
958 reg
[i
] = gethex (4, linebuf
+ 34 + 5 * i
, &gottok
);
963 for (i
= 0; i
< NUM_REGS
; i
++)
968 swapped
[0] = (reg
[i
]) >> 8;
970 supply_register (i
, swapped
);
974 /* Store register REGNO, or all if REGNO == -1.
975 Return errno value. */
977 hms_store_register (regno
)
982 for (regno
= 0; regno
< NUM_REGS
; regno
++)
984 hms_store_register (regno
);
989 char *name
= get_reg_name (regno
);
991 /* Some regs dont really exist */
992 if (!(name
[0] == 'p' && name
[1] == 'r')
993 && !(name
[0] == 'c' && name
[1] == 'y')
994 && !(name
[0] == 't' && name
[1] == 'i')
995 && !(name
[0] == 'i' && name
[1] == 'n'))
997 sprintf (buffer
, "r %s=%x", name
, read_register (regno
));
998 hms_write_cr (buffer
);
1005 /* Get ready to modify the registers array. On machines which store
1006 individual registers, this doesn't need to do anything. On machines
1007 which store all the registers in one fell swoop, this makes sure
1008 that registers contains all the registers from the program being
1012 hms_prepare_to_store ()
1014 /* Do nothing, since we can store individual regs */
1018 translate_addr (addr
)
1028 hms_xfer_inferior_memory (memaddr
, myaddr
, len
, write
, target
)
1033 struct target_ops
*target
; /* ignored */
1040 hms_write_inferior_memory (memaddr
, myaddr
, len
)
1042 unsigned char *myaddr
;
1058 thisgo
= len
- done
;
1062 sprintf (ptr
, "M.B %4x =", memaddr
+ done
);
1064 for (idx
= 0; idx
< thisgo
; idx
++)
1066 sprintf (ptr
, "%2x ", myaddr
[idx
+ done
]);
1069 hms_write_cr (buffer
);
1078 char *file
= "nothing";
1081 file
= bfd_get_filename (exec_bfd
);
1085 printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file
);
1087 printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name
, baudrate
, file
);
1089 printf_filtered ("\ton an H8/300 processor.\n");
1092 /* Copy LEN bytes of data from debugger memory at MYADDR
1093 to inferior's memory at MEMADDR. Returns errno value.
1094 * sb/sh instructions don't work on unaligned addresses, when TU=1.
1097 /* Read LEN bytes from inferior memory at MEMADDR. Put the result
1098 at debugger address MYADDR. Returns errno value. */
1100 hms_read_inferior_memory (memaddr
, myaddr
, len
)
1105 /* Align to nearest low 16 bits */
1108 CORE_ADDR start
= memaddr
;
1109 CORE_ADDR end
= memaddr
+ len
- 1;
1114 AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
1115 012345678901234567890123456789012345678901234567890123456789012345
1125 sprintf (buffer
, "m %4x %4x", start
& 0xffff, end
& 0xffff);
1128 hms_write_cr (buffer
);
1129 /* drop the echo and newline */
1130 for (i
= 0; i
< 13; i
++)
1133 /* Grab the lines as they come out and fill the area */
1144 buffer
[0] = readchar ();
1145 while (buffer
[0] == '\r'
1146 || buffer
[0] == '\n')
1147 buffer
[0] = readchar ();
1149 if (buffer
[0] == 'M')
1152 for (i
= 1; i
< 50; i
++)
1154 buffer
[i
] = readchar ();
1156 /* sometimes we loose characters in the ascii representation of the
1157 data. I don't know where. So just scan for the end of line */
1159 while (i
!= '\n' && i
!= '\r')
1162 /* Now parse the line */
1164 addr
= gethex (4, buffer
, &ok
);
1166 for (p
= 0; p
< 16; p
+= 2)
1168 byte
[p
] = gethex (2, buffer
+ idx
, &ok
);
1169 byte
[p
+ 1] = gethex (2, buffer
+ idx
+ 2, &ok
);
1173 for (p
= 0; p
< 16; p
++)
1175 if (addr
+ p
>= memaddr
&&
1176 addr
+ p
< memaddr
+ len
)
1178 myaddr
[(addr
+ p
) - memaddr
] = byte
[p
];
1184 #ifdef GDB_TARGET_IS_H8500
1187 #ifdef GDB_TARGET_IS_H8300
1198 #define MAX_BREAKS 16
1199 static int num_brkpts
= 0;
1201 hms_insert_breakpoint (addr
, save
)
1203 char *save
; /* Throw away, let hms save instructions */
1207 if (num_brkpts
< MAX_BREAKS
)
1212 sprintf (buffer
, "b %x", addr
& 0xffff);
1213 hms_write_cr (buffer
);
1219 fprintf_filtered (gdb_stderr
,
1220 "Too many break points, break point not installed\n");
1226 hms_remove_breakpoint (addr
, save
)
1228 char *save
; /* Throw away, let hms save instructions */
1235 sprintf (buffer
, "b - %x", addr
& 0xffff);
1236 hms_write_cr (buffer
);
1243 /* Clear the hmss notion of what the break points are */
1245 hms_clear_breakpoints ()
1250 hms_write_cr ("b -");
1258 hms_clear_breakpoints ();
1259 unpush_target (&hms_ops
);
1260 generic_mourn_inferior ();
1263 /* Put a command string, in args, out to the hms. The hms is assumed to
1264 be in raw mode, all writing/reading done through desc.
1265 Ouput from the hms is placed on the users terminal until the
1266 prompt from the hms is seen.
1267 FIXME: Can't handle commands that take input. */
1270 hms_com (args
, fromtty
)
1279 /* Clear all input so only command relative output is displayed */
1281 hms_write_cr (args
);
1282 /* hms_write ("\030", 1); */
1287 hms_open (name
, from_tty
)
1300 dev_name
= strdup (name
);
1302 if (!(desc
= SERIAL_OPEN (dev_name
)))
1303 perror_with_name ((char *) dev_name
);
1307 push_target (&hms_ops
);
1308 dcache_ptr
= dcache_init (hms_read_inferior_memory
,
1309 hms_write_inferior_memory
);
1311 /* Hello? Are you there? */
1312 SERIAL_WRITE (desc
, "\r\n", 2);
1315 /* Clear any break points */
1316 hms_clear_breakpoints ();
1318 printf_filtered ("Connected to remote board running HMS monitor.\n");
1323 /* Define the target subroutine names */
1325 struct target_ops hms_ops
;
1330 hms_ops
.to_shortname
= "hms";
1331 hms_ops
.to_longname
= "Remote HMS monitor";
1332 hms_ops
.to_doc
= "Use the H8 evaluation board running the HMS monitor connected\n\
1334 hms_ops
.to_open
= hms_open
;
1335 hms_ops
.to_close
= hms_close
;
1336 hms_ops
.to_attach
= 0;
1337 hms_ops
.to_post_attach
= NULL
;
1338 hms_ops
.to_require_attach
= NULL
;
1339 hms_ops
.to_detach
= hms_detach
;
1340 hms_ops
.to_require_detach
= NULL
;
1341 hms_ops
.to_resume
= hms_resume
;
1342 hms_ops
.to_wait
= hms_wait
;
1343 hms_ops
.to_post_wait
= NULL
;
1344 hms_ops
.to_fetch_registers
= hms_fetch_register
;
1345 hms_ops
.to_store_registers
= hms_store_register
;
1346 hms_ops
.to_prepare_to_store
= hms_prepare_to_store
;
1347 hms_ops
.to_xfer_memory
= hms_xfer_inferior_memory
;
1348 hms_ops
.to_files_info
= hms_files_info
;
1349 hms_ops
.to_insert_breakpoint
= hms_insert_breakpoint
;
1350 hms_ops
.to_remove_breakpoint
= hms_remove_breakpoint
;
1351 hms_ops
.to_terminal_init
= 0;
1352 hms_ops
.to_terminal_inferior
= 0;
1353 hms_ops
.to_terminal_ours_for_output
= 0;
1354 hms_ops
.to_terminal_ours
= 0;
1355 hms_ops
.to_terminal_info
= 0;
1356 hms_ops
.to_kill
= hms_kill
;
1357 hms_ops
.to_load
= generic_load
;
1358 hms_ops
.to_lookup_symbol
= 0;
1359 hms_ops
.to_create_inferior
= hms_create_inferior
;
1360 hms_ops
.to_post_startup_inferior
= NULL
;
1361 hms_ops
.to_acknowledge_created_inferior
= NULL
;
1362 hms_ops
.to_clone_and_follow_inferior
= NULL
;
1363 hms_ops
.to_post_follow_inferior_by_clone
= NULL
;
1364 hms_ops
.to_insert_fork_catchpoint
= NULL
;
1365 hms_ops
.to_remove_fork_catchpoint
= NULL
;
1366 hms_ops
.to_insert_vfork_catchpoint
= NULL
;
1367 hms_ops
.to_remove_vfork_catchpoint
= NULL
;
1368 hms_ops
.to_has_forked
= NULL
;
1369 hms_ops
.to_has_vforked
= NULL
;
1370 hms_ops
.to_can_follow_vfork_prior_to_exec
= NULL
;
1371 hms_ops
.to_post_follow_vfork
= NULL
;
1372 hms_ops
.to_insert_exec_catchpoint
= NULL
;
1373 hms_ops
.to_remove_exec_catchpoint
= NULL
;
1374 hms_ops
.to_has_execd
= NULL
;
1375 hms_ops
.to_reported_exec_events_per_exec_call
= NULL
;
1376 hms_ops
.to_has_exited
= NULL
;
1377 hms_ops
.to_mourn_inferior
= hms_mourn
;
1378 hms_ops
.to_can_run
= 0;
1379 hms_ops
.to_notice_signals
= 0;
1380 hms_ops
.to_thread_alive
= 0;
1381 hms_ops
.to_stop
= 0;
1382 hms_ops
.to_pid_to_exec_file
= NULL
;
1383 hms_ops
.to_core_file_to_sym_file
= NULL
;
1384 hms_ops
.to_stratum
= process_stratum
;
1385 hms_ops
.DONT_USE
= 0;
1386 hms_ops
.to_has_all_memory
= 1;
1387 hms_ops
.to_has_memory
= 1;
1388 hms_ops
.to_has_stack
= 1;
1389 hms_ops
.to_has_registers
= 1;
1390 hms_ops
.to_has_execution
= 1;
1391 hms_ops
.to_sections
= 0;
1392 hms_ops
.to_sections_end
= 0;
1393 hms_ops
.to_magic
= OPS_MAGIC
;
1396 hms_quiet () /* FIXME - this routine can be removed after Dec '94 */
1400 printf_filtered ("Snoop disabled\n");
1402 printf_filtered ("Snoop enabled\n");
1404 printf_filtered ("`snoop' is obsolete, please use `set remotedebug'.\n");
1412 dev_name
= get_word (&s
);
1425 int newrate
= atoi (s
);
1428 if (SERIAL_SETBAUDRATE (desc
, newrate
))
1429 error ("Can't use %d baud\n", newrate
);
1431 printf_filtered ("Checking target is in sync\n");
1433 printf_filtered ("Sending commands to set target to %d\n",
1436 sprintf (buffer
, "tm %d. N 8 1", baudrate
);
1437 hms_write_cr (buffer
);
1441 /***********************************************************************/
1444 hms_drain (args
, fromtty
)
1451 c
= SERIAL_READCHAR (desc
, 1);
1452 if (c
== SERIAL_TIMEOUT
)
1454 if (c
== SERIAL_ERROR
)
1456 if (c
> ' ' && c
< 127)
1457 printf ("%c", c
& 0xff);
1459 printf ("<%x>", c
& 0xff);
1467 add_com ("hms_drain", class_obscure
, hms_drain
,
1468 "Drain pending hms text buffers.");
1474 extern struct cmd_list_element
*cmdlist
;
1475 delete_cmd ("hms-drain", &cmdlist
);
1480 _initialize_remote_hms ()
1483 add_target (&hms_ops
);
1485 add_com ("hms <command>", class_obscure
, hms_com
,
1486 "Send a command to the HMS monitor.");
1488 /* FIXME - hms_quiet and `snoop' can be removed after Dec '94 */
1489 add_com ("snoop", class_obscure
, hms_quiet
,
1490 "Show what commands are going to the monitor (OBSOLETE - see 'set remotedebug')");
1492 add_com ("device", class_obscure
, hms_device
,
1493 "Set the terminal line for HMS communications");
1495 add_com ("speed", class_obscure
, hms_speed
,
1496 "Set the terminal line speed for HMS communications");