1 /* Remote debugging for the ARM RDP interface.
2 Copyright 1994, 1995, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
27 Much of this file (in particular the SWI stuff) is based on code by
30 I hacked on and simplified it by removing a lot of sexy features he
31 had added, and some of the (unix specific) workarounds he'd done
32 for other GDB problems - which if they still exist should be fixed
33 in GDB, not in a remote-foo thing . I also made it conform more to
34 the doc I have; which may be wrong.
48 #include "remote-utils.h"
49 #include "gdb_string.h"
58 extern struct target_ops remote_rdp_ops;
59 static struct serial *io;
60 static host_callback *callback = &default_callback;
69 char command_line[10];
71 int rdi_stopped_status;
77 /* Definitions for the RDP protocol. */
79 #define RDP_MOUTHFULL (1<<6)
80 #define FPU_COPRO_NUMBER 1
83 #define RDP_OPEN_TYPE_COLD 0
84 #define RDP_OPEN_TYPE_WARM 1
85 #define RDP_OPEN_TYPE_BAUDRATE 2
87 #define RDP_OPEN_BAUDRATE_9600 1
88 #define RDP_OPEN_BAUDRATE_19200 2
89 #define RDP_OPEN_BAUDRATE_38400 3
91 #define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
95 #define RDP_MEM_READ 2
97 #define RDP_MEM_WRITE 3
99 #define RDP_CPU_READ 4
100 #define RDP_CPU_WRITE 5
101 #define RDP_CPU_READWRITE_MODE_CURRENT 255
102 #define RDP_CPU_READWRITE_MASK_PC (1<<16)
103 #define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
104 #define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
106 #define RDP_COPRO_READ 6
107 #define RDP_COPRO_WRITE 7
108 #define RDP_FPU_READWRITE_MASK_FPS (1<<8)
110 #define RDP_SET_BREAK 0xa
111 #define RDP_SET_BREAK_TYPE_PC_EQUAL 0
112 #define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
114 #define RDP_CLEAR_BREAK 0xb
116 #define RDP_EXEC 0x10
117 #define RDP_EXEC_TYPE_SYNC 0
119 #define RDP_STEP 0x11
121 #define RDP_INFO 0x12
122 #define RDP_INFO_ABOUT_STEP 2
123 #define RDP_INFO_ABOUT_STEP_GT_1 1
124 #define RDP_INFO_ABOUT_STEP_TO_JMP 2
125 #define RDP_INFO_ABOUT_STEP_1 4
126 #define RDP_INFO_ABOUT_TARGET 0
127 #define RDP_INFO_ABOUT_BREAK 1
128 #define RDP_INFO_ABOUT_BREAK_COMP 1
129 #define RDP_INFO_ABOUT_BREAK_RANGE 2
130 #define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
131 #define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
132 #define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
133 #define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
134 #define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
135 #define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
136 #define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
137 #define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
138 #define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
139 #define RDP_INFO_ABOUT_BREAK_COND (1<<11)
140 #define RDP_INFO_VECTOR_CATCH (0x180)
141 #define RDP_INFO_ICEBREAKER (7)
142 #define RDP_INFO_SET_CMDLINE (0x300)
144 #define RDP_SELECT_CONFIG (0x16)
145 #define RDI_ConfigCPU 0
146 #define RDI_ConfigSystem 1
147 #define RDI_MatchAny 0
148 #define RDI_MatchExactly 1
149 #define RDI_MatchNoEarlier 2
151 #define RDP_RESET 0x7f
153 /* Returns from RDP */
154 #define RDP_RES_STOPPED 0x20
155 #define RDP_RES_SWI 0x21
156 #define RDP_RES_FATAL 0x5e
157 #define RDP_RES_VALUE 0x5f
158 #define RDP_RES_VALUE_LITTLE_ENDIAN 240
159 #define RDP_RES_VALUE_BIG_ENDIAN 241
160 #define RDP_RES_RESET 0x7f
161 #define RDP_RES_AT_BREAKPOINT 143
162 #define RDP_RES_IDUNNO 0xe6
163 #define RDP_OSOpReply 0x13
164 #define RDP_OSOpWord 2
165 #define RDP_OSOpNothing 0
167 static int timeout = 2;
169 static char *commandline = NULL;
172 remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
174 struct mem_attrib *attrib,
175 struct target_ops *target);
178 /* Stuff for talking to the serial layer. */
183 int c = serial_readchar (io, timeout);
186 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", c);
188 if (c == SERIAL_TIMEOUT)
191 return (unsigned char) c;
193 error ("Timeout reading from remote_system");
199 /* Note that the target always speaks little-endian to us,
200 even if it's a big endian machine. */
204 unsigned int val = 0;
207 for (n = 0; n < 4; n++)
219 fprintf_unfiltered (gdb_stdlog, "(%02x)\n", val);
220 serial_write (io, &val, 1);
226 /* We always send in little endian */
234 fprintf_unfiltered (gdb_stdlog, "(%04x)", val);
236 serial_write (io, b, 4);
241 /* Stuff for talking to the RDP layer. */
243 /* This is a bit more fancy that need be so that it syncs even in nasty cases.
245 I'be been unable to make it reliably sync up with the change
246 baudrate open command. It likes to sit and say it's been reset,
247 with no more action. So I took all that code out. I'd rather sync
248 reliably at 9600 than wait forever for a possible 19200 connection.
252 rdp_init (int cold, int tty)
255 int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
258 time_t now = time (0);
259 time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
262 while (time (0) < stop_time && !sync)
267 serial_flush_input (io);
268 serial_flush_output (io);
271 printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
274 ** It seems necessary to reset an EmbeddedICE to get it going.
275 ** This has the side benefit of displaying the startup banner.
279 put_byte (RDP_RESET);
280 while ((restype = serial_readchar (io, 1)) > 0)
287 /* Sent at start of reset process: ignore */
290 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
297 /* Got end-of-banner mark */
298 printf_filtered ("\n");
304 put_byte (type | RDP_OPEN_TYPE_RETURN_SEX);
307 while (!sync && (restype = serial_readchar (io, 1)) > 0)
310 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", restype);
318 while ((restype = serial_readchar (io, 1)) == RDP_RESET)
322 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
324 while ((restype = serial_readchar (io, 1)) > 0);
328 printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
329 printf_unfiltered ("Waiting for it to settle down...\n");
333 printf_unfiltered ("\nTrying again.\n");
342 int resval = serial_readchar (io, 1);
345 fprintf_unfiltered (gdb_stdlog, "[%02x]\n", resval);
351 case RDP_RES_VALUE_LITTLE_ENDIAN:
352 target_byte_order = LITTLE_ENDIAN;
355 case RDP_RES_VALUE_BIG_ENDIAN:
356 target_byte_order = BIG_ENDIAN;
369 error ("Couldn't reset the board, try pressing the reset button");
375 send_rdp (char *template,...)
380 va_start (alist, template);
392 val = va_arg (alist, int);
396 val = va_arg (alist, int);
404 if (val != RDP_RES_VALUE)
406 printf_unfiltered ("got bad res value of %d, %x\n", val, val);
410 pstat = va_arg (alist, int *);
411 pi = va_arg (alist, int *);
413 *pstat = get_byte ();
414 /* Check the result was zero, if not read the syndrome */
421 /* Check the result code */
428 /* Target can't do it; never mind */
429 printf_unfiltered ("RDP: Insufficient privilege\n");
432 /* Target can't do it; never mind */
433 printf_unfiltered ("RDP: Unimplemented message\n");
436 error ("Command garbled");
439 error ("Corrupt reply from target");
444 /* Read a word from the target */
445 pi = va_arg (alist, int *);
449 /* Read in some bytes from the target. */
450 pc = va_arg (alist, char *);
451 val = va_arg (alist, int);
452 for (i = 0; i < val; i++)
458 /* send what's being pointed at */
459 pc = va_arg (alist, char *);
460 val = va_arg (alist, int);
462 serial_write (io, pc, val);
465 /* Send whats in the queue */
468 serial_write (io, buf, dst - buf);
473 pi = va_arg (alist, int *);
477 internal_error (__FILE__, __LINE__, "failed internal consistency check");
483 internal_error (__FILE__, __LINE__, "failed internal consistency check");
488 rdp_write (CORE_ADDR memaddr, char *buf, int len)
493 send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
504 rdp_read (CORE_ADDR memaddr, char *buf, int len)
508 send_rdp ("bww-S-P-V",
509 RDP_MEM_READ, memaddr, len,
520 rdp_fetch_one_register (int mask, char *buf)
523 send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
524 store_signed_integer (buf, 4, val);
528 rdp_fetch_one_fpu_register (int mask, char *buf)
531 /* !!! Since the PIE board doesn't work as documented,
532 and it doesn't have FPU hardware anyway and since it
533 slows everything down, I've disabled this. */
535 if (mask == RDP_FPU_READWRITE_MASK_FPS)
537 /* this guy is only a word */
538 send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
539 store_signed_integer (buf, 4, val);
543 /* There are 12 bytes long
544 !! fixme about endianness
546 int dummy; /* I've seen these come back as four words !! */
547 send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
550 memset (buf, 0, MAX_REGISTER_RAW_SIZE);
555 rdp_store_one_register (int mask, char *buf)
557 int val = extract_unsigned_integer (buf, 4);
560 RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
565 rdp_store_one_fpu_register (int mask, char *buf)
568 /* See comment in fetch_one_fpu_register */
569 if (mask == RDP_FPU_READWRITE_MASK_FPS)
571 int val = extract_unsigned_integer (buf, 4);
572 /* this guy is only a word */
573 send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
579 /* There are 12 bytes long
580 !! fixme about endianness
583 /* I've seen these come as four words, not the three advertized !! */
584 printf ("Sending mask %x\n", mask);
585 send_rdp ("bbwwwww-SZ",
594 printf ("done mask %x\n", mask);
600 /* Convert between GDB requests and the RDP layer. */
603 remote_rdp_fetch_register (int regno)
607 for (regno = 0; regno < NUM_REGS; regno++)
608 remote_rdp_fetch_register (regno);
612 char buf[MAX_REGISTER_RAW_SIZE];
614 rdp_fetch_one_register (1 << regno, buf);
615 else if (regno == PC_REGNUM)
616 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
617 else if (regno == PS_REGNUM)
618 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
619 else if (regno == FPS_REGNUM)
620 rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
621 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
622 rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
625 printf ("Help me with fetch reg %d\n", regno);
627 supply_register (regno, buf);
633 remote_rdp_store_register (int regno)
637 for (regno = 0; regno < NUM_REGS; regno++)
638 remote_rdp_store_register (regno);
642 char tmp[MAX_REGISTER_RAW_SIZE];
643 read_register_gen (regno, tmp);
645 rdp_store_one_register (1 << regno, tmp);
646 else if (regno == PC_REGNUM)
647 rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
648 else if (regno == PS_REGNUM)
649 rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
650 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
651 rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
654 printf ("Help me with reg %d\n", regno);
660 remote_rdp_kill (void)
662 callback->shutdown (callback);
669 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
671 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
673 send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
677 ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
679 ds.rdi_level = (ds.target_info >> 5) & 3;
684 rdp_execute_start (void)
686 /* Start it off, but don't wait for it */
687 send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
692 rdp_set_command_line (char *command, char *args)
695 ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
696 ** don't implement that, and get all confused at the unexpected text.
697 ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
700 if (commandline != NULL)
703 xasprintf (&commandline, "%s %s", command, args);
707 rdp_catch_vectors (void)
710 ** We want the target monitor to intercept the abort vectors
711 ** i.e. stop the program if any of these are used.
713 send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
715 ** Specify a bitmask including
717 ** the undefined instruction vector
718 ** the prefetch abort vector
719 ** the data abort vector
720 ** the address exception vector
722 (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5)
745 #define SWI_WriteC 0x0
746 #define SWI_Write0 0x2
747 #define SWI_ReadC 0x4
749 #define SWI_GetEnv 0x10
750 #define SWI_Exit 0x11
751 #define SWI_EnterOS 0x16
753 #define SWI_GetErrno 0x60
754 #define SWI_Clock 0x61
756 #define SWI_Time 0x63
757 #define SWI_Remove 0x64
758 #define SWI_Rename 0x65
759 #define SWI_Open 0x66
761 #define SWI_Close 0x68
762 #define SWI_Write 0x69
763 #define SWI_Read 0x6a
764 #define SWI_Seek 0x6b
765 #define SWI_Flen 0x6c
767 #define SWI_IsTTY 0x6e
768 #define SWI_TmpNam 0x6f
769 #define SWI_InstallHandler 0x70
770 #define SWI_GenerateError 0x71
777 static int translate_open_mode[] =
780 O_RDONLY + O_BINARY, /* "rb" */
782 O_RDWR + O_BINARY, /* "r+b" */
783 O_WRONLY + O_CREAT + O_TRUNC, /* "w" */
784 O_WRONLY + O_BINARY + O_CREAT + O_TRUNC, /* "wb" */
785 O_RDWR + O_CREAT + O_TRUNC, /* "w+" */
786 O_RDWR + O_BINARY + O_CREAT + O_TRUNC, /* "w+b" */
787 O_WRONLY + O_APPEND + O_CREAT, /* "a" */
788 O_WRONLY + O_BINARY + O_APPEND + O_CREAT, /* "ab" */
789 O_RDWR + O_APPEND + O_CREAT, /* "a+" */
790 O_RDWR + O_BINARY + O_APPEND + O_CREAT /* "a+b" */
794 exec_swi (int swi, argsin *args)
801 callback->write_stdout (callback, &c, 1);
804 for (i = 0; i < args->n; i++)
805 callback->write_stdout (callback, args->s, strlen (args->s));
808 callback->read_stdin (callback, &c, 1);
812 args->n = callback->system (callback, args->s);
815 args->n = callback->get_errno (callback);
818 args->n = callback->time (callback, NULL);
822 /* return number of centi-seconds... */
824 #ifdef CLOCKS_PER_SEC
825 (CLOCKS_PER_SEC >= 100)
826 ? (clock () / (CLOCKS_PER_SEC / 100))
827 : ((clock () * 100) / CLOCKS_PER_SEC);
829 /* presume unix... clock() returns microseconds */
835 args->n = callback->unlink (callback, args->s);
838 args->n = callback->rename (callback, args[0].s, args[1].s);
842 /* Now we need to decode the Demon open mode */
843 i = translate_open_mode[args[1].n];
845 /* Filename ":tt" is special: it denotes stdin/out */
846 if (strcmp (args->s, ":tt") == 0)
848 if (i == O_RDONLY) /* opening tty "r" */
849 args->n = 0 /* stdin */ ;
851 args->n = 1 /* stdout */ ;
854 args->n = callback->open (callback, args->s, i);
858 args->n = callback->close (callback, args->n);
862 /* Return the number of bytes *not* written */
863 args->n = args[1].n -
864 callback->write (callback, args[0].n, args[1].s, args[1].n);
869 char *copy = alloca (args[2].n);
870 int done = callback->read (callback, args[0].n, copy, args[2].n);
872 remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0, 0);
873 args->n = args[2].n - done;
878 /* Return non-zero on failure */
879 args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
884 long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
885 args->n = callback->lseek (callback, args->n, 0, SEEK_END);
886 callback->lseek (callback, args->n, old, 0);
891 args->n = callback->isatty (callback, args->n);
895 if (commandline != NULL)
897 int len = strlen (commandline);
901 commandline[255] = '\0';
903 remote_rdp_xfer_inferior_memory (args[0].n,
904 commandline, len + 1, 1, 0, 0);
907 remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0, 0);
924 int swino = get_word ();
925 int type = get_byte ();
931 args[count].n = get_byte ();
935 args[count].n = get_word ();
939 /* If the word is under 32 bytes it will be sent otherwise
940 an address to it is passed. Also: Special case of 255 */
950 remote_rdp_xfer_inferior_memory (get_word (),
960 buf = alloca (len + 1);
961 for (i = 0; i < len; i++)
962 buf[i] = get_byte ();
970 error ("Unimplemented SWI argument");
977 if (exec_swi (swino, args))
979 /* We have two options here reply with either a byte or a word
980 which is stored in args[0].n. There is no harm in replying with
981 a word all the time, so thats what I do! */
982 send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
986 send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
991 rdp_execute_finish (void)
998 res = serial_readchar (io, 1);
999 while (res == SERIAL_TIMEOUT)
1002 printf_filtered ("Waiting for target..\n");
1003 res = serial_readchar (io, 1);
1012 send_rdp ("B", &ds.rdi_stopped_status);
1016 printf_filtered ("Target reset\n");
1020 printf_filtered ("Ignoring %x\n", res);
1030 rdp_execute_start ();
1031 rdp_execute_finish ();
1035 remote_rdp_insert_breakpoint (CORE_ADDR addr, char *save)
1038 if (ds.rdi_level > 0)
1040 send_rdp ("bwb-SWB",
1043 RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
1052 RDP_SET_BREAK_TYPE_PC_EQUAL,
1059 remote_rdp_remove_breakpoint (CORE_ADDR addr, char *save)
1062 if (ds.rdi_level > 0)
1064 send_rdp ("b-p-S-B",
1082 if (ds.can_step && 0)
1084 /* The pie board can't do steps so I can't test this, and
1085 the other code will always work. */
1087 send_rdp ("bbw-S-B",
1094 CORE_ADDR pc = read_register (PC_REGNUM);
1095 pc = arm_get_next_pc (pc);
1096 remote_rdp_insert_breakpoint (pc, handle);
1098 remote_rdp_remove_breakpoint (pc, handle);
1103 remote_rdp_open (char *args, int from_tty)
1108 error_no_arg ("serial port device name");
1112 target_preopen (from_tty);
1114 io = serial_open (args);
1117 perror_with_name (args);
1121 rdp_init (1, from_tty);
1126 printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
1131 /* Need to set up the vector interception state */
1132 rdp_catch_vectors ();
1135 ** If it's an EmbeddedICE, we need to set the processor config.
1136 ** Assume we can always have ARM7TDI...
1138 send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, ¬_icebreaker);
1139 if (!not_icebreaker)
1141 const char *CPU = "ARM7TDI";
1143 int len = strlen (CPU);
1145 send_rdp ("bbbbw-p-SWZ",
1147 RDI_ConfigCPU, /* Aspect: set the CPU */
1148 len, /* The number of bytes in the name */
1149 RDI_MatchAny, /* We'll take whatever we get */
1150 0, /* We'll take whatever version's there */
1155 /* command line initialised on 'run' */
1157 push_target (&remote_rdp_ops);
1159 callback->init (callback);
1160 flush_cached_frames ();
1161 registers_changed ();
1162 stop_pc = read_pc ();
1163 set_current_frame (create_new_frame (read_fp (), stop_pc));
1164 select_frame (get_current_frame (), 0);
1165 print_stack_frame (selected_frame, -1, 1);
1170 /* Close out all files and local state before this target loses control. */
1173 remote_rdp_close (int quitting)
1175 callback->shutdown (callback);
1182 /* Resume execution of the target process. STEP says whether to single-step
1183 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
1184 to the target, or zero for no signal. */
1187 remote_rdp_resume (ptid_t ptid, int step, enum target_signal siggnal)
1195 /* Wait for inferior process to do something. Return pid of child,
1196 or -1 in case of error; store status through argument pointer STATUS,
1197 just as `wait' would. */
1200 remote_rdp_wait (ptid_t ptid, struct target_waitstatus *status)
1202 switch (ds.rdi_stopped_status)
1207 status->kind = TARGET_WAITKIND_EXITED;
1208 status->value.integer = read_register (0);
1210 case RDP_RES_AT_BREAKPOINT:
1211 status->kind = TARGET_WAITKIND_STOPPED;
1212 /* The signal in sigrc is a host signal. That probably
1214 status->value.sig = TARGET_SIGNAL_TRAP;
1218 status->kind = TARGET_WAITKIND_SIGNALLED;
1219 /* The signal in sigrc is a host signal. That probably
1221 status->value.sig = target_signal_from_host (sigrc);
1226 return inferior_ptid;
1229 /* Get ready to modify the registers array. On machines which store
1230 individual registers, this doesn't need to do anything. On machines
1231 which store all the registers in one fell swoop, this makes sure
1232 that registers contains all the registers from the program being
1236 remote_rdp_prepare_to_store (void)
1238 /* Do nothing, since we can store individual regs */
1241 /* Transfer LEN bytes between GDB address MYADDR and target address
1242 MEMADDR. If WRITE is non-zero, transfer them to the target,
1243 otherwise transfer them from the target. TARGET is unused.
1245 Returns the number of bytes transferred. */
1248 remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
1250 struct mem_attrib *attrib ATTRIBUTE_UNUSED,
1251 struct target_ops *target ATTRIBUTE_UNUSED)
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);