1 /* Remote debugging for the ARM RDP interface.
3 Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002 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.
28 Much of this file (in particular the SWI stuff) is based on code by
31 I hacked on and simplified it by removing a lot of sexy features he
32 had added, and some of the (unix specific) workarounds he'd done
33 for other GDB problems - which if they still exist should be fixed
34 in GDB, not in a remote-foo thing . I also made it conform more to
35 the doc I have; which may be wrong.
49 #include "remote-utils.h"
50 #include "gdb_string.h"
59 extern struct target_ops remote_rdp_ops;
60 static struct serial *io;
61 static host_callback *callback = &default_callback;
70 char command_line[10];
72 int rdi_stopped_status;
78 /* Definitions for the RDP protocol. */
80 #define RDP_MOUTHFULL (1<<6)
81 #define FPU_COPRO_NUMBER 1
84 #define RDP_OPEN_TYPE_COLD 0
85 #define RDP_OPEN_TYPE_WARM 1
86 #define RDP_OPEN_TYPE_BAUDRATE 2
88 #define RDP_OPEN_BAUDRATE_9600 1
89 #define RDP_OPEN_BAUDRATE_19200 2
90 #define RDP_OPEN_BAUDRATE_38400 3
92 #define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
96 #define RDP_MEM_READ 2
98 #define RDP_MEM_WRITE 3
100 #define RDP_CPU_READ 4
101 #define RDP_CPU_WRITE 5
102 #define RDP_CPU_READWRITE_MODE_CURRENT 255
103 #define RDP_CPU_READWRITE_MASK_PC (1<<16)
104 #define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
105 #define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
107 #define RDP_COPRO_READ 6
108 #define RDP_COPRO_WRITE 7
109 #define RDP_FPU_READWRITE_MASK_FPS (1<<8)
111 #define RDP_SET_BREAK 0xa
112 #define RDP_SET_BREAK_TYPE_PC_EQUAL 0
113 #define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
115 #define RDP_CLEAR_BREAK 0xb
117 #define RDP_EXEC 0x10
118 #define RDP_EXEC_TYPE_SYNC 0
120 #define RDP_STEP 0x11
122 #define RDP_INFO 0x12
123 #define RDP_INFO_ABOUT_STEP 2
124 #define RDP_INFO_ABOUT_STEP_GT_1 1
125 #define RDP_INFO_ABOUT_STEP_TO_JMP 2
126 #define RDP_INFO_ABOUT_STEP_1 4
127 #define RDP_INFO_ABOUT_TARGET 0
128 #define RDP_INFO_ABOUT_BREAK 1
129 #define RDP_INFO_ABOUT_BREAK_COMP 1
130 #define RDP_INFO_ABOUT_BREAK_RANGE 2
131 #define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
132 #define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
133 #define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
134 #define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
135 #define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
136 #define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
137 #define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
138 #define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
139 #define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
140 #define RDP_INFO_ABOUT_BREAK_COND (1<<11)
141 #define RDP_INFO_VECTOR_CATCH (0x180)
142 #define RDP_INFO_ICEBREAKER (7)
143 #define RDP_INFO_SET_CMDLINE (0x300)
145 #define RDP_SELECT_CONFIG (0x16)
146 #define RDI_ConfigCPU 0
147 #define RDI_ConfigSystem 1
148 #define RDI_MatchAny 0
149 #define RDI_MatchExactly 1
150 #define RDI_MatchNoEarlier 2
152 #define RDP_RESET 0x7f
154 /* Returns from RDP */
155 #define RDP_RES_STOPPED 0x20
156 #define RDP_RES_SWI 0x21
157 #define RDP_RES_FATAL 0x5e
158 #define RDP_RES_VALUE 0x5f
159 #define RDP_RES_VALUE_LITTLE_ENDIAN 240
160 #define RDP_RES_VALUE_BIG_ENDIAN 241
161 #define RDP_RES_RESET 0x7f
162 #define RDP_RES_AT_BREAKPOINT 143
163 #define RDP_RES_IDUNNO 0xe6
164 #define RDP_OSOpReply 0x13
165 #define RDP_OSOpWord 2
166 #define RDP_OSOpNothing 0
168 static int timeout = 2;
170 static char *commandline = NULL;
173 remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
175 struct mem_attrib *attrib,
176 struct target_ops *target);
179 /* Stuff for talking to the serial layer. */
184 int c = serial_readchar (io, timeout);
187 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", c);
189 if (c == SERIAL_TIMEOUT)
192 return (unsigned char) c;
194 error ("Timeout reading from remote_system");
200 /* Note that the target always speaks little-endian to us,
201 even if it's a big endian machine. */
205 unsigned int val = 0;
208 for (n = 0; n < 4; n++)
220 fprintf_unfiltered (gdb_stdlog, "(%02x)\n", val);
221 serial_write (io, &val, 1);
227 /* We always send in little endian */
235 fprintf_unfiltered (gdb_stdlog, "(%04x)", val);
237 serial_write (io, b, 4);
242 /* Stuff for talking to the RDP layer. */
244 /* This is a bit more fancy that need be so that it syncs even in nasty cases.
246 I'be been unable to make it reliably sync up with the change
247 baudrate open command. It likes to sit and say it's been reset,
248 with no more action. So I took all that code out. I'd rather sync
249 reliably at 9600 than wait forever for a possible 19200 connection.
253 rdp_init (int cold, int tty)
256 int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
259 time_t now = time (0);
260 time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
263 while (time (0) < stop_time && !sync)
268 serial_flush_input (io);
269 serial_flush_output (io);
272 printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
275 ** It seems necessary to reset an EmbeddedICE to get it going.
276 ** This has the side benefit of displaying the startup banner.
280 put_byte (RDP_RESET);
281 while ((restype = serial_readchar (io, 1)) > 0)
288 /* Sent at start of reset process: ignore */
291 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
298 /* Got end-of-banner mark */
299 printf_filtered ("\n");
305 put_byte (type | RDP_OPEN_TYPE_RETURN_SEX);
308 while (!sync && (restype = serial_readchar (io, 1)) > 0)
311 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", restype);
319 while ((restype = serial_readchar (io, 1)) == RDP_RESET)
323 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
325 while ((restype = serial_readchar (io, 1)) > 0);
329 printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
330 printf_unfiltered ("Waiting for it to settle down...\n");
334 printf_unfiltered ("\nTrying again.\n");
343 int resval = serial_readchar (io, 1);
346 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", resval);
352 case RDP_RES_VALUE_LITTLE_ENDIAN:
353 target_byte_order = BFD_ENDIAN_LITTLE;
356 case RDP_RES_VALUE_BIG_ENDIAN:
357 target_byte_order = BFD_ENDIAN_BIG;
370 error ("Couldn't reset the board, try pressing the reset button");
376 send_rdp (char *template,...)
381 va_start (alist, template);
393 val = va_arg (alist, int);
397 val = va_arg (alist, int);
405 if (val != RDP_RES_VALUE)
407 printf_unfiltered ("got bad res value of %d, %x\n", val, val);
411 pstat = va_arg (alist, int *);
412 pi = va_arg (alist, int *);
414 *pstat = get_byte ();
415 /* Check the result was zero, if not read the syndrome */
422 /* Check the result code */
429 /* Target can't do it; never mind */
430 printf_unfiltered ("RDP: Insufficient privilege\n");
433 /* Target can't do it; never mind */
434 printf_unfiltered ("RDP: Unimplemented message\n");
437 error ("Command garbled");
440 error ("Corrupt reply from target");
445 /* Read a word from the target */
446 pi = va_arg (alist, int *);
450 /* Read in some bytes from the target. */
451 pc = va_arg (alist, char *);
452 val = va_arg (alist, int);
453 for (i = 0; i < val; i++)
459 /* send what's being pointed at */
460 pc = va_arg (alist, char *);
461 val = va_arg (alist, int);
463 serial_write (io, pc, val);
466 /* Send whats in the queue */
469 serial_write (io, buf, dst - buf);
474 pi = va_arg (alist, int *);
478 internal_error (__FILE__, __LINE__, "failed internal consistency check");
484 internal_error (__FILE__, __LINE__, "failed internal consistency check");
489 rdp_write (CORE_ADDR memaddr, char *buf, int len)
494 send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
505 rdp_read (CORE_ADDR memaddr, char *buf, int len)
509 send_rdp ("bww-S-P-V",
510 RDP_MEM_READ, memaddr, len,
521 rdp_fetch_one_register (int mask, char *buf)
524 send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
525 store_signed_integer (buf, 4, val);
529 rdp_fetch_one_fpu_register (int mask, char *buf)
532 /* !!! Since the PIE board doesn't work as documented,
533 and it doesn't have FPU hardware anyway and since it
534 slows everything down, I've disabled this. */
536 if (mask == RDP_FPU_READWRITE_MASK_FPS)
538 /* this guy is only a word */
539 send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
540 store_signed_integer (buf, 4, val);
544 /* There are 12 bytes long
545 !! fixme about endianness
547 int dummy; /* I've seen these come back as four words !! */
548 send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
551 memset (buf, 0, MAX_REGISTER_RAW_SIZE);
556 rdp_store_one_register (int mask, char *buf)
558 int val = extract_unsigned_integer (buf, 4);
561 RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
566 rdp_store_one_fpu_register (int mask, char *buf)
569 /* See comment in fetch_one_fpu_register */
570 if (mask == RDP_FPU_READWRITE_MASK_FPS)
572 int val = extract_unsigned_integer (buf, 4);
573 /* this guy is only a word */
574 send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
580 /* There are 12 bytes long
581 !! fixme about endianness
584 /* I've seen these come as four words, not the three advertized !! */
585 printf ("Sending mask %x\n", mask);
586 send_rdp ("bbwwwww-SZ",
595 printf ("done mask %x\n", mask);
601 /* Convert between GDB requests and the RDP layer. */
604 remote_rdp_fetch_register (int regno)
608 for (regno = 0; regno < NUM_REGS; regno++)
609 remote_rdp_fetch_register (regno);
613 char buf[MAX_REGISTER_RAW_SIZE];
615 rdp_fetch_one_register (1 << regno, buf);
616 else if (regno == PC_REGNUM)
617 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
618 else if (regno == PS_REGNUM)
619 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
620 else if (regno == FPS_REGNUM)
621 rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
622 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
623 rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
626 printf ("Help me with fetch reg %d\n", regno);
628 supply_register (regno, buf);
634 remote_rdp_store_register (int regno)
638 for (regno = 0; regno < NUM_REGS; regno++)
639 remote_rdp_store_register (regno);
643 char tmp[MAX_REGISTER_RAW_SIZE];
644 read_register_gen (regno, tmp);
646 rdp_store_one_register (1 << regno, tmp);
647 else if (regno == PC_REGNUM)
648 rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
649 else if (regno == PS_REGNUM)
650 rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
651 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
652 rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
655 printf ("Help me with reg %d\n", regno);
661 remote_rdp_kill (void)
663 callback->shutdown (callback);
670 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
672 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
674 send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
678 ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
680 ds.rdi_level = (ds.target_info >> 5) & 3;
685 rdp_execute_start (void)
687 /* Start it off, but don't wait for it */
688 send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
693 rdp_set_command_line (char *command, char *args)
696 ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
697 ** don't implement that, and get all confused at the unexpected text.
698 ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
701 if (commandline != NULL)
704 xasprintf (&commandline, "%s %s", command, args);
708 rdp_catch_vectors (void)
711 ** We want the target monitor to intercept the abort vectors
712 ** i.e. stop the program if any of these are used.
714 send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
716 ** Specify a bitmask including
718 ** the undefined instruction vector
719 ** the prefetch abort vector
720 ** the data abort vector
721 ** the address exception vector
723 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5)
746 #define SWI_WriteC 0x0
747 #define SWI_Write0 0x2
748 #define SWI_ReadC 0x4
750 #define SWI_GetEnv 0x10
751 #define SWI_Exit 0x11
752 #define SWI_EnterOS 0x16
754 #define SWI_GetErrno 0x60
755 #define SWI_Clock 0x61
757 #define SWI_Time 0x63
758 #define SWI_Remove 0x64
759 #define SWI_Rename 0x65
760 #define SWI_Open 0x66
762 #define SWI_Close 0x68
763 #define SWI_Write 0x69
764 #define SWI_Read 0x6a
765 #define SWI_Seek 0x6b
766 #define SWI_Flen 0x6c
768 #define SWI_IsTTY 0x6e
769 #define SWI_TmpNam 0x6f
770 #define SWI_InstallHandler 0x70
771 #define SWI_GenerateError 0x71
778 static int translate_open_mode[] =
781 O_RDONLY + O_BINARY, /* "rb" */
783 O_RDWR + O_BINARY, /* "r+b" */
784 O_WRONLY + O_CREAT + O_TRUNC, /* "w" */
785 O_WRONLY + O_BINARY + O_CREAT + O_TRUNC, /* "wb" */
786 O_RDWR + O_CREAT + O_TRUNC, /* "w+" */
787 O_RDWR + O_BINARY + O_CREAT + O_TRUNC, /* "w+b" */
788 O_WRONLY + O_APPEND + O_CREAT, /* "a" */
789 O_WRONLY + O_BINARY + O_APPEND + O_CREAT, /* "ab" */
790 O_RDWR + O_APPEND + O_CREAT, /* "a+" */
791 O_RDWR + O_BINARY + O_APPEND + O_CREAT /* "a+b" */
795 exec_swi (int swi, argsin *args)
802 callback->write_stdout (callback, &c, 1);
805 for (i = 0; i < args->n; i++)
806 callback->write_stdout (callback, args->s, strlen (args->s));
809 callback->read_stdin (callback, &c, 1);
813 args->n = callback->system (callback, args->s);
816 args->n = callback->get_errno (callback);
819 args->n = callback->time (callback, NULL);
823 /* return number of centi-seconds... */
825 #ifdef CLOCKS_PER_SEC
826 (CLOCKS_PER_SEC >= 100)
827 ? (clock () / (CLOCKS_PER_SEC / 100))
828 : ((clock () * 100) / CLOCKS_PER_SEC);
830 /* presume unix... clock() returns microseconds */
836 args->n = callback->unlink (callback, args->s);
839 args->n = callback->rename (callback, args[0].s, args[1].s);
843 /* Now we need to decode the Demon open mode */
844 i = translate_open_mode[args[1].n];
846 /* Filename ":tt" is special: it denotes stdin/out */
847 if (strcmp (args->s, ":tt") == 0)
849 if (i == O_RDONLY) /* opening tty "r" */
850 args->n = 0 /* stdin */ ;
852 args->n = 1 /* stdout */ ;
855 args->n = callback->open (callback, args->s, i);
859 args->n = callback->close (callback, args->n);
863 /* Return the number of bytes *not* written */
864 args->n = args[1].n -
865 callback->write (callback, args[0].n, args[1].s, args[1].n);
870 char *copy = alloca (args[2].n);
871 int done = callback->read (callback, args[0].n, copy, args[2].n);
873 remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0, 0);
874 args->n = args[2].n - done;
879 /* Return non-zero on failure */
880 args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
885 long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
886 args->n = callback->lseek (callback, args->n, 0, SEEK_END);
887 callback->lseek (callback, args->n, old, 0);
892 args->n = callback->isatty (callback, args->n);
896 if (commandline != NULL)
898 int len = strlen (commandline);
902 commandline[255] = '\0';
904 remote_rdp_xfer_inferior_memory (args[0].n,
905 commandline, len + 1, 1, 0, 0);
908 remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0, 0);
925 int swino = get_word ();
926 int type = get_byte ();
932 args[count].n = get_byte ();
936 args[count].n = get_word ();
940 /* If the word is under 32 bytes it will be sent otherwise
941 an address to it is passed. Also: Special case of 255 */
951 remote_rdp_xfer_inferior_memory (get_word (),
961 buf = alloca (len + 1);
962 for (i = 0; i < len; i++)
963 buf[i] = get_byte ();
971 error ("Unimplemented SWI argument");
978 if (exec_swi (swino, args))
980 /* We have two options here reply with either a byte or a word
981 which is stored in args[0].n. There is no harm in replying with
982 a word all the time, so thats what I do! */
983 send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
987 send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
992 rdp_execute_finish (void)
999 res = serial_readchar (io, 1);
1000 while (res == SERIAL_TIMEOUT)
1003 printf_filtered ("Waiting for target..\n");
1004 res = serial_readchar (io, 1);
1013 send_rdp ("B", &ds.rdi_stopped_status);
1017 printf_filtered ("Target reset\n");
1021 printf_filtered ("Ignoring %x\n", res);
1031 rdp_execute_start ();
1032 rdp_execute_finish ();
1036 remote_rdp_insert_breakpoint (CORE_ADDR addr, char *save)
1039 if (ds.rdi_level > 0)
1041 send_rdp ("bwb-SWB",
1044 RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
1053 RDP_SET_BREAK_TYPE_PC_EQUAL,
1060 remote_rdp_remove_breakpoint (CORE_ADDR addr, char *save)
1063 if (ds.rdi_level > 0)
1065 send_rdp ("b-p-S-B",
1083 if (ds.can_step && 0)
1085 /* The pie board can't do steps so I can't test this, and
1086 the other code will always work. */
1088 send_rdp ("bbw-S-B",
1095 CORE_ADDR pc = read_register (PC_REGNUM);
1096 pc = arm_get_next_pc (pc);
1097 remote_rdp_insert_breakpoint (pc, handle);
1099 remote_rdp_remove_breakpoint (pc, handle);
1104 remote_rdp_open (char *args, int from_tty)
1109 error_no_arg ("serial port device name");
1113 target_preopen (from_tty);
1115 io = serial_open (args);
1118 perror_with_name (args);
1122 rdp_init (1, from_tty);
1127 printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
1132 /* Need to set up the vector interception state */
1133 rdp_catch_vectors ();
1136 ** If it's an EmbeddedICE, we need to set the processor config.
1137 ** Assume we can always have ARM7TDI...
1139 send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, ¬_icebreaker);
1140 if (!not_icebreaker)
1142 const char *CPU = "ARM7TDI";
1144 int len = strlen (CPU);
1146 send_rdp ("bbbbw-p-SWZ",
1148 RDI_ConfigCPU, /* Aspect: set the CPU */
1149 len, /* The number of bytes in the name */
1150 RDI_MatchAny, /* We'll take whatever we get */
1151 0, /* We'll take whatever version's there */
1156 /* command line initialised on 'run' */
1158 push_target (&remote_rdp_ops);
1160 callback->init (callback);
1161 flush_cached_frames ();
1162 registers_changed ();
1163 stop_pc = read_pc ();
1164 set_current_frame (create_new_frame (read_fp (), stop_pc));
1165 select_frame (get_current_frame (), 0);
1166 print_stack_frame (selected_frame, -1, 1);
1171 /* Close out all files and local state before this target loses control. */
1174 remote_rdp_close (int quitting)
1176 callback->shutdown (callback);
1183 /* Resume execution of the target process. STEP says whether to single-step
1184 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
1185 to the target, or zero for no signal. */
1188 remote_rdp_resume (ptid_t ptid, int step, enum target_signal siggnal)
1196 /* Wait for inferior process to do something. Return pid of child,
1197 or -1 in case of error; store status through argument pointer STATUS,
1198 just as `wait' would. */
1201 remote_rdp_wait (ptid_t ptid, struct target_waitstatus *status)
1203 switch (ds.rdi_stopped_status)
1208 status->kind = TARGET_WAITKIND_EXITED;
1209 status->value.integer = read_register (0);
1211 case RDP_RES_AT_BREAKPOINT:
1212 status->kind = TARGET_WAITKIND_STOPPED;
1213 /* The signal in sigrc is a host signal. That probably
1215 status->value.sig = TARGET_SIGNAL_TRAP;
1219 status->kind = TARGET_WAITKIND_SIGNALLED;
1220 /* The signal in sigrc is a host signal. That probably
1222 status->value.sig = target_signal_from_host (sigrc);
1227 return inferior_ptid;
1230 /* Get ready to modify the registers array. On machines which store
1231 individual registers, this doesn't need to do anything. On machines
1232 which store all the registers in one fell swoop, this makes sure
1233 that registers contains all the registers from the program being
1237 remote_rdp_prepare_to_store (void)
1239 /* Do nothing, since we can store individual regs */
1242 /* Transfer LEN bytes between GDB address MYADDR and target address
1243 MEMADDR. If WRITE is non-zero, transfer them to the target,
1244 otherwise transfer them from the target. TARGET is unused.
1246 Returns the number of bytes transferred. */
1249 remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
1250 int write, struct mem_attrib *attrib,
1251 struct target_ops *target)
1253 /* I infer from D Taylor's code that there's a limit on the amount
1254 we can transfer in one chunk.. */
1259 int thisbite = len - done;
1260 if (thisbite > RDP_MOUTHFULL)
1261 thisbite = RDP_MOUTHFULL;
1267 justdone = rdp_write (memaddr + done, myaddr + done, thisbite);
1271 justdone = rdp_read (memaddr + done, myaddr + done, thisbite);
1276 if (justdone != thisbite)
1289 static struct yn stepinfo[] =
1291 {"Step more than one instruction", RDP_INFO_ABOUT_STEP_GT_1},
1292 {"Step to jump", RDP_INFO_ABOUT_STEP_TO_JMP},
1293 {"Step one instruction", RDP_INFO_ABOUT_STEP_1},
1297 static struct yn breakinfo[] =
1299 {"comparison breakpoints supported", RDP_INFO_ABOUT_BREAK_COMP},
1300 {"range breakpoints supported", RDP_INFO_ABOUT_BREAK_RANGE},
1301 {"watchpoints for byte reads supported", RDP_INFO_ABOUT_BREAK_BYTE_READ},
1302 {"watchpoints for half-word reads supported", RDP_INFO_ABOUT_BREAK_HALFWORD_READ},
1303 {"watchpoints for word reads supported", RDP_INFO_ABOUT_BREAK_WORD_READ},
1304 {"watchpoints for byte writes supported", RDP_INFO_ABOUT_BREAK_BYTE_WRITE},
1305 {"watchpoints for half-word writes supported", RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE},
1306 {"watchpoints for word writes supported", RDP_INFO_ABOUT_BREAK_WORD_WRITE},
1307 {"mask break/watch-points supported", RDP_INFO_ABOUT_BREAK_MASK},
1308 {"thread-specific breakpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_BREAK},
1309 {"thread-specific watchpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_WATCH},
1310 {"conditional breakpoints supported", RDP_INFO_ABOUT_BREAK_COND},
1316 dump_bits (struct yn *t, int info)
1320 printf_unfiltered (" %-45s : %s\n", t->name, (info & t->bit) ? "Yes" : "No");
1326 remote_rdp_files_info (struct target_ops *target)
1328 printf_filtered ("Target capabilities:\n");
1329 dump_bits (stepinfo, ds.step_info);
1330 dump_bits (breakinfo, ds.break_info);
1331 printf_unfiltered ("target level RDI %x\n", (ds.target_info >> 5) & 3);
1336 remote_rdp_create_inferior (char *exec_file, char *allargs, char **env)
1338 CORE_ADDR entry_point;
1340 if (exec_file == 0 || exec_bfd == 0)
1341 error ("No executable file specified.");
1343 entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1346 remove_breakpoints ();
1347 init_wait_for_inferior ();
1349 /* This gives us a chance to set up the command line */
1350 rdp_set_command_line (exec_file, allargs);
1352 inferior_ptid = pid_to_ptid (42);
1353 insert_breakpoints (); /* Needed to get correct instruction in cache */
1356 ** RDP targets don't provide any facility to set the top of memory,
1357 ** so we don't bother to look for MEMSIZE in the environment.
1361 proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
1364 /* Accept any stray run/attach commands */
1366 remote_rdp_can_run (void)
1371 /* Attach doesn't need to do anything */
1373 remote_rdp_attach (char *args, int from_tty)
1378 /* Define the target subroutine names */
1380 struct target_ops remote_rdp_ops;
1383 init_remote_rdp_ops (void)
1385 remote_rdp_ops.to_shortname = "rdp";
1386 remote_rdp_ops.to_longname = "Remote Target using the RDProtocol";
1387 remote_rdp_ops.to_doc = "Use a remote ARM system which uses the ARM Remote Debugging Protocol";
1388 remote_rdp_ops.to_open = remote_rdp_open;
1389 remote_rdp_ops.to_close = remote_rdp_close;
1390 remote_rdp_ops.to_attach = remote_rdp_attach;
1391 remote_rdp_ops.to_post_attach = NULL;
1392 remote_rdp_ops.to_require_attach = NULL;
1393 remote_rdp_ops.to_detach = NULL;
1394 remote_rdp_ops.to_require_detach = NULL;
1395 remote_rdp_ops.to_resume = remote_rdp_resume;
1396 remote_rdp_ops.to_wait = remote_rdp_wait;
1397 remote_rdp_ops.to_post_wait = NULL;
1398 remote_rdp_ops.to_fetch_registers = remote_rdp_fetch_register;
1399 remote_rdp_ops.to_store_registers = remote_rdp_store_register;
1400 remote_rdp_ops.to_prepare_to_store = remote_rdp_prepare_to_store;
1401 remote_rdp_ops.to_xfer_memory = remote_rdp_xfer_inferior_memory;
1402 remote_rdp_ops.to_files_info = remote_rdp_files_info;
1403 remote_rdp_ops.to_insert_breakpoint = remote_rdp_insert_breakpoint;
1404 remote_rdp_ops.to_remove_breakpoint = remote_rdp_remove_breakpoint;
1405 remote_rdp_ops.to_terminal_init = NULL;
1406 remote_rdp_ops.to_terminal_inferior = NULL;
1407 remote_rdp_ops.to_terminal_ours_for_output = NULL;
1408 remote_rdp_ops.to_terminal_ours = NULL;
1409 remote_rdp_ops.to_terminal_info = NULL;
1410 remote_rdp_ops.to_kill = remote_rdp_kill;
1411 remote_rdp_ops.to_load = generic_load;
1412 remote_rdp_ops.to_lookup_symbol = NULL;
1413 remote_rdp_ops.to_create_inferior = remote_rdp_create_inferior;
1414 remote_rdp_ops.to_post_startup_inferior = NULL;
1415 remote_rdp_ops.to_acknowledge_created_inferior = NULL;
1416 remote_rdp_ops.to_clone_and_follow_inferior = NULL;
1417 remote_rdp_ops.to_post_follow_inferior_by_clone = NULL;
1418 remote_rdp_ops.to_insert_fork_catchpoint = NULL;
1419 remote_rdp_ops.to_remove_fork_catchpoint = NULL;
1420 remote_rdp_ops.to_insert_vfork_catchpoint = NULL;
1421 remote_rdp_ops.to_remove_vfork_catchpoint = NULL;
1422 remote_rdp_ops.to_has_forked = NULL;
1423 remote_rdp_ops.to_has_vforked = NULL;
1424 remote_rdp_ops.to_can_follow_vfork_prior_to_exec = NULL;
1425 remote_rdp_ops.to_post_follow_vfork = NULL;
1426 remote_rdp_ops.to_insert_exec_catchpoint = NULL;
1427 remote_rdp_ops.to_remove_exec_catchpoint = NULL;
1428 remote_rdp_ops.to_has_execd = NULL;
1429 remote_rdp_ops.to_reported_exec_events_per_exec_call = NULL;
1430 remote_rdp_ops.to_has_exited = NULL;
1431 remote_rdp_ops.to_mourn_inferior = generic_mourn_inferior;
1432 remote_rdp_ops.to_can_run = remote_rdp_can_run;
1433 remote_rdp_ops.to_notice_signals = 0;
1434 remote_rdp_ops.to_thread_alive = 0;
1435 remote_rdp_ops.to_stop = 0;
1436 remote_rdp_ops.to_pid_to_exec_file = NULL;
1437 remote_rdp_ops.to_stratum = process_stratum;
1438 remote_rdp_ops.DONT_USE = NULL;
1439 remote_rdp_ops.to_has_all_memory = 1;
1440 remote_rdp_ops.to_has_memory = 1;
1441 remote_rdp_ops.to_has_stack = 1;
1442 remote_rdp_ops.to_has_registers = 1;
1443 remote_rdp_ops.to_has_execution = 1;
1444 remote_rdp_ops.to_sections = NULL;
1445 remote_rdp_ops.to_sections_end = NULL;
1446 remote_rdp_ops.to_magic = OPS_MAGIC;
1450 _initialize_remote_rdp (void)
1452 init_remote_rdp_ops ();
1453 add_target (&remote_rdp_ops);