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, Boston, MA 02111-1307, USA.
25 Much of this file (in particular the SWI stuff) is based on code by
28 I hacked on and simplified it by removing a lot of sexy features he
29 had added, and some of the (unix specific) workarounds he'd done
30 for other GDB problems - which if they still exist should be fixed
31 in GDB, not in a remote-foo thing . I also made it conform more to
32 the doc I have; which may be wrong.
44 #ifdef ANSI_PROTOTYPES
52 #include "remote-utils.h"
53 #include "gdb_string.h"
60 extern struct target_ops remote_rdp_ops;
62 static host_callback *callback = &default_callback;
71 char command_line[10];
73 int rdi_stopped_status;
79 /* Definitions for the RDP protocol. */
81 #define RDP_MOUTHFULL (1<<6)
82 #define FPU_COPRO_NUMBER 1
85 #define RDP_OPEN_TYPE_COLD 0
86 #define RDP_OPEN_TYPE_WARM 1
87 #define RDP_OPEN_TYPE_BAUDRATE 2
89 #define RDP_OPEN_BAUDRATE_9600 1
90 #define RDP_OPEN_BAUDRATE_19200 2
91 #define RDP_OPEN_BAUDRATE_38400 3
93 #define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
97 #define RDP_MEM_READ 2
99 #define RDP_MEM_WRITE 3
101 #define RDP_CPU_READ 4
102 #define RDP_CPU_WRITE 5
103 #define RDP_CPU_READWRITE_MODE_CURRENT 255
104 #define RDP_CPU_READWRITE_MASK_PC (1<<16)
105 #define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
106 #define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
108 #define RDP_COPRO_READ 6
109 #define RDP_COPRO_WRITE 7
110 #define RDP_FPU_READWRITE_MASK_FPS (1<<8)
112 #define RDP_SET_BREAK 0xa
113 #define RDP_SET_BREAK_TYPE_PC_EQUAL 0
114 #define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
116 #define RDP_CLEAR_BREAK 0xb
118 #define RDP_EXEC 0x10
119 #define RDP_EXEC_TYPE_SYNC 0
121 #define RDP_STEP 0x11
123 #define RDP_INFO 0x12
124 #define RDP_INFO_ABOUT_STEP 2
125 #define RDP_INFO_ABOUT_STEP_GT_1 1
126 #define RDP_INFO_ABOUT_STEP_TO_JMP 2
127 #define RDP_INFO_ABOUT_STEP_1 4
128 #define RDP_INFO_ABOUT_TARGET 0
129 #define RDP_INFO_ABOUT_BREAK 1
130 #define RDP_INFO_ABOUT_BREAK_COMP 1
131 #define RDP_INFO_ABOUT_BREAK_RANGE 2
132 #define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
133 #define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
134 #define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
135 #define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
136 #define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
137 #define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
138 #define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
139 #define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
140 #define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
141 #define RDP_INFO_ABOUT_BREAK_COND (1<<11)
142 #define RDP_INFO_VECTOR_CATCH (0x180)
143 #define RDP_INFO_ICEBREAKER (7)
144 #define RDP_INFO_SET_CMDLINE (0x300)
146 #define RDP_SELECT_CONFIG (0x16)
147 #define RDI_ConfigCPU 0
148 #define RDI_ConfigSystem 1
149 #define RDI_MatchAny 0
150 #define RDI_MatchExactly 1
151 #define RDI_MatchNoEarlier 2
153 #define RDP_RESET 0x7f
155 /* Returns from RDP */
156 #define RDP_RES_STOPPED 0x20
157 #define RDP_RES_SWI 0x21
158 #define RDP_RES_FATAL 0x5e
159 #define RDP_RES_VALUE 0x5f
160 #define RDP_RES_VALUE_LITTLE_ENDIAN 240
161 #define RDP_RES_VALUE_BIG_ENDIAN 241
162 #define RDP_RES_RESET 0x7f
163 #define RDP_RES_AT_BREAKPOINT 143
164 #define RDP_RES_IDUNNO 0xe6
165 #define RDP_OSOpReply 0x13
166 #define RDP_OSOpWord 2
167 #define RDP_OSOpNothing 0
169 static int timeout = 2;
171 static char * commandline = NULL;
174 remote_rdp_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
178 struct target_ops * target));
181 /* Stuff for talking to the serial layer. */
186 int c = SERIAL_READCHAR (io, timeout);
189 printf ("[%02x]\n", c);
191 if (c == SERIAL_TIMEOUT)
194 return (unsigned char) c;
196 error ("Timeout reading from remote_system");
202 /* Note that the target always speaks little-endian to us,
203 even if it's a big endian machine. */
207 unsigned int val = 0;
210 for (n = 0; n < 4; n++)
223 printf ("(%02x)\n", val);
224 SERIAL_WRITE (io, &val, 1);
231 /* We always send in little endian */
239 printf ("(%04x)", val);
241 SERIAL_WRITE (io, b, 4);
246 /* Stuff for talking to the RDP layer. */
248 /* This is a bit more fancy that need be so that it syncs even in nasty cases.
250 I'be been unable to make it reliably sync up with the change
251 baudrate open command. It likes to sit and say it's been reset,
252 with no more action. So I took all that code out. I'd rather sync
253 reliably at 9600 than wait forever for a possible 19200 connection.
262 int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
265 time_t now = time (0);
266 time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
269 while (time (0) < stop_time && !sync)
274 SERIAL_FLUSH_INPUT (io);
275 SERIAL_FLUSH_OUTPUT (io);
278 printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
281 ** It seems necessary to reset an EmbeddedICE to get it going.
282 ** This has the side benefit of displaying the startup banner.
286 put_byte (RDP_RESET);
287 while ((restype = SERIAL_READCHAR (io, 1)) > 0)
294 /* Sent at start of reset process: ignore */
297 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
304 /* Got end-of-banner mark */
305 printf_filtered ("\n");
311 put_byte (type | RDP_OPEN_TYPE_RETURN_SEX );
314 while (!sync && (restype = SERIAL_READCHAR (io, 1)) > 0)
317 printf_unfiltered ("[%02x]\n", restype);
325 while ((restype = SERIAL_READCHAR (io, 1)) == RDP_RESET)
329 printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
331 while ((restype = SERIAL_READCHAR (io, 1)) > 0);
335 printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
336 printf_unfiltered ("Waiting for it to settle down...\n");
340 printf_unfiltered ("\nTrying again.\n");
349 int resval = SERIAL_READCHAR (io, 1);
352 printf_unfiltered ("[%02x]\n", resval);
358 case RDP_RES_VALUE_LITTLE_ENDIAN:
359 target_byte_order = LITTLE_ENDIAN;
362 case RDP_RES_VALUE_BIG_ENDIAN:
363 target_byte_order = BIG_ENDIAN;
376 error ("Couldn't reset the board, try pressing the reset button");
381 #ifdef ANSI_PROTOTYPES
383 send_rdp (char *template,...)
386 send_rdp (char *template, va_alist)
393 #ifdef ANSI_PROTOTYPES
394 va_start (alist, template);
409 val = va_arg (alist, int);
413 val = va_arg (alist, int);
421 if (val != RDP_RES_VALUE)
423 printf_unfiltered ("got bad res value of %d, %x\n", val, val);
427 pstat = va_arg (alist, int *);
428 pi = va_arg (alist, int *);
430 *pstat = get_byte ();
431 /* Check the result was zero, if not read the syndrome */
438 /* Check the result code */
445 /* Target can't do it; never mind */
446 printf_unfiltered ("RDP: Insufficient privilege\n");
449 /* Target can't do it; never mind */
450 printf_unfiltered ("RDP: Unimplemented message\n");
453 error ("Command garbled");
456 error ("Corrupt reply from target");
461 /* Read a word from the target */
462 pi = va_arg (alist, int *);
466 /* Read in some bytes from the target. */
467 pc = va_arg (alist, char *);
468 val = va_arg (alist, int);
469 for (i = 0; i < val; i++)
475 /* send what's being pointed at */
476 pc = va_arg (alist, char *);
477 val = va_arg (alist, int);
479 SERIAL_WRITE (io, pc, val);
482 /* Send whats in the queue */
485 SERIAL_WRITE (io, buf, dst - buf);
490 pi = va_arg (alist, int *);
505 rdp_write (memaddr, buf, len)
513 send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
524 rdp_read (memaddr, buf, len)
531 send_rdp ("bww-S-P-V",
532 RDP_MEM_READ, memaddr, len,
543 rdp_fetch_one_register (mask, buf)
548 send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
549 store_signed_integer (buf, 4, val);
553 rdp_fetch_one_fpu_register (mask, buf)
558 /* !!! Since the PIE board doesn't work as documented,
559 and it doesn't have FPU hardware anyway and since it
560 slows everything down, I've disabled this. */
562 if (mask == RDP_FPU_READWRITE_MASK_FPS)
564 /* this guy is only a word */
565 send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
566 store_signed_integer (buf, 4, val);
570 /* There are 12 bytes long
571 !! fixme about endianness
573 int dummy; /* I've seen these come back as four words !! */
574 send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
577 memset (buf, 0, MAX_REGISTER_RAW_SIZE);
582 rdp_store_one_register (mask, buf)
586 int val = extract_unsigned_integer (buf, 4);
589 RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
594 rdp_store_one_fpu_register (mask, buf)
599 /* See comment in fetch_one_fpu_register */
600 if (mask == RDP_FPU_READWRITE_MASK_FPS)
602 int val = extract_unsigned_integer (buf, 4);
603 /* this guy is only a word */
604 send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
610 /* There are 12 bytes long
611 !! fixme about endianness
614 /* I've seen these come as four words, not the three advertized !! */
615 printf ("Sending mask %x\n", mask);
616 send_rdp ("bbwwwww-SZ",
625 printf ("done mask %x\n", mask);
631 /* Convert between GDB requests and the RDP layer. */
634 remote_rdp_fetch_register (regno)
639 for (regno = 0; regno < NUM_REGS; regno++)
640 remote_rdp_fetch_register (regno);
644 char buf[MAX_REGISTER_RAW_SIZE];
646 rdp_fetch_one_register (1 << regno, buf);
647 else if (regno == PC_REGNUM)
648 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
649 else if (regno == PS_REGNUM)
650 rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
651 else if (regno == FPS_REGNUM)
652 rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
653 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
654 rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
657 printf ("Help me with fetch reg %d\n", regno);
659 supply_register (regno, buf);
665 remote_rdp_store_register (regno)
670 for (regno = 0; regno < NUM_REGS; regno++)
671 remote_rdp_store_register (regno);
675 char tmp[MAX_REGISTER_RAW_SIZE];
676 read_register_gen (regno, tmp);
678 rdp_store_one_register (1 << regno, tmp);
679 else if (regno == PC_REGNUM)
680 rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
681 else if (regno == PS_REGNUM)
682 rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
683 else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
684 rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
687 printf ("Help me with reg %d\n", regno);
695 callback->shutdown (callback);
702 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
704 send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
706 send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
710 ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
712 ds.rdi_level = (ds.target_info >> 5) & 3;
719 /* Start it off, but don't wait for it */
720 send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
725 rdp_set_command_line (command, args)
730 ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
731 ** don't implement that, and get all confused at the unexpected text.
732 ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
735 if (commandline != NULL)
738 commandline = malloc (strlen (command) + strlen (args) + 2);
739 if (commandline != NULL)
741 strcpy (commandline, command);
742 strcat (commandline, " ");
743 strcat (commandline, args);
751 ** We want the target monitor to intercept the abort vectors
752 ** i.e. stop the program if any of these are used.
754 send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
756 ** Specify a bitmask including
758 ** the undefined instruction vector
759 ** the prefetch abort vector
760 ** the data abort vector
761 ** the address exception vector
763 (1<<0)|(1<<1)|(1<<3)|(1<<4)|(1<<5)
786 #define SWI_WriteC 0x0
787 #define SWI_Write0 0x2
788 #define SWI_ReadC 0x4
790 #define SWI_GetEnv 0x10
791 #define SWI_Exit 0x11
792 #define SWI_EnterOS 0x16
794 #define SWI_GetErrno 0x60
795 #define SWI_Clock 0x61
797 #define SWI_Time 0x63
798 #define SWI_Remove 0x64
799 #define SWI_Rename 0x65
800 #define SWI_Open 0x66
802 #define SWI_Close 0x68
803 #define SWI_Write 0x69
804 #define SWI_Read 0x6a
805 #define SWI_Seek 0x6b
806 #define SWI_Flen 0x6c
808 #define SWI_IsTTY 0x6e
809 #define SWI_TmpNam 0x6f
810 #define SWI_InstallHandler 0x70
811 #define SWI_GenerateError 0x71
818 static int translate_open_mode[] =
821 O_RDONLY+O_BINARY, /* "rb" */
823 O_RDWR +O_BINARY, /* "r+b" */
824 O_WRONLY +O_CREAT+O_TRUNC, /* "w" */
825 O_WRONLY+O_BINARY+O_CREAT+O_TRUNC, /* "wb" */
826 O_RDWR +O_CREAT+O_TRUNC, /* "w+" */
827 O_RDWR +O_BINARY+O_CREAT+O_TRUNC, /* "w+b" */
828 O_WRONLY +O_APPEND+O_CREAT,/* "a" */
829 O_WRONLY+O_BINARY+O_APPEND+O_CREAT,/* "ab" */
830 O_RDWR +O_APPEND+O_CREAT,/* "a+" */
831 O_RDWR +O_BINARY+O_APPEND+O_CREAT /* "a+b" */
844 callback->write_stdout (callback, &c, 1);
847 for (i = 0; i < args->n; i++)
848 callback->write_stdout (callback, args->s, strlen (args->s));
851 callback->read_stdin (callback, &c, 1);
855 args->n = callback->system (callback, args->s);
858 args->n = callback->get_errno (callback);
861 args->n = callback->time (callback, NULL);
865 /* return number of centi-seconds... */
867 #ifdef CLOCKS_PER_SEC
868 (CLOCKS_PER_SEC >= 100)
869 ? (clock() / (CLOCKS_PER_SEC / 100))
870 : ((clock() * 100) / CLOCKS_PER_SEC) ;
872 /* presume unix... clock() returns microseconds */
878 args->n = callback->unlink (callback, args->s);
881 args->n = callback->rename (callback, args[0].s, args[1].s);
885 /* Now we need to decode the Demon open mode */
886 i = translate_open_mode[args[1].n];
888 /* Filename ":tt" is special: it denotes stdin/out */
889 if (strcmp(args->s,":tt")==0)
891 if (i == O_RDONLY ) /* opening tty "r" */
892 args->n = 0 /* stdin */ ;
894 args->n = 1 /* stdout */ ;
897 args->n = callback->open (callback, args->s, i);
901 args->n = callback->close (callback, args->n);
905 /* Return the number of bytes *not* written */
906 args->n = args[1].n -
907 callback->write (callback, args[0].n, args[1].s, args[1].n);
912 char *copy = alloca (args[2].n);
913 int done = callback->read (callback, args[0].n, copy, args[2].n);
915 remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0);
916 args->n = args[2].n-done;
921 /* Return non-zero on failure */
922 args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
927 long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
928 args->n = callback->lseek (callback, args->n, 0, SEEK_END);
929 callback->lseek (callback, args->n, old, 0);
934 args->n = callback->isatty (callback, args->n);
938 if (commandline != NULL)
940 int len = strlen (commandline);
944 commandline [255]='\0';
946 remote_rdp_xfer_inferior_memory (args[0].n,
947 commandline, len+1, 1, 0);
950 remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0);
967 int swino = get_word ();
968 int type = get_byte ();
974 args[count].n = get_byte ();
978 args[count].n = get_word ();
982 /* If the word is under 32 bytes it will be sent otherwise
983 an address to it is passed. Also: Special case of 255 */
993 remote_rdp_xfer_inferior_memory (get_word (),
1002 buf = alloca (len + 1);
1003 for (i = 0; i < len; i++)
1004 buf[i] = get_byte ();
1007 args[count].n = len;
1008 args[count].s = buf;
1012 error ("Unimplented SWI argument");
1019 if (exec_swi (swino, args))
1021 /* We have two options here reply with either a byte or a word
1022 which is stored in args[0].n. There is no harm in replying with
1023 a word all the time, so thats what I do! */
1024 send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
1028 send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
1033 rdp_execute_finish ()
1040 res = SERIAL_READCHAR (io, 1);
1041 while (res == SERIAL_TIMEOUT)
1044 printf_filtered ("Waiting for target..\n");
1045 res = SERIAL_READCHAR (io, 1);
1054 send_rdp ("B", &ds.rdi_stopped_status);
1058 printf_filtered ("Target reset\n");
1062 printf_filtered ("Ignoring %x\n", res);
1072 rdp_execute_start ();
1073 rdp_execute_finish ();
1077 remote_rdp_insert_breakpoint (addr, save)
1082 if (ds.rdi_level > 0)
1084 send_rdp ("bwb-SWB",
1087 RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
1096 RDP_SET_BREAK_TYPE_PC_EQUAL,
1103 remote_rdp_remove_breakpoint (addr, save)
1108 if (ds.rdi_level > 0)
1110 send_rdp ("b-p-S-B",
1128 if (ds.can_step && 0)
1130 /* The pie board can't do steps so I can't test this, and
1131 the other code will always work. */
1133 send_rdp ("bbw-S-B",
1140 CORE_ADDR pc = read_register (PC_REGNUM);
1141 pc = arm_get_next_pc (pc);
1142 remote_rdp_insert_breakpoint (pc, &handle);
1144 remote_rdp_remove_breakpoint (pc, &handle);
1149 remote_rdp_open (args, from_tty)
1156 error_no_arg ("serial port device name");
1160 target_preopen (from_tty);
1162 io = SERIAL_OPEN (args);
1165 perror_with_name (args);
1169 rdp_init (1, from_tty);
1174 printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
1179 /* Need to set up the vector interception state */
1180 rdp_catch_vectors();
1183 ** If it's an EmbeddedICE, we need to set the processor config.
1184 ** Assume we can always have ARM7TDI...
1186 send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, & not_icebreaker);
1187 if (!not_icebreaker)
1189 const char * CPU = "ARM7TDI";
1191 int len = strlen (CPU);
1193 send_rdp ("bbbbw-p-SWZ",
1195 RDI_ConfigCPU, /* Aspect: set the CPU */
1196 len, /* The number of bytes in the name */
1197 RDI_MatchAny, /* We'll take whatever we get */
1198 0, /* We'll take whatever version's there */
1203 /* command line initialised on 'run'*/
1205 push_target (& remote_rdp_ops);
1207 callback->init (callback);
1208 flush_cached_frames ();
1209 registers_changed ();
1210 stop_pc = read_pc ();
1211 set_current_frame (create_new_frame (read_fp (), stop_pc));
1212 select_frame (get_current_frame (), 0);
1213 print_stack_frame (selected_frame, -1, 1);
1218 /* Close out all files and local state before this target loses control. */
1221 remote_rdp_close (quitting)
1224 callback->shutdown (callback);
1231 /* Resume execution of the target process. STEP says whether to single-step
1232 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
1233 to the target, or zero for no signal. */
1236 remote_rdp_resume (pid, step, siggnal)
1238 enum target_signal siggnal;
1246 /* Wait for inferior process to do something. Return pid of child,
1247 or -1 in case of error; store status through argument pointer STATUS,
1248 just as `wait' would. */
1251 remote_rdp_wait (pid, status)
1253 struct target_waitstatus *status;
1255 switch (ds.rdi_stopped_status)
1260 status->kind = TARGET_WAITKIND_EXITED;
1261 status->value.integer = read_register (0);
1263 case RDP_RES_AT_BREAKPOINT:
1264 status->kind = TARGET_WAITKIND_STOPPED;
1265 /* The signal in sigrc is a host signal. That probably
1267 status->value.sig = TARGET_SIGNAL_TRAP;
1271 status->kind = TARGET_WAITKIND_SIGNALLED;
1272 /* The signal in sigrc is a host signal. That probably
1274 status->value.sig = target_signal_from_host (sigrc);
1279 return inferior_pid;
1282 /* Get ready to modify the registers array. On machines which store
1283 individual registers, this doesn't need to do anything. On machines
1284 which store all the registers in one fell swoop, this makes sure
1285 that registers contains all the registers from the program being
1289 remote_rdp_prepare_to_store ()
1291 /* Do nothing, since we can store individual regs */
1295 remote_rdp_xfer_inferior_memory (memaddr, myaddr, len, write, target)
1300 struct target_ops *target; /* ignored */
1302 /* I infer from D Taylor's code that there's a limit on the amount
1303 we can transfer in one chunk.. */
1308 int thisbite = len - done;
1309 if (thisbite > RDP_MOUTHFULL)
1310 thisbite = RDP_MOUTHFULL;
1316 justdone = rdp_write (memaddr + done, myaddr + done, thisbite);
1320 justdone = rdp_read (memaddr + done, myaddr + done, thisbite);
1325 if (justdone != thisbite)
1338 static struct yn stepinfo[] =
1340 {"Step more than one instruction", RDP_INFO_ABOUT_STEP_GT_1},
1341 {"Step to jump", RDP_INFO_ABOUT_STEP_TO_JMP},
1342 {"Step one instruction", RDP_INFO_ABOUT_STEP_1},
1346 static struct yn breakinfo[] =
1348 {"comparison breakpoints supported", RDP_INFO_ABOUT_BREAK_COMP},
1349 {"range breakpoints supported", RDP_INFO_ABOUT_BREAK_RANGE},
1350 {"watchpoints for byte reads supported", RDP_INFO_ABOUT_BREAK_BYTE_READ},
1351 {"watchpoints for half-word reads supported", RDP_INFO_ABOUT_BREAK_HALFWORD_READ},
1352 {"watchpoints for word reads supported", RDP_INFO_ABOUT_BREAK_WORD_READ},
1353 {"watchpoints for byte writes supported", RDP_INFO_ABOUT_BREAK_BYTE_WRITE},
1354 {"watchpoints for half-word writes supported", RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE},
1355 {"watchpoints for word writes supported", RDP_INFO_ABOUT_BREAK_WORD_WRITE},
1356 {"mask break/watch-points supported", RDP_INFO_ABOUT_BREAK_MASK},
1357 {"thread-specific breakpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_BREAK},
1358 {"thread-specific watchpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_WATCH},
1359 {"conditional breakpoints supported", RDP_INFO_ABOUT_BREAK_COND},
1371 printf_unfiltered (" %-45s : %s\n", t->name, (info & t->bit) ? "Yes" : "No");
1377 remote_rdp_files_info (target)
1378 struct target_ops *target;
1380 printf_filtered ("Target capabilities:\n");
1381 dump_bits (stepinfo, ds.step_info);
1382 dump_bits (breakinfo, ds.break_info);
1383 printf_unfiltered ("target level RDI %x\n", (ds.target_info >> 5) & 3);
1388 remote_rdp_create_inferior (exec_file, allargs, env)
1393 CORE_ADDR entry_point;
1395 if (exec_file == 0 || exec_bfd == 0)
1396 error ("No executable file specified.");
1398 entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1401 remove_breakpoints ();
1402 init_wait_for_inferior ();
1404 /* This gives us a chance to set up the command line */
1405 rdp_set_command_line (exec_file, allargs);
1408 insert_breakpoints (); /* Needed to get correct instruction in cache */
1411 ** RDP targets don't provide any facility to set the top of memory,
1412 ** so we don't bother to look for MEMSIZE in the environment.
1416 proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
1419 /* Accept any stray run/attach commands */
1421 remote_rdp_can_run()
1426 /* Attach doesn't need to do anything */
1428 remote_rdp_attach(args, from_tty)
1435 /* Define the target subroutine names */
1437 struct target_ops remote_rdp_ops ;
1439 static void init_remote_rdp_ops(void)
1441 remote_rdp_ops.to_shortname = "rdp";
1442 remote_rdp_ops.to_longname = "Remote Target using the RDProtocol";
1443 remote_rdp_ops.to_doc = "Use a remote ARM system which uses the ARM Remote Debugging Protocol";
1444 remote_rdp_ops.to_open = remote_rdp_open;
1445 remote_rdp_ops.to_close = remote_rdp_close;
1446 remote_rdp_ops.to_attach = remote_rdp_attach;
1447 remote_rdp_ops.to_detach = NULL;
1448 remote_rdp_ops.to_resume = remote_rdp_resume;
1449 remote_rdp_ops.to_wait = remote_rdp_wait;
1450 remote_rdp_ops.to_fetch_registers = remote_rdp_fetch_register;
1451 remote_rdp_ops.to_store_registers = remote_rdp_store_register;
1452 remote_rdp_ops.to_prepare_to_store = remote_rdp_prepare_to_store;
1453 remote_rdp_ops.to_xfer_memory = remote_rdp_xfer_inferior_memory;
1454 remote_rdp_ops.to_files_info = remote_rdp_files_info;
1455 remote_rdp_ops.to_insert_breakpoint = remote_rdp_insert_breakpoint;
1456 remote_rdp_ops.to_remove_breakpoint = remote_rdp_remove_breakpoint;
1457 remote_rdp_ops.to_terminal_init = NULL;
1458 remote_rdp_ops.to_terminal_inferior = NULL;
1459 remote_rdp_ops.to_terminal_ours_for_output = NULL;
1460 remote_rdp_ops.to_terminal_ours = NULL;
1461 remote_rdp_ops.to_terminal_info = NULL;
1462 remote_rdp_ops.to_kill = remote_rdp_kill;
1463 remote_rdp_ops.to_load = generic_load;
1464 remote_rdp_ops.to_lookup_symbol = NULL;
1465 remote_rdp_ops.to_create_inferior = remote_rdp_create_inferior;
1466 remote_rdp_ops.to_mourn_inferior = generic_mourn_inferior;
1467 remote_rdp_ops.to_can_run = remote_rdp_can_run;
1468 remote_rdp_ops.to_notice_signals = 0;
1469 remote_rdp_ops.to_thread_alive = 0;
1470 remote_rdp_ops.to_stop = 0;
1471 remote_rdp_ops.to_stratum = process_stratum;
1472 remote_rdp_ops.DONT_USE = NULL;
1473 remote_rdp_ops.to_has_all_memory = 1;
1474 remote_rdp_ops.to_has_memory = 1;
1475 remote_rdp_ops.to_has_stack = 1;
1476 remote_rdp_ops.to_has_registers = 1;
1477 remote_rdp_ops.to_has_execution = 1;
1478 remote_rdp_ops.to_sections = NULL;
1479 remote_rdp_ops.to_sections_end = NULL;
1480 remote_rdp_ops.to_magic = OPS_MAGIC;
1484 _initialize_remote_rdp ()
1486 init_remote_rdp_ops() ;
1487 add_target (&remote_rdp_ops);