1 /* Target communications support for Macraigor Systems' On-Chip Debugging
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free
4 Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
34 #include "gdb-stabs.h"
35 #include <sys/types.h>
41 /* Prototypes for local functions */
43 static int ocd_read_bytes (CORE_ADDR memaddr, char *myaddr, int len);
45 static int ocd_start_remote (void *dummy);
47 static int readchar (int timeout);
49 static void ocd_interrupt (int signo);
51 static void ocd_interrupt_twice (int signo);
53 static void interrupt_query (void);
55 static unsigned char *ocd_do_command (int cmd, int *statusp, int *lenp);
57 static void ocd_put_packet (unsigned char *packet, int pktlen);
59 static unsigned char *ocd_get_packet (int cmd, int *pktlen, int timeout);
61 static struct target_ops *current_ops = NULL;
63 static int last_run_status;
65 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
66 ocd_open knows that we don't have a file open when the program
68 static struct serial *ocd_desc = NULL;
71 ocd_error (char *s, int error_code)
75 fputs_filtered (s, gdb_stderr);
76 fputs_filtered (" ", gdb_stderr);
87 s = "Cable disconnected";
90 s = "Couldn't enter OCD mode";
93 s = "Target stuck in reset";
96 s = "OCD hasn't been initialized";
99 s = "Write verify failed";
102 s = "Reg buff error (during MPC5xx fp reg read/write)";
105 s = "Invalid CPU register access attempt failed";
111 s = "Checksum error";
114 s = "Illegal command";
117 s = "Parameter error";
120 s = "Internal error";
123 s = "Flash erase error";
126 sprintf (buf, "Unknown error code %d", error_code);
133 /* Return nonzero if the thread TH is still alive on the remote system. */
136 ocd_thread_alive (ptid_t th)
141 /* Clean up connection to a remote debugger. */
144 ocd_close (int quitting)
147 serial_close (ocd_desc);
151 /* Stub for catch_errors. */
154 ocd_start_remote (void *dummy)
156 unsigned char buf[10], *p;
161 enum ocd_target_type target_type;
163 target_type = *(enum ocd_target_type *) dummy;
165 immediate_quit++; /* Allow user to interrupt it */
167 serial_send_break (ocd_desc); /* Wake up the wiggler */
169 speed = 80; /* Divide clock by 4000 */
173 buf[2] = speed & 0xff;
174 buf[3] = target_type;
175 ocd_put_packet (buf, 4); /* Init OCD params */
176 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
179 error ("Truncated response packet from OCD device");
185 ocd_error ("OCD_INIT:", error_code);
187 ocd_do_command (OCD_AYT, &status, &pktlen);
189 p = ocd_do_command (OCD_GET_VERSION, &status, &pktlen);
191 printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
192 p[0], p[1], (p[2] << 16) | p[3]);
194 /* If processor is still running, stop it. */
196 if (!(status & OCD_FLAG_BDM))
199 /* When using a target box, we want to asynchronously return status when
200 target stops. The OCD_SET_CTL_FLAGS command is ignored by Wigglers.dll
201 when using a parallel Wiggler */
202 buf[0] = OCD_SET_CTL_FLAGS;
205 ocd_put_packet (buf, 3);
207 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
210 error ("Truncated response packet from OCD device");
216 ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
220 /* This is really the job of start_remote however, that makes an assumption
221 that the target is about to print out a status message of some sort. That
222 doesn't happen here (in fact, it may not be possible to get the monitor to
223 send the appropriate packet). */
225 flush_cached_frames ();
226 registers_changed ();
227 stop_pc = read_pc ();
228 print_stack_frame (get_selected_frame (), 0, SRC_AND_LOC);
230 buf[0] = OCD_LOG_FILE;
231 buf[1] = 3; /* close existing WIGGLERS.LOG */
232 ocd_put_packet (buf, 2);
233 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
235 buf[0] = OCD_LOG_FILE;
236 buf[1] = 2; /* append to existing WIGGLERS.LOG */
237 ocd_put_packet (buf, 2);
238 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
243 /* Open a connection to a remote debugger.
244 NAME is the filename used for communication. */
247 ocd_open (char *name, int from_tty, enum ocd_target_type target_type,
248 struct target_ops *ops)
250 unsigned char buf[10], *p;
254 error ("To open an OCD connection, you need to specify the\n\
255 device the OCD device is attached to (e.g. /dev/ttya).");
257 target_preopen (from_tty);
261 unpush_target (current_ops);
263 ocd_desc = serial_open (name);
265 perror_with_name (name);
269 if (serial_setbaudrate (ocd_desc, baud_rate))
271 serial_close (ocd_desc);
272 perror_with_name (name);
276 serial_raw (ocd_desc);
278 /* If there is something sitting in the buffer we might take it as a
279 response to a command, which would be bad. */
280 serial_flush_input (ocd_desc);
284 puts_filtered ("Remote target wiggler connected to ");
285 puts_filtered (name);
286 puts_filtered ("\n");
288 push_target (current_ops); /* Switch to using remote target now */
290 /* Without this, some commands which require an active target (such as kill)
291 won't work. This variable serves (at least) double duty as both the pid
292 of the target process (if it has such), and as a flag indicating that a
293 target is active. These functions should be split out into seperate
294 variables, especially since GDB will someday have a notion of debugging
295 several processes. */
297 inferior_ptid = pid_to_ptid (42000);
298 /* Start the remote connection; if error (0), discard this target.
299 In particular, if the user quits, be sure to discard it
300 (we'd be in an inconsistent state otherwise). */
301 if (!catch_errors (ocd_start_remote, &target_type,
302 "Couldn't establish connection to remote target\n",
306 error ("Failed to connect to OCD.");
310 /* This takes a program previously attached to and detaches it. After
311 this is done, GDB can be used to debug some other program. We
312 better not have left any breakpoints in the target program or it'll
313 die when it hits one. */
316 ocd_detach (char *args, int from_tty)
319 error ("Argument given to \"detach\" when remotely debugging.");
323 puts_filtered ("Ending remote debugging.\n");
326 /* Tell the remote machine to resume. */
329 ocd_resume (ptid_t ptid, int step, enum target_signal siggnal)
334 ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
336 ocd_do_command (OCD_RUN, &last_run_status, &pktlen);
345 ocd_do_command (OCD_STOP, &status, &pktlen);
347 if (!(status & OCD_FLAG_BDM))
348 error ("Can't stop target via BDM");
351 static volatile int ocd_interrupt_flag;
353 /* Send ^C to target to halt it. Target will respond, and send us a
357 ocd_interrupt (int signo)
359 /* If this doesn't work, try more severe steps. */
360 signal (signo, ocd_interrupt_twice);
363 printf_unfiltered ("ocd_interrupt called\n");
370 ocd_put_packet (buf, 1);
371 ocd_interrupt_flag = 1;
375 static void (*ofunc) ();
377 /* The user typed ^C twice. */
379 ocd_interrupt_twice (int signo)
381 signal (signo, ofunc);
385 signal (signo, ocd_interrupt);
388 /* Ask the user what to do when an interrupt is received. */
391 interrupt_query (void)
393 target_terminal_ours ();
395 if (query ("Interrupted while waiting for the program.\n\
396 Give up (and stop debugging it)? "))
398 target_mourn_inferior ();
399 throw_exception (RETURN_QUIT);
402 target_terminal_inferior ();
405 /* If nonzero, ignore the next kill. */
406 static int kill_kludge;
408 /* Wait until the remote machine stops, then return,
409 storing status in STATUS just as `wait' would.
410 Returns "pid" (though it's not clear what, if anything, that
411 means in the case of this target). */
421 ocd_interrupt_flag = 0;
423 /* Target might already be stopped by the time we get here. */
424 /* If we aren't already stopped, we need to loop until we've dropped
425 back into BDM mode */
427 while (!(last_run_status & OCD_FLAG_BDM))
430 ocd_put_packet (buf, 1);
431 p = ocd_get_packet (OCD_AYT, &pktlen, -1);
433 ofunc = (void (*)()) signal (SIGINT, ocd_interrupt);
434 signal (SIGINT, ofunc);
437 error ("Truncated response packet from OCD device");
439 last_run_status = p[1];
443 ocd_error ("target_wait:", error_code);
445 if (last_run_status & OCD_FLAG_PWF)
446 error ("OCD device lost VCC at BDM interface.");
447 else if (last_run_status & OCD_FLAG_CABLE_DISC)
448 error ("OCD device cable appears to have been disconnected.");
451 if (ocd_interrupt_flag)
457 /* Read registers from the OCD device. Specify the starting and ending
458 register number. Return the number of regs actually read in *NUMREGS.
459 Returns a pointer to a static array containing the register contents. */
462 ocd_read_bdm_registers (int first_bdm_regno, int last_bdm_regno, int *reglen)
464 unsigned char buf[10];
468 int error_code, status;
471 buf[0] = OCD_READ_REGS;
472 buf[1] = first_bdm_regno >> 8;
473 buf[2] = first_bdm_regno & 0xff;
474 buf[3] = last_bdm_regno >> 8;
475 buf[4] = last_bdm_regno & 0xff;
477 ocd_put_packet (buf, 5);
478 p = ocd_get_packet (OCD_READ_REGS, &pktlen, remote_timeout);
484 ocd_error ("read_bdm_registers:", error_code);
492 error ("Register block size bad: %d", i);
501 /* Read register BDM_REGNO and returns its value ala read_register() */
504 ocd_read_bdm_register (int bdm_regno)
510 p = ocd_read_bdm_registers (bdm_regno, bdm_regno, ®len);
511 regval = extract_unsigned_integer (p, reglen);
517 ocd_write_bdm_registers (int first_bdm_regno, unsigned char *regptr, int reglen)
521 int error_code, status;
524 buf = alloca (4 + reglen);
526 buf[0] = OCD_WRITE_REGS;
527 buf[1] = first_bdm_regno >> 8;
528 buf[2] = first_bdm_regno & 0xff;
530 memcpy (buf + 4, regptr, reglen);
532 ocd_put_packet (buf, 4 + reglen);
533 p = ocd_get_packet (OCD_WRITE_REGS, &pktlen, remote_timeout);
536 error ("Truncated response packet from OCD device");
542 ocd_error ("ocd_write_bdm_registers:", error_code);
546 ocd_write_bdm_register (int bdm_regno, CORE_ADDR reg)
548 unsigned char buf[4];
550 store_unsigned_integer (buf, 4, reg);
552 ocd_write_bdm_registers (bdm_regno, buf, 4);
556 ocd_prepare_to_store (void)
560 /* Write memory data directly to the remote machine.
561 This does not inform the data cache; the data cache uses this.
562 MEMADDR is the address in the remote memory space.
563 MYADDR is the address of the buffer in our space.
564 LEN is the number of bytes.
566 Returns number of bytes transferred, or 0 for error. */
568 static int write_mem_command = OCD_WRITE_MEM;
571 ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
579 buf[0] = write_mem_command;
580 buf[5] = 1; /* Write as bytes */
581 buf[6] = 0; /* Don't verify */
587 int status, error_code;
589 numbytes = min (len, 256 - 8);
591 buf[1] = memaddr >> 24;
592 buf[2] = memaddr >> 16;
593 buf[3] = memaddr >> 8;
598 memcpy (&buf[8], myaddr, numbytes);
599 ocd_put_packet (buf, 8 + numbytes);
600 p = ocd_get_packet (OCD_WRITE_MEM, &pktlen, remote_timeout);
602 error ("Truncated response packet from OCD device");
607 if (error_code == 0x11) /* Got a bus error? */
609 CORE_ADDR error_address;
611 error_address = p[3] << 24;
612 error_address |= p[4] << 16;
613 error_address |= p[5] << 8;
614 error_address |= p[6];
615 numbytes = error_address - memaddr;
623 else if (error_code != 0)
624 ocd_error ("ocd_write_bytes:", error_code);
631 return origlen - len;
634 /* Read memory data directly from the remote machine.
635 This does not use the data cache; the data cache uses this.
636 MEMADDR is the address in the remote memory space.
637 MYADDR is the address of the buffer in our space.
638 LEN is the number of bytes.
640 Returns number of bytes transferred, or 0 for error. */
643 ocd_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
651 buf[0] = OCD_READ_MEM;
652 buf[5] = 1; /* Read as bytes */
658 int status, error_code;
660 numbytes = min (len, 256 - 7);
662 buf[1] = memaddr >> 24;
663 buf[2] = memaddr >> 16;
664 buf[3] = memaddr >> 8;
669 ocd_put_packet (buf, 7);
670 p = ocd_get_packet (OCD_READ_MEM, &pktlen, remote_timeout);
672 error ("Truncated response packet from OCD device");
677 if (error_code == 0x11) /* Got a bus error? */
679 CORE_ADDR error_address;
681 error_address = p[3] << 24;
682 error_address |= p[4] << 16;
683 error_address |= p[5] << 8;
684 error_address |= p[6];
685 numbytes = error_address - memaddr;
693 else if (error_code != 0)
694 ocd_error ("ocd_read_bytes:", error_code);
696 memcpy (myaddr, &p[4], numbytes);
703 return origlen - len;
706 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
707 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
708 nonzero. Returns length of data written or read; 0 for error. TARGET
712 ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
713 struct mem_attrib *attrib, struct target_ops *target)
718 res = ocd_write_bytes (memaddr, myaddr, len);
720 res = ocd_read_bytes (memaddr, myaddr, len);
726 ocd_files_info (struct target_ops *ignore)
728 puts_filtered ("Debugging a target over a serial line.\n");
731 /* Stuff for dealing with the packets which are part of this protocol.
732 See comment at top of file for details. */
734 /* Read a single character from the remote side, handling wierd errors. */
737 readchar (int timeout)
741 ch = serial_readchar (ocd_desc, timeout);
746 error ("Remote connection closed");
748 perror_with_name ("Remote communication error");
755 /* Send a packet to the OCD device. The packet framed by a SYN character,
756 a byte count and a checksum. The byte count only counts the number of
757 bytes between the count and the checksum. A count of zero actually
758 means 256. Any SYNs within the packet (including the checksum and
759 count) must be quoted. The quote character must be quoted as well.
760 Quoting is done by replacing the character with the two-character sequence
761 DLE, {char} | 0100. Note that the quoting mechanism has no effect on the
765 ocd_put_packet (unsigned char *buf, int len)
767 unsigned char checksum;
769 unsigned char *packet, *packet_ptr;
771 packet = alloca (len + 1 + 1); /* packet + SYN + checksum */
776 *packet_ptr++ = 0x55;
786 *packet_ptr++ = -checksum;
787 if (serial_write (ocd_desc, packet, packet_ptr - packet))
788 perror_with_name ("output_packet: write failed");
791 /* Get a packet from the OCD device. Timeout is only enforced for the
792 first byte of the packet. Subsequent bytes are expected to arrive in
793 time <= remote_timeout. Returns a pointer to a static buffer containing
794 the payload of the packet. *LENP contains the length of the packet.
797 static unsigned char *
798 ocd_get_packet (int cmd, int *lenp, int timeout)
802 static unsigned char packet[512];
803 unsigned char *packet_ptr;
804 unsigned char checksum;
806 ch = readchar (timeout);
809 error ("ocd_get_packet (readchar): %d", ch);
812 error ("ocd_get_packet (readchar): %d", ch);
814 /* Found the start of a packet */
819 /* Read command char. That sort of tells us how long the packet is. */
821 ch = readchar (timeout);
824 error ("ocd_get_packet (readchar): %d", ch);
831 ch = readchar (timeout);
834 error ("ocd_get_packet (readchar): %d", ch);
838 /* Get error code. */
840 ch = readchar (timeout);
843 error ("ocd_get_packet (readchar): %d", ch);
847 switch (ch) /* Figure out length of packet */
849 case 0x7: /* Write verify error? */
850 len = 8; /* write address, value read back */
852 case 0x11: /* Bus error? */
853 /* write address, read flag */
854 case 0x15: /* Internal error */
855 len = 5; /* error code, vector */
857 default: /* Error w/no params */
860 case 0x0: /* Normal result */
863 case OCD_AYT: /* Are You There? */
864 case OCD_SET_BAUD_RATE: /* Set Baud Rate */
865 case OCD_INIT: /* Initialize OCD device */
866 case OCD_SET_SPEED: /* Set Speed */
867 case OCD_SET_FUNC_CODE: /* Set Function Code */
868 case OCD_SET_CTL_FLAGS: /* Set Control Flags */
869 case OCD_SET_BUF_ADDR: /* Set Register Buffer Address */
870 case OCD_RUN: /* Run Target from PC */
871 case OCD_RUN_ADDR: /* Run Target from Specified Address */
872 case OCD_STOP: /* Stop Target */
873 case OCD_RESET_RUN: /* Reset Target and Run */
874 case OCD_RESET: /* Reset Target and Halt */
875 case OCD_STEP: /* Single Step */
876 case OCD_WRITE_REGS: /* Write Register */
877 case OCD_WRITE_MEM: /* Write Memory */
878 case OCD_FILL_MEM: /* Fill Memory */
879 case OCD_MOVE_MEM: /* Move Memory */
880 case OCD_WRITE_INT_MEM: /* Write Internal Memory */
881 case OCD_JUMP: /* Jump to Subroutine */
882 case OCD_ERASE_FLASH: /* Erase flash memory */
883 case OCD_PROGRAM_FLASH: /* Write flash memory */
884 case OCD_EXIT_MON: /* Exit the flash programming monitor */
885 case OCD_ENTER_MON: /* Enter the flash programming monitor */
886 case OCD_LOG_FILE: /* Make Wigglers.dll save Wigglers.log */
887 case OCD_SET_CONNECTION: /* Set type of connection in Wigglers.dll */
890 case OCD_GET_VERSION: /* Get Version */
893 case OCD_GET_STATUS_MASK: /* Get Status Mask */
896 case OCD_GET_CTRS: /* Get Error Counters */
897 case OCD_READ_REGS: /* Read Register */
898 case OCD_READ_MEM: /* Read Memory */
899 case OCD_READ_INT_MEM: /* Read Internal Memory */
903 error ("ocd_get_packet: unknown packet type 0x%x\n", ch);
907 if (len == 257) /* Byte stream? */
908 { /* Yes, byte streams contain the length */
909 ch = readchar (timeout);
912 error ("ocd_get_packet (readchar): %d", ch);
920 while (len-- >= 0) /* Do rest of packet and checksum */
922 ch = readchar (timeout);
925 error ("ocd_get_packet (readchar): %d", ch);
931 error ("ocd_get_packet: bad packet checksum");
933 if (cmd != -1 && cmd != packet[0])
934 error ("Response phase error. Got 0x%x, expected 0x%x", packet[0], cmd);
936 *lenp = packet_ptr - packet - 1; /* Subtract checksum byte */
940 /* Execute a simple (one-byte) command. Returns a pointer to the data
941 following the error code. */
943 static unsigned char *
944 ocd_do_command (int cmd, int *statusp, int *lenp)
946 unsigned char buf[100], *p;
947 int status, error_code;
950 unsigned char logbuf[100];
954 ocd_put_packet (buf, 1); /* Send command */
955 p = ocd_get_packet (*buf, lenp, remote_timeout);
958 error ("Truncated response packet from OCD device");
965 sprintf (errbuf, "ocd_do_command (0x%x):", cmd);
966 ocd_error (errbuf, error_code);
969 if (status & OCD_FLAG_PWF)
970 error ("OCD device can't detect VCC at BDM interface.");
971 else if (status & OCD_FLAG_CABLE_DISC)
972 error ("BDM cable appears to be disconnected.");
976 logbuf[0] = OCD_LOG_FILE;
977 logbuf[1] = 3; /* close existing WIGGLERS.LOG */
978 ocd_put_packet (logbuf, 2);
979 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
981 logbuf[0] = OCD_LOG_FILE;
982 logbuf[1] = 2; /* append to existing WIGGLERS.LOG */
983 ocd_put_packet (logbuf, 2);
984 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
992 /* For some mysterious reason, wait_for_inferior calls kill instead of
993 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
997 target_mourn_inferior ();
1001 /* Don't wait for it to die. I'm not really sure it matters whether
1003 target_mourn_inferior ();
1009 unpush_target (current_ops);
1010 generic_mourn_inferior ();
1013 /* All we actually do is set the PC to the start address of exec_bfd, and start
1014 the program at that point. */
1017 ocd_create_inferior (char *exec_file, char *args, char **env, int from_tty)
1019 if (args && (*args != '\000'))
1020 error ("Args are not supported by BDM.");
1022 clear_proceed_status ();
1023 proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
1027 ocd_load (char *args, int from_tty)
1029 generic_load (args, from_tty);
1031 inferior_ptid = null_ptid;
1033 /* This is necessary because many things were based on the PC at the time that
1034 we attached to the monitor, which is no longer valid now that we have loaded
1035 new code (and just changed the PC). Another way to do this might be to call
1036 normal_stop, except that the stack may not be valid, and things would get
1037 horribly confused... */
1039 clear_symtab_users ();
1042 /* This should be defined for each target */
1043 /* But we want to be able to compile this file for some configurations
1044 not yet supported fully */
1046 #define BDM_BREAKPOINT {0x0,0x0,0x0,0x0} /* For ppc 8xx */
1048 /* BDM (at least on CPU32) uses a different breakpoint */
1051 ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
1053 static char break_insn[] = BDM_BREAKPOINT;
1056 val = target_read_memory (addr, contents_cache, sizeof (break_insn));
1059 val = target_write_memory (addr, break_insn, sizeof (break_insn));
1065 ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
1067 static char break_insn[] = BDM_BREAKPOINT;
1070 val = target_write_memory (addr, contents_cache, sizeof (break_insn));
1076 bdm_command (char *args, int from_tty)
1078 error ("bdm command must be followed by `reset'");
1082 bdm_reset_command (char *args, int from_tty)
1087 error ("Not connected to OCD device.");
1089 ocd_do_command (OCD_RESET, &status, &pktlen);
1090 dcache_invalidate (target_dcache);
1091 registers_changed ();
1095 bdm_restart_command (char *args, int from_tty)
1100 error ("Not connected to OCD device.");
1102 ocd_do_command (OCD_RESET_RUN, &status, &pktlen);
1103 last_run_status = status;
1104 clear_proceed_status ();
1105 wait_for_inferior ();
1109 /* Temporary replacement for target_store_registers(). This prevents
1110 generic_load from trying to set the PC. */
1113 noop_store_registers (int regno)
1118 bdm_update_flash_command (char *args, int from_tty)
1121 struct cleanup *old_chain;
1122 void (*store_registers_tmp) (int);
1125 error ("Not connected to OCD device.");
1128 error ("Must specify file containing new OCD code.");
1130 /* old_chain = make_cleanup (flash_cleanup, 0); */
1132 ocd_do_command (OCD_ENTER_MON, &status, &pktlen);
1134 ocd_do_command (OCD_ERASE_FLASH, &status, &pktlen);
1136 write_mem_command = OCD_PROGRAM_FLASH;
1137 store_registers_tmp = current_target.to_store_registers;
1138 current_target.to_store_registers = noop_store_registers;
1140 generic_load (args, from_tty);
1142 current_target.to_store_registers = store_registers_tmp;
1143 write_mem_command = OCD_WRITE_MEM;
1145 ocd_do_command (OCD_EXIT_MON, &status, &pktlen);
1147 /* discard_cleanups (old_chain); */
1150 extern initialize_file_ftype _initialize_remote_ocd; /* -Wmissing-prototypes */
1153 _initialize_remote_ocd (void)
1155 extern struct cmd_list_element *cmdlist;
1156 static struct cmd_list_element *ocd_cmd_list = NULL;
1158 deprecated_add_show_from_set
1159 (add_set_cmd ("remotetimeout", no_class,
1160 var_integer, (char *) &remote_timeout,
1161 "Set timeout value for remote read.\n", &setlist),
1164 add_prefix_cmd ("ocd", class_obscure, bdm_command, "", &ocd_cmd_list, "ocd ",
1167 add_cmd ("reset", class_obscure, bdm_reset_command, "", &ocd_cmd_list);
1168 add_cmd ("restart", class_obscure, bdm_restart_command, "", &ocd_cmd_list);
1169 add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &ocd_cmd_list);