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.
45 #ifdef ANSI_PROTOTYPES
53 #include "remote-utils.h"
54 #include "gdb_string.h"
61 extern struct target_ops remote_rdp_ops;
63 static host_callback *callback = &default_callback;
72 char command_line[10];
74 int rdi_stopped_status;
80 /* Definitions for the RDP protocol. */
82 #define RDP_MOUTHFULL (1<<6)
83 #define FPU_COPRO_NUMBER 1
86 #define RDP_OPEN_TYPE_COLD 0
87 #define RDP_OPEN_TYPE_WARM 1
88 #define RDP_OPEN_TYPE_BAUDRATE 2
90 #define RDP_OPEN_BAUDRATE_9600 1
91 #define RDP_OPEN_BAUDRATE_19200 2
92 #define RDP_OPEN_BAUDRATE_38400 3
94 #define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
98 #define RDP_MEM_READ 2
100 #define RDP_MEM_WRITE 3
102 #define RDP_CPU_READ 4
103 #define RDP_CPU_WRITE 5
104 #define RDP_CPU_READWRITE_MODE_CURRENT 255
105 #define RDP_CPU_READWRITE_MASK_PC (1<<16)
106 #define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
107 #define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
109 #define RDP_COPRO_READ 6
110 #define RDP_COPRO_WRITE 7
111 #define RDP_FPU_READWRITE_MASK_FPS (1<<8)
113 #define RDP_SET_BREAK 0xa
114 #define RDP_SET_BREAK_TYPE_PC_EQUAL 0
115 #define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
117 #define RDP_CLEAR_BREAK 0xb
119 #define RDP_EXEC 0x10
120 #define RDP_EXEC_TYPE_SYNC 0
122 #define RDP_STEP 0x11
124 #define RDP_INFO 0x12
125 #define RDP_INFO_ABOUT_STEP 2
126 #define RDP_INFO_ABOUT_STEP_GT_1 1
127 #define RDP_INFO_ABOUT_STEP_TO_JMP 2
128 #define RDP_INFO_ABOUT_STEP_1 4
129 #define RDP_INFO_ABOUT_TARGET 0
130 #define RDP_INFO_ABOUT_BREAK 1
131 #define RDP_INFO_ABOUT_BREAK_COMP 1
132 #define RDP_INFO_ABOUT_BREAK_RANGE 2
133 #define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
134 #define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
135 #define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
136 #define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
137 #define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
138 #define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
139 #define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
140 #define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
141 #define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
142 #define RDP_INFO_ABOUT_BREAK_COND (1<<11)
143 #define RDP_INFO_VECTOR_CATCH (0x180)
144 #define RDP_INFO_ICEBREAKER (7)
145 #define RDP_INFO_SET_CMDLINE (0x300)
147 #define RDP_SELECT_CONFIG (0x16)
148 #define RDI_ConfigCPU 0
149 #define RDI_ConfigSystem 1
150 #define RDI_MatchAny 0
151 #define RDI_MatchExactly 1
152 #define RDI_MatchNoEarlier 2
154 #define RDP_RESET 0x7f
156 /* Returns from RDP */
157 #define RDP_RES_STOPPED 0x20
158 #define RDP_RES_SWI 0x21
159 #define RDP_RES_FATAL 0x5e
160 #define RDP_RES_VALUE 0x5f
161 #define RDP_RES_VALUE_LITTLE_ENDIAN 240
162 #define RDP_RES_VALUE_BIG_ENDIAN 241
163 #define RDP_RES_RESET 0x7f
164 #define RDP_RES_AT_BREAKPOINT 143
165 #define RDP_RES_IDUNNO 0xe6
166 #define RDP_OSOpReply 0x13
167 #define RDP_OSOpWord 2
168 #define RDP_OSOpNothing 0
170 static int timeout = 2;
172 static char *commandline = NULL;
175 remote_rdp_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
179 struct target_ops * target));
182 /* Stuff for talking to the serial layer. */
187 int c = SERIAL_READCHAR (io, timeout);
190 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", c);
192 if (c == SERIAL_TIMEOUT)
195 return (unsigned char) c;
197 error ("Timeout reading from remote_system");
203 /* Note that the target always speaks little-endian to us,
204 even if it's a big endian machine. */
208 unsigned int val = 0;
211 for (n = 0; n < 4; n++)
224 fprintf_unfiltered (gdb_stdlog, "(%02x)\n", val);
225 SERIAL_WRITE (io, &val, 1);
232 /* We always send in little endian */
240 fprintf_unfiltered (gdb_stdlog, "(%04x)", val);
242 SERIAL_WRITE (io, b, 4);
247 /* Stuff for talking to the RDP layer. */
249 /* This is a bit more fancy that need be so that it syncs even in nasty cases.
251 I'be been unable to make it reliably sync up with the change
252 baudrate open command. It likes to sit and say it's been reset,
253 with no more action. So I took all that code out. I'd rather sync
254 reliably at 9600 than wait forever for a possible 19200 connection.
263 int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
266 time_t now = time (0);
267 time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
270 while (time (0) < stop_time && !sync)
275 SERIAL_FLUSH_INPUT (io);
276 SERIAL_FLUSH_OUTPUT (io);
279 printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
282 ** It seems necessary to reset an EmbeddedICE to get it going.
283 ** This has the side benefit of displaying the startup banner.
287 put_byte (RDP_RESET);
288 while ((restype = SERIAL_READCHAR (io, 1)) > 0)
295 /* Sent at start of reset process: ignore */
298 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
305 /* Got end-of-banner mark */
306 printf_filtered ("\n");
312 put_byte (type | RDP_OPEN_TYPE_RETURN_SEX);
315 while (!sync && (restype = SERIAL_READCHAR (io, 1)) > 0)
318 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", restype);
326 while ((restype = SERIAL_READCHAR (io, 1)) == RDP_RESET)
330 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
332 while ((restype = SERIAL_READCHAR (io, 1)) > 0);
336 printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
337 printf_unfiltered ("Waiting for it to settle down...\n");
341 printf_unfiltered ("\nTrying again.\n");
350 int resval = SERIAL_READCHAR (io, 1);
353 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", resval);
359 case RDP_RES_VALUE_LITTLE_ENDIAN:
360 target_byte_order = LITTLE_ENDIAN;
363 case RDP_RES_VALUE_BIG_ENDIAN:
364 target_byte_order = BIG_ENDIAN;
377 error ("Couldn't reset the board, try pressing the reset button");
382 #ifdef ANSI_PROTOTYPES
384 send_rdp (char *template,...)
387 send_rdp (char *template, va_alist)
394 #ifdef ANSI_PROTOTYPES
395 va_start (alist, template);
410 val = va_arg (alist, int);
414 val = va_arg (alist, int);
422 if (val != RDP_RES_VALUE)
424 printf_unfiltered ("got bad res value of %d, %x\n", val, val);
428 pstat = va_arg (alist, int *);
429 pi = va_arg (alist, int *);
431 *pstat = get_byte ();
432 /* Check the result was zero, if not read the syndrome */
439 /* Check the result code */
446 /* Target can't do it; never mind */
447 printf_unfiltered ("RDP: Insufficient privilege\n");
450 /* Target can't do it; never mind */
451 printf_unfiltered ("RDP: Unimplemented message\n");
454 error ("Command garbled");
457 error ("Corrupt reply from target");
462 /* Read a word from the target */
463 pi = va_arg (alist, int *);
467 /* Read in some bytes from the target. */
468 pc = va_arg (alist, char *);
469 val = va_arg (alist, int);
470 for (i = 0; i < val; i++)
476 /* send what's being pointed at */
477 pc = va_arg (alist, char *);
478 val = va_arg (alist, int);
480 SERIAL_WRITE (io, pc, val);
483 /* Send whats in the queue */
486 SERIAL_WRITE (io, buf, dst - buf);
491 pi = va_arg (alist, int *);
506 rdp_write (memaddr, buf, len)
514 send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
525 rdp_read (memaddr, buf, len)
532 send_rdp ("bww-S-P-V",
533 RDP_MEM_READ, memaddr, len,
544 rdp_fetch_one_register (mask, buf)
549 send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
550 store_signed_integer (buf, 4, val);
554 rdp_fetch_one_fpu_register (mask, buf)
559 /* !!! Since the PIE board doesn't work as documented,
560 and it doesn't have FPU hardware anyway and since it
561 slows everything down, I've disabled this. */
563 if (mask == RDP_FPU_READWRITE_MASK_FPS)
565 /* this guy is only a word */
566 send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
567 store_signed_integer (buf, 4, val);
571 /* There are 12 bytes long
572 !! fixme about endianness
574 int dummy; /* I've seen these come back as four words !! */
575 send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
578 memset (buf, 0, MAX_REGISTER_RAW_SIZE);
583 rdp_store_one_register (mask, buf)
587 int val = extract_unsigned_integer (buf, 4);
590 RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
595 rdp_store_one_fpu_register (mask, buf)
600 /* See comment in fetch_one_fpu_register */
601 if (mask == RDP_FPU_READWRITE_MASK_FPS)
603 int val = extract_unsigned_integer (buf, 4);
604 /* this guy is only a word */
605 send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
611 /* There are 12 bytes long
612 !! fixme about endianness
615 /* I've seen these come as four words, not the three advertized !! */
616 printf ("Sending mask %x\n", mask);
617 send_rdp ("bbwwwww-SZ",
626 printf ("done mask %x\n", mask);
632 /* Convert between GDB requests and the RDP layer. */
635 remote_rdp_fetch_register (regno)
640 for (regno = 0; regno < NUM_REGS; regno++)
641 remote_rdp_fetch_register (regno);
645 char buf[MAX_REGISTER_RAW_SIZE];
647 rdp_fetch_one_register (1 << regno, buf);
648 else if (regno == PC_REGNUM)
649 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
650 else if (regno == PS_REGNUM)
651 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
652 else if (regno == FPS_REGNUM)
653 rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
654 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
655 rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
658 printf ("Help me with fetch reg %d\n", regno);
660 supply_register (regno, buf);
666 remote_rdp_store_register (regno)
671 for (regno = 0; regno < NUM_REGS; regno++)
672 remote_rdp_store_register (regno);
676 char tmp[MAX_REGISTER_RAW_SIZE];
677 read_register_gen (regno, tmp);
679 rdp_store_one_register (1 << regno, tmp);
680 else if (regno == PC_REGNUM)
681 rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
682 else if (regno == PS_REGNUM)
683 rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
684 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
685 rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
688 printf ("Help me with reg %d\n", regno);
696 callback->shutdown (callback);
703 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
705 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
707 send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
711 ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
713 ds.rdi_level = (ds.target_info >> 5) & 3;
720 /* Start it off, but don't wait for it */
721 send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
726 rdp_set_command_line (command, args)
731 ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
732 ** don't implement that, and get all confused at the unexpected text.
733 ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
736 if (commandline != NULL)
739 commandline = malloc (strlen (command) + strlen (args) + 2);
740 if (commandline != NULL)
742 strcpy (commandline, command);
743 strcat (commandline, " ");
744 strcat (commandline, args);
752 ** We want the target monitor to intercept the abort vectors
753 ** i.e. stop the program if any of these are used.
755 send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
757 ** Specify a bitmask including
759 ** the undefined instruction vector
760 ** the prefetch abort vector
761 ** the data abort vector
762 ** the address exception vector
764 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5)
787 #define SWI_WriteC 0x0
788 #define SWI_Write0 0x2
789 #define SWI_ReadC 0x4
791 #define SWI_GetEnv 0x10
792 #define SWI_Exit 0x11
793 #define SWI_EnterOS 0x16
795 #define SWI_GetErrno 0x60
796 #define SWI_Clock 0x61
798 #define SWI_Time 0x63
799 #define SWI_Remove 0x64
800 #define SWI_Rename 0x65
801 #define SWI_Open 0x66
803 #define SWI_Close 0x68
804 #define SWI_Write 0x69
805 #define SWI_Read 0x6a
806 #define SWI_Seek 0x6b
807 #define SWI_Flen 0x6c
809 #define SWI_IsTTY 0x6e
810 #define SWI_TmpNam 0x6f
811 #define SWI_InstallHandler 0x70
812 #define SWI_GenerateError 0x71
819 static int translate_open_mode[] =
822 O_RDONLY + O_BINARY, /* "rb" */
824 O_RDWR + O_BINARY, /* "r+b" */
825 O_WRONLY + O_CREAT + O_TRUNC, /* "w" */
826 O_WRONLY + O_BINARY + O_CREAT + O_TRUNC, /* "wb" */
827 O_RDWR + O_CREAT + O_TRUNC, /* "w+" */
828 O_RDWR + O_BINARY + O_CREAT + O_TRUNC, /* "w+b" */
829 O_WRONLY + O_APPEND + O_CREAT, /* "a" */
830 O_WRONLY + O_BINARY + O_APPEND + O_CREAT, /* "ab" */
831 O_RDWR + O_APPEND + O_CREAT, /* "a+" */
832 O_RDWR + O_BINARY + O_APPEND + O_CREAT /* "a+b" */
845 callback->write_stdout (callback, &c, 1);
848 for (i = 0; i < args->n; i++)
849 callback->write_stdout (callback, args->s, strlen (args->s));
852 callback->read_stdin (callback, &c, 1);
856 args->n = callback->system (callback, args->s);
859 args->n = callback->get_errno (callback);
862 args->n = callback->time (callback, NULL);
866 /* return number of centi-seconds... */
868 #ifdef CLOCKS_PER_SEC
869 (CLOCKS_PER_SEC >= 100)
870 ? (clock () / (CLOCKS_PER_SEC / 100))
871 : ((clock () * 100) / CLOCKS_PER_SEC);
873 /* presume unix... clock() returns microseconds */
879 args->n = callback->unlink (callback, args->s);
882 args->n = callback->rename (callback, args[0].s, args[1].s);
886 /* Now we need to decode the Demon open mode */
887 i = translate_open_mode[args[1].n];
889 /* Filename ":tt" is special: it denotes stdin/out */
890 if (strcmp (args->s, ":tt") == 0)
892 if (i == O_RDONLY) /* opening tty "r" */
893 args->n = 0 /* stdin */ ;
895 args->n = 1 /* stdout */ ;
898 args->n = callback->open (callback, args->s, i);
902 args->n = callback->close (callback, args->n);
906 /* Return the number of bytes *not* written */
907 args->n = args[1].n -
908 callback->write (callback, args[0].n, args[1].s, args[1].n);
913 char *copy = alloca (args[2].n);
914 int done = callback->read (callback, args[0].n, copy, args[2].n);
916 remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0);
917 args->n = args[2].n - done;
922 /* Return non-zero on failure */
923 args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
928 long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
929 args->n = callback->lseek (callback, args->n, 0, SEEK_END);
930 callback->lseek (callback, args->n, old, 0);
935 args->n = callback->isatty (callback, args->n);
939 if (commandline != NULL)
941 int len = strlen (commandline);
945 commandline[255] = '\0';
947 remote_rdp_xfer_inferior_memory (args[0].n,
948 commandline, len + 1, 1, 0);
951 remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0);
968 int swino = get_word ();
969 int type = get_byte ();
975 args[count].n = get_byte ();
979 args[count].n = get_word ();
983 /* If the word is under 32 bytes it will be sent otherwise
984 an address to it is passed. Also: Special case of 255 */
994 remote_rdp_xfer_inferior_memory (get_word (),
1003 buf = alloca (len + 1);
1004 for (i = 0; i < len; i++)
1005 buf[i] = get_byte ();
1008 args[count].n = len;
1009 args[count].s = buf;
1013 error ("Unimplented SWI argument");
1020 if (exec_swi (swino, args))
1022 /* We have two options here reply with either a byte or a word
1023 which is stored in args[0].n. There is no harm in replying with
1024 a word all the time, so thats what I do! */
1025 send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
1029 send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
1034 rdp_execute_finish ()
1041 res = SERIAL_READCHAR (io, 1);
1042 while (res == SERIAL_TIMEOUT)
1045 printf_filtered ("Waiting for target..\n");
1046 res = SERIAL_READCHAR (io, 1);
1055 send_rdp ("B", &ds.rdi_stopped_status);
1059 printf_filtered ("Target reset\n");
1063 printf_filtered ("Ignoring %x\n", res);
1073 rdp_execute_start ();
1074 rdp_execute_finish ();
1078 remote_rdp_insert_breakpoint (addr, save)
1083 if (ds.rdi_level > 0)
1085 send_rdp ("bwb-SWB",
1088 RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
1097 RDP_SET_BREAK_TYPE_PC_EQUAL,
1104 remote_rdp_remove_breakpoint (addr, save)
1109 if (ds.rdi_level > 0)
1111 send_rdp ("b-p-S-B",
1129 if (ds.can_step && 0)
1131 /* The pie board can't do steps so I can't test this, and
1132 the other code will always work. */
1134 send_rdp ("bbw-S-B",
1141 CORE_ADDR pc = read_register (PC_REGNUM);
1142 pc = arm_get_next_pc (pc);
1143 remote_rdp_insert_breakpoint (pc, &handle);
1145 remote_rdp_remove_breakpoint (pc, &handle);
1150 remote_rdp_open (args, from_tty)
1157 error_no_arg ("serial port device name");
1161 target_preopen (from_tty);
1163 io = SERIAL_OPEN (args);
1166 perror_with_name (args);
1170 rdp_init (1, from_tty);
1175 printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
1180 /* Need to set up the vector interception state */
1181 rdp_catch_vectors ();
1184 ** If it's an EmbeddedICE, we need to set the processor config.
1185 ** Assume we can always have ARM7TDI...
1187 send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, ¬_icebreaker);
1188 if (!not_icebreaker)
1190 const char *CPU = "ARM7TDI";
1192 int len = strlen (CPU);
1194 send_rdp ("bbbbw-p-SWZ",
1196 RDI_ConfigCPU, /* Aspect: set the CPU */
1197 len, /* The number of bytes in the name */
1198 RDI_MatchAny, /* We'll take whatever we get */
1199 0, /* We'll take whatever version's there */
1204 /* command line initialised on 'run' */
1206 push_target (&remote_rdp_ops);
1208 callback->init (callback);
1209 flush_cached_frames ();
1210 registers_changed ();
1211 stop_pc = read_pc ();
1212 set_current_frame (create_new_frame (read_fp (), stop_pc));
1213 select_frame (get_current_frame (), 0);
1214 print_stack_frame (selected_frame, -1, 1);
1219 /* Close out all files and local state before this target loses control. */
1222 remote_rdp_close (quitting)
1225 callback->shutdown (callback);
1232 /* Resume execution of the target process. STEP says whether to single-step
1233 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
1234 to the target, or zero for no signal. */
1237 remote_rdp_resume (pid, step, siggnal)
1239 enum target_signal siggnal;
1247 /* Wait for inferior process to do something. Return pid of child,
1248 or -1 in case of error; store status through argument pointer STATUS,
1249 just as `wait' would. */
1252 remote_rdp_wait (pid, status)
1254 struct target_waitstatus *status;
1256 switch (ds.rdi_stopped_status)
1261 status->kind = TARGET_WAITKIND_EXITED;
1262 status->value.integer = read_register (0);
1264 case RDP_RES_AT_BREAKPOINT:
1265 status->kind = TARGET_WAITKIND_STOPPED;
1266 /* The signal in sigrc is a host signal. That probably
1268 status->value.sig = TARGET_SIGNAL_TRAP;
1272 status->kind = TARGET_WAITKIND_SIGNALLED;
1273 /* The signal in sigrc is a host signal. That probably
1275 status->value.sig = target_signal_from_host (sigrc);
1280 return inferior_pid;
1283 /* Get ready to modify the registers array. On machines which store
1284 individual registers, this doesn't need to do anything. On machines
1285 which store all the registers in one fell swoop, this makes sure
1286 that registers contains all the registers from the program being
1290 remote_rdp_prepare_to_store ()
1292 /* Do nothing, since we can store individual regs */
1296 remote_rdp_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1301 struct target_ops *target; /* ignored */
1303 /* I infer from D Taylor's code that there's a limit on the amount
1304 we can transfer in one chunk.. */
1309 int thisbite = len - done;
1310 if (thisbite > RDP_MOUTHFULL)
1311 thisbite = RDP_MOUTHFULL;
1317 justdone = rdp_write (memaddr + done, myaddr + done, thisbite);
1321 justdone = rdp_read (memaddr + done, myaddr + done, thisbite);
1326 if (justdone != thisbite)
1339 static struct yn stepinfo[] =
1341 {"Step more than one instruction", RDP_INFO_ABOUT_STEP_GT_1},
1342 {"Step to jump", RDP_INFO_ABOUT_STEP_TO_JMP},
1343 {"Step one instruction", RDP_INFO_ABOUT_STEP_1},
1347 static struct yn breakinfo[] =
1349 {"comparison breakpoints supported", RDP_INFO_ABOUT_BREAK_COMP},
1350 {"range breakpoints supported", RDP_INFO_ABOUT_BREAK_RANGE},
1351 {"watchpoints for byte reads supported", RDP_INFO_ABOUT_BREAK_BYTE_READ},
1352 {"watchpoints for half-word reads supported", RDP_INFO_ABOUT_BREAK_HALFWORD_READ},
1353 {"watchpoints for word reads supported", RDP_INFO_ABOUT_BREAK_WORD_READ},
1354 {"watchpoints for byte writes supported", RDP_INFO_ABOUT_BREAK_BYTE_WRITE},
1355 {"watchpoints for half-word writes supported", RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE},
1356 {"watchpoints for word writes supported", RDP_INFO_ABOUT_BREAK_WORD_WRITE},
1357 {"mask break/watch-points supported", RDP_INFO_ABOUT_BREAK_MASK},
1358 {"thread-specific breakpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_BREAK},
1359 {"thread-specific watchpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_WATCH},
1360 {"conditional breakpoints supported", RDP_INFO_ABOUT_BREAK_COND},
1372 printf_unfiltered (" %-45s : %s\n", t->name, (info & t->bit) ? "Yes" : "No");
1378 remote_rdp_files_info (target)
1379 struct target_ops *target;
1381 printf_filtered ("Target capabilities:\n");
1382 dump_bits (stepinfo, ds.step_info);
1383 dump_bits (breakinfo, ds.break_info);
1384 printf_unfiltered ("target level RDI %x\n", (ds.target_info >> 5) & 3);
1389 remote_rdp_create_inferior (exec_file, allargs, env)
1394 CORE_ADDR entry_point;
1396 if (exec_file == 0 || exec_bfd == 0)
1397 error ("No executable file specified.");
1399 entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1402 remove_breakpoints ();
1403 init_wait_for_inferior ();
1405 /* This gives us a chance to set up the command line */
1406 rdp_set_command_line (exec_file, allargs);
1409 insert_breakpoints (); /* Needed to get correct instruction in cache */
1412 ** RDP targets don't provide any facility to set the top of memory,
1413 ** so we don't bother to look for MEMSIZE in the environment.
1417 proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
1420 /* Accept any stray run/attach commands */
1422 remote_rdp_can_run ()
1427 /* Attach doesn't need to do anything */
1429 remote_rdp_attach (args, from_tty)
1436 /* Define the target subroutine names */
1438 struct target_ops remote_rdp_ops;
1441 init_remote_rdp_ops (void)
1443 remote_rdp_ops.to_shortname = "rdp";
1444 remote_rdp_ops.to_longname = "Remote Target using the RDProtocol";
1445 remote_rdp_ops.to_doc = "Use a remote ARM system which uses the ARM Remote Debugging Protocol";
1446 remote_rdp_ops.to_open = remote_rdp_open;
1447 remote_rdp_ops.to_close = remote_rdp_close;
1448 remote_rdp_ops.to_attach = remote_rdp_attach;
1449 remote_rdp_ops.to_post_attach = NULL;
1450 remote_rdp_ops.to_require_attach = NULL;
1451 remote_rdp_ops.to_detach = NULL;
1452 remote_rdp_ops.to_require_detach = NULL;
1453 remote_rdp_ops.to_resume = remote_rdp_resume;
1454 remote_rdp_ops.to_wait = remote_rdp_wait;
1455 remote_rdp_ops.to_post_wait = NULL;
1456 remote_rdp_ops.to_fetch_registers = remote_rdp_fetch_register;
1457 remote_rdp_ops.to_store_registers = remote_rdp_store_register;
1458 remote_rdp_ops.to_prepare_to_store = remote_rdp_prepare_to_store;
1459 remote_rdp_ops.to_xfer_memory = remote_rdp_xfer_inferior_memory;
1460 remote_rdp_ops.to_files_info = remote_rdp_files_info;
1461 remote_rdp_ops.to_insert_breakpoint = remote_rdp_insert_breakpoint;
1462 remote_rdp_ops.to_remove_breakpoint = remote_rdp_remove_breakpoint;
1463 remote_rdp_ops.to_terminal_init = NULL;
1464 remote_rdp_ops.to_terminal_inferior = NULL;
1465 remote_rdp_ops.to_terminal_ours_for_output = NULL;
1466 remote_rdp_ops.to_terminal_ours = NULL;
1467 remote_rdp_ops.to_terminal_info = NULL;
1468 remote_rdp_ops.to_kill = remote_rdp_kill;
1469 remote_rdp_ops.to_load = generic_load;
1470 remote_rdp_ops.to_lookup_symbol = NULL;
1471 remote_rdp_ops.to_create_inferior = remote_rdp_create_inferior;
1472 remote_rdp_ops.to_post_startup_inferior = NULL;
1473 remote_rdp_ops.to_acknowledge_created_inferior = NULL;
1474 remote_rdp_ops.to_clone_and_follow_inferior = NULL;
1475 remote_rdp_ops.to_post_follow_inferior_by_clone = NULL;
1476 remote_rdp_ops.to_insert_fork_catchpoint = NULL;
1477 remote_rdp_ops.to_remove_fork_catchpoint = NULL;
1478 remote_rdp_ops.to_insert_vfork_catchpoint = NULL;
1479 remote_rdp_ops.to_remove_vfork_catchpoint = NULL;
1480 remote_rdp_ops.to_has_forked = NULL;
1481 remote_rdp_ops.to_has_vforked = NULL;
1482 remote_rdp_ops.to_can_follow_vfork_prior_to_exec = NULL;
1483 remote_rdp_ops.to_post_follow_vfork = NULL;
1484 remote_rdp_ops.to_insert_exec_catchpoint = NULL;
1485 remote_rdp_ops.to_remove_exec_catchpoint = NULL;
1486 remote_rdp_ops.to_has_execd = NULL;
1487 remote_rdp_ops.to_reported_exec_events_per_exec_call = NULL;
1488 remote_rdp_ops.to_has_exited = NULL;
1489 remote_rdp_ops.to_mourn_inferior = generic_mourn_inferior;
1490 remote_rdp_ops.to_can_run = remote_rdp_can_run;
1491 remote_rdp_ops.to_notice_signals = 0;
1492 remote_rdp_ops.to_thread_alive = 0;
1493 remote_rdp_ops.to_stop = 0;
1494 remote_rdp_ops.to_pid_to_exec_file = NULL;
1495 remote_rdp_ops.to_core_file_to_sym_file = NULL;
1496 remote_rdp_ops.to_stratum = process_stratum;
1497 remote_rdp_ops.DONT_USE = NULL;
1498 remote_rdp_ops.to_has_all_memory = 1;
1499 remote_rdp_ops.to_has_memory = 1;
1500 remote_rdp_ops.to_has_stack = 1;
1501 remote_rdp_ops.to_has_registers = 1;
1502 remote_rdp_ops.to_has_execution = 1;
1503 remote_rdp_ops.to_sections = NULL;
1504 remote_rdp_ops.to_sections_end = NULL;
1505 remote_rdp_ops.to_magic = OPS_MAGIC;
1509 _initialize_remote_rdp ()
1511 init_remote_rdp_ops ();
1512 add_target (&remote_rdp_ops);