1 /* Remote target communications for serial-line targets using SDS' protocol.
3 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software
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. */
23 /* This interface was written by studying the behavior of the SDS
24 monitor on an ADS 821/860 board, and by consulting the
25 documentation of the monitor that is available on Motorola's web
29 #include "gdb_string.h"
38 #include "gdb-stabs.h"
39 #include "gdbthread.h"
44 #include <sys/types.h>
50 extern void _initialize_remote_sds (void);
52 /* Declarations of local functions. */
54 static int sds_write_bytes (CORE_ADDR
, char *, int);
56 static int sds_read_bytes (CORE_ADDR
, char *, int);
58 static void sds_files_info (struct target_ops
*ignore
);
60 static int sds_xfer_memory (CORE_ADDR
, char *, int, int,
61 struct mem_attrib
*, struct target_ops
*);
63 static void sds_prepare_to_store (void);
65 static void sds_fetch_registers (int);
67 static void sds_resume (ptid_t
, int, enum target_signal
);
69 static int sds_start_remote (void *);
71 static void sds_open (char *, int);
73 static void sds_close (int);
75 static void sds_store_registers (int);
77 static void sds_mourn (void);
79 static void sds_load (char *, int);
81 static int getmessage (unsigned char *, int);
83 static int putmessage (unsigned char *, int);
85 static int sds_send (unsigned char *, int);
87 static int readchar (int);
89 static ptid_t
sds_wait (ptid_t
, struct target_waitstatus
*);
91 static void sds_kill (void);
93 static int fromhex (int);
95 static void sds_detach (char *, int);
97 static void sds_interrupt (int);
99 static void sds_interrupt_twice (int);
101 static void interrupt_query (void);
103 static int read_frame (char *);
105 static int sds_insert_breakpoint (CORE_ADDR
, char *);
107 static int sds_remove_breakpoint (CORE_ADDR
, char *);
109 static void init_sds_ops (void);
111 static void sds_command (char *args
, int from_tty
);
113 /* Define the target operations vector. */
115 static struct target_ops sds_ops
;
117 /* This was 5 seconds, which is a long time to sit and wait.
118 Unless this is going though some terminal server or multiplexer or
119 other form of hairy serial connection, I would think 2 seconds would
122 static int sds_timeout
= 2;
124 /* Descriptor for I/O to remote machine. Initialize it to NULL so
125 that sds_open knows that we don't have a file open when the program
128 static struct serial
*sds_desc
= NULL
;
130 /* This limit comes from the monitor. */
134 /* Maximum number of bytes to read/write at once. The value here
135 is chosen to fill up a packet (the headers account for the 32). */
136 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
138 static int next_msg_id
;
140 static int just_started
;
142 static int message_pending
;
145 /* Clean up connection to a remote debugger. */
148 sds_close (int quitting
)
151 serial_close (sds_desc
);
155 /* Stub for catch_errors. */
158 sds_start_remote (void *dummy
)
161 unsigned char buf
[200];
163 immediate_quit
++; /* Allow user to interrupt it */
165 /* Ack any packet which the remote side has already sent. */
166 serial_write (sds_desc
, "{#*\r\n", 5);
167 serial_write (sds_desc
, "{#}\r\n", 5);
169 while ((c
= readchar (1)) >= 0)
170 printf_unfiltered ("%c", c
);
171 printf_unfiltered ("\n");
183 start_remote (); /* Initialize gdb process mechanisms */
187 /* Open a connection to a remote debugger.
188 NAME is the filename used for communication. */
191 sds_open (char *name
, int from_tty
)
194 error ("To open a remote debug connection, you need to specify what serial\n\
195 device is attached to the remote system (e.g. /dev/ttya).");
197 target_preopen (from_tty
);
199 unpush_target (&sds_ops
);
201 sds_desc
= serial_open (name
);
203 perror_with_name (name
);
207 if (serial_setbaudrate (sds_desc
, baud_rate
))
209 serial_close (sds_desc
);
210 perror_with_name (name
);
215 serial_raw (sds_desc
);
217 /* If there is something sitting in the buffer we might take it as a
218 response to a command, which would be bad. */
219 serial_flush_input (sds_desc
);
223 puts_filtered ("Remote debugging using ");
224 puts_filtered (name
);
225 puts_filtered ("\n");
227 push_target (&sds_ops
); /* Switch to using remote target now */
231 /* Start the remote connection; if error (0), discard this target.
232 In particular, if the user quits, be sure to discard it (we'd be
233 in an inconsistent state otherwise). */
234 if (!catch_errors (sds_start_remote
, NULL
,
235 "Couldn't establish connection to remote target\n",
240 /* This takes a program previously attached to and detaches it. After
241 this is done, GDB can be used to debug some other program. We
242 better not have left any breakpoints in the target program or it'll
243 die when it hits one. */
246 sds_detach (char *args
, int from_tty
)
251 error ("Argument given to \"detach\" when remotely debugging.");
254 /* Tell the remote target to detach. */
261 puts_filtered ("Ending remote debugging.\n");
264 /* Convert hex digit A to a number. */
269 if (a
>= '0' && a
<= '9')
271 else if (a
>= 'a' && a
<= 'f')
274 error ("Reply contains invalid hex digit %d", a
);
278 tob64 (unsigned char *inbuf
, char *outbuf
, int len
)
284 error ("bad length");
287 for (i
= 0; i
< len
; i
+= 3)
289 /* Collect the next three bytes into a number. */
290 sum
= ((long) *inbuf
++) << 16;
291 sum
|= ((long) *inbuf
++) << 8;
292 sum
|= ((long) *inbuf
++);
294 /* Spit out 4 6-bit encodings. */
295 *p
++ = ((sum
>> 18) & 0x3f) + '0';
296 *p
++ = ((sum
>> 12) & 0x3f) + '0';
297 *p
++ = ((sum
>> 6) & 0x3f) + '0';
298 *p
++ = (sum
& 0x3f) + '0';
304 fromb64 (char *inbuf
, char *outbuf
, int len
)
309 error ("bad length");
311 for (i
= 0; i
< len
; i
+= 4)
313 /* Collect 4 6-bit digits. */
314 sum
= (*inbuf
++ - '0') << 18;
315 sum
|= (*inbuf
++ - '0') << 12;
316 sum
|= (*inbuf
++ - '0') << 6;
317 sum
|= (*inbuf
++ - '0');
319 /* Now take the resulting 24-bit number and get three bytes out
321 *outbuf
++ = (sum
>> 16) & 0xff;
322 *outbuf
++ = (sum
>> 8) & 0xff;
323 *outbuf
++ = sum
& 0xff;
326 return (len
/ 4) * 3;
330 /* Tell the remote machine to resume. */
332 static enum target_signal last_sent_signal
= TARGET_SIGNAL_0
;
336 sds_resume (ptid_t ptid
, int step
, enum target_signal siggnal
)
338 unsigned char buf
[PBUFSIZ
];
340 last_sent_signal
= siggnal
;
341 last_sent_step
= step
;
343 buf
[0] = (step
? 21 : 20);
344 buf
[1] = 0; /* (should be signal?) */
349 /* Send a message to target to halt it. Target will respond, and send
350 us a message pending notice. */
353 sds_interrupt (int signo
)
355 unsigned char buf
[PBUFSIZ
];
357 /* If this doesn't work, try more severe steps. */
358 signal (signo
, sds_interrupt_twice
);
361 fprintf_unfiltered (gdb_stdlog
, "sds_interrupt called\n");
367 static void (*ofunc
) ();
369 /* The user typed ^C twice. */
372 sds_interrupt_twice (int signo
)
374 signal (signo
, ofunc
);
378 signal (signo
, sds_interrupt
);
381 /* Ask the user what to do when an interrupt is received. */
384 interrupt_query (void)
386 target_terminal_ours ();
388 if (query ("Interrupted while waiting for the program.\n\
389 Give up (and stop debugging it)? "))
391 target_mourn_inferior ();
392 throw_exception (RETURN_QUIT
);
395 target_terminal_inferior ();
398 /* If nonzero, ignore the next kill. */
401 /* Wait until the remote machine stops, then return, storing status in
402 STATUS just as `wait' would. Returns "pid" (though it's not clear
403 what, if anything, that means in the case of this target). */
406 sds_wait (ptid_t ptid
, struct target_waitstatus
*status
)
408 unsigned char buf
[PBUFSIZ
];
411 status
->kind
= TARGET_WAITKIND_EXITED
;
412 status
->value
.integer
= 0;
414 ofunc
= (void (*)()) signal (SIGINT
, sds_interrupt
);
416 signal (SIGINT
, ofunc
);
421 status
->kind
= TARGET_WAITKIND_STOPPED
;
422 return inferior_ptid
;
432 retlen
= sds_send (buf
, 1);
435 fprintf_unfiltered (gdb_stdlog
, "Signals: %02x%02x %02x %02x\n",
440 status
->kind
= TARGET_WAITKIND_STOPPED
;
441 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
446 return inferior_ptid
;
449 static unsigned char sprs
[16];
451 /* Read the remote registers into the block REGS. */
452 /* Currently we just read all the registers, so we don't use regno. */
455 sds_fetch_registers (int regno
)
457 unsigned char buf
[PBUFSIZ
];
459 char *regs
= alloca (DEPRECATED_REGISTER_BYTES
);
461 /* Unimplemented registers read as all bits zero. */
462 memset (regs
, 0, DEPRECATED_REGISTER_BYTES
);
467 retlen
= sds_send (buf
, 3);
469 for (i
= 0; i
< 4 * 6; ++i
)
470 regs
[i
+ 4 * 32 + 8 * 32] = buf
[i
];
471 for (i
= 0; i
< 4 * 4; ++i
)
472 sprs
[i
] = buf
[i
+ 4 * 7];
477 retlen
= sds_send (buf
, 3);
479 for (i
= 0; i
< retlen
; i
++)
482 /* (should warn about reply too short) */
484 for (i
= 0; i
< NUM_REGS
; i
++)
485 regcache_raw_supply (current_regcache
, i
,
486 ®s
[DEPRECATED_REGISTER_BYTE (i
)]);
489 /* Prepare to store registers. Since we may send them all, we have to
490 read out the ones we don't want to change first. */
493 sds_prepare_to_store (void)
495 /* Make sure the entire registers array is valid. */
496 deprecated_read_register_bytes (0, (char *) NULL
, DEPRECATED_REGISTER_BYTES
);
499 /* Store register REGNO, or all registers if REGNO == -1, from the contents
500 of REGISTERS. FIXME: ignores errors. */
503 sds_store_registers (int regno
)
505 unsigned char *p
, buf
[PBUFSIZ
];
508 /* Store all the special-purpose registers. */
514 for (i
= 0; i
< 4 * 6; i
++)
515 *p
++ = deprecated_registers
[i
+ 4 * 32 + 8 * 32];
516 for (i
= 0; i
< 4 * 1; i
++)
518 for (i
= 0; i
< 4 * 4; i
++)
521 sds_send (buf
, p
- buf
);
523 /* Store all the general-purpose registers. */
529 for (i
= 0; i
< 4 * 32; i
++)
530 *p
++ = deprecated_registers
[i
];
532 sds_send (buf
, p
- buf
);
536 /* Write memory data directly to the remote machine. This does not
537 inform the data cache; the data cache uses this. MEMADDR is the
538 address in the remote memory space. MYADDR is the address of the
539 buffer in our space. LEN is the number of bytes.
541 Returns number of bytes transferred, or 0 for error. */
544 sds_write_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
546 int max_buf_size
; /* Max size of packet output buffer */
548 unsigned char buf
[PBUFSIZ
];
552 /* Chop the transfer down if necessary */
559 todo
= min (len
, max_buf_size
);
563 buf
[2] = (int) (memaddr
>> 24) & 0xff;
564 buf
[3] = (int) (memaddr
>> 16) & 0xff;
565 buf
[4] = (int) (memaddr
>> 8) & 0xff;
566 buf
[5] = (int) (memaddr
) & 0xff;
570 for (i
= 0; i
< todo
; i
++)
571 buf
[i
+ 8] = myaddr
[i
];
573 sds_send (buf
, 8 + todo
);
575 /* (should look at result) */
584 /* Read memory data directly from the remote machine. This does not
585 use the data cache; the data cache uses this. MEMADDR is the
586 address in the remote memory space. MYADDR is the address of the
587 buffer in our space. LEN is the number of bytes.
589 Returns number of bytes transferred, or 0 for error. */
592 sds_read_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
594 int max_buf_size
; /* Max size of packet output buffer */
596 unsigned char buf
[PBUFSIZ
];
600 /* Chop the transfer down if necessary */
607 todo
= min (len
, max_buf_size
);
611 buf
[2] = (int) (memaddr
>> 24) & 0xff;
612 buf
[3] = (int) (memaddr
>> 16) & 0xff;
613 buf
[4] = (int) (memaddr
>> 8) & 0xff;
614 buf
[5] = (int) (memaddr
) & 0xff;
615 buf
[6] = (int) (todo
>> 8) & 0xff;
616 buf
[7] = (int) (todo
) & 0xff;
619 retlen
= sds_send (buf
, 9);
621 if (retlen
- 2 != todo
)
626 /* Reply describes memory byte by byte. */
628 for (i
= 0; i
< todo
; i
++)
629 myaddr
[i
] = buf
[i
+ 2];
639 /* Read or write LEN bytes from inferior memory at MEMADDR,
640 transferring to or from debugger address MYADDR. Write to inferior
641 if SHOULD_WRITE is nonzero. Returns length of data written or
642 read; 0 for error. TARGET is unused. */
645 sds_xfer_memory (CORE_ADDR memaddr
, char *myaddr
, int len
, int should_write
,
646 struct mem_attrib
*attrib
, struct target_ops
*target
)
651 res
= sds_write_bytes (memaddr
, myaddr
, len
);
653 res
= sds_read_bytes (memaddr
, myaddr
, len
);
660 sds_files_info (struct target_ops
*ignore
)
662 puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
665 /* Stuff for dealing with the packets which are part of this protocol.
666 See comment at top of file for details. */
668 /* Read a single character from the remote end, masking it down to 7 bits. */
671 readchar (int timeout
)
675 ch
= serial_readchar (sds_desc
, timeout
);
677 if (remote_debug
> 1 && ch
>= 0)
678 fprintf_unfiltered (gdb_stdlog
, "%c(%x)", ch
, ch
);
683 error ("Remote connection closed");
685 perror_with_name ("Remote communication error");
693 /* An SDS-style checksum is a sum of the bytes modulo 253. (Presumably
694 because 253, 254, and 255 are special flags in the protocol.) */
697 compute_checksum (int csum
, char *buf
, int len
)
701 for (i
= 0; i
< len
; ++i
)
702 csum
+= (unsigned char) buf
[i
];
708 /* Send the command in BUF to the remote machine, and read the reply
712 sds_send (unsigned char *buf
, int len
)
714 putmessage (buf
, len
);
716 return getmessage (buf
, 0);
719 /* Send a message to the remote machine. */
722 putmessage (unsigned char *buf
, int len
)
725 unsigned char csum
= 0;
726 char buf2
[PBUFSIZ
], buf3
[PBUFSIZ
];
727 unsigned char header
[3];
730 /* Copy the packet into buffer BUF2, encapsulating it
731 and giving it a checksum. */
733 if (len
> 170) /* Prosanity check */
734 internal_error (__FILE__
, __LINE__
, "failed internal consistency check");
738 fprintf_unfiltered (gdb_stdlog
, "Message to send: \"");
739 for (i
= 0; i
< len
; ++i
)
740 fprintf_unfiltered (gdb_stdlog
, "%02x", buf
[i
]);
741 fprintf_unfiltered (gdb_stdlog
, "\"\n");
753 header
[1] = next_msg_id
;
757 csum
= compute_checksum (csum
, buf
, len
);
758 csum
= compute_checksum (csum
, header
+ 1, 2);
762 tob64 (header
, p
, 3);
764 enclen
= tob64 (buf
, buf3
, ((len
+ 2) / 3) * 3);
766 for (i
= 0; i
< enclen
; ++i
)
771 next_msg_id
= (next_msg_id
+ 3) % 245;
773 /* Send it over and over until we get a positive ack. */
780 fprintf_unfiltered (gdb_stdlog
, "Sending encoded: \"%s\"", buf2
);
781 fprintf_unfiltered (gdb_stdlog
,
782 " (Checksum %d, id %d, length %d)\n",
783 header
[0], header
[1], header
[2]);
784 gdb_flush (gdb_stdlog
);
786 if (serial_write (sds_desc
, buf2
, p
- buf2
))
787 perror_with_name ("putmessage: write failed");
793 /* Come here after finding the start of the frame. Collect the rest
794 into BUF. Returns 0 on any error, 1 on success. */
797 read_frame (char *buf
)
806 c
= readchar (sds_timeout
);
812 fputs_filtered ("Timeout in mid-message, retrying\n", gdb_stdlog
);
816 fputs_filtered ("Saw new packet start in middle of old one\n",
818 return 0; /* Start a new packet, count retries */
826 fprintf_unfiltered (gdb_stdlog
, "Received encoded: \"%s\"\n",
832 if (bp
< buf
+ PBUFSIZ
- 1)
839 puts_filtered ("Message too long: ");
841 puts_filtered ("\n");
848 /* Read a packet from the remote machine, with error checking,
849 and store it in BUF. BUF is expected to be of size PBUFSIZ.
850 If FOREVER, wait forever rather than timing out; this is used
851 while the target is executing user code. */
854 getmessage (unsigned char *buf
, int forever
)
859 int val
, i
, len
, csum
;
860 unsigned char header
[3];
861 unsigned char inbuf
[500];
863 strcpy (buf
, "timeout");
867 timeout
= watchdog
> 0 ? watchdog
: -1;
871 timeout
= sds_timeout
;
875 for (tries
= 1; tries
<= MAX_TRIES
; tries
++)
877 /* This can loop forever if the remote side sends us characters
878 continuously, but if it pauses, we'll get a zero from readchar
879 because of timeout. Then we'll count that as a retry. */
881 /* Note that we will only wait forever prior to the start of a packet.
882 After that, we expect characters to arrive at a brisk pace. They
883 should show up within sds_timeout intervals. */
887 c
= readchar (timeout
);
889 if (c
== SERIAL_TIMEOUT
)
891 if (forever
) /* Watchdog went off. Kill the target. */
893 target_mourn_inferior ();
894 error ("Watchdog has expired. Target detached.\n");
897 fputs_filtered ("Timed out.\n", gdb_stdlog
);
901 while (c
!= '$' && c
!= '{');
903 /* We might have seen a "trigraph", a sequence of three characters
904 that indicate various sorts of communication state. */
908 /* Read the other two chars of the trigraph. */
909 c2
= readchar (timeout
);
910 c3
= readchar (timeout
);
912 fprintf_unfiltered (gdb_stdlog
, "Trigraph %c%c%c received\n",
922 val
= read_frame (inbuf
);
926 fromb64 (inbuf
, header
, 4);
927 /* (should check out other bits) */
928 fromb64 (inbuf
+ 4, buf
, strlen (inbuf
) - 4);
933 csum
= compute_checksum (csum
, buf
, len
);
934 csum
= compute_checksum (csum
, header
+ 1, 2);
936 if (csum
!= header
[0])
937 fprintf_unfiltered (gdb_stderr
,
938 "Checksum mismatch: computed %d, received %d\n",
941 if (header
[2] == 0xff)
942 fprintf_unfiltered (gdb_stderr
, "Requesting resend...\n");
946 fprintf_unfiltered (gdb_stdlog
,
947 "... (Got checksum %d, id %d, length %d)\n",
948 header
[0], header
[1], header
[2]);
949 fprintf_unfiltered (gdb_stdlog
, "Message received: \"");
950 for (i
= 0; i
< len
; ++i
)
952 fprintf_unfiltered (gdb_stdlog
, "%02x", (unsigned char) buf
[i
]);
954 fprintf_unfiltered (gdb_stdlog
, "\"\n");
957 /* no ack required? */
961 /* Try the whole thing again. */
963 /* need to do something here */
967 /* We have tried hard enough, and just can't receive the packet. Give up. */
969 printf_unfiltered ("Ignoring packet error, continuing...\n");
976 /* Don't try to do anything to the target. */
982 unpush_target (&sds_ops
);
983 generic_mourn_inferior ();
987 sds_create_inferior (char *exec_file
, char *args
, char **env
, int from_tty
)
989 inferior_ptid
= pid_to_ptid (42000);
991 /* Clean up from the last time we were running. */
992 clear_proceed_status ();
994 /* Let the remote process run. */
995 proceed (bfd_get_start_address (exec_bfd
), TARGET_SIGNAL_0
, 0);
999 sds_load (char *filename
, int from_tty
)
1001 generic_load (filename
, from_tty
);
1003 inferior_ptid
= null_ptid
;
1006 /* The SDS monitor has commands for breakpoint insertion, although it
1007 it doesn't actually manage the breakpoints, it just returns the
1008 replaced instruction back to the debugger. */
1011 sds_insert_breakpoint (CORE_ADDR addr
, char *contents_cache
)
1014 unsigned char *p
, buf
[PBUFSIZ
];
1019 *p
++ = (int) (addr
>> 24) & 0xff;
1020 *p
++ = (int) (addr
>> 16) & 0xff;
1021 *p
++ = (int) (addr
>> 8) & 0xff;
1022 *p
++ = (int) (addr
) & 0xff;
1024 retlen
= sds_send (buf
, p
- buf
);
1026 for (i
= 0; i
< 4; ++i
)
1027 contents_cache
[i
] = buf
[i
+ 2];
1033 sds_remove_breakpoint (CORE_ADDR addr
, char *contents_cache
)
1036 unsigned char *p
, buf
[PBUFSIZ
];
1041 *p
++ = (int) (addr
>> 24) & 0xff;
1042 *p
++ = (int) (addr
>> 16) & 0xff;
1043 *p
++ = (int) (addr
>> 8) & 0xff;
1044 *p
++ = (int) (addr
) & 0xff;
1045 for (i
= 0; i
< 4; ++i
)
1046 *p
++ = contents_cache
[i
];
1048 retlen
= sds_send (buf
, p
- buf
);
1056 sds_ops
.to_shortname
= "sds";
1057 sds_ops
.to_longname
= "Remote serial target with SDS protocol";
1058 sds_ops
.to_doc
= "Use a remote computer via a serial line; using the SDS protocol.\n\
1059 Specify the serial device it is connected to (e.g. /dev/ttya).";
1060 sds_ops
.to_open
= sds_open
;
1061 sds_ops
.to_close
= sds_close
;
1062 sds_ops
.to_detach
= sds_detach
;
1063 sds_ops
.to_resume
= sds_resume
;
1064 sds_ops
.to_wait
= sds_wait
;
1065 sds_ops
.to_fetch_registers
= sds_fetch_registers
;
1066 sds_ops
.to_store_registers
= sds_store_registers
;
1067 sds_ops
.to_prepare_to_store
= sds_prepare_to_store
;
1068 sds_ops
.to_xfer_memory
= sds_xfer_memory
;
1069 sds_ops
.to_files_info
= sds_files_info
;
1070 sds_ops
.to_insert_breakpoint
= sds_insert_breakpoint
;
1071 sds_ops
.to_remove_breakpoint
= sds_remove_breakpoint
;
1072 sds_ops
.to_kill
= sds_kill
;
1073 sds_ops
.to_load
= sds_load
;
1074 sds_ops
.to_create_inferior
= sds_create_inferior
;
1075 sds_ops
.to_mourn_inferior
= sds_mourn
;
1076 sds_ops
.to_stratum
= process_stratum
;
1077 sds_ops
.to_has_all_memory
= 1;
1078 sds_ops
.to_has_memory
= 1;
1079 sds_ops
.to_has_stack
= 1;
1080 sds_ops
.to_has_registers
= 1;
1081 sds_ops
.to_has_execution
= 1;
1082 sds_ops
.to_magic
= OPS_MAGIC
;
1085 /* Put a command string, in args, out to the monitor and display the
1089 sds_command (char *args
, int from_tty
)
1093 unsigned char buf
[1000];
1095 /* Convert hexadecimal chars into a byte buffer. */
1100 buf
[len
++] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
1106 retlen
= sds_send (buf
, len
);
1108 printf_filtered ("Reply is ");
1109 for (i
= 0; i
< retlen
; ++i
)
1111 printf_filtered ("%02x", buf
[i
]);
1113 printf_filtered ("\n");
1117 _initialize_remote_sds (void)
1120 add_target (&sds_ops
);
1122 add_show_from_set (add_set_cmd ("sdstimeout", no_class
,
1123 var_integer
, (char *) &sds_timeout
,
1124 "Set timeout value for sds read.\n", &setlist
),
1127 add_com ("sds", class_obscure
, sds_command
,
1128 "Send a command to the SDS monitor.");