1 /* Remote debugging for the ARM RDP interface.
2 Copyright 1994, 1995 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
26 Much of this file (in particular the SWI stuff) is based on code by
29 I hacked on and simplified it by removing a lot of sexy features he
30 had added, and some of the (unix specific) workarounds he'd done
31 for other GDB problems - which if they still exist should be fixed
32 in GDB, not in a remote-foo thing . I also made it conform more to
33 the doc I have; which may be wrong.
48 #include "remote-utils.h"
49 #include "gdb_string.h"
56 extern struct target_ops remote_rdp_ops;
58 static host_callback *callback = &default_callback;
67 char command_line[10];
69 int rdi_stopped_status;
75 /* Definitions for the RDP protocol. */
77 #define RDP_MOUTHFULL (1<<6)
78 #define FPU_COPRO_NUMBER 1
81 #define RDP_OPEN_TYPE_COLD 0
82 #define RDP_OPEN_TYPE_WARM 1
83 #define RDP_OPEN_TYPE_BAUDRATE 2
85 #define RDP_OPEN_BAUDRATE_9600 1
86 #define RDP_OPEN_BAUDRATE_19200 2
87 #define RDP_OPEN_BAUDRATE_38400 3
89 #define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
93 #define RDP_MEM_READ 2
95 #define RDP_MEM_WRITE 3
97 #define RDP_CPU_READ 4
98 #define RDP_CPU_WRITE 5
99 #define RDP_CPU_READWRITE_MODE_CURRENT 255
100 #define RDP_CPU_READWRITE_MASK_PC (1<<16)
101 #define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
102 #define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
104 #define RDP_COPRO_READ 6
105 #define RDP_COPRO_WRITE 7
106 #define RDP_FPU_READWRITE_MASK_FPS (1<<8)
108 #define RDP_SET_BREAK 0xa
109 #define RDP_SET_BREAK_TYPE_PC_EQUAL 0
110 #define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
112 #define RDP_CLEAR_BREAK 0xb
114 #define RDP_EXEC 0x10
115 #define RDP_EXEC_TYPE_SYNC 0
117 #define RDP_STEP 0x11
119 #define RDP_INFO 0x12
120 #define RDP_INFO_ABOUT_STEP 2
121 #define RDP_INFO_ABOUT_STEP_GT_1 1
122 #define RDP_INFO_ABOUT_STEP_TO_JMP 2
123 #define RDP_INFO_ABOUT_STEP_1 4
124 #define RDP_INFO_ABOUT_TARGET 0
125 #define RDP_INFO_ABOUT_BREAK 1
126 #define RDP_INFO_ABOUT_BREAK_COMP 1
127 #define RDP_INFO_ABOUT_BREAK_RANGE 2
128 #define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
129 #define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
130 #define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
131 #define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
132 #define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
133 #define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
134 #define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
135 #define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
136 #define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
137 #define RDP_INFO_ABOUT_BREAK_COND (1<<11)
138 #define RDP_INFO_VECTOR_CATCH (0x180)
139 #define RDP_INFO_ICEBREAKER (7)
140 #define RDP_INFO_SET_CMDLINE (0x300)
142 #define RDP_SELECT_CONFIG (0x16)
143 #define RDI_ConfigCPU 0
144 #define RDI_ConfigSystem 1
145 #define RDI_MatchAny 0
146 #define RDI_MatchExactly 1
147 #define RDI_MatchNoEarlier 2
149 #define RDP_RESET 0x7f
151 /* Returns from RDP */
152 #define RDP_RES_STOPPED 0x20
153 #define RDP_RES_SWI 0x21
154 #define RDP_RES_FATAL 0x5e
155 #define RDP_RES_VALUE 0x5f
156 #define RDP_RES_VALUE_LITTLE_ENDIAN 240
157 #define RDP_RES_VALUE_BIG_ENDIAN 241
158 #define RDP_RES_RESET 0x7f
159 #define RDP_RES_AT_BREAKPOINT 143
160 #define RDP_RES_IDUNNO 0xe6
161 #define RDP_OSOpReply 0x13
162 #define RDP_OSOpWord 2
163 #define RDP_OSOpNothing 0
165 static int timeout = 2;
167 static char *commandline = NULL;
170 remote_rdp_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
174 struct target_ops * target));
177 /* Stuff for talking to the serial layer. */
182 int c = SERIAL_READCHAR (io, timeout);
185 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", c);
187 if (c == SERIAL_TIMEOUT)
190 return (unsigned char) c;
192 error ("Timeout reading from remote_system");
198 /* Note that the target always speaks little-endian to us,
199 even if it's a big endian machine. */
203 unsigned int val = 0;
206 for (n = 0; n < 4; n++)
219 fprintf_unfiltered (gdb_stdlog, "(%02x)\n", val);
220 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.
258 int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
261 time_t now = time (0);
262 time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
265 while (time (0) < stop_time && !sync)
270 SERIAL_FLUSH_INPUT (io);
271 SERIAL_FLUSH_OUTPUT (io);
274 printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
277 ** It seems necessary to reset an EmbeddedICE to get it going.
278 ** This has the side benefit of displaying the startup banner.
282 put_byte (RDP_RESET);
283 while ((restype = SERIAL_READCHAR (io, 1)) > 0)
290 /* Sent at start of reset process: ignore */
293 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
300 /* Got end-of-banner mark */
301 printf_filtered ("\n");
307 put_byte (type | RDP_OPEN_TYPE_RETURN_SEX);
310 while (!sync && (restype = SERIAL_READCHAR (io, 1)) > 0)
313 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", restype);
321 while ((restype = SERIAL_READCHAR (io, 1)) == RDP_RESET)
325 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
327 while ((restype = SERIAL_READCHAR (io, 1)) > 0);
331 printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
332 printf_unfiltered ("Waiting for it to settle down...\n");
336 printf_unfiltered ("\nTrying again.\n");
345 int resval = SERIAL_READCHAR (io, 1);
348 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", resval);
354 case RDP_RES_VALUE_LITTLE_ENDIAN:
355 target_byte_order = LITTLE_ENDIAN;
358 case RDP_RES_VALUE_BIG_ENDIAN:
359 target_byte_order = BIG_ENDIAN;
372 error ("Couldn't reset the board, try pressing the reset button");
378 send_rdp (char *template,...)
383 va_start (alist, template);
395 val = va_arg (alist, int);
399 val = va_arg (alist, int);
407 if (val != RDP_RES_VALUE)
409 printf_unfiltered ("got bad res value of %d, %x\n", val, val);
413 pstat = va_arg (alist, int *);
414 pi = va_arg (alist, int *);
416 *pstat = get_byte ();
417 /* Check the result was zero, if not read the syndrome */
424 /* Check the result code */
431 /* Target can't do it; never mind */
432 printf_unfiltered ("RDP: Insufficient privilege\n");
435 /* Target can't do it; never mind */
436 printf_unfiltered ("RDP: Unimplemented message\n");
439 error ("Command garbled");
442 error ("Corrupt reply from target");
447 /* Read a word from the target */
448 pi = va_arg (alist, int *);
452 /* Read in some bytes from the target. */
453 pc = va_arg (alist, char *);
454 val = va_arg (alist, int);
455 for (i = 0; i < val; i++)
461 /* send what's being pointed at */
462 pc = va_arg (alist, char *);
463 val = va_arg (alist, int);
465 SERIAL_WRITE (io, pc, val);
468 /* Send whats in the queue */
471 SERIAL_WRITE (io, buf, dst - buf);
476 pi = va_arg (alist, int *);
491 rdp_write (memaddr, buf, len)
499 send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
510 rdp_read (memaddr, buf, len)
517 send_rdp ("bww-S-P-V",
518 RDP_MEM_READ, memaddr, len,
529 rdp_fetch_one_register (mask, buf)
534 send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
535 store_signed_integer (buf, 4, val);
539 rdp_fetch_one_fpu_register (mask, buf)
544 /* !!! Since the PIE board doesn't work as documented,
545 and it doesn't have FPU hardware anyway and since it
546 slows everything down, I've disabled this. */
548 if (mask == RDP_FPU_READWRITE_MASK_FPS)
550 /* this guy is only a word */
551 send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
552 store_signed_integer (buf, 4, val);
556 /* There are 12 bytes long
557 !! fixme about endianness
559 int dummy; /* I've seen these come back as four words !! */
560 send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
563 memset (buf, 0, MAX_REGISTER_RAW_SIZE);
568 rdp_store_one_register (mask, buf)
572 int val = extract_unsigned_integer (buf, 4);
575 RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
580 rdp_store_one_fpu_register (mask, buf)
585 /* See comment in fetch_one_fpu_register */
586 if (mask == RDP_FPU_READWRITE_MASK_FPS)
588 int val = extract_unsigned_integer (buf, 4);
589 /* this guy is only a word */
590 send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
596 /* There are 12 bytes long
597 !! fixme about endianness
600 /* I've seen these come as four words, not the three advertized !! */
601 printf ("Sending mask %x\n", mask);
602 send_rdp ("bbwwwww-SZ",
611 printf ("done mask %x\n", mask);
617 /* Convert between GDB requests and the RDP layer. */
620 remote_rdp_fetch_register (regno)
625 for (regno = 0; regno < NUM_REGS; regno++)
626 remote_rdp_fetch_register (regno);
630 char buf[MAX_REGISTER_RAW_SIZE];
632 rdp_fetch_one_register (1 << regno, buf);
633 else if (regno == PC_REGNUM)
634 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
635 else if (regno == PS_REGNUM)
636 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
637 else if (regno == FPS_REGNUM)
638 rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
639 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
640 rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
643 printf ("Help me with fetch reg %d\n", regno);
645 supply_register (regno, buf);
651 remote_rdp_store_register (regno)
656 for (regno = 0; regno < NUM_REGS; regno++)
657 remote_rdp_store_register (regno);
661 char tmp[MAX_REGISTER_RAW_SIZE];
662 read_register_gen (regno, tmp);
664 rdp_store_one_register (1 << regno, tmp);
665 else if (regno == PC_REGNUM)
666 rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
667 else if (regno == PS_REGNUM)
668 rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
669 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
670 rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
673 printf ("Help me with reg %d\n", regno);
681 callback->shutdown (callback);
688 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
690 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
692 send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
696 ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
698 ds.rdi_level = (ds.target_info >> 5) & 3;
705 /* Start it off, but don't wait for it */
706 send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
711 rdp_set_command_line (command, args)
716 ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
717 ** don't implement that, and get all confused at the unexpected text.
718 ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
721 if (commandline != NULL)
724 commandline = malloc (strlen (command) + strlen (args) + 2);
725 if (commandline != NULL)
727 strcpy (commandline, command);
728 strcat (commandline, " ");
729 strcat (commandline, args);
737 ** We want the target monitor to intercept the abort vectors
738 ** i.e. stop the program if any of these are used.
740 send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
742 ** Specify a bitmask including
744 ** the undefined instruction vector
745 ** the prefetch abort vector
746 ** the data abort vector
747 ** the address exception vector
749 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5)
772 #define SWI_WriteC 0x0
773 #define SWI_Write0 0x2
774 #define SWI_ReadC 0x4
776 #define SWI_GetEnv 0x10
777 #define SWI_Exit 0x11
778 #define SWI_EnterOS 0x16
780 #define SWI_GetErrno 0x60
781 #define SWI_Clock 0x61
783 #define SWI_Time 0x63
784 #define SWI_Remove 0x64
785 #define SWI_Rename 0x65
786 #define SWI_Open 0x66
788 #define SWI_Close 0x68
789 #define SWI_Write 0x69
790 #define SWI_Read 0x6a
791 #define SWI_Seek 0x6b
792 #define SWI_Flen 0x6c
794 #define SWI_IsTTY 0x6e
795 #define SWI_TmpNam 0x6f
796 #define SWI_InstallHandler 0x70
797 #define SWI_GenerateError 0x71
804 static int translate_open_mode[] =
807 O_RDONLY + O_BINARY, /* "rb" */
809 O_RDWR + O_BINARY, /* "r+b" */
810 O_WRONLY + O_CREAT + O_TRUNC, /* "w" */
811 O_WRONLY + O_BINARY + O_CREAT + O_TRUNC, /* "wb" */
812 O_RDWR + O_CREAT + O_TRUNC, /* "w+" */
813 O_RDWR + O_BINARY + O_CREAT + O_TRUNC, /* "w+b" */
814 O_WRONLY + O_APPEND + O_CREAT, /* "a" */
815 O_WRONLY + O_BINARY + O_APPEND + O_CREAT, /* "ab" */
816 O_RDWR + O_APPEND + O_CREAT, /* "a+" */
817 O_RDWR + O_BINARY + O_APPEND + O_CREAT /* "a+b" */
830 callback->write_stdout (callback, &c, 1);
833 for (i = 0; i < args->n; i++)
834 callback->write_stdout (callback, args->s, strlen (args->s));
837 callback->read_stdin (callback, &c, 1);
841 args->n = callback->system (callback, args->s);
844 args->n = callback->get_errno (callback);
847 args->n = callback->time (callback, NULL);
851 /* return number of centi-seconds... */
853 #ifdef CLOCKS_PER_SEC
854 (CLOCKS_PER_SEC >= 100)
855 ? (clock () / (CLOCKS_PER_SEC / 100))
856 : ((clock () * 100) / CLOCKS_PER_SEC);
858 /* presume unix... clock() returns microseconds */
864 args->n = callback->unlink (callback, args->s);
867 args->n = callback->rename (callback, args[0].s, args[1].s);
871 /* Now we need to decode the Demon open mode */
872 i = translate_open_mode[args[1].n];
874 /* Filename ":tt" is special: it denotes stdin/out */
875 if (strcmp (args->s, ":tt") == 0)
877 if (i == O_RDONLY) /* opening tty "r" */
878 args->n = 0 /* stdin */ ;
880 args->n = 1 /* stdout */ ;
883 args->n = callback->open (callback, args->s, i);
887 args->n = callback->close (callback, args->n);
891 /* Return the number of bytes *not* written */
892 args->n = args[1].n -
893 callback->write (callback, args[0].n, args[1].s, args[1].n);
898 char *copy = alloca (args[2].n);
899 int done = callback->read (callback, args[0].n, copy, args[2].n);
901 remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0);
902 args->n = args[2].n - done;
907 /* Return non-zero on failure */
908 args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
913 long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
914 args->n = callback->lseek (callback, args->n, 0, SEEK_END);
915 callback->lseek (callback, args->n, old, 0);
920 args->n = callback->isatty (callback, args->n);
924 if (commandline != NULL)
926 int len = strlen (commandline);
930 commandline[255] = '\0';
932 remote_rdp_xfer_inferior_memory (args[0].n,
933 commandline, len + 1, 1, 0);
936 remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0);
953 int swino = get_word ();
954 int type = get_byte ();
960 args[count].n = get_byte ();
964 args[count].n = get_word ();
968 /* If the word is under 32 bytes it will be sent otherwise
969 an address to it is passed. Also: Special case of 255 */
979 remote_rdp_xfer_inferior_memory (get_word (),
988 buf = alloca (len + 1);
989 for (i = 0; i < len; i++)
990 buf[i] = get_byte ();
998 error ("Unimplented SWI argument");
1005 if (exec_swi (swino, args))
1007 /* We have two options here reply with either a byte or a word
1008 which is stored in args[0].n. There is no harm in replying with
1009 a word all the time, so thats what I do! */
1010 send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
1014 send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
1019 rdp_execute_finish ()
1026 res = SERIAL_READCHAR (io, 1);
1027 while (res == SERIAL_TIMEOUT)
1030 printf_filtered ("Waiting for target..\n");
1031 res = SERIAL_READCHAR (io, 1);
1040 send_rdp ("B", &ds.rdi_stopped_status);
1044 printf_filtered ("Target reset\n");
1048 printf_filtered ("Ignoring %x\n", res);
1058 rdp_execute_start ();
1059 rdp_execute_finish ();
1063 remote_rdp_insert_breakpoint (addr, save)
1068 if (ds.rdi_level > 0)
1070 send_rdp ("bwb-SWB",
1073 RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
1082 RDP_SET_BREAK_TYPE_PC_EQUAL,
1089 remote_rdp_remove_breakpoint (addr, save)
1094 if (ds.rdi_level > 0)
1096 send_rdp ("b-p-S-B",
1114 if (ds.can_step && 0)
1116 /* The pie board can't do steps so I can't test this, and
1117 the other code will always work. */
1119 send_rdp ("bbw-S-B",
1126 CORE_ADDR pc = read_register (PC_REGNUM);
1127 pc = arm_get_next_pc (pc);
1128 remote_rdp_insert_breakpoint (pc, &handle);
1130 remote_rdp_remove_breakpoint (pc, &handle);
1135 remote_rdp_open (args, from_tty)
1142 error_no_arg ("serial port device name");
1146 target_preopen (from_tty);
1148 io = SERIAL_OPEN (args);
1151 perror_with_name (args);
1155 rdp_init (1, from_tty);
1160 printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
1165 /* Need to set up the vector interception state */
1166 rdp_catch_vectors ();
1169 ** If it's an EmbeddedICE, we need to set the processor config.
1170 ** Assume we can always have ARM7TDI...
1172 send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, ¬_icebreaker);
1173 if (!not_icebreaker)
1175 const char *CPU = "ARM7TDI";
1177 int len = strlen (CPU);
1179 send_rdp ("bbbbw-p-SWZ",
1181 RDI_ConfigCPU, /* Aspect: set the CPU */
1182 len, /* The number of bytes in the name */
1183 RDI_MatchAny, /* We'll take whatever we get */
1184 0, /* We'll take whatever version's there */
1189 /* command line initialised on 'run' */
1191 push_target (&remote_rdp_ops);
1193 callback->init (callback);
1194 flush_cached_frames ();
1195 registers_changed ();
1196 stop_pc = read_pc ();
1197 set_current_frame (create_new_frame (read_fp (), stop_pc));
1198 select_frame (get_current_frame (), 0);
1199 print_stack_frame (selected_frame, -1, 1);
1204 /* Close out all files and local state before this target loses control. */
1207 remote_rdp_close (quitting)
1210 callback->shutdown (callback);
1217 /* Resume execution of the target process. STEP says whether to single-step
1218 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
1219 to the target, or zero for no signal. */
1222 remote_rdp_resume (pid, step, siggnal)
1224 enum target_signal siggnal;
1232 /* Wait for inferior process to do something. Return pid of child,
1233 or -1 in case of error; store status through argument pointer STATUS,
1234 just as `wait' would. */
1237 remote_rdp_wait (pid, status)
1239 struct target_waitstatus *status;
1241 switch (ds.rdi_stopped_status)
1246 status->kind = TARGET_WAITKIND_EXITED;
1247 status->value.integer = read_register (0);
1249 case RDP_RES_AT_BREAKPOINT:
1250 status->kind = TARGET_WAITKIND_STOPPED;
1251 /* The signal in sigrc is a host signal. That probably
1253 status->value.sig = TARGET_SIGNAL_TRAP;
1257 status->kind = TARGET_WAITKIND_SIGNALLED;
1258 /* The signal in sigrc is a host signal. That probably
1260 status->value.sig = target_signal_from_host (sigrc);
1265 return inferior_pid;
1268 /* Get ready to modify the registers array. On machines which store
1269 individual registers, this doesn't need to do anything. On machines
1270 which store all the registers in one fell swoop, this makes sure
1271 that registers contains all the registers from the program being
1275 remote_rdp_prepare_to_store ()
1277 /* Do nothing, since we can store individual regs */
1281 remote_rdp_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1286 struct target_ops *target; /* ignored */
1288 /* I infer from D Taylor's code that there's a limit on the amount
1289 we can transfer in one chunk.. */
1294 int thisbite = len - done;
1295 if (thisbite > RDP_MOUTHFULL)
1296 thisbite = RDP_MOUTHFULL;
1302 justdone = rdp_write (memaddr + done, myaddr + done, thisbite);
1306 justdone = rdp_read (memaddr + done, myaddr + done, thisbite);
1311 if (justdone != thisbite)
1324 static struct yn stepinfo[] =
1326 {"Step more than one instruction", RDP_INFO_ABOUT_STEP_GT_1},
1327 {"Step to jump", RDP_INFO_ABOUT_STEP_TO_JMP},
1328 {"Step one instruction", RDP_INFO_ABOUT_STEP_1},
1332 static struct yn breakinfo[] =
1334 {"comparison breakpoints supported", RDP_INFO_ABOUT_BREAK_COMP},
1335 {"range breakpoints supported", RDP_INFO_ABOUT_BREAK_RANGE},
1336 {"watchpoints for byte reads supported", RDP_INFO_ABOUT_BREAK_BYTE_READ},
1337 {"watchpoints for half-word reads supported", RDP_INFO_ABOUT_BREAK_HALFWORD_READ},
1338 {"watchpoints for word reads supported", RDP_INFO_ABOUT_BREAK_WORD_READ},
1339 {"watchpoints for byte writes supported", RDP_INFO_ABOUT_BREAK_BYTE_WRITE},
1340 {"watchpoints for half-word writes supported", RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE},
1341 {"watchpoints for word writes supported", RDP_INFO_ABOUT_BREAK_WORD_WRITE},
1342 {"mask break/watch-points supported", RDP_INFO_ABOUT_BREAK_MASK},
1343 {"thread-specific breakpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_BREAK},
1344 {"thread-specific watchpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_WATCH},
1345 {"conditional breakpoints supported", RDP_INFO_ABOUT_BREAK_COND},
1357 printf_unfiltered (" %-45s : %s\n", t->name, (info & t->bit) ? "Yes" : "No");
1363 remote_rdp_files_info (target)
1364 struct target_ops *target;
1366 printf_filtered ("Target capabilities:\n");
1367 dump_bits (stepinfo, ds.step_info);
1368 dump_bits (breakinfo, ds.break_info);
1369 printf_unfiltered ("target level RDI %x\n", (ds.target_info >> 5) & 3);
1374 remote_rdp_create_inferior (exec_file, allargs, env)
1379 CORE_ADDR entry_point;
1381 if (exec_file == 0 || exec_bfd == 0)
1382 error ("No executable file specified.");
1384 entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1387 remove_breakpoints ();
1388 init_wait_for_inferior ();
1390 /* This gives us a chance to set up the command line */
1391 rdp_set_command_line (exec_file, allargs);
1394 insert_breakpoints (); /* Needed to get correct instruction in cache */
1397 ** RDP targets don't provide any facility to set the top of memory,
1398 ** so we don't bother to look for MEMSIZE in the environment.
1402 proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
1405 /* Accept any stray run/attach commands */
1407 remote_rdp_can_run ()
1412 /* Attach doesn't need to do anything */
1414 remote_rdp_attach (args, from_tty)
1421 /* Define the target subroutine names */
1423 struct target_ops remote_rdp_ops;
1426 init_remote_rdp_ops (void)
1428 remote_rdp_ops.to_shortname = "rdp";
1429 remote_rdp_ops.to_longname = "Remote Target using the RDProtocol";
1430 remote_rdp_ops.to_doc = "Use a remote ARM system which uses the ARM Remote Debugging Protocol";
1431 remote_rdp_ops.to_open = remote_rdp_open;
1432 remote_rdp_ops.to_close = remote_rdp_close;
1433 remote_rdp_ops.to_attach = remote_rdp_attach;
1434 remote_rdp_ops.to_post_attach = NULL;
1435 remote_rdp_ops.to_require_attach = NULL;
1436 remote_rdp_ops.to_detach = NULL;
1437 remote_rdp_ops.to_require_detach = NULL;
1438 remote_rdp_ops.to_resume = remote_rdp_resume;
1439 remote_rdp_ops.to_wait = remote_rdp_wait;
1440 remote_rdp_ops.to_post_wait = NULL;
1441 remote_rdp_ops.to_fetch_registers = remote_rdp_fetch_register;
1442 remote_rdp_ops.to_store_registers = remote_rdp_store_register;
1443 remote_rdp_ops.to_prepare_to_store = remote_rdp_prepare_to_store;
1444 remote_rdp_ops.to_xfer_memory = remote_rdp_xfer_inferior_memory;
1445 remote_rdp_ops.to_files_info = remote_rdp_files_info;
1446 remote_rdp_ops.to_insert_breakpoint = remote_rdp_insert_breakpoint;
1447 remote_rdp_ops.to_remove_breakpoint = remote_rdp_remove_breakpoint;
1448 remote_rdp_ops.to_terminal_init = NULL;
1449 remote_rdp_ops.to_terminal_inferior = NULL;
1450 remote_rdp_ops.to_terminal_ours_for_output = NULL;
1451 remote_rdp_ops.to_terminal_ours = NULL;
1452 remote_rdp_ops.to_terminal_info = NULL;
1453 remote_rdp_ops.to_kill = remote_rdp_kill;
1454 remote_rdp_ops.to_load = generic_load;
1455 remote_rdp_ops.to_lookup_symbol = NULL;
1456 remote_rdp_ops.to_create_inferior = remote_rdp_create_inferior;
1457 remote_rdp_ops.to_post_startup_inferior = NULL;
1458 remote_rdp_ops.to_acknowledge_created_inferior = NULL;
1459 remote_rdp_ops.to_clone_and_follow_inferior = NULL;
1460 remote_rdp_ops.to_post_follow_inferior_by_clone = NULL;
1461 remote_rdp_ops.to_insert_fork_catchpoint = NULL;
1462 remote_rdp_ops.to_remove_fork_catchpoint = NULL;
1463 remote_rdp_ops.to_insert_vfork_catchpoint = NULL;
1464 remote_rdp_ops.to_remove_vfork_catchpoint = NULL;
1465 remote_rdp_ops.to_has_forked = NULL;
1466 remote_rdp_ops.to_has_vforked = NULL;
1467 remote_rdp_ops.to_can_follow_vfork_prior_to_exec = NULL;
1468 remote_rdp_ops.to_post_follow_vfork = NULL;
1469 remote_rdp_ops.to_insert_exec_catchpoint = NULL;
1470 remote_rdp_ops.to_remove_exec_catchpoint = NULL;
1471 remote_rdp_ops.to_has_execd = NULL;
1472 remote_rdp_ops.to_reported_exec_events_per_exec_call = NULL;
1473 remote_rdp_ops.to_has_exited = NULL;
1474 remote_rdp_ops.to_mourn_inferior = generic_mourn_inferior;
1475 remote_rdp_ops.to_can_run = remote_rdp_can_run;
1476 remote_rdp_ops.to_notice_signals = 0;
1477 remote_rdp_ops.to_thread_alive = 0;
1478 remote_rdp_ops.to_stop = 0;
1479 remote_rdp_ops.to_pid_to_exec_file = NULL;
1480 remote_rdp_ops.to_core_file_to_sym_file = NULL;
1481 remote_rdp_ops.to_stratum = process_stratum;
1482 remote_rdp_ops.DONT_USE = NULL;
1483 remote_rdp_ops.to_has_all_memory = 1;
1484 remote_rdp_ops.to_has_memory = 1;
1485 remote_rdp_ops.to_has_stack = 1;
1486 remote_rdp_ops.to_has_registers = 1;
1487 remote_rdp_ops.to_has_execution = 1;
1488 remote_rdp_ops.to_sections = NULL;
1489 remote_rdp_ops.to_sections_end = NULL;
1490 remote_rdp_ops.to_magic = OPS_MAGIC;
1494 _initialize_remote_rdp ()
1496 init_remote_rdp_ops ();
1497 add_target (&remote_rdp_ops);