1 /* Remote debugging interface for MIPS remote debugging protocol.
2 Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by Ian Lance Taylor
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, Boston, MA 02111-1307, USA. */
31 #include "remote-utils.h"
34 #ifdef ANSI_PROTOTYPES
40 extern char *mips_read_processor_type PARAMS ((void));
42 extern void mips_set_processor_type_command PARAMS ((char *, int));
45 /* Prototypes for local functions. */
47 static int mips_readchar PARAMS ((int timeout));
49 static int mips_receive_header PARAMS ((unsigned char *hdr, int *pgarbage,
50 int ch, int timeout));
52 static int mips_receive_trailer PARAMS ((unsigned char *trlr, int *pgarbage,
53 int *pch, int timeout));
55 static int mips_cksum PARAMS ((const unsigned char *hdr,
56 const unsigned char *data,
59 static void mips_send_packet PARAMS ((const char *s, int get_ack));
61 static int mips_receive_packet PARAMS ((char *buff, int throw_error,
64 static int mips_request PARAMS ((char cmd, unsigned int addr,
65 unsigned int data, int *perr, int timeout));
67 static void mips_initialize PARAMS ((void));
69 static void mips_open PARAMS ((char *name, int from_tty));
71 static void mips_close PARAMS ((int quitting));
73 static void mips_detach PARAMS ((char *args, int from_tty));
75 static void mips_resume PARAMS ((int pid, int step,
76 enum target_signal siggnal));
78 static int mips_wait PARAMS ((int pid, struct target_waitstatus *status));
80 static int mips_map_regno PARAMS ((int regno));
82 static void mips_fetch_registers PARAMS ((int regno));
84 static void mips_prepare_to_store PARAMS ((void));
86 static void mips_store_registers PARAMS ((int regno));
88 static int mips_fetch_word PARAMS ((CORE_ADDR addr));
90 static int mips_store_word PARAMS ((CORE_ADDR addr, int value,
93 static int mips_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
94 int write, struct target_ops *ignore));
96 static void mips_files_info PARAMS ((struct target_ops *ignore));
98 static void mips_create_inferior PARAMS ((char *execfile, char *args,
101 static void mips_mourn_inferior PARAMS ((void));
103 static void mips_load PARAMS ((char *file, int from_tty));
105 static int mips_make_srec PARAMS ((char *buffer, char type, CORE_ADDR memaddr,
106 unsigned char *myaddr, int len));
108 /* A forward declaration. */
109 extern struct target_ops mips_ops;
111 /* The MIPS remote debugging interface is built on top of a simple
112 packet protocol. Each packet is organized as follows:
114 SYN The first character is always a SYN (ASCII 026, or ^V). SYN
115 may not appear anywhere else in the packet. Any time a SYN is
116 seen, a new packet should be assumed to have begun.
119 This byte contains the upper five bits of the logical length
120 of the data section, plus a single bit indicating whether this
121 is a data packet or an acknowledgement. The documentation
122 indicates that this bit is 1 for a data packet, but the actual
123 board uses 1 for an acknowledgement. The value of the byte is
124 0x40 + (ack ? 0x20 : 0) + (len >> 6)
125 (we always have 0 <= len < 1024). Acknowledgement packets do
126 not carry data, and must have a data length of 0.
128 LEN1 This byte contains the lower six bits of the logical length of
129 the data section. The value is
132 SEQ This byte contains the six bit sequence number of the packet.
135 An acknowlegment packet contains the sequence number of the
136 packet being acknowledged plus 1 modulo 64. Data packets are
137 transmitted in sequence. There may only be one outstanding
138 unacknowledged data packet at a time. The sequence numbers
139 are independent in each direction. If an acknowledgement for
140 the previous packet is received (i.e., an acknowledgement with
141 the sequence number of the packet just sent) the packet just
142 sent should be retransmitted. If no acknowledgement is
143 received within a timeout period, the packet should be
144 retransmitted. This has an unfortunate failure condition on a
145 high-latency line, as a delayed acknowledgement may lead to an
146 endless series of duplicate packets.
148 DATA The actual data bytes follow. The following characters are
149 escaped inline with DLE (ASCII 020, or ^P):
155 The additional DLE characters are not counted in the logical
156 length stored in the TYPE_LEN and LEN1 bytes.
161 These bytes contain an 18 bit checksum of the complete
162 contents of the packet excluding the SEQ byte and the
163 CSUM[123] bytes. The checksum is simply the twos complement
164 addition of all the bytes treated as unsigned characters. The
165 values of the checksum bytes are:
166 CSUM1: 0x40 + ((cksum >> 12) & 0x3f)
167 CSUM2: 0x40 + ((cksum >> 6) & 0x3f)
168 CSUM3: 0x40 + (cksum & 0x3f)
170 It happens that the MIPS remote debugging protocol always
171 communicates with ASCII strings. Because of this, this
172 implementation doesn't bother to handle the DLE quoting mechanism,
173 since it will never be required. */
175 /* The SYN character which starts each packet. */
178 /* The 0x40 used to offset each packet (this value ensures that all of
179 the header and trailer bytes, other than SYN, are printable ASCII
181 #define HDR_OFFSET 0x40
183 /* The indices of the bytes in the packet header. */
184 #define HDR_INDX_SYN 0
185 #define HDR_INDX_TYPE_LEN 1
186 #define HDR_INDX_LEN1 2
187 #define HDR_INDX_SEQ 3
190 /* The data/ack bit in the TYPE_LEN header byte. */
191 #define TYPE_LEN_DA_BIT 0x20
192 #define TYPE_LEN_DATA 0
193 #define TYPE_LEN_ACK TYPE_LEN_DA_BIT
195 /* How to compute the header bytes. */
196 #define HDR_SET_SYN(data, len, seq) (SYN)
197 #define HDR_SET_TYPE_LEN(data, len, seq) \
199 + ((data) ? TYPE_LEN_DATA : TYPE_LEN_ACK) \
200 + (((len) >> 6) & 0x1f))
201 #define HDR_SET_LEN1(data, len, seq) (HDR_OFFSET + ((len) & 0x3f))
202 #define HDR_SET_SEQ(data, len, seq) (HDR_OFFSET + (seq))
204 /* Check that a header byte is reasonable. */
205 #define HDR_CHECK(ch) (((ch) & HDR_OFFSET) == HDR_OFFSET)
207 /* Get data from the header. These macros evaluate their argument
209 #define HDR_IS_DATA(hdr) \
210 (((hdr)[HDR_INDX_TYPE_LEN] & TYPE_LEN_DA_BIT) == TYPE_LEN_DATA)
211 #define HDR_GET_LEN(hdr) \
212 ((((hdr)[HDR_INDX_TYPE_LEN] & 0x1f) << 6) + (((hdr)[HDR_INDX_LEN1] & 0x3f)))
213 #define HDR_GET_SEQ(hdr) ((hdr)[HDR_INDX_SEQ] & 0x3f)
215 /* The maximum data length. */
216 #define DATA_MAXLEN 1023
218 /* The trailer offset. */
219 #define TRLR_OFFSET HDR_OFFSET
221 /* The indices of the bytes in the packet trailer. */
222 #define TRLR_INDX_CSUM1 0
223 #define TRLR_INDX_CSUM2 1
224 #define TRLR_INDX_CSUM3 2
225 #define TRLR_LENGTH 3
227 /* How to compute the trailer bytes. */
228 #define TRLR_SET_CSUM1(cksum) (TRLR_OFFSET + (((cksum) >> 12) & 0x3f))
229 #define TRLR_SET_CSUM2(cksum) (TRLR_OFFSET + (((cksum) >> 6) & 0x3f))
230 #define TRLR_SET_CSUM3(cksum) (TRLR_OFFSET + (((cksum) ) & 0x3f))
232 /* Check that a trailer byte is reasonable. */
233 #define TRLR_CHECK(ch) (((ch) & TRLR_OFFSET) == TRLR_OFFSET)
235 /* Get data from the trailer. This evaluates its argument multiple
237 #define TRLR_GET_CKSUM(trlr) \
238 ((((trlr)[TRLR_INDX_CSUM1] & 0x3f) << 12) \
239 + (((trlr)[TRLR_INDX_CSUM2] & 0x3f) << 6) \
240 + ((trlr)[TRLR_INDX_CSUM3] & 0x3f))
242 /* The sequence number modulos. */
243 #define SEQ_MODULOS (64)
245 /* Set to 1 if the target is open. */
246 static int mips_is_open;
248 /* Set to 1 while the connection is being initialized. */
249 static int mips_initializing;
251 /* The next sequence number to send. */
252 static int mips_send_seq;
254 /* The next sequence number we expect to receive. */
255 static int mips_receive_seq;
257 /* The time to wait before retransmitting a packet, in seconds. */
258 static int mips_retransmit_wait = 3;
260 /* The number of times to try retransmitting a packet before giving up. */
261 static int mips_send_retries = 10;
263 /* The number of garbage characters to accept when looking for an
264 SYN for the next packet. */
265 static int mips_syn_garbage = 1050;
267 /* The time to wait for a packet, in seconds. */
268 static int mips_receive_wait = 5;
270 /* Set if we have sent a packet to the board but have not yet received
272 static int mips_need_reply = 0;
274 /* Handle used to access serial I/O stream. */
275 static serial_t mips_desc;
277 /* Handle low-level error that we can't recover from. Note that just
278 error()ing out from target_wait or some such low-level place will cause
279 all hell to break loose--the rest of GDB will tend to get left in an
280 inconsistent state. */
283 #ifdef ANSI_PROTOTYPES
284 mips_error (char *string, ...)
286 mips_error (va_alist)
292 #ifdef ANSI_PROTOTYPES
293 va_start (args, string);
297 string = va_arg (args, char *);
300 target_terminal_ours ();
301 wrap_here(""); /* Force out any buffered output */
302 gdb_flush (gdb_stdout);
304 fprintf_filtered (gdb_stderr, error_pre_print);
305 vfprintf_filtered (gdb_stderr, string, args);
306 fprintf_filtered (gdb_stderr, "\n");
309 /* Clean up in such a way that mips_close won't try to talk to the
310 board (it almost surely won't work since we weren't able to talk to
313 SERIAL_CLOSE (mips_desc);
315 printf_unfiltered ("Ending remote MIPS debugging.\n");
316 target_mourn_inferior ();
318 return_to_top_level (RETURN_ERROR);
332 /* Must use SERIAL_READCHAR here cuz mips_readchar would get confused if we
333 were waiting for "<IDT>"... */
335 c = SERIAL_READCHAR (mips_desc, 2);
337 if (c == SERIAL_TIMEOUT)
358 /* Read a character from the remote, aborting on error. Returns
359 SERIAL_TIMEOUT on timeout (since that's what SERIAL_READCHAR
360 returns). FIXME: If we see the string "<IDT>" from the board, then
361 we are debugging on the main console port, and we have somehow
362 dropped out of remote debugging mode. In this case, we
363 automatically go back in to remote debugging mode. This is a hack,
364 put in because I can't find any way for a program running on the
365 remote board to terminate without also ending remote debugging
366 mode. I assume users won't have any trouble with this; for one
367 thing, the IDT documentation generally assumes that the remote
368 debugging port is not the console port. This is, however, very
369 convenient for DejaGnu when you only have one connected serial
372 /* CYGNUS LOCAL jsmith */
373 /* The old code assumed a 5 character identification string, making it
374 a chore to change the string value. However, we need to ensure
375 that the method of ascertaining the length of the string is
376 completely portable, without resorting to calling strlen(). */
379 mips_readchar (timeout)
383 static int state = 0;
384 static char nextstate[] = TARGET_MONITOR_PROMPT; /* CYGNUS LOCAL jsmith */
385 #ifdef MAINTENANCE_CMDS
389 if (i == -1 && watchdog > 0)
393 if (state == (sizeof(nextstate) / sizeof(char))) /* CYGNUS LOCAL jsmith */
395 ch = SERIAL_READCHAR (mips_desc, timeout);
396 #ifdef MAINTENANCE_CMDS
397 if (ch == SERIAL_TIMEOUT && timeout == -1) /* Watchdog went off */
399 target_mourn_inferior ();
400 error ("Watchdog has expired. Target detached.\n");
403 if (ch == SERIAL_EOF)
404 mips_error ("End of file from remote");
405 if (ch == SERIAL_ERROR)
406 mips_error ("Error reading from remote: %s", safe_strerror (errno));
407 if (sr_get_debug () > 1)
409 /* Don't use _filtered; we can't deal with a QUIT out of
410 target_wait, and I think this might be called from there. */
411 if (ch != SERIAL_TIMEOUT)
412 printf_unfiltered ("Read '%c' %d 0x%x\n", ch, ch, ch);
414 printf_unfiltered ("Timed out in read\n");
417 /* If we have seen <IDT> and we either time out, or we see a @
418 (which was echoed from a packet we sent), reset the board as
419 described above. The first character in a packet after the SYN
420 (which is not echoed) is always an @ unless the packet is more
421 than 64 characters long, which ours never are. */
422 if ((ch == SERIAL_TIMEOUT || ch == '@')
423 && state == (sizeof(nextstate) / sizeof(char)) /* CYGNUS LOCAL jsmith */
424 && ! mips_initializing)
426 if (sr_get_debug () > 0)
427 /* Don't use _filtered; we can't deal with a QUIT out of
428 target_wait, and I think this might be called from there. */
429 printf_unfiltered ("Reinitializing MIPS debugging mode\n");
430 SERIAL_WRITE (mips_desc, "\015db tty0\015", sizeof "\015db tty0\015" - 1);
438 /* At this point, about the only thing we can do is abort the command
439 in progress and get back to command level as quickly as possible. */
441 error ("Remote board reset, debug protocol re-initialized.");
444 if (ch == nextstate[state])
452 /* Get a packet header, putting the data in the supplied buffer.
453 PGARBAGE is a pointer to the number of garbage characters received
454 so far. CH is the last character received. Returns 0 for success,
455 or -1 for timeout. */
458 mips_receive_header (hdr, pgarbage, ch, timeout)
468 /* Wait for a SYN. mips_syn_garbage is intended to prevent
469 sitting here indefinitely if the board sends us one garbage
470 character per second. ch may already have a value from the
471 last time through the loop. */
474 ch = mips_readchar (timeout);
475 if (ch == SERIAL_TIMEOUT)
479 /* Printing the character here lets the user of gdb see
480 what the program is outputting, if the debugging is
481 being done on the console port. Don't use _filtered;
482 we can't deal with a QUIT out of target_wait. */
483 if (! mips_initializing || sr_get_debug () > 0)
485 if (ch < 0x20 && ch != '\n')
487 putchar_unfiltered ('^');
488 putchar_unfiltered (ch + 0x40);
491 putchar_unfiltered (ch);
492 gdb_flush (gdb_stdout);
496 if (*pgarbage > mips_syn_garbage)
497 mips_error ("Remote debugging protocol failure");
501 /* Get the packet header following the SYN. */
502 for (i = 1; i < HDR_LENGTH; i++)
504 ch = mips_readchar (timeout);
505 if (ch == SERIAL_TIMEOUT)
508 /* Make sure this is a header byte. */
509 if (ch == SYN || ! HDR_CHECK (ch))
515 /* If we got the complete header, we can return. Otherwise we
516 loop around and keep looking for SYN. */
522 /* Get a packet header, putting the data in the supplied buffer.
523 PGARBAGE is a pointer to the number of garbage characters received
524 so far. The last character read is returned in *PCH. Returns 0
525 for success, -1 for timeout, -2 for error. */
528 mips_receive_trailer (trlr, pgarbage, pch, timeout)
537 for (i = 0; i < TRLR_LENGTH; i++)
539 ch = mips_readchar (timeout);
541 if (ch == SERIAL_TIMEOUT)
543 if (! TRLR_CHECK (ch))
550 /* Get the checksum of a packet. HDR points to the packet header.
551 DATA points to the packet data. LEN is the length of DATA. */
554 mips_cksum (hdr, data, len)
555 const unsigned char *hdr;
556 const unsigned char *data;
559 register const unsigned char *p;
565 /* The initial SYN is not included in the checksum. */
579 /* Send a packet containing the given ASCII string. */
582 mips_send_packet (s, get_ack)
587 unsigned char *packet;
592 if (len > DATA_MAXLEN)
593 mips_error ("MIPS protocol data packet too long: %s", s);
595 packet = (unsigned char *) alloca (HDR_LENGTH + len + TRLR_LENGTH + 1);
597 packet[HDR_INDX_SYN] = HDR_SET_SYN (1, len, mips_send_seq);
598 packet[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (1, len, mips_send_seq);
599 packet[HDR_INDX_LEN1] = HDR_SET_LEN1 (1, len, mips_send_seq);
600 packet[HDR_INDX_SEQ] = HDR_SET_SEQ (1, len, mips_send_seq);
602 memcpy (packet + HDR_LENGTH, s, len);
604 cksum = mips_cksum (packet, packet + HDR_LENGTH, len);
605 packet[HDR_LENGTH + len + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
606 packet[HDR_LENGTH + len + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
607 packet[HDR_LENGTH + len + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
609 /* Increment the sequence number. This will set mips_send_seq to
610 the sequence number we expect in the acknowledgement. */
611 mips_send_seq = (mips_send_seq + 1) % SEQ_MODULOS;
613 /* We can only have one outstanding data packet, so we just wait for
614 the acknowledgement here. Keep retransmitting the packet until
615 we get one, or until we've tried too many times. */
616 for (try = 0; try < mips_send_retries; try++)
621 if (sr_get_debug () > 0)
623 /* Don't use _filtered; we can't deal with a QUIT out of
624 target_wait, and I think this might be called from there. */
625 packet[HDR_LENGTH + len + TRLR_LENGTH] = '\0';
626 printf_unfiltered ("Writing \"%s\"\n", packet + 1);
629 if (SERIAL_WRITE (mips_desc, packet,
630 HDR_LENGTH + len + TRLR_LENGTH) != 0)
631 mips_error ("write to target failed: %s", safe_strerror (errno));
640 unsigned char hdr[HDR_LENGTH + 1];
641 unsigned char trlr[TRLR_LENGTH + 1];
645 /* Get the packet header. If we time out, resend the data
647 err = mips_receive_header (hdr, &garbage, ch, mips_retransmit_wait);
653 /* If we get a data packet, assume it is a duplicate and
654 ignore it. FIXME: If the acknowledgement is lost, this
655 data packet may be the packet the remote sends after the
657 if (HDR_IS_DATA (hdr))
660 /* If the length is not 0, this is a garbled packet. */
661 if (HDR_GET_LEN (hdr) != 0)
664 /* Get the packet trailer. */
665 err = mips_receive_trailer (trlr, &garbage, &ch,
666 mips_retransmit_wait);
668 /* If we timed out, resend the data packet. */
672 /* If we got a bad character, reread the header. */
676 /* If the checksum does not match the trailer checksum, this
677 is a bad packet; ignore it. */
678 if (mips_cksum (hdr, (unsigned char *) NULL, 0)
679 != TRLR_GET_CKSUM (trlr))
682 if (sr_get_debug () > 0)
684 hdr[HDR_LENGTH] = '\0';
685 trlr[TRLR_LENGTH] = '\0';
686 /* Don't use _filtered; we can't deal with a QUIT out of
687 target_wait, and I think this might be called from there. */
688 printf_unfiltered ("Got ack %d \"%s%s\"\n",
689 HDR_GET_SEQ (hdr), hdr + 1, trlr);
692 /* If this ack is for the current packet, we're done. */
693 seq = HDR_GET_SEQ (hdr);
694 if (seq == mips_send_seq)
697 /* If this ack is for the last packet, resend the current
699 if ((seq + 1) % SEQ_MODULOS == mips_send_seq)
702 /* Otherwise this is a bad ack; ignore it. Increment the
703 garbage count to ensure that we do not stay in this loop
709 mips_error ("Remote did not acknowledge packet");
712 /* Receive and acknowledge a packet, returning the data in BUFF (which
713 should be DATA_MAXLEN + 1 bytes). The protocol documentation
714 implies that only the sender retransmits packets, so this code just
715 waits silently for a packet. It returns the length of the received
716 packet. If THROW_ERROR is nonzero, call error() on errors. If not,
717 don't print an error message and return -1. */
720 mips_receive_packet (buff, throw_error, timeout)
728 unsigned char ack[HDR_LENGTH + TRLR_LENGTH + 1];
735 unsigned char hdr[HDR_LENGTH];
736 unsigned char trlr[TRLR_LENGTH];
740 if (mips_receive_header (hdr, &garbage, ch, timeout) != 0)
743 mips_error ("Timed out waiting for remote packet");
750 /* An acknowledgement is probably a duplicate; ignore it. */
751 if (! HDR_IS_DATA (hdr))
753 /* Don't use _filtered; we can't deal with a QUIT out of
754 target_wait, and I think this might be called from there. */
755 if (sr_get_debug () > 0)
756 printf_unfiltered ("Ignoring unexpected ACK\n");
760 /* If this is the wrong sequence number, ignore it. */
761 if (HDR_GET_SEQ (hdr) != mips_receive_seq)
763 /* Don't use _filtered; we can't deal with a QUIT out of
764 target_wait, and I think this might be called from there. */
765 if (sr_get_debug () > 0)
766 printf_unfiltered ("Ignoring sequence number %d (want %d)\n",
767 HDR_GET_SEQ (hdr), mips_receive_seq);
771 len = HDR_GET_LEN (hdr);
773 for (i = 0; i < len; i++)
777 rch = mips_readchar (timeout);
783 if (rch == SERIAL_TIMEOUT)
786 mips_error ("Timed out waiting for remote packet");
795 /* Don't use _filtered; we can't deal with a QUIT out of
796 target_wait, and I think this might be called from there. */
797 if (sr_get_debug () > 0)
798 printf_unfiltered ("Got new SYN after %d chars (wanted %d)\n",
803 err = mips_receive_trailer (trlr, &garbage, &ch, timeout);
807 mips_error ("Timed out waiting for packet");
813 /* Don't use _filtered; we can't deal with a QUIT out of
814 target_wait, and I think this might be called from there. */
815 if (sr_get_debug () > 0)
816 printf_unfiltered ("Got SYN when wanted trailer\n");
820 if (mips_cksum (hdr, buff, len) == TRLR_GET_CKSUM (trlr))
823 if (sr_get_debug () > 0)
824 /* Don't use _filtered; we can't deal with a QUIT out of
825 target_wait, and I think this might be called from there. */
826 printf_unfiltered ("Bad checksum; data %d, trailer %d\n",
827 mips_cksum (hdr, buff, len),
828 TRLR_GET_CKSUM (trlr));
830 /* The checksum failed. Send an acknowledgement for the
831 previous packet to tell the remote to resend the packet. */
832 ack[HDR_INDX_SYN] = HDR_SET_SYN (0, 0, mips_receive_seq);
833 ack[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (0, 0, mips_receive_seq);
834 ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
835 ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
837 cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
839 ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
840 ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
841 ack[HDR_LENGTH + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
843 if (sr_get_debug () > 0)
845 ack[HDR_LENGTH + TRLR_LENGTH] = '\0';
846 /* Don't use _filtered; we can't deal with a QUIT out of
847 target_wait, and I think this might be called from there. */
848 printf_unfiltered ("Writing ack %d \"%s\"\n", mips_receive_seq,
852 if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
855 mips_error ("write to target failed: %s", safe_strerror (errno));
861 if (sr_get_debug () > 0)
864 /* Don't use _filtered; we can't deal with a QUIT out of
865 target_wait, and I think this might be called from there. */
866 printf_unfiltered ("Got packet \"%s\"\n", buff);
869 /* We got the packet. Send an acknowledgement. */
870 mips_receive_seq = (mips_receive_seq + 1) % SEQ_MODULOS;
872 ack[HDR_INDX_SYN] = HDR_SET_SYN (0, 0, mips_receive_seq);
873 ack[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (0, 0, mips_receive_seq);
874 ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
875 ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
877 cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
879 ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
880 ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
881 ack[HDR_LENGTH + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
883 if (sr_get_debug () > 0)
885 ack[HDR_LENGTH + TRLR_LENGTH] = '\0';
886 /* Don't use _filtered; we can't deal with a QUIT out of
887 target_wait, and I think this might be called from there. */
888 printf_unfiltered ("Writing ack %d \"%s\"\n", mips_receive_seq,
892 if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
895 mips_error ("write to target failed: %s", safe_strerror (errno));
903 /* Optionally send a request to the remote system and optionally wait
904 for the reply. This implements the remote debugging protocol,
905 which is built on top of the packet protocol defined above. Each
906 request has an ADDR argument and a DATA argument. The following
907 requests are defined:
909 \0 don't send a request; just wait for a reply
910 i read word from instruction space at ADDR
911 d read word from data space at ADDR
912 I write DATA to instruction space at ADDR
913 D write DATA to data space at ADDR
914 r read register number ADDR
915 R set register number ADDR to value DATA
916 c continue execution (if ADDR != 1, set pc to ADDR)
917 s single step (if ADDR != 1, set pc to ADDR)
919 The read requests return the value requested. The write requests
920 return the previous value in the changed location. The execution
921 requests return a UNIX wait value (the approximate signal which
922 caused execution to stop is in the upper eight bits).
924 If PERR is not NULL, this function waits for a reply. If an error
925 occurs, it sets *PERR to 1 and sets errno according to what the
926 target board reports. */
929 mips_request (cmd, addr, data, perr, timeout)
936 char buff[DATA_MAXLEN + 1];
946 fatal ("mips_request: Trying to send command before reply");
947 sprintf (buff, "0x0 %c 0x%x 0x%x", cmd, addr, data);
948 mips_send_packet (buff, 1);
952 if (perr == (int *) NULL)
955 if (! mips_need_reply)
956 fatal ("mips_request: Trying to get reply before command");
960 len = mips_receive_packet (buff, 1, timeout);
963 if (sscanf (buff, "0x%x %c 0x%x 0x%x",
964 &rpid, &rcmd, &rerrflg, &rresponse) != 4
965 || (cmd != '\0' && rcmd != cmd))
966 mips_error ("Bad response from remote board");
972 /* FIXME: This will returns MIPS errno numbers, which may or may
973 not be the same as errno values used on other systems. If
974 they stick to common errno values, they will be the same, but
975 if they don't, they must be translated. */
986 mips_initialize_cleanups (arg)
989 mips_initializing = 0;
992 /* Initialize a new connection to the MIPS board, and make sure we are
999 char buff[DATA_MAXLEN + 1];
1001 struct cleanup *old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
1003 /* What is this code doing here? I don't see any way it can happen, and
1004 it might mean mips_initializing didn't get cleared properly.
1005 So I'll make it a warning. */
1006 if (mips_initializing)
1008 warning ("internal error: mips_initialize called twice");
1012 mips_initializing = 1;
1015 mips_receive_seq = 0;
1017 if (mips_receive_packet (buff, 0, 3) < 0)
1023 /* We did not receive the packet we expected; try resetting the
1024 board and trying again. */
1026 /* We are possibly in binary download mode, having aborted in the middle
1027 of an S-record. ^C won't work because of binary mode. The only
1028 reliable way out is to send enough termination packets (8 bytes) to
1029 fill up and then overflow the largest size S-record (255 bytes in this
1030 case). This amounts to 256/8 + 1. */
1032 mips_make_srec (srec, '7', 0, NULL, 0);
1034 for (i = 1; i <= 33; i++)
1036 SERIAL_WRITE (mips_desc, srec, 8);
1038 if (SERIAL_READCHAR (mips_desc, 0) >= 0)
1039 break; /* Break immediatly if we get something from
1043 printf_filtered ("Failed to initialize; trying to reset board\n");
1045 SERIAL_WRITE (mips_desc, &cc, 1);
1047 SERIAL_WRITE (mips_desc, "\015db tty0\015", sizeof "\015db tty0\015" - 1);
1050 SERIAL_WRITE (mips_desc, &cr, 1);
1052 mips_receive_packet (buff, 1, 3);
1055 do_cleanups (old_cleanups);
1057 /* If this doesn't call error, we have connected; we don't care if
1058 the request itself succeeds or fails. */
1059 mips_request ('r', (unsigned int) 0, (unsigned int) 0, &err,
1063 /* Open a connection to the remote board. */
1066 mips_open (name, from_tty)
1074 "To open a MIPS remote debugging connection, you need to specify what serial\n\
1075 device is attached to the target board (e.g., /dev/ttya).");
1077 target_preopen (from_tty);
1080 unpush_target (&mips_ops);
1082 mips_desc = SERIAL_OPEN (name);
1083 if (mips_desc == (serial_t) NULL)
1084 perror_with_name (name);
1086 if (baud_rate != -1)
1088 if (SERIAL_SETBAUDRATE (mips_desc, baud_rate))
1090 SERIAL_CLOSE (mips_desc);
1091 perror_with_name (name);
1095 SERIAL_RAW (mips_desc);
1102 printf_unfiltered ("Remote MIPS debugging using %s\n", name);
1104 /* Switch to using remote target now. */
1105 push_target (&mips_ops);
1107 /* FIXME: Should we call start_remote here? */
1109 /* Try to figure out the processor model if possible. */
1110 ptype = mips_read_processor_type ();
1112 mips_set_processor_type_command (strsave (ptype), 0);
1114 /* This is really the job of start_remote however, that makes an assumption
1115 that the target is about to print out a status message of some sort. That
1116 doesn't happen here (in fact, it may not be possible to get the monitor to
1117 send the appropriate packet). */
1119 flush_cached_frames ();
1120 registers_changed ();
1121 stop_pc = read_pc ();
1122 set_current_frame (create_new_frame (read_fp (), stop_pc));
1123 select_frame (get_current_frame (), 0);
1124 print_stack_frame (selected_frame, -1, 1);
1127 /* Close a connection to the remote board. */
1130 mips_close (quitting)
1139 /* Get the board out of remote debugging mode. */
1140 mips_request ('x', (unsigned int) 0, (unsigned int) 0, &err,
1143 SERIAL_CLOSE (mips_desc);
1147 /* Detach from the remote board. */
1150 mips_detach (args, from_tty)
1155 error ("Argument given to \"detach\" when remotely debugging.");
1159 printf_unfiltered ("Ending remote MIPS debugging.\n");
1162 /* Tell the target board to resume. This does not wait for a reply
1166 mips_resume (pid, step, siggnal)
1168 enum target_signal siggnal;
1170 if (siggnal != TARGET_SIGNAL_0)
1172 ("Can't send signals to a remote system. Try `handle %s ignore'.",
1173 target_signal_to_name (siggnal));
1175 mips_request (step ? 's' : 'c',
1182 /* Return the signal corresponding to SIG, where SIG is the number which
1183 the MIPS protocol uses for the signal. */
1185 mips_signal_from_protocol (sig)
1188 /* We allow a few more signals than the IDT board actually returns, on
1189 the theory that there is at least *some* hope that perhaps the numbering
1190 for these signals is widely agreed upon. */
1193 return TARGET_SIGNAL_UNKNOWN;
1195 /* Don't want to use target_signal_from_host because we are converting
1196 from MIPS signal numbers, not host ones. Our internal numbers
1197 match the MIPS numbers for the signals the board can return, which
1198 are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP. */
1199 return (enum target_signal) sig;
1202 /* Wait until the remote stops, and return a wait status. */
1205 mips_wait (pid, status)
1207 struct target_waitstatus *status;
1212 /* If we have not sent a single step or continue command, then the
1213 board is waiting for us to do something. Return a status
1214 indicating that it is stopped. */
1215 if (! mips_need_reply)
1217 status->kind = TARGET_WAITKIND_STOPPED;
1218 status->value.sig = TARGET_SIGNAL_TRAP;
1222 /* No timeout; we sit here as long as the program continues to execute. */
1223 rstatus = mips_request ('\0', (unsigned int) 0, (unsigned int) 0, &err, -1);
1225 mips_error ("Remote failure: %s", safe_strerror (errno));
1227 /* Translate a MIPS waitstatus. We use constants here rather than WTERMSIG
1228 and so on, because the constants we want here are determined by the
1229 MIPS protocol and have nothing to do with what host we are running on. */
1230 if ((rstatus & 0377) == 0)
1232 status->kind = TARGET_WAITKIND_EXITED;
1233 status->value.integer = (((rstatus) >> 8) & 0377);
1235 else if ((rstatus & 0377) == 0177)
1237 status->kind = TARGET_WAITKIND_STOPPED;
1238 status->value.sig = mips_signal_from_protocol (((rstatus) >> 8) & 0377);
1242 status->kind = TARGET_WAITKIND_SIGNALLED;
1243 status->value.sig = mips_signal_from_protocol (rstatus & 0177);
1249 /* We have to map between the register numbers used by gdb and the
1250 register numbers used by the debugging protocol. This function
1251 assumes that we are using tm-mips.h. */
1253 #define REGNO_OFFSET 96
1256 mips_map_regno (regno)
1261 if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
1262 return regno - FP0_REGNUM + 32;
1266 return REGNO_OFFSET + 0;
1268 return REGNO_OFFSET + 1;
1270 return REGNO_OFFSET + 2;
1272 return REGNO_OFFSET + 3;
1274 return REGNO_OFFSET + 4;
1276 return REGNO_OFFSET + 5;
1278 /* FIXME: Is there a way to get the status register? */
1283 /* Fetch the remote registers. */
1286 mips_fetch_registers (regno)
1289 unsigned LONGEST val;
1294 for (regno = 0; regno < NUM_REGS; regno++)
1295 mips_fetch_registers (regno);
1299 if (regno == FP_REGNUM || regno == ZERO_REGNUM)
1300 /* FP_REGNUM on the mips is a hack which is just supposed to read
1301 zero (see also mips-nat.c). */
1305 val = mips_request ('r', (unsigned int) mips_map_regno (regno),
1306 (unsigned int) 0, &err, mips_receive_wait);
1308 mips_error ("Can't read register %d: %s", regno,
1309 safe_strerror (errno));
1313 char buf[MAX_REGISTER_RAW_SIZE];
1315 /* We got the number the register holds, but gdb expects to see a
1316 value in the target byte ordering. */
1317 store_unsigned_integer (buf, REGISTER_RAW_SIZE (regno), val);
1318 supply_register (regno, buf);
1322 /* Prepare to store registers. The MIPS protocol can store individual
1323 registers, so this function doesn't have to do anything. */
1326 mips_prepare_to_store ()
1330 /* Store remote register(s). */
1333 mips_store_registers (regno)
1340 for (regno = 0; regno < NUM_REGS; regno++)
1341 mips_store_registers (regno);
1345 mips_request ('R', (unsigned int) mips_map_regno (regno),
1346 (unsigned int) read_register (regno),
1347 &err, mips_receive_wait);
1349 mips_error ("Can't write register %d: %s", regno, safe_strerror (errno));
1352 /* Fetch a word from the target board. */
1355 mips_fetch_word (addr)
1361 val = mips_request ('d', (unsigned int) addr, (unsigned int) 0, &err,
1365 /* Data space failed; try instruction space. */
1366 val = mips_request ('i', (unsigned int) addr, (unsigned int) 0, &err,
1369 mips_error ("Can't read address 0x%x: %s", addr, safe_strerror (errno));
1374 /* Store a word to the target board. Returns errno code or zero for
1375 success. If OLD_CONTENTS is non-NULL, put the old contents of that
1376 memory location there. */
1379 mips_store_word (addr, val, old_contents)
1385 unsigned int oldcontents;
1387 oldcontents = mips_request ('D', (unsigned int) addr, (unsigned int) val,
1392 /* Data space failed; try instruction space. */
1393 oldcontents = mips_request ('I', (unsigned int) addr,
1394 (unsigned int) val, &err,
1399 if (old_contents != NULL)
1400 store_unsigned_integer (old_contents, 4, oldcontents);
1404 /* Read or write LEN bytes from inferior memory at MEMADDR,
1405 transferring to or from debugger address MYADDR. Write to inferior
1406 if SHOULD_WRITE is nonzero. Returns length of data written or
1407 read; 0 for error. Note that protocol gives us the correct value
1408 for a longword, since it transfers values in ASCII. We want the
1409 byte values, so we have to swap the longword values. */
1412 mips_xfer_memory (memaddr, myaddr, len, write, ignore)
1417 struct target_ops *ignore;
1420 /* Round starting address down to longword boundary. */
1421 register CORE_ADDR addr = memaddr &~ 3;
1422 /* Round ending address up; get number of longwords that makes. */
1423 register int count = (((memaddr + len) - addr) + 3) / 4;
1424 /* Allocate buffer of that many longwords. */
1425 register char *buffer = alloca (count * 4);
1431 /* Fill start and end extra bytes of buffer with existing data. */
1432 if (addr != memaddr || len < 4)
1434 /* Need part of initial word -- fetch it. */
1435 store_unsigned_integer (&buffer[0], 4, mips_fetch_word (addr));
1440 /* Need part of last word -- fetch it. FIXME: we do this even
1441 if we don't need it. */
1442 store_unsigned_integer (&buffer[(count - 1) * 4], 4,
1443 mips_fetch_word (addr + (count - 1) * 4));
1446 /* Copy data to be written over corresponding part of buffer */
1448 memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
1450 /* Write the entire buffer. */
1452 for (i = 0; i < count; i++, addr += 4)
1454 status = mips_store_word (addr,
1455 extract_unsigned_integer (&buffer[i*4], 4),
1457 /* Report each kilobyte (we download 32-bit words at a time) */
1460 printf_unfiltered ("*");
1468 /* FIXME: Do we want a QUIT here? */
1471 printf_unfiltered ("\n");
1475 /* Read all the longwords */
1476 for (i = 0; i < count; i++, addr += 4)
1478 store_unsigned_integer (&buffer[i*4], 4, mips_fetch_word (addr));
1482 /* Copy appropriate bytes out of the buffer. */
1483 memcpy (myaddr, buffer + (memaddr & 3), len);
1488 /* Print info on this target. */
1491 mips_files_info (ignore)
1492 struct target_ops *ignore;
1494 printf_unfiltered ("Debugging a MIPS board over a serial line.\n");
1497 /* Kill the process running on the board. This will actually only
1498 work if we are doing remote debugging over the console input. I
1499 think that if IDT/sim had the remote debug interrupt enabled on the
1500 right port, we could interrupt the process with a break signal. */
1512 SERIAL_WRITE (mips_desc, &cc, 1);
1514 target_mourn_inferior ();
1519 /* Start running on the target board. */
1522 mips_create_inferior (execfile, args, env)
1532 Can't pass arguments to remote MIPS board; arguments ignored.");
1533 /* And don't try to use them on the next "run" command. */
1534 execute_command ("set args", 0);
1537 if (execfile == 0 || exec_bfd == 0)
1538 error ("No executable file specified");
1540 entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1542 init_wait_for_inferior ();
1544 /* FIXME: Should we set inferior_pid here? */
1546 proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
1549 /* Clean up after a process. Actually nothing to do. */
1552 mips_mourn_inferior ()
1554 unpush_target (&mips_ops);
1555 generic_mourn_inferior ();
1558 /* We can write a breakpoint and read the shadow contents in one
1561 /* The IDT board uses an unusual breakpoint value, and sometimes gets
1562 confused when it sees the usual MIPS breakpoint instruction. */
1564 #define BREAK_INSN (0x00000a0d)
1565 #define BREAK_INSN_SIZE (4)
1567 /* Insert a breakpoint on targets that don't have any better breakpoint
1568 support. We read the contents of the target location and stash it,
1569 then overwrite it with a breakpoint instruction. ADDR is the target
1570 location in the target machine. CONTENTS_CACHE is a pointer to
1571 memory allocated for saving the target contents. It is guaranteed
1572 by the caller to be long enough to save sizeof BREAKPOINT bytes (this
1573 is accomplished via BREAKPOINT_MAX). */
1576 mips_insert_breakpoint (addr, contents_cache)
1578 char *contents_cache;
1582 return mips_store_word (addr, BREAK_INSN, contents_cache);
1586 mips_remove_breakpoint (addr, contents_cache)
1588 char *contents_cache;
1590 return target_write_memory (addr, contents_cache, BREAK_INSN_SIZE);
1594 send_srec (srec, len, addr)
1603 SERIAL_WRITE (mips_desc, srec, len);
1605 ch = mips_readchar (2);
1609 case SERIAL_TIMEOUT:
1610 error ("Timeout during download.");
1614 case 0x15: /* NACK */
1615 fprintf_unfiltered (gdb_stderr, "Download got a NACK at byte %d! Retrying.\n", addr);
1618 error ("Download got unexpected ack char: 0x%x, retrying.\n", ch);
1623 /* Download a binary file by converting it to S records. */
1626 mips_load_srec (args)
1631 char *buffer, srec[1024];
1633 int srec_frame = 200;
1635 static int hashmark = 1;
1637 buffer = alloca (srec_frame * 2 + 256);
1639 abfd = bfd_openr (args, 0);
1642 printf_filtered ("Unable to open file %s\n", args);
1646 if (bfd_check_format (abfd, bfd_object) == 0)
1648 printf_filtered ("File is not an object file\n");
1652 #define LOAD_CMD "load -b -s tty0\015"
1654 SERIAL_WRITE (mips_desc, LOAD_CMD, sizeof LOAD_CMD - 1);
1656 mips_expect (LOAD_CMD);
1657 mips_expect ("\012");
1659 for (s = abfd->sections; s; s = s->next)
1661 if (s->flags & SEC_LOAD)
1665 printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
1666 s->vma + s->_raw_size);
1667 gdb_flush (gdb_stdout);
1669 for (i = 0; i < s->_raw_size; i += numbytes)
1671 numbytes = min (srec_frame, s->_raw_size - i);
1673 bfd_get_section_contents (abfd, s, buffer, i, numbytes);
1675 reclen = mips_make_srec (srec, '3', s->vma + i, buffer, numbytes);
1676 send_srec (srec, reclen, s->vma + i);
1680 putchar_unfiltered ('#');
1681 gdb_flush (gdb_stdout);
1684 } /* Per-packet (or S-record) loop */
1686 putchar_unfiltered ('\n');
1687 } /* Loadable sections */
1690 putchar_unfiltered ('\n');
1692 /* Write a type 7 terminator record. no data for a type 7, and there
1693 is no data, so len is 0. */
1695 reclen = mips_make_srec (srec, '7', abfd->start_address, NULL, 0);
1697 send_srec (srec, reclen, abfd->start_address);
1699 SERIAL_FLUSH_INPUT (mips_desc);
1703 * mips_make_srec -- make an srecord. This writes each line, one at a
1704 * time, each with it's own header and trailer line.
1705 * An srecord looks like this:
1707 * byte count-+ address
1708 * start ---+ | | data +- checksum
1710 * S01000006F6B692D746573742E73726563E4
1711 * S315000448600000000000000000FC00005900000000E9
1712 * S31A0004000023C1400037DE00F023604000377B009020825000348D
1713 * S30B0004485A0000000000004E
1716 * S<type><length><address><data><checksum>
1720 * is the number of bytes following upto the checksum. Note that
1721 * this is not the number of chars following, since it takes two
1722 * chars to represent a byte.
1726 * 1) two byte address data record
1727 * 2) three byte address data record
1728 * 3) four byte address data record
1729 * 7) four byte address termination record
1730 * 8) three byte address termination record
1731 * 9) two byte address termination record
1734 * is the start address of the data following, or in the case of
1735 * a termination record, the start address of the image
1739 * is the sum of all the raw byte data in the record, from the length
1740 * upwards, modulo 256 and subtracted from 255.
1742 * This routine returns the length of the S-record.
1747 mips_make_srec (buf, type, memaddr, myaddr, len)
1751 unsigned char *myaddr;
1754 unsigned char checksum;
1757 /* Create the header for the srec. addr_size is the number of bytes in the address,
1758 and 1 is the number of bytes in the count. */
1762 buf[2] = len + 4 + 1; /* len + 4 byte address + 1 byte checksum */
1763 buf[3] = memaddr >> 24;
1764 buf[4] = memaddr >> 16;
1765 buf[5] = memaddr >> 8;
1767 memcpy (&buf[7], myaddr, len);
1769 /* Note that the checksum is calculated on the raw data, not the hexified
1770 data. It includes the length, address and the data portions of the
1774 buf += 2; /* Point at length byte */
1775 for (i = 0; i < len + 4 + 1; i++)
1783 /* mips_load -- download a file. */
1786 mips_load (file, from_tty)
1792 /* Get the board out of remote debugging mode. */
1794 mips_request ('x', (unsigned int) 0, (unsigned int) 0, &err,
1798 if (!mips_expect ("\015\012<IDT>"))
1799 error ("mips_load: Couldn't get into monitor mode.");
1801 mips_load_srec (file);
1803 SERIAL_WRITE (mips_desc, "\015db tty0\015", sizeof "\015db tty0\015" - 1);
1807 /* Finally, make the PC point at the start address */
1810 write_pc (bfd_get_start_address (exec_bfd));
1812 inferior_pid = 0; /* No process now */
1814 /* This is necessary because many things were based on the PC at the time that
1815 we attached to the monitor, which is no longer valid now that we have loaded
1816 new code (and just changed the PC). Another way to do this might be to call
1817 normal_stop, except that the stack may not be valid, and things would get
1818 horribly confused... */
1820 clear_symtab_users ();
1823 /* The target vector. */
1825 struct target_ops mips_ops =
1827 "mips", /* to_shortname */
1828 "Remote MIPS debugging over serial line", /* to_longname */
1830 Debug a board using the MIPS remote debugging protocol over a serial line.\n\
1831 The argument is the device it is connected to or, if it contains a colon,\n\
1832 HOST:PORT to access a board over a network", /* to_doc */
1833 mips_open, /* to_open */
1834 mips_close, /* to_close */
1835 NULL, /* to_attach */
1836 mips_detach, /* to_detach */
1837 mips_resume, /* to_resume */
1838 mips_wait, /* to_wait */
1839 mips_fetch_registers, /* to_fetch_registers */
1840 mips_store_registers, /* to_store_registers */
1841 mips_prepare_to_store, /* to_prepare_to_store */
1842 mips_xfer_memory, /* to_xfer_memory */
1843 mips_files_info, /* to_files_info */
1844 mips_insert_breakpoint, /* to_insert_breakpoint */
1845 mips_remove_breakpoint, /* to_remove_breakpoint */
1846 NULL, /* to_terminal_init */
1847 NULL, /* to_terminal_inferior */
1848 NULL, /* to_terminal_ours_for_output */
1849 NULL, /* to_terminal_ours */
1850 NULL, /* to_terminal_info */
1851 mips_kill, /* to_kill */
1852 mips_load, /* to_load */
1853 NULL, /* to_lookup_symbol */
1854 mips_create_inferior, /* to_create_inferior */
1855 mips_mourn_inferior, /* to_mourn_inferior */
1856 NULL, /* to_can_run */
1857 NULL, /* to_notice_signals */
1858 0, /* to_thread_alive */
1860 process_stratum, /* to_stratum */
1862 1, /* to_has_all_memory */
1863 1, /* to_has_memory */
1864 1, /* to_has_stack */
1865 1, /* to_has_registers */
1866 1, /* to_has_execution */
1867 NULL, /* sections */
1868 NULL, /* sections_end */
1869 OPS_MAGIC /* to_magic */
1873 _initialize_remote_mips ()
1875 add_target (&mips_ops);
1878 add_set_cmd ("timeout", no_class, var_zinteger,
1879 (char *) &mips_receive_wait,
1880 "Set timeout in seconds for remote MIPS serial I/O.",
1885 add_set_cmd ("retransmit-timeout", no_class, var_zinteger,
1886 (char *) &mips_retransmit_wait,
1887 "Set retransmit timeout in seconds for remote MIPS serial I/O.\n\
1888 This is the number of seconds to wait for an acknowledgement to a packet\n\
1889 before resending the packet.", &setlist),