1 /* Remote target communications for serial-line targets using SDS' protocol.
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006 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., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, 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"
33 #include "exceptions.h"
39 #include "gdb-stabs.h"
40 #include "gdbthread.h"
47 extern void _initialize_remote_sds (void);
49 /* Declarations of local functions. */
51 static int sds_write_bytes (CORE_ADDR
, char *, int);
53 static int sds_read_bytes (CORE_ADDR
, char *, int);
55 static void sds_files_info (struct target_ops
*ignore
);
57 static int sds_xfer_memory (CORE_ADDR
, char *, int, int,
58 struct mem_attrib
*, struct target_ops
*);
60 static void sds_prepare_to_store (void);
62 static void sds_fetch_registers (int);
64 static void sds_resume (ptid_t
, int, enum target_signal
);
66 static int sds_start_remote (void *);
68 static void sds_open (char *, int);
70 static void sds_close (int);
72 static void sds_store_registers (int);
74 static void sds_mourn (void);
76 static void sds_load (char *, int);
78 static int getmessage (unsigned char *, int);
80 static int putmessage (unsigned char *, int);
82 static int sds_send (unsigned char *, int);
84 static int readchar (int);
86 static ptid_t
sds_wait (ptid_t
, struct target_waitstatus
*);
88 static void sds_kill (void);
90 static int fromhex (int);
92 static void sds_detach (char *, int);
94 static void sds_interrupt (int);
96 static void sds_interrupt_twice (int);
98 static void interrupt_query (void);
100 static int read_frame (char *);
102 static void init_sds_ops (void);
104 static void sds_command (char *args
, int from_tty
);
106 /* Define the target operations vector. */
108 static struct target_ops sds_ops
;
110 /* This was 5 seconds, which is a long time to sit and wait.
111 Unless this is going though some terminal server or multiplexer or
112 other form of hairy serial connection, I would think 2 seconds would
115 static int sds_timeout
= 2;
117 /* Descriptor for I/O to remote machine. Initialize it to NULL so
118 that sds_open knows that we don't have a file open when the program
121 static struct serial
*sds_desc
= NULL
;
123 /* This limit comes from the monitor. */
127 /* Maximum number of bytes to read/write at once. The value here
128 is chosen to fill up a packet (the headers account for the 32). */
129 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
131 static int next_msg_id
;
133 static int just_started
;
135 static int message_pending
;
138 /* Clean up connection to a remote debugger. */
141 sds_close (int quitting
)
144 serial_close (sds_desc
);
148 /* Stub for catch_errors. */
151 sds_start_remote (void *from_tty_p
)
153 int from_tty
= * (int *) from_tty
;
155 unsigned char buf
[200];
157 immediate_quit
++; /* Allow user to interrupt it */
159 /* Ack any packet which the remote side has already sent. */
160 serial_write (sds_desc
, "{#*\r\n", 5);
161 serial_write (sds_desc
, "{#}\r\n", 5);
163 while ((c
= readchar (1)) >= 0)
164 printf_unfiltered ("%c", c
);
165 printf_unfiltered ("\n");
177 start_remote (from_tty
); /* Initialize gdb process mechanisms */
181 /* Open a connection to a remote debugger.
182 NAME is the filename used for communication. */
185 sds_open (char *name
, int from_tty
)
188 error ("To open a remote debug connection, you need to specify what serial\n\
189 device is attached to the remote system (e.g. /dev/ttya).");
191 target_preopen (from_tty
);
193 unpush_target (&sds_ops
);
195 sds_desc
= serial_open (name
);
197 perror_with_name (name
);
201 if (serial_setbaudrate (sds_desc
, baud_rate
))
203 serial_close (sds_desc
);
204 perror_with_name (name
);
209 serial_raw (sds_desc
);
211 /* If there is something sitting in the buffer we might take it as a
212 response to a command, which would be bad. */
213 serial_flush_input (sds_desc
);
217 puts_filtered ("Remote debugging using ");
218 puts_filtered (name
);
219 puts_filtered ("\n");
221 push_target (&sds_ops
); /* Switch to using remote target now */
225 /* Start the remote connection; if error (0), discard this target.
226 In particular, if the user quits, be sure to discard it (we'd be
227 in an inconsistent state otherwise). */
228 if (!catch_errors (sds_start_remote
, &from_tty
,
229 "Couldn't establish connection to remote target\n",
234 /* This takes a program previously attached to and detaches it. After
235 this is done, GDB can be used to debug some other program. We
236 better not have left any breakpoints in the target program or it'll
237 die when it hits one. */
240 sds_detach (char *args
, int from_tty
)
245 error ("Argument given to \"detach\" when remotely debugging.");
248 /* Tell the remote target to detach. */
255 puts_filtered ("Ending remote debugging.\n");
258 /* Convert hex digit A to a number. */
263 if (a
>= '0' && a
<= '9')
265 else if (a
>= 'a' && a
<= 'f')
268 error ("Reply contains invalid hex digit %d", a
);
272 tob64 (unsigned char *inbuf
, char *outbuf
, int len
)
278 error ("bad length");
281 for (i
= 0; i
< len
; i
+= 3)
283 /* Collect the next three bytes into a number. */
284 sum
= ((long) *inbuf
++) << 16;
285 sum
|= ((long) *inbuf
++) << 8;
286 sum
|= ((long) *inbuf
++);
288 /* Spit out 4 6-bit encodings. */
289 *p
++ = ((sum
>> 18) & 0x3f) + '0';
290 *p
++ = ((sum
>> 12) & 0x3f) + '0';
291 *p
++ = ((sum
>> 6) & 0x3f) + '0';
292 *p
++ = (sum
& 0x3f) + '0';
298 fromb64 (char *inbuf
, char *outbuf
, int len
)
303 error ("bad length");
305 for (i
= 0; i
< len
; i
+= 4)
307 /* Collect 4 6-bit digits. */
308 sum
= (*inbuf
++ - '0') << 18;
309 sum
|= (*inbuf
++ - '0') << 12;
310 sum
|= (*inbuf
++ - '0') << 6;
311 sum
|= (*inbuf
++ - '0');
313 /* Now take the resulting 24-bit number and get three bytes out
315 *outbuf
++ = (sum
>> 16) & 0xff;
316 *outbuf
++ = (sum
>> 8) & 0xff;
317 *outbuf
++ = sum
& 0xff;
320 return (len
/ 4) * 3;
324 /* Tell the remote machine to resume. */
326 static enum target_signal last_sent_signal
= TARGET_SIGNAL_0
;
330 sds_resume (ptid_t ptid
, int step
, enum target_signal siggnal
)
332 unsigned char buf
[PBUFSIZ
];
334 last_sent_signal
= siggnal
;
335 last_sent_step
= step
;
337 buf
[0] = (step
? 21 : 20);
338 buf
[1] = 0; /* (should be signal?) */
343 /* Send a message to target to halt it. Target will respond, and send
344 us a message pending notice. */
347 sds_interrupt (int signo
)
349 unsigned char buf
[PBUFSIZ
];
351 /* If this doesn't work, try more severe steps. */
352 signal (signo
, sds_interrupt_twice
);
355 fprintf_unfiltered (gdb_stdlog
, "sds_interrupt called\n");
361 static void (*ofunc
) ();
363 /* The user typed ^C twice. */
366 sds_interrupt_twice (int signo
)
368 signal (signo
, ofunc
);
372 signal (signo
, sds_interrupt
);
375 /* Ask the user what to do when an interrupt is received. */
378 interrupt_query (void)
380 target_terminal_ours ();
382 if (query ("Interrupted while waiting for the program.\n\
383 Give up (and stop debugging it)? "))
385 target_mourn_inferior ();
386 deprecated_throw_reason (RETURN_QUIT
);
389 target_terminal_inferior ();
392 /* If nonzero, ignore the next kill. */
395 /* Wait until the remote machine stops, then return, storing status in
396 STATUS just as `wait' would. Returns "pid" (though it's not clear
397 what, if anything, that means in the case of this target). */
400 sds_wait (ptid_t ptid
, struct target_waitstatus
*status
)
402 unsigned char buf
[PBUFSIZ
];
405 status
->kind
= TARGET_WAITKIND_EXITED
;
406 status
->value
.integer
= 0;
408 ofunc
= (void (*)()) signal (SIGINT
, sds_interrupt
);
410 signal (SIGINT
, ofunc
);
415 status
->kind
= TARGET_WAITKIND_STOPPED
;
416 return inferior_ptid
;
426 retlen
= sds_send (buf
, 1);
429 fprintf_unfiltered (gdb_stdlog
, "Signals: %02x%02x %02x %02x\n",
434 status
->kind
= TARGET_WAITKIND_STOPPED
;
435 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
440 return inferior_ptid
;
443 static unsigned char sprs
[16];
445 /* Read the remote registers into the block REGS. */
446 /* Currently we just read all the registers, so we don't use regno. */
449 sds_fetch_registers (int regno
)
451 unsigned char buf
[PBUFSIZ
];
453 char *regs
= alloca (deprecated_register_bytes ());
455 /* Unimplemented registers read as all bits zero. */
456 memset (regs
, 0, deprecated_register_bytes ());
461 retlen
= sds_send (buf
, 3);
463 for (i
= 0; i
< 4 * 6; ++i
)
464 regs
[i
+ 4 * 32 + 8 * 32] = buf
[i
];
465 for (i
= 0; i
< 4 * 4; ++i
)
466 sprs
[i
] = buf
[i
+ 4 * 7];
471 retlen
= sds_send (buf
, 3);
473 for (i
= 0; i
< retlen
; i
++)
476 /* (should warn about reply too short) */
478 for (i
= 0; i
< NUM_REGS
; i
++)
479 regcache_raw_supply (current_regcache
, i
,
480 ®s
[DEPRECATED_REGISTER_BYTE (i
)]);
483 /* Prepare to store registers. Since we may send them all, we have to
484 read out the ones we don't want to change first. */
487 sds_prepare_to_store (void)
489 /* Make sure the entire registers array is valid. */
490 deprecated_read_register_bytes (0, (char *) NULL
, deprecated_register_bytes ());
493 /* Store register REGNO, or all registers if REGNO == -1, from the contents
494 of REGISTERS. FIXME: ignores errors. */
497 sds_store_registers (int regno
)
499 unsigned char *p
, buf
[PBUFSIZ
];
502 /* Store all the special-purpose registers. */
508 for (i
= 0; i
< 4 * 6; i
++)
509 *p
++ = deprecated_registers
[i
+ 4 * 32 + 8 * 32];
510 for (i
= 0; i
< 4 * 1; i
++)
512 for (i
= 0; i
< 4 * 4; i
++)
515 sds_send (buf
, p
- buf
);
517 /* Store all the general-purpose registers. */
523 for (i
= 0; i
< 4 * 32; i
++)
524 *p
++ = deprecated_registers
[i
];
526 sds_send (buf
, p
- buf
);
530 /* Write memory data directly to the remote machine. This does not
531 inform the data cache; the data cache uses this. MEMADDR is the
532 address in the remote memory space. MYADDR is the address of the
533 buffer in our space. LEN is the number of bytes.
535 Returns number of bytes transferred, or 0 for error. */
538 sds_write_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
540 int max_buf_size
; /* Max size of packet output buffer */
542 unsigned char buf
[PBUFSIZ
];
546 /* Chop the transfer down if necessary */
553 todo
= min (len
, max_buf_size
);
557 buf
[2] = (int) (memaddr
>> 24) & 0xff;
558 buf
[3] = (int) (memaddr
>> 16) & 0xff;
559 buf
[4] = (int) (memaddr
>> 8) & 0xff;
560 buf
[5] = (int) (memaddr
) & 0xff;
564 for (i
= 0; i
< todo
; i
++)
565 buf
[i
+ 8] = myaddr
[i
];
567 sds_send (buf
, 8 + todo
);
569 /* (should look at result) */
578 /* Read memory data directly from the remote machine. This does not
579 use the data cache; the data cache uses this. MEMADDR is the
580 address in the remote memory space. MYADDR is the address of the
581 buffer in our space. LEN is the number of bytes.
583 Returns number of bytes transferred, or 0 for error. */
586 sds_read_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
588 int max_buf_size
; /* Max size of packet output buffer */
590 unsigned char buf
[PBUFSIZ
];
594 /* Chop the transfer down if necessary */
601 todo
= min (len
, max_buf_size
);
605 buf
[2] = (int) (memaddr
>> 24) & 0xff;
606 buf
[3] = (int) (memaddr
>> 16) & 0xff;
607 buf
[4] = (int) (memaddr
>> 8) & 0xff;
608 buf
[5] = (int) (memaddr
) & 0xff;
609 buf
[6] = (int) (todo
>> 8) & 0xff;
610 buf
[7] = (int) (todo
) & 0xff;
613 retlen
= sds_send (buf
, 9);
615 if (retlen
- 2 != todo
)
620 /* Reply describes memory byte by byte. */
622 for (i
= 0; i
< todo
; i
++)
623 myaddr
[i
] = buf
[i
+ 2];
633 /* Read or write LEN bytes from inferior memory at MEMADDR,
634 transferring to or from debugger address MYADDR. Write to inferior
635 if SHOULD_WRITE is nonzero. Returns length of data written or
636 read; 0 for error. TARGET is unused. */
639 sds_xfer_memory (CORE_ADDR memaddr
, char *myaddr
, int len
, int should_write
,
640 struct mem_attrib
*attrib
, struct target_ops
*target
)
645 res
= sds_write_bytes (memaddr
, myaddr
, len
);
647 res
= sds_read_bytes (memaddr
, myaddr
, len
);
654 sds_files_info (struct target_ops
*ignore
)
656 puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
659 /* Stuff for dealing with the packets which are part of this protocol.
660 See comment at top of file for details. */
662 /* Read a single character from the remote end, masking it down to 7 bits. */
665 readchar (int timeout
)
669 ch
= serial_readchar (sds_desc
, timeout
);
671 if (remote_debug
> 1 && ch
>= 0)
672 fprintf_unfiltered (gdb_stdlog
, "%c(%x)", ch
, ch
);
677 error ("Remote connection closed");
679 perror_with_name ("Remote communication error");
687 /* An SDS-style checksum is a sum of the bytes modulo 253. (Presumably
688 because 253, 254, and 255 are special flags in the protocol.) */
691 compute_checksum (int csum
, char *buf
, int len
)
695 for (i
= 0; i
< len
; ++i
)
696 csum
+= (unsigned char) buf
[i
];
702 /* Send the command in BUF to the remote machine, and read the reply
706 sds_send (unsigned char *buf
, int len
)
708 putmessage (buf
, len
);
710 return getmessage (buf
, 0);
713 /* Send a message to the remote machine. */
716 putmessage (unsigned char *buf
, int len
)
719 unsigned char csum
= 0;
720 char buf2
[PBUFSIZ
], buf3
[PBUFSIZ
];
721 unsigned char header
[3];
724 /* Copy the packet into buffer BUF2, encapsulating it
725 and giving it a checksum. */
727 if (len
> 170) /* Prosanity check */
728 internal_error (__FILE__
, __LINE__
, _("failed internal consistency check"));
732 fprintf_unfiltered (gdb_stdlog
, "Message to send: \"");
733 for (i
= 0; i
< len
; ++i
)
734 fprintf_unfiltered (gdb_stdlog
, "%02x", buf
[i
]);
735 fprintf_unfiltered (gdb_stdlog
, "\"\n");
747 header
[1] = next_msg_id
;
751 csum
= compute_checksum (csum
, buf
, len
);
752 csum
= compute_checksum (csum
, header
+ 1, 2);
756 tob64 (header
, p
, 3);
758 enclen
= tob64 (buf
, buf3
, ((len
+ 2) / 3) * 3);
760 for (i
= 0; i
< enclen
; ++i
)
765 next_msg_id
= (next_msg_id
+ 3) % 245;
767 /* Send it over and over until we get a positive ack. */
774 fprintf_unfiltered (gdb_stdlog
, "Sending encoded: \"%s\"", buf2
);
775 fprintf_unfiltered (gdb_stdlog
,
776 " (Checksum %d, id %d, length %d)\n",
777 header
[0], header
[1], header
[2]);
778 gdb_flush (gdb_stdlog
);
780 if (serial_write (sds_desc
, buf2
, p
- buf2
))
781 perror_with_name ("putmessage: write failed");
787 /* Come here after finding the start of the frame. Collect the rest
788 into BUF. Returns 0 on any error, 1 on success. */
791 read_frame (char *buf
)
800 c
= readchar (sds_timeout
);
806 fputs_filtered ("Timeout in mid-message, retrying\n", gdb_stdlog
);
810 fputs_filtered ("Saw new packet start in middle of old one\n",
812 return 0; /* Start a new packet, count retries */
820 fprintf_unfiltered (gdb_stdlog
, "Received encoded: \"%s\"\n",
826 if (bp
< buf
+ PBUFSIZ
- 1)
833 puts_filtered ("Message too long: ");
835 puts_filtered ("\n");
842 /* Read a packet from the remote machine, with error checking,
843 and store it in BUF. BUF is expected to be of size PBUFSIZ.
844 If FOREVER, wait forever rather than timing out; this is used
845 while the target is executing user code. */
848 getmessage (unsigned char *buf
, int forever
)
853 int val
, i
, len
, csum
;
854 unsigned char header
[3];
855 unsigned char inbuf
[500];
857 strcpy (buf
, "timeout");
861 timeout
= watchdog
> 0 ? watchdog
: -1;
865 timeout
= sds_timeout
;
869 for (tries
= 1; tries
<= MAX_TRIES
; tries
++)
871 /* This can loop forever if the remote side sends us characters
872 continuously, but if it pauses, we'll get a zero from readchar
873 because of timeout. Then we'll count that as a retry. */
875 /* Note that we will only wait forever prior to the start of a packet.
876 After that, we expect characters to arrive at a brisk pace. They
877 should show up within sds_timeout intervals. */
881 c
= readchar (timeout
);
883 if (c
== SERIAL_TIMEOUT
)
885 if (forever
) /* Watchdog went off. Kill the target. */
887 target_mourn_inferior ();
888 error ("Watchdog has expired. Target detached.\n");
891 fputs_filtered ("Timed out.\n", gdb_stdlog
);
895 while (c
!= '$' && c
!= '{');
897 /* We might have seen a "trigraph", a sequence of three characters
898 that indicate various sorts of communication state. */
902 /* Read the other two chars of the trigraph. */
903 c2
= readchar (timeout
);
904 c3
= readchar (timeout
);
906 fprintf_unfiltered (gdb_stdlog
, "Trigraph %c%c%c received\n",
916 val
= read_frame (inbuf
);
920 fromb64 (inbuf
, header
, 4);
921 /* (should check out other bits) */
922 fromb64 (inbuf
+ 4, buf
, strlen (inbuf
) - 4);
927 csum
= compute_checksum (csum
, buf
, len
);
928 csum
= compute_checksum (csum
, header
+ 1, 2);
930 if (csum
!= header
[0])
931 fprintf_unfiltered (gdb_stderr
,
932 "Checksum mismatch: computed %d, received %d\n",
935 if (header
[2] == 0xff)
936 fprintf_unfiltered (gdb_stderr
, "Requesting resend...\n");
940 fprintf_unfiltered (gdb_stdlog
,
941 "... (Got checksum %d, id %d, length %d)\n",
942 header
[0], header
[1], header
[2]);
943 fprintf_unfiltered (gdb_stdlog
, "Message received: \"");
944 for (i
= 0; i
< len
; ++i
)
946 fprintf_unfiltered (gdb_stdlog
, "%02x", (unsigned char) buf
[i
]);
948 fprintf_unfiltered (gdb_stdlog
, "\"\n");
951 /* no ack required? */
955 /* Try the whole thing again. */
957 /* need to do something here */
961 /* We have tried hard enough, and just can't receive the packet. Give up. */
963 printf_unfiltered ("Ignoring packet error, continuing...\n");
970 /* Don't try to do anything to the target. */
976 unpush_target (&sds_ops
);
977 generic_mourn_inferior ();
981 sds_create_inferior (char *exec_file
, char *args
, char **env
, int from_tty
)
983 inferior_ptid
= pid_to_ptid (42000);
985 /* Clean up from the last time we were running. */
986 clear_proceed_status ();
988 write_pc (bfd_get_start_address (exec_bfd
));
992 sds_load (char *filename
, int from_tty
)
994 generic_load (filename
, from_tty
);
996 inferior_ptid
= null_ptid
;
999 /* The SDS monitor has commands for breakpoint insertion, although it
1000 it doesn't actually manage the breakpoints, it just returns the
1001 replaced instruction back to the debugger. */
1004 sds_insert_breakpoint (struct bp_target_info
*bp_tgt
)
1006 CORE_ADDR addr
= bp_tgt
->placed_address
;
1008 unsigned char *p
, buf
[PBUFSIZ
];
1013 *p
++ = (int) (addr
>> 24) & 0xff;
1014 *p
++ = (int) (addr
>> 16) & 0xff;
1015 *p
++ = (int) (addr
>> 8) & 0xff;
1016 *p
++ = (int) (addr
) & 0xff;
1018 retlen
= sds_send (buf
, p
- buf
);
1020 for (i
= 0; i
< 4; ++i
)
1021 bp_tgt
->shadow_contents
[i
] = buf
[i
+ 2];
1027 sds_remove_breakpoint (struct bp_target_info
*bp_tgt
)
1029 CORE_ADDR addr
= bp_tgt
->placed_address
;
1031 unsigned char *p
, buf
[PBUFSIZ
];
1036 *p
++ = (int) (addr
>> 24) & 0xff;
1037 *p
++ = (int) (addr
>> 16) & 0xff;
1038 *p
++ = (int) (addr
>> 8) & 0xff;
1039 *p
++ = (int) (addr
) & 0xff;
1040 for (i
= 0; i
< 4; ++i
)
1041 *p
++ = bp_tgt
->shadow_contents
[i
];
1043 retlen
= sds_send (buf
, p
- buf
);
1051 sds_ops
.to_shortname
= "sds";
1052 sds_ops
.to_longname
= "Remote serial target with SDS protocol";
1053 sds_ops
.to_doc
= "Use a remote computer via a serial line; using the SDS protocol.\n\
1054 Specify the serial device it is connected to (e.g. /dev/ttya).";
1055 sds_ops
.to_open
= sds_open
;
1056 sds_ops
.to_close
= sds_close
;
1057 sds_ops
.to_detach
= sds_detach
;
1058 sds_ops
.to_resume
= sds_resume
;
1059 sds_ops
.to_wait
= sds_wait
;
1060 sds_ops
.to_fetch_registers
= sds_fetch_registers
;
1061 sds_ops
.to_store_registers
= sds_store_registers
;
1062 sds_ops
.to_prepare_to_store
= sds_prepare_to_store
;
1063 sds_ops
.deprecated_xfer_memory
= sds_xfer_memory
;
1064 sds_ops
.to_files_info
= sds_files_info
;
1065 sds_ops
.to_insert_breakpoint
= sds_insert_breakpoint
;
1066 sds_ops
.to_remove_breakpoint
= sds_remove_breakpoint
;
1067 sds_ops
.to_kill
= sds_kill
;
1068 sds_ops
.to_load
= sds_load
;
1069 sds_ops
.to_create_inferior
= sds_create_inferior
;
1070 sds_ops
.to_mourn_inferior
= sds_mourn
;
1071 sds_ops
.to_stratum
= process_stratum
;
1072 sds_ops
.to_has_all_memory
= 1;
1073 sds_ops
.to_has_memory
= 1;
1074 sds_ops
.to_has_stack
= 1;
1075 sds_ops
.to_has_registers
= 1;
1076 sds_ops
.to_has_execution
= 1;
1077 sds_ops
.to_magic
= OPS_MAGIC
;
1080 /* Put a command string, in args, out to the monitor and display the
1084 sds_command (char *args
, int from_tty
)
1088 unsigned char buf
[1000];
1090 /* Convert hexadecimal chars into a byte buffer. */
1095 buf
[len
++] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
1101 retlen
= sds_send (buf
, len
);
1103 printf_filtered ("Reply is ");
1104 for (i
= 0; i
< retlen
; ++i
)
1106 printf_filtered ("%02x", buf
[i
]);
1108 printf_filtered ("\n");
1112 _initialize_remote_sds (void)
1115 add_target (&sds_ops
);
1117 add_setshow_integer_cmd ("sdstimeout", no_class
, &sds_timeout
, _("\
1118 Set timeout value for sds read."), _("\
1119 Show timeout value for sds read."), NULL
,
1121 NULL
, /* FIXME: i18n: */
1122 &setlist
, &showlist
);
1124 add_com ("sds", class_obscure
, sds_command
,
1125 _("Send a command to the SDS monitor."));