* New R5900 COP2 test case.
[deliverable/binutils-gdb.git] / gdb / ocd.c
CommitLineData
160db9b2 1/* Target communications support for Macraigor Systems' On-Chip Debugging
35ce4f08 2 Copyright 1996, 1997 Free Software Foundation, Inc.
d9951af4
SG
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#include "defs.h"
21#include "gdbcore.h"
22#include "gdb_string.h"
23#include <fcntl.h>
24#include "frame.h"
25#include "inferior.h"
26#include "bfd.h"
27#include "symfile.h"
28#include "target.h"
29#include "wait.h"
30#include "gdbcmd.h"
31#include "objfiles.h"
32#include "gdb-stabs.h"
d9951af4 33#include "dcache.h"
d9951af4 34#include <sys/types.h>
d9951af4
SG
35#include <signal.h>
36#include "serial.h"
35ce4f08 37#include "ocd.h"
d9951af4
SG
38
39/* Prototypes for local functions */
40
706eff3f 41static int ocd_read_bytes PARAMS ((CORE_ADDR memaddr,
d9951af4
SG
42 char *myaddr, int len));
43
706eff3f 44static int ocd_start_remote PARAMS ((char *dummy));
d9951af4 45
d9951af4
SG
46static int readchar PARAMS ((int timeout));
47
48static void reset_packet PARAMS ((void));
49
50static void output_packet PARAMS ((void));
51
52static int get_quoted_char PARAMS ((int timeout));
53
54static void put_quoted_char PARAMS ((int c));
55
706eff3f 56static void ocd_interrupt PARAMS ((int signo));
d9951af4 57
706eff3f 58static void ocd_interrupt_twice PARAMS ((int signo));
d9951af4
SG
59
60static void interrupt_query PARAMS ((void));
61
2d38a02f 62static unsigned char * ocd_do_command PARAMS ((int cmd, int *statusp, int *lenp));
d9951af4 63
706eff3f 64static void ocd_put_packet PARAMS ((unsigned char *packet, int pktlen));
35ce4f08 65
706eff3f 66static unsigned char * ocd_get_packet PARAMS ((int cmd, int *pktlen, int timeout));
d9951af4 67
35ce4f08 68static struct target_ops *current_ops = NULL;
d9951af4
SG
69
70static int last_run_status;
71
72/* This was 5 seconds, which is a long time to sit and wait.
73 Unless this is going though some terminal server or multiplexer or
74 other form of hairy serial connection, I would think 2 seconds would
75 be plenty. */
76
61a0d022
GN
77/* FIXME: Change to allow option to set timeout value on a per target
78 basis.
79
80static int remote_timeout = 2;
d9951af4
SG
81
82/* Descriptor for I/O to remote machine. Initialize it to NULL so that
706eff3f 83 ocd_open knows that we don't have a file open when the program
d9951af4 84 starts. */
706eff3f 85static serial_t ocd_desc = NULL;
d9951af4 86\f
35ce4f08 87void
706eff3f 88ocd_error (s, error_code)
d9951af4
SG
89 char *s;
90 int error_code;
91{
92 char buf[100];
93
94 fputs_filtered (s, gdb_stderr);
7bd1f0c5 95 fputs_filtered (" ", gdb_stderr);
d9951af4
SG
96
97 switch (error_code)
98 {
5819f35d
SG
99 case 0x1: s = "Unknown fault"; break;
100 case 0x2: s = "Power failed"; break;
101 case 0x3: s = "Cable disconnected"; break;
160db9b2 102 case 0x4: s = "Couldn't enter OCD mode"; break;
5819f35d 103 case 0x5: s = "Target stuck in reset"; break;
160db9b2 104 case 0x6: s = "OCD hasn't been initialized"; break;
5819f35d 105 case 0x7: s = "Write verify failed"; break;
160db9b2
GN
106 case 0x8: s = "Reg buff error (during MPC5xx fp reg read/write)"; break;
107 case 0x9: s = "Invalid CPU register access attempt failed"; break;
5819f35d
SG
108 case 0x11: s = "Bus error"; break;
109 case 0x12: s = "Checksum error"; break;
110 case 0x13: s = "Illegal command"; break;
111 case 0x14: s = "Parameter error"; break;
112 case 0x15: s = "Internal error"; break;
7bd1f0c5 113 case 0x80: s = "Flash erase error"; break;
d9951af4
SG
114 default:
115 sprintf (buf, "Unknown error code %d", error_code);
5819f35d 116 s = buf;
d9951af4
SG
117 }
118
119 error (s);
120}
121
122/* Return nonzero if the thread TH is still alive on the remote system. */
123
35ce4f08 124int
706eff3f 125ocd_thread_alive (th)
d9951af4
SG
126 int th;
127{
128 return 1;
129}
130\f
131/* Clean up connection to a remote debugger. */
132
133/* ARGSUSED */
35ce4f08 134void
706eff3f 135ocd_close (quitting)
d9951af4
SG
136 int quitting;
137{
706eff3f
GN
138 if (ocd_desc)
139 SERIAL_CLOSE (ocd_desc);
140 ocd_desc = NULL;
d9951af4
SG
141}
142
143/* Stub for catch_errors. */
144
145static int
706eff3f 146ocd_start_remote (dummy)
d9951af4
SG
147 char *dummy;
148{
149 unsigned char buf[10], *p;
150 int pktlen;
151 int status;
152 int error_code;
153 int speed;
706eff3f 154 enum ocd_target_type target_type;
35ce4f08 155
706eff3f 156 target_type = (enum ocd_target_type)dummy;
d9951af4
SG
157
158 immediate_quit = 1; /* Allow user to interrupt it */
159
706eff3f 160 SERIAL_SEND_BREAK (ocd_desc); /* Wake up the wiggler */
d9951af4 161
69f78b0e 162 speed = 80; /* Divide clock by 4000 */
d9951af4 163
706eff3f 164 buf[0] = OCD_INIT;
d9951af4
SG
165 buf[1] = speed >> 8;
166 buf[2] = speed & 0xff;
35ce4f08 167 buf[3] = target_type;
706eff3f
GN
168 ocd_put_packet (buf, 4); /* Init OCD params */
169 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
d9951af4
SG
170
171 if (pktlen < 2)
706eff3f 172 error ("Truncated response packet from OCD device");
d9951af4
SG
173
174 status = p[1];
175 error_code = p[2];
176
177 if (error_code != 0)
706eff3f 178 ocd_error ("OCD_INIT:", error_code);
160db9b2
GN
179
180 ocd_do_command (OCD_AYT, &status, &pktlen);
181
182 p = ocd_do_command (OCD_GET_VERSION, &status, &pktlen);
183
184 printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
185 p[0], p[1], (p[2] << 16) | p[3]);
d9951af4
SG
186
187#if 0
188 /* Reset the target */
189
2d38a02f
GN
190 ocd_do_command (OCD_RESET_RUN, &status, &pktlen);
191/* ocd_do_command (OCD_RESET, &status, &pktlen);*/
d9951af4
SG
192#endif
193
194 /* If processor is still running, stop it. */
195
706eff3f
GN
196 if (!(status & OCD_FLAG_BDM))
197 ocd_stop ();
d9951af4
SG
198
199#if 1
61a0d022
GN
200 /* When using a target box, we want to asynchronously return status when
201 target stops. The OCD_SET_CTL_FLAGS command is ignored by Wigglers.dll
202 when using a parallel Wiggler */
706eff3f 203 buf[0] = OCD_SET_CTL_FLAGS;
d9951af4 204 buf[1] = 0;
61a0d022 205 buf[2] = 1;
706eff3f 206 ocd_put_packet (buf, 3);
d9951af4 207
706eff3f 208 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
d9951af4
SG
209
210 if (pktlen < 2)
706eff3f 211 error ("Truncated response packet from OCD device");
d9951af4
SG
212
213 status = p[1];
214 error_code = p[2];
215
216 if (error_code != 0)
706eff3f 217 ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
d9951af4
SG
218#endif
219
220 immediate_quit = 0;
221
222/* This is really the job of start_remote however, that makes an assumption
223 that the target is about to print out a status message of some sort. That
224 doesn't happen here (in fact, it may not be possible to get the monitor to
225 send the appropriate packet). */
226
227 flush_cached_frames ();
228 registers_changed ();
229 stop_pc = read_pc ();
230 set_current_frame (create_new_frame (read_fp (), stop_pc));
231 select_frame (get_current_frame (), 0);
232 print_stack_frame (selected_frame, -1, 1);
233
9cf7f520
GN
234 buf[0] = OCD_LOG_FILE;
235 buf[1] = 3; /* close existing WIGGLERS.LOG */
236 ocd_put_packet (buf, 2);
237 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
238
160db9b2
GN
239 buf[0] = OCD_LOG_FILE;
240 buf[1] = 2; /* append to existing WIGGLERS.LOG */
241 ocd_put_packet (buf, 2);
242 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
243
d9951af4
SG
244 return 1;
245}
246
247/* Open a connection to a remote debugger.
248 NAME is the filename used for communication. */
249
706eff3f 250static DCACHE *ocd_dcache;
d9951af4 251
35ce4f08 252void
706eff3f 253ocd_open (name, from_tty, target_type, ops)
d9951af4
SG
254 char *name;
255 int from_tty;
706eff3f 256 enum ocd_target_type target_type;
35ce4f08 257 struct target_ops *ops;
d9951af4 258{
9cf7f520
GN
259 unsigned char buf[10], *p;
260 int status;
261 int pktlen;
262
d9951af4 263 if (name == 0)
706eff3f
GN
264 error ("To open an OCD connection, you need to specify the\n\
265device the OCD device is attached to (e.g. /dev/ttya).");
d9951af4
SG
266
267 target_preopen (from_tty);
268
35ce4f08
GN
269 current_ops = ops;
270
271 unpush_target (current_ops);
d9951af4 272
706eff3f 273 ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
d9951af4 274
9cf7f520
GN
275 if (strncmp(name,"wiggler",7) == 0)
276 {
277 ocd_desc = SERIAL_OPEN ("ocd");
278 if (!ocd_desc)
279 perror_with_name (name);
280
281 buf[0] = OCD_LOG_FILE;
282 buf[1] = 1; /* open new or overwrite existing WIGGLERS.LOG */
283 ocd_put_packet (buf, 2);
284 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
285
286 buf[0] = OCD_SET_CONNECTION;
287 buf[1] = 0x01; /* atoi (name[11]); */
288 ocd_put_packet (buf, 2);
289 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
290 }
291 else /* not using Wigglers.dll */
292 {
293 ocd_desc = SERIAL_OPEN (name);
294 if (!ocd_desc)
295 perror_with_name (name);
296 }
d9951af4
SG
297
298 if (baud_rate != -1)
299 {
706eff3f 300 if (SERIAL_SETBAUDRATE (ocd_desc, baud_rate))
d9951af4 301 {
706eff3f 302 SERIAL_CLOSE (ocd_desc);
d9951af4
SG
303 perror_with_name (name);
304 }
305 }
306
706eff3f 307 SERIAL_RAW (ocd_desc);
d9951af4
SG
308
309 /* If there is something sitting in the buffer we might take it as a
310 response to a command, which would be bad. */
706eff3f 311 SERIAL_FLUSH_INPUT (ocd_desc);
d9951af4
SG
312
313 if (from_tty)
314 {
315 puts_filtered ("Remote target wiggler connected to ");
316 puts_filtered (name);
317 puts_filtered ("\n");
318 }
35ce4f08 319 push_target (current_ops); /* Switch to using remote target now */
d9951af4
SG
320
321 /* Without this, some commands which require an active target (such as kill)
322 won't work. This variable serves (at least) double duty as both the pid
323 of the target process (if it has such), and as a flag indicating that a
324 target is active. These functions should be split out into seperate
325 variables, especially since GDB will someday have a notion of debugging
326 several processes. */
327
328 inferior_pid = 42000;
329 /* Start the remote connection; if error (0), discard this target.
330 In particular, if the user quits, be sure to discard it
331 (we'd be in an inconsistent state otherwise). */
706eff3f 332 if (!catch_errors (ocd_start_remote, (char *)target_type,
9cf7f520
GN
333 "Couldn't establish connection to remote target\n",
334 RETURN_MASK_ALL))
17772016
KS
335 {
336 pop_target();
337 error ("Failed to connect to OCD.");
338 }
d9951af4
SG
339}
340
341/* This takes a program previously attached to and detaches it. After
342 this is done, GDB can be used to debug some other program. We
343 better not have left any breakpoints in the target program or it'll
344 die when it hits one. */
345
35ce4f08 346void
706eff3f 347ocd_detach (args, from_tty)
d9951af4
SG
348 char *args;
349 int from_tty;
350{
351 if (args)
352 error ("Argument given to \"detach\" when remotely debugging.");
353
354 pop_target ();
355 if (from_tty)
356 puts_filtered ("Ending remote debugging.\n");
357}
358\f
359/* Tell the remote machine to resume. */
360
35ce4f08 361void
706eff3f 362ocd_resume (pid, step, siggnal)
d9951af4
SG
363 int pid, step;
364 enum target_signal siggnal;
365{
366 int pktlen;
367
706eff3f 368 dcache_flush (ocd_dcache);
d9951af4
SG
369
370 if (step)
2d38a02f 371 ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
d9951af4 372 else
2d38a02f 373 ocd_do_command (OCD_RUN, &last_run_status, &pktlen);
d9951af4
SG
374}
375\f
35ce4f08 376void
706eff3f 377ocd_stop ()
d9951af4
SG
378{
379 int status;
380 int pktlen;
381
2d38a02f 382 ocd_do_command (OCD_STOP, &status, &pktlen);
d9951af4 383
706eff3f 384 if (!(status & OCD_FLAG_BDM))
d9951af4
SG
385 error ("Can't stop target via BDM");
386}
387
706eff3f 388static volatile int ocd_interrupt_flag;
d9951af4
SG
389
390/* Send ^C to target to halt it. Target will respond, and send us a
391 packet. */
392
393static void
706eff3f 394ocd_interrupt (signo)
d9951af4
SG
395 int signo;
396{
397 /* If this doesn't work, try more severe steps. */
706eff3f 398 signal (signo, ocd_interrupt_twice);
d9951af4
SG
399
400 if (remote_debug)
706eff3f 401 printf_unfiltered ("ocd_interrupt called\n");
d9951af4
SG
402
403 {
404 char buf[1];
405
706eff3f
GN
406 ocd_stop ();
407 buf[0] = OCD_AYT;
408 ocd_put_packet (buf, 1);
409 ocd_interrupt_flag = 1;
d9951af4
SG
410 }
411}
412
413static void (*ofunc)();
414
415/* The user typed ^C twice. */
416static void
706eff3f 417ocd_interrupt_twice (signo)
d9951af4
SG
418 int signo;
419{
420 signal (signo, ofunc);
421
422 interrupt_query ();
423
706eff3f 424 signal (signo, ocd_interrupt);
d9951af4
SG
425}
426
427/* Ask the user what to do when an interrupt is received. */
428
429static void
430interrupt_query ()
431{
432 target_terminal_ours ();
433
434 if (query ("Interrupted while waiting for the program.\n\
435Give up (and stop debugging it)? "))
436 {
437 target_mourn_inferior ();
438 return_to_top_level (RETURN_QUIT);
439 }
440
441 target_terminal_inferior ();
442}
443
444/* If nonzero, ignore the next kill. */
445static int kill_kludge;
446
447/* Wait until the remote machine stops, then return,
448 storing status in STATUS just as `wait' would.
449 Returns "pid" (though it's not clear what, if anything, that
450 means in the case of this target). */
451
35ce4f08 452int
706eff3f 453ocd_wait ()
d9951af4
SG
454{
455 unsigned char *p;
61a0d022 456 int error_code;
d9951af4 457 int pktlen;
61a0d022 458 char buf[1];
d9951af4 459
706eff3f 460 ocd_interrupt_flag = 0;
d9951af4 461
61a0d022
GN
462 /* Target might already be stopped by the time we get here. */
463 /* If we aren't already stopped, we need to loop until we've dropped
464 back into BDM mode */
a2c23081 465
a2c23081 466 while (!(last_run_status & OCD_FLAG_BDM))
d9951af4 467 {
61a0d022
GN
468 buf[0] = OCD_AYT;
469 ocd_put_packet (buf, 1);
706eff3f 470 p = ocd_get_packet (OCD_AYT, &pktlen, -1);
d9951af4 471
61a0d022 472 ofunc = (void (*)()) signal (SIGINT, ocd_interrupt);
d9951af4
SG
473 signal (SIGINT, ofunc);
474
475 if (pktlen < 2)
706eff3f 476 error ("Truncated response packet from OCD device");
d9951af4 477
a2c23081 478 last_run_status = p[1];
d9951af4
SG
479 error_code = p[2];
480
481 if (error_code != 0)
706eff3f 482 ocd_error ("target_wait:", error_code);
d9951af4 483
a2c23081 484 if (last_run_status & OCD_FLAG_PWF)
706eff3f 485 error ("OCD device lost VCC at BDM interface.");
a2c23081
GN
486 else if (last_run_status & OCD_FLAG_CABLE_DISC)
487 error ("OCD device cable appears to have been disconnected.");
d9951af4
SG
488 }
489
706eff3f 490 if (ocd_interrupt_flag)
35ce4f08
GN
491 return 1;
492 else
493 return 0;
d9951af4
SG
494}
495
706eff3f
GN
496/* Read registers from the OCD device. Specify the starting and ending
497 register number. Return the number of regs actually read in *NUMREGS.
498 Returns a pointer to a static array containing the register contents. */
d9951af4 499
35ce4f08 500unsigned char *
706eff3f 501ocd_read_bdm_registers (first_bdm_regno, last_bdm_regno, reglen)
d9951af4
SG
502 int first_bdm_regno;
503 int last_bdm_regno;
35ce4f08 504 int *reglen;
d9951af4
SG
505{
506 unsigned char buf[10];
507 int i;
508 unsigned char *p;
509 unsigned char *regs;
510 int error_code, status;
511 int pktlen;
512
706eff3f 513 buf[0] = OCD_READ_REGS;
d9951af4
SG
514 buf[1] = first_bdm_regno >> 8;
515 buf[2] = first_bdm_regno & 0xff;
516 buf[3] = last_bdm_regno >> 8;
517 buf[4] = last_bdm_regno & 0xff;
518
706eff3f
GN
519 ocd_put_packet (buf, 5);
520 p = ocd_get_packet (OCD_READ_REGS, &pktlen, remote_timeout);
d9951af4
SG
521
522 status = p[1];
523 error_code = p[2];
524
525 if (error_code != 0)
706eff3f 526 ocd_error ("read_bdm_registers:", error_code);
d9951af4
SG
527
528 i = p[3];
529 if (i == 0)
530 i = 256;
531
532 if (i > pktlen - 4
533 || ((i & 3) != 0))
534 error ("Register block size bad: %d", i);
535
35ce4f08 536 *reglen = i;
d9951af4
SG
537
538 regs = p + 4;
539
540 return regs;
541}
542
35ce4f08 543/* Read register BDM_REGNO and returns its value ala read_register() */
d9951af4 544
35ce4f08 545CORE_ADDR
706eff3f 546ocd_read_bdm_register (bdm_regno)
35ce4f08 547 int bdm_regno;
d9951af4 548{
35ce4f08
GN
549 int reglen;
550 unsigned char *p;
551 CORE_ADDR regval;
d9951af4 552
706eff3f 553 p = ocd_read_bdm_registers (bdm_regno, bdm_regno, &reglen);
35ce4f08 554 regval = extract_unsigned_integer (p, reglen);
d9951af4 555
35ce4f08 556 return regval;
d9951af4
SG
557}
558
35ce4f08 559void
706eff3f 560ocd_write_bdm_registers (first_bdm_regno, regptr, reglen)
35ce4f08
GN
561 int first_bdm_regno;
562 unsigned char *regptr;
563 int reglen;
d9951af4 564{
35ce4f08 565 unsigned char *buf;
d9951af4
SG
566 unsigned char *p;
567 int error_code, status;
568 int pktlen;
d9951af4 569
35ce4f08 570 buf = alloca (4 + reglen);
d9951af4 571
706eff3f 572 buf[0] = OCD_WRITE_REGS;
35ce4f08
GN
573 buf[1] = first_bdm_regno >> 8;
574 buf[2] = first_bdm_regno & 0xff;
575 buf[3] = reglen;
576 memcpy (buf + 4, regptr, reglen);
d9951af4 577
706eff3f
GN
578 ocd_put_packet (buf, 4 + reglen);
579 p = ocd_get_packet (OCD_WRITE_REGS, &pktlen, remote_timeout);
d9951af4 580
35ce4f08 581 if (pktlen < 3)
706eff3f 582 error ("Truncated response packet from OCD device");
d9951af4 583
35ce4f08
GN
584 status = p[1];
585 error_code = p[2];
d9951af4 586
35ce4f08 587 if (error_code != 0)
706eff3f 588 ocd_error ("ocd_write_bdm_registers:", error_code);
35ce4f08 589}
d9951af4 590
35ce4f08 591void
706eff3f 592ocd_write_bdm_register (bdm_regno, reg)
35ce4f08
GN
593 int bdm_regno;
594 CORE_ADDR reg;
595{
596 unsigned char buf[4];
d9951af4 597
35ce4f08 598 store_unsigned_integer (buf, 4, reg);
d9951af4 599
706eff3f 600 ocd_write_bdm_registers (bdm_regno, buf, 4);
35ce4f08
GN
601}
602\f
603void
706eff3f 604ocd_prepare_to_store ()
35ce4f08 605{
d9951af4
SG
606}
607\f
608/* Write memory data directly to the remote machine.
609 This does not inform the data cache; the data cache uses this.
610 MEMADDR is the address in the remote memory space.
611 MYADDR is the address of the buffer in our space.
612 LEN is the number of bytes.
613
614 Returns number of bytes transferred, or 0 for error. */
615
706eff3f 616static int write_mem_command = OCD_WRITE_MEM;
35ce4f08 617
160db9b2 618int
706eff3f 619ocd_write_bytes (memaddr, myaddr, len)
d9951af4
SG
620 CORE_ADDR memaddr;
621 char *myaddr;
622 int len;
623{
624 char buf[256 + 10];
625 unsigned char *p;
626 int origlen;
627
628 origlen = len;
629
35ce4f08 630 buf[0] = write_mem_command;
d9951af4
SG
631 buf[5] = 1; /* Write as bytes */
632 buf[6] = 0; /* Don't verify */
633
634 while (len > 0)
635 {
636 int numbytes;
637 int pktlen;
638 int status, error_code;
639
640 numbytes = min (len, 256 - 8);
d9951af4
SG
641
642 buf[1] = memaddr >> 24;
643 buf[2] = memaddr >> 16;
644 buf[3] = memaddr >> 8;
645 buf[4] = memaddr;
646
647 buf[7] = numbytes;
648
649 memcpy (&buf[8], myaddr, numbytes);
706eff3f
GN
650 ocd_put_packet (buf, 8 + numbytes);
651 p = ocd_get_packet (OCD_WRITE_MEM, &pktlen, remote_timeout);
d9951af4 652 if (pktlen < 3)
706eff3f 653 error ("Truncated response packet from OCD device");
d9951af4
SG
654
655 status = p[1];
656 error_code = p[2];
657
7bd1f0c5 658 if (error_code == 0x11) /* Got a bus error? */
d9951af4
SG
659 {
660 CORE_ADDR error_address;
661
662 error_address = p[3] << 24;
663 error_address |= p[4] << 16;
664 error_address |= p[5] << 8;
665 error_address |= p[6];
666 numbytes = error_address - memaddr;
667
668 len -= numbytes;
669
670 errno = EIO;
671
672 break;
673 }
674 else if (error_code != 0)
706eff3f 675 ocd_error ("ocd_write_bytes:", error_code);
d9951af4
SG
676
677 len -= numbytes;
678 memaddr += numbytes;
679 myaddr += numbytes;
680 }
681
682 return origlen - len;
683}
684
685/* Read memory data directly from the remote machine.
686 This does not use the data cache; the data cache uses this.
687 MEMADDR is the address in the remote memory space.
688 MYADDR is the address of the buffer in our space.
689 LEN is the number of bytes.
690
691 Returns number of bytes transferred, or 0 for error. */
692
693static int
706eff3f 694ocd_read_bytes (memaddr, myaddr, len)
d9951af4
SG
695 CORE_ADDR memaddr;
696 char *myaddr;
697 int len;
698{
699 char buf[256 + 10];
700 unsigned char *p;
701 int origlen;
702
703 origlen = len;
704
706eff3f 705 buf[0] = OCD_READ_MEM;
d9951af4
SG
706 buf[5] = 1; /* Read as bytes */
707
708 while (len > 0)
709 {
710 int numbytes;
711 int pktlen;
712 int status, error_code;
713
714 numbytes = min (len, 256 - 7);
715
716 buf[1] = memaddr >> 24;
717 buf[2] = memaddr >> 16;
718 buf[3] = memaddr >> 8;
719 buf[4] = memaddr;
720
721 buf[6] = numbytes;
722
706eff3f
GN
723 ocd_put_packet (buf, 7);
724 p = ocd_get_packet (OCD_READ_MEM, &pktlen, remote_timeout);
d9951af4 725 if (pktlen < 4)
706eff3f 726 error ("Truncated response packet from OCD device");
d9951af4
SG
727
728 status = p[1];
729 error_code = p[2];
730
731 if (error_code == 0x11) /* Got a bus error? */
732 {
733 CORE_ADDR error_address;
734
735 error_address = p[3] << 24;
736 error_address |= p[4] << 16;
737 error_address |= p[5] << 8;
738 error_address |= p[6];
739 numbytes = error_address - memaddr;
740
741 len -= numbytes;
742
743 errno = EIO;
744
745 break;
746 }
747 else if (error_code != 0)
706eff3f 748 ocd_error ("ocd_read_bytes:", error_code);
d9951af4
SG
749
750 memcpy (myaddr, &p[4], numbytes);
751
752 len -= numbytes;
753 memaddr += numbytes;
754 myaddr += numbytes;
755 }
756
757 return origlen - len;
758}
759\f
760/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
761 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
762 nonzero. Returns length of data written or read; 0 for error. */
763
764/* ARGSUSED */
35ce4f08 765int
706eff3f 766ocd_xfer_memory (memaddr, myaddr, len, should_write, target)
d9951af4
SG
767 CORE_ADDR memaddr;
768 char *myaddr;
769 int len;
770 int should_write;
771 struct target_ops *target; /* ignored */
772{
706eff3f 773 return dcache_xfer_memory (ocd_dcache, memaddr, myaddr, len, should_write);
d9951af4
SG
774}
775\f
35ce4f08 776void
706eff3f 777ocd_files_info (ignore)
d9951af4
SG
778 struct target_ops *ignore;
779{
780 puts_filtered ("Debugging a target over a serial line.\n");
781}
782\f
783/* Stuff for dealing with the packets which are part of this protocol.
784 See comment at top of file for details. */
785
786/* Read a single character from the remote side, handling wierd errors. */
787
788static int
789readchar (timeout)
790 int timeout;
791{
792 int ch;
793
706eff3f 794 ch = SERIAL_READCHAR (ocd_desc, timeout);
d9951af4
SG
795
796 switch (ch)
797 {
798 case SERIAL_EOF:
799 error ("Remote connection closed");
800 case SERIAL_ERROR:
801 perror_with_name ("Remote communication error");
802 case SERIAL_TIMEOUT:
803 default:
804 return ch;
805 }
806}
807
808#if 0
809/* Read a character from the data stream, dequoting as necessary. SYN is
810 treated special. Any SYNs appearing in the data stream are returned as the
811 distinct value RAW_SYN (which has a value > 8 bits and therefore cannot be
812 mistaken for real data). */
813
814static int
815get_quoted_char (timeout)
816 int timeout;
817{
818 int ch;
819
820 ch = readchar (timeout);
821
822 switch (ch)
823 {
824 case SERIAL_TIMEOUT:
825 error ("Timeout in mid-packet, aborting");
826 case SYN:
827 return RAW_SYN;
828 case DLE:
829 ch = readchar (timeout);
830 if (ch == SYN)
831 return RAW_SYN;
832 return ch & ~0100;
833 default:
834 return ch;
835 }
836}
837
838static unsigned char pkt[256 * 2 + 10], *pktp; /* Worst case */
839
840static void
841reset_packet ()
842{
843 pktp = pkt;
844}
845
846static void
847output_packet ()
848{
706eff3f 849 if (SERIAL_WRITE (ocd_desc, pkt, pktp - pkt))
d9951af4
SG
850 perror_with_name ("output_packet: write failed");
851
852 reset_packet ();
853}
854
855/* Output a quoted character. SYNs and DLEs are quoted. Everything else goes
856 through untouched. */
857
858static void
859put_quoted_char (c)
860 int c;
861{
862 switch (c)
863 {
864 case SYN:
865 case DLE:
866 *pktp++ = DLE;
867 c |= 0100;
868 }
869
870 *pktp++ = c;
871}
872
706eff3f
GN
873/* Send a packet to the OCD device. The packet framed by a SYN character,
874 a byte count and a checksum. The byte count only counts the number of
875 bytes between the count and the checksum. A count of zero actually
876 means 256. Any SYNs within the packet (including the checksum and
877 count) must be quoted. The quote character must be quoted as well.
878 Quoting is done by replacing the character with the two-character sequence
879 DLE, {char} | 0100. Note that the quoting mechanism has no effect on the
880 byte count. */
d9951af4
SG
881
882static void
883stu_put_packet (buf, len)
884 unsigned char *buf;
885 int len;
886{
887 unsigned char checksum;
888 unsigned char c;
889
890 if (len == 0 || len > 256)
891 abort (); /* Can't represent 0 length packet */
892
893 reset_packet ();
894
895 checksum = 0;
896
897 put_quoted_char (RAW_SYN);
898
899 c = len;
900
901 do
902 {
903 checksum += c;
904
905 put_quoted_char (c);
906
907 c = *buf++;
908 }
909 while (len-- > 0);
910
911 put_quoted_char (-checksum & 0xff);
912
913 output_packet ();
914}
915
916#else
917
706eff3f
GN
918/* Send a packet to the OCD device. The packet framed by a SYN character,
919 a byte count and a checksum. The byte count only counts the number of
920 bytes between the count and the checksum. A count of zero actually
921 means 256. Any SYNs within the packet (including the checksum and
922 count) must be quoted. The quote character must be quoted as well.
923 Quoting is done by replacing the character with the two-character sequence
924 DLE, {char} | 0100. Note that the quoting mechanism has no effect on the
925 byte count. */
d9951af4
SG
926
927static void
706eff3f 928ocd_put_packet (buf, len)
d9951af4
SG
929 unsigned char *buf;
930 int len;
931{
932 unsigned char checksum;
933 unsigned char c;
934 unsigned char *packet, *packet_ptr;
935
936 packet = alloca (len + 1 + 1); /* packet + SYN + checksum */
937 packet_ptr = packet;
938
939 checksum = 0;
940
941 *packet_ptr++ = 0x55;
942
943 while (len-- > 0)
944 {
945 c = *buf++;
946
947 checksum += c;
948 *packet_ptr++ = c;
949 }
950
951 *packet_ptr++ = -checksum;
706eff3f 952 if (SERIAL_WRITE (ocd_desc, packet, packet_ptr - packet))
d9951af4
SG
953 perror_with_name ("output_packet: write failed");
954}
955#endif
956
957#if 0
706eff3f
GN
958/* Get a packet from the OCD device. Timeout is only enforced for the
959 first byte of the packet. Subsequent bytes are expected to arrive in
960 time <= remote_timeout. Returns a pointer to a static buffer containing
961 the payload of the packet. *LENP contains the length of the packet.
d9951af4
SG
962*/
963
964static unsigned char *
965stu_get_packet (cmd, lenp, timeout)
966 unsigned char cmd;
967 int *lenp;
968{
969 int ch;
970 int len;
971 static unsigned char buf[256 + 10], *p;
972 unsigned char checksum;
973
974 find_packet:
975
976 ch = get_quoted_char (timeout);
977
978 if (ch < 0)
979 error ("get_packet (readchar): %d", ch);
980
981 if (ch != RAW_SYN)
982 goto find_packet;
983
984 found_syn: /* Found the start of a packet */
985
986 p = buf;
987 checksum = 0;
988
989 len = get_quoted_char (remote_timeout);
990
991 if (len == RAW_SYN)
992 goto found_syn;
993
994 checksum += len;
995
996 if (len == 0)
997 len = 256;
998
999 len++; /* Include checksum */
1000
1001 while (len-- > 0)
1002 {
1003 ch = get_quoted_char (remote_timeout);
1004 if (ch == RAW_SYN)
1005 goto found_syn;
1006
1007 *p++ = ch;
1008 checksum += ch;
1009 }
1010
1011 if (checksum != 0)
1012 goto find_packet;
1013
1014 if (cmd != buf[0])
1015 error ("Response phase error. Got 0x%x, expected 0x%x", buf[0], cmd);
1016
1017 *lenp = p - buf - 1;
1018 return buf;
1019}
1020
1021#else
1022
706eff3f
GN
1023/* Get a packet from the OCD device. Timeout is only enforced for the
1024 first byte of the packet. Subsequent bytes are expected to arrive in
1025 time <= remote_timeout. Returns a pointer to a static buffer containing
1026 the payload of the packet. *LENP contains the length of the packet.
d9951af4
SG
1027*/
1028
1029static unsigned char *
706eff3f 1030ocd_get_packet (cmd, lenp, timeout)
d9951af4
SG
1031 int cmd;
1032 int *lenp;
1033{
1034 int ch;
1035 int len;
1036 int i;
1037 static unsigned char packet[512];
1038 unsigned char *packet_ptr;
1039 unsigned char checksum;
1040
d9951af4
SG
1041 ch = readchar (timeout);
1042
1043 if (ch < 0)
706eff3f 1044 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1045
1046 if (ch != 0x55)
61a0d022 1047 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1048
1049/* Found the start of a packet */
1050
1051 packet_ptr = packet;
1052 checksum = 0;
1053
1054/* Read command char. That sort of tells us how long the packet is. */
1055
1056 ch = readchar (timeout);
1057
1058 if (ch < 0)
706eff3f 1059 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1060
1061 *packet_ptr++ = ch;
1062 checksum += ch;
1063
1064/* Get status. */
1065
1066 ch = readchar (timeout);
1067
1068 if (ch < 0)
706eff3f 1069 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1070 *packet_ptr++ = ch;
1071 checksum += ch;
1072
1073/* Get error code. */
1074
1075 ch = readchar (timeout);
1076
1077 if (ch < 0)
706eff3f 1078 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1079 *packet_ptr++ = ch;
1080 checksum += ch;
1081
1082 switch (ch) /* Figure out length of packet */
1083 {
1084 case 0x7: /* Write verify error? */
1085 len = 8; /* write address, value read back */
1086 break;
1087 case 0x11: /* Bus error? */
1088 /* write address, read flag */
1089 case 0x15: /* Internal error */
1090 len = 5; /* error code, vector */
1091 break;
1092 default: /* Error w/no params */
1093 len = 0;
35ce4f08 1094 break;
d9951af4
SG
1095 case 0x0: /* Normal result */
1096 switch (packet[0])
1097 {
706eff3f
GN
1098 case OCD_AYT: /* Are You There? */
1099 case OCD_SET_BAUD_RATE: /* Set Baud Rate */
1100 case OCD_INIT: /* Initialize OCD device */
1101 case OCD_SET_SPEED: /* Set Speed */
1102 case OCD_SET_FUNC_CODE: /* Set Function Code */
1103 case OCD_SET_CTL_FLAGS: /* Set Control Flags */
1104 case OCD_SET_BUF_ADDR: /* Set Register Buffer Address */
1105 case OCD_RUN: /* Run Target from PC */
1106 case OCD_RUN_ADDR: /* Run Target from Specified Address */
1107 case OCD_STOP: /* Stop Target */
1108 case OCD_RESET_RUN: /* Reset Target and Run */
1109 case OCD_RESET: /* Reset Target and Halt */
1110 case OCD_STEP: /* Single Step */
1111 case OCD_WRITE_REGS: /* Write Register */
1112 case OCD_WRITE_MEM: /* Write Memory */
1113 case OCD_FILL_MEM: /* Fill Memory */
1114 case OCD_MOVE_MEM: /* Move Memory */
1115 case OCD_WRITE_INT_MEM: /* Write Internal Memory */
1116 case OCD_JUMP: /* Jump to Subroutine */
1117 case OCD_ERASE_FLASH: /* Erase flash memory */
1118 case OCD_PROGRAM_FLASH: /* Write flash memory */
1119 case OCD_EXIT_MON: /* Exit the flash programming monitor */
1120 case OCD_ENTER_MON: /* Enter the flash programming monitor */
9cf7f520
GN
1121 case OCD_LOG_FILE: /* Make Wigglers.dll save Wigglers.log */
1122 case OCD_SET_CONNECTION: /* Set type of connection in Wigglers.dll */
d9951af4
SG
1123 len = 0;
1124 break;
706eff3f 1125 case OCD_GET_VERSION: /* Get Version */
35ce4f08 1126 len = 10;
d9951af4 1127 break;
706eff3f 1128 case OCD_GET_STATUS_MASK: /* Get Status Mask */
d9951af4
SG
1129 len = 1;
1130 break;
706eff3f
GN
1131 case OCD_GET_CTRS: /* Get Error Counters */
1132 case OCD_READ_REGS: /* Read Register */
1133 case OCD_READ_MEM: /* Read Memory */
1134 case OCD_READ_INT_MEM: /* Read Internal Memory */
d9951af4
SG
1135 len = 257;
1136 break;
1137 default:
61a0d022 1138 error ("ocd_get_packet: unknown packet type 0x%x\n", ch);
d9951af4
SG
1139 }
1140 }
1141
1142 if (len == 257) /* Byte stream? */
1143 { /* Yes, byte streams contain the length */
1144 ch = readchar (timeout);
1145
1146 if (ch < 0)
706eff3f 1147 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1148 *packet_ptr++ = ch;
1149 checksum += ch;
1150 len = ch;
1151 if (len == 0)
1152 len = 256;
1153 }
1154
1155 while (len-- >= 0) /* Do rest of packet and checksum */
1156 {
1157 ch = readchar (timeout);
1158
1159 if (ch < 0)
706eff3f 1160 error ("ocd_get_packet (readchar): %d", ch);
d9951af4
SG
1161 *packet_ptr++ = ch;
1162 checksum += ch;
1163 }
1164
1165 if (checksum != 0)
61a0d022 1166 error ("ocd_get_packet: bad packet checksum");
d9951af4
SG
1167
1168 if (cmd != -1 && cmd != packet[0])
1169 error ("Response phase error. Got 0x%x, expected 0x%x", packet[0], cmd);
1170
1171 *lenp = packet_ptr - packet - 1; /* Subtract checksum byte */
1172 return packet;
1173}
1174#endif
1175
1176/* Execute a simple (one-byte) command. Returns a pointer to the data
1177 following the error code. */
1178
1179static unsigned char *
2d38a02f 1180ocd_do_command (cmd, statusp, lenp)
d9951af4
SG
1181 int cmd;
1182 int *statusp;
1183 int *lenp;
1184{
1185 unsigned char buf[100], *p;
1186 int status, error_code;
1187 char errbuf[100];
1188
160db9b2
GN
1189 unsigned char logbuf[100];
1190 int logpktlen;
1191
d9951af4 1192 buf[0] = cmd;
706eff3f
GN
1193 ocd_put_packet (buf, 1); /* Send command */
1194 p = ocd_get_packet (*buf, lenp, remote_timeout);
d9951af4
SG
1195
1196 if (*lenp < 3)
706eff3f 1197 error ("Truncated response packet from OCD device");
d9951af4
SG
1198
1199 status = p[1];
1200 error_code = p[2];
1201
1202 if (error_code != 0)
1203 {
2d38a02f 1204 sprintf (errbuf, "ocd_do_command (0x%x):", cmd);
706eff3f 1205 ocd_error (errbuf, error_code);
d9951af4
SG
1206 }
1207
706eff3f
GN
1208 if (status & OCD_FLAG_PWF)
1209 error ("OCD device can't detect VCC at BDM interface.");
1210 else if (status & OCD_FLAG_CABLE_DISC)
d9951af4
SG
1211 error ("BDM cable appears to be disconnected.");
1212
1213 *statusp = status;
1214
160db9b2
GN
1215 logbuf[0] = OCD_LOG_FILE;
1216 logbuf[1] = 3; /* close existing WIGGLERS.LOG */
1217 ocd_put_packet (logbuf, 2);
1218 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
1219
1220 logbuf[0] = OCD_LOG_FILE;
1221 logbuf[1] = 2; /* append to existing WIGGLERS.LOG */
1222 ocd_put_packet (logbuf, 2);
1223 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
1224
d9951af4
SG
1225 return p + 3;
1226}
1227\f
35ce4f08 1228void
706eff3f 1229ocd_kill ()
d9951af4
SG
1230{
1231 /* For some mysterious reason, wait_for_inferior calls kill instead of
1232 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
1233 if (kill_kludge)
1234 {
1235 kill_kludge = 0;
1236 target_mourn_inferior ();
1237 return;
1238 }
1239
1240 /* Don't wait for it to die. I'm not really sure it matters whether
1241 we do or not. */
1242 target_mourn_inferior ();
1243}
1244
35ce4f08 1245void
706eff3f 1246ocd_mourn ()
d9951af4 1247{
35ce4f08 1248 unpush_target (current_ops);
d9951af4
SG
1249 generic_mourn_inferior ();
1250}
1251
1252/* All we actually do is set the PC to the start address of exec_bfd, and start
1253 the program at that point. */
1254
35ce4f08 1255void
706eff3f 1256ocd_create_inferior (exec_file, args, env)
d9951af4
SG
1257 char *exec_file;
1258 char *args;
1259 char **env;
1260{
1261 if (args && (*args != '\000'))
1262 error ("Args are not supported by BDM.");
1263
1264 clear_proceed_status ();
1265 proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
1266}
1267
35ce4f08 1268void
706eff3f 1269ocd_load (args, from_tty)
d9951af4
SG
1270 char *args;
1271 int from_tty;
1272{
1273 generic_load (args, from_tty);
7bd1f0c5 1274
d9951af4 1275 inferior_pid = 0;
7bd1f0c5
SG
1276
1277/* This is necessary because many things were based on the PC at the time that
1278 we attached to the monitor, which is no longer valid now that we have loaded
1279 new code (and just changed the PC). Another way to do this might be to call
1280 normal_stop, except that the stack may not be valid, and things would get
1281 horribly confused... */
1282
1283 clear_symtab_users ();
d9951af4
SG
1284}
1285
2549d2b3 1286/* This should be defined for each target */
160db9b2
GN
1287/* But we want to be able to compile this file for some configurations
1288 not yet supported fully */
1289
69f78b0e 1290#define BDM_BREAKPOINT {0x0,0x0,0x0,0x0} /* For ppc 8xx */
2549d2b3 1291/* #define BDM_BREAKPOINT {0x4a,0xfa} /* BGND insn used for CPU32 */
160db9b2 1292
d9951af4
SG
1293/* BDM (at least on CPU32) uses a different breakpoint */
1294
160db9b2 1295int
706eff3f 1296ocd_insert_breakpoint (addr, contents_cache)
d9951af4
SG
1297 CORE_ADDR addr;
1298 char *contents_cache;
1299{
2549d2b3 1300 static char break_insn[] = BDM_BREAKPOINT;
d9951af4
SG
1301 int val;
1302
160db9b2 1303 val = target_read_memory (addr, contents_cache, sizeof (break_insn));
d9951af4
SG
1304
1305 if (val == 0)
160db9b2
GN
1306 val = target_write_memory (addr, break_insn, sizeof (break_insn));
1307
1308 return val;
1309}
1310
1311int
1312ocd_remove_breakpoint (addr, contents_cache)
1313 CORE_ADDR addr;
1314 char *contents_cache;
1315{
2549d2b3 1316 static char break_insn[] = BDM_BREAKPOINT;
160db9b2
GN
1317 int val;
1318
1319 val = target_write_memory (addr, contents_cache, sizeof (break_insn));
d9951af4
SG
1320
1321 return val;
1322}
1323
1324static void
1325bdm_command (args, from_tty)
1326 char *args;
1327 int from_tty;
1328{
1329 error ("bdm command must be followed by `reset'");
1330}
1331
1332static void
1333bdm_reset_command (args, from_tty)
1334 char *args;
1335 int from_tty;
1336{
1337 int status, pktlen;
1338
706eff3f
GN
1339 if (!ocd_desc)
1340 error ("Not connected to OCD device.");
d9951af4 1341
2d38a02f 1342 ocd_do_command (OCD_RESET, &status, &pktlen);
706eff3f 1343 dcache_flush (ocd_dcache);
d9951af4
SG
1344 registers_changed ();
1345}
1346
1347static void
1348bdm_restart_command (args, from_tty)
1349 char *args;
1350 int from_tty;
1351{
1352 int status, pktlen;
1353
706eff3f
GN
1354 if (!ocd_desc)
1355 error ("Not connected to OCD device.");
d9951af4 1356
2d38a02f 1357 ocd_do_command (OCD_RESET_RUN, &status, &pktlen);
d9951af4
SG
1358 last_run_status = status;
1359 clear_proceed_status ();
1360 wait_for_inferior ();
1361 normal_stop ();
1362}
7bd1f0c5 1363
35ce4f08
GN
1364/* Temporary replacement for target_store_registers(). This prevents
1365 generic_load from trying to set the PC. */
7bd1f0c5 1366
35ce4f08
GN
1367static void
1368noop_store_registers (regno)
1369 int regno;
1370{
7bd1f0c5
SG
1371}
1372
1373static void
1374bdm_update_flash_command (args, from_tty)
1375 char *args;
1376 int from_tty;
1377{
1378 int status, pktlen;
1379 struct cleanup *old_chain;
35ce4f08 1380 void (*store_registers_tmp) PARAMS ((int));
7bd1f0c5 1381
706eff3f
GN
1382 if (!ocd_desc)
1383 error ("Not connected to OCD device.");
7bd1f0c5
SG
1384
1385 if (!args)
706eff3f 1386 error ("Must specify file containing new OCD code.");
7bd1f0c5
SG
1387
1388/* old_chain = make_cleanup (flash_cleanup, 0);*/
1389
2d38a02f 1390 ocd_do_command (OCD_ENTER_MON, &status, &pktlen);
7bd1f0c5 1391
2d38a02f 1392 ocd_do_command (OCD_ERASE_FLASH, &status, &pktlen);
7bd1f0c5 1393
706eff3f 1394 write_mem_command = OCD_PROGRAM_FLASH;
35ce4f08
GN
1395 store_registers_tmp = current_target.to_store_registers;
1396 current_target.to_store_registers = noop_store_registers;
7bd1f0c5
SG
1397
1398 generic_load (args, from_tty);
1399
35ce4f08 1400 current_target.to_store_registers = store_registers_tmp;
706eff3f 1401 write_mem_command = OCD_WRITE_MEM;
7bd1f0c5 1402
2d38a02f 1403 ocd_do_command (OCD_EXIT_MON, &status, &pktlen);
7bd1f0c5
SG
1404
1405/* discard_cleanups (old_chain);*/
1406}
d9951af4 1407
35ce4f08
GN
1408static void
1409bdm_read_register_command (args, from_tty)
1410 char *args;
1411 int from_tty;
1412{
1413 /* XXX repeat should go on to the next register */
1414
706eff3f
GN
1415 if (!ocd_desc)
1416 error ("Not connected to OCD device.");
35ce4f08
GN
1417
1418 if (!args)
1419 error ("Must specify BDM register number.");
1420
1421}
1422\f
d9951af4 1423void
706eff3f 1424_initialize_remote_ocd ()
d9951af4
SG
1425{
1426 extern struct cmd_list_element *cmdlist;
706eff3f 1427 static struct cmd_list_element *ocd_cmd_list = NULL;
d9951af4 1428
d9951af4
SG
1429 add_show_from_set (add_set_cmd ("remotetimeout", no_class,
1430 var_integer, (char *)&remote_timeout,
1431 "Set timeout value for remote read.\n", &setlist),
1432 &showlist);
1433
706eff3f 1434 add_prefix_cmd ("ocd", class_obscure, bdm_command, "", &ocd_cmd_list, "ocd ",
d9951af4
SG
1435 0, &cmdlist);
1436
706eff3f
GN
1437 add_cmd ("reset", class_obscure, bdm_reset_command, "", &ocd_cmd_list);
1438 add_cmd ("restart", class_obscure, bdm_restart_command, "", &ocd_cmd_list);
1439 add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &ocd_cmd_list);
1440 /* add_cmd ("read-register", class_obscure, bdm_read_register_command, "", &ocd_cmd_list);*/
d9951af4 1441}
This page took 0.192413 seconds and 4 git commands to generate.