OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [remote-or1k.c] - Blame information for rev 379

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* Remote debugging interface for various or1k debugging protocols.
2 118 markom
   Currently supported or1k targets are: simulator, jtag, dummy.
3
 
4 106 markom
   Copyright 1993-1995, 2000 Free Software Foundation, Inc.
5
   Contributed by Cygnus Support.  Written by Marko Mlinar
6
   <markom@opencores.org>
7
 
8
   This file is part of GDB.
9
 
10
   This program is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 2 of the License, or
13
   (at your option) any later version.
14
 
15
   This program is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program; if not, write to the Free Software
22
   Foundation, Inc., 59 Temple Place - Suite 330,
23
   Boston, MA 02111-1307, USA.  */
24
 
25
#include "defs.h"
26
#include "inferior.h"
27
#include "bfd.h"
28
#include "symfile.h"
29
#include "gdb_wait.h"
30
#include "gdbcmd.h"
31
#include "gdbcore.h"
32
#include "target.h"
33
#include "remote-utils.h"
34
#include "gdb_string.h"
35
#include "tm.h"
36
 
37
#include <signal.h>
38
#include <sys/types.h>
39
#include <sys/stat.h>
40
#include <sys/ioctl.h>
41
#include <fcntl.h>
42
 
43 362 markom
#define debug if (remote_debug) printf_unfiltered
44
 
45 125 chris
/* The following prototype is necessary or the compiler will not
46
   correctly promote the data argument to ULONGEST */
47
static void or1k_write_reg (unsigned int, ULONGEST);
48 372 markom
static int insn_has_delay_slot (unsigned int);
49 125 chris
 
50 118 markom
/* JTAG or1k target ops.  */
51 106 markom
extern void jtag_init PARAMS ((char * args));
52 122 markom
extern ULONGEST jtag_read_reg PARAMS ((unsigned int regno));
53
extern void jtag_write_reg PARAMS ((unsigned int regno, ULONGEST data));
54 106 markom
extern void jtag_done PARAMS ((void));
55 143 chris
extern int jtag_read_block PARAMS ((unsigned int regno, void* block, int nRegisters));
56
extern int jtag_write_block PARAMS ((unsigned int regno, void* block, int nRegisters));
57 113 markom
extern void jtag_set_chain PARAMS ((int chain));
58 106 markom
struct target_ops or1k_jtag_ops;
59
static struct or1k_target_ops or1k_target_jtag =
60
  {
61
    "jtag",
62
    jtag_init,
63
    jtag_done,
64
    jtag_read_reg,
65
    jtag_write_reg,
66 143 chris
    jtag_read_block,
67
    jtag_write_block,
68 113 markom
    jtag_set_chain,
69 106 markom
    NULL,
70
    &or1k_jtag_ops,
71
    OPS_MAGIC
72
  };
73
 
74 118 markom
/* simulator or1k target ops.  */
75 106 markom
struct target_ops or1k_sim_ops;
76
static struct or1k_target_ops or1k_target_sim =
77
  {
78
    "simulator",
79
    NULL,
80
    NULL,
81
    NULL,
82
    NULL,
83
    NULL,
84
    NULL,
85 143 chris
    NULL,
86
    NULL,
87 106 markom
    &or1k_sim_ops,
88
    OPS_MAGIC
89
  };
90
 
91 118 markom
/* dummy or1k target ops.  */
92 106 markom
struct target_ops or1k_dummy_ops;
93
static struct or1k_target_ops or1k_target_dummy =
94
  {
95
    "dummy",
96
    NULL,
97
    NULL,
98
    NULL,
99
    NULL,
100
    NULL,
101
    NULL,
102 143 chris
    NULL,
103
    NULL,
104 106 markom
    &or1k_dummy_ops,
105
    OPS_MAGIC
106
  };
107
 
108
const char *str_err[] =
109
  {
110
    "None", "CRC error"
111
  };
112
 
113
const char *status_name[] =
114
  {
115
    "UNDEFINED", "CONNECTING", "DISCONNECTING", "RUNNING", "STOPPED"
116
  };
117
 
118 113 markom
/* Names for matchpoint related stuff.  */
119
static char *ct_names[] =
120
  {
121
    "DIS", "IFEA", "LEA", "SEA", "AEA", "LDATA", "SDATA", "ADATA"
122
  };
123
 
124
static char *cc_names[] =
125
  {
126
    "&", "==", "<", "<=", ">", ">=", "!=", "ERR"
127
  };
128
 
129
static char *ch_names[] =
130
  {
131
    "ERR", "&", "|", "ERR"
132
  };
133
 
134 106 markom
/* Implementation specific information.  Set by or1k_initialize.  */
135
struct struct_or1k_implementation or1k_implementation;
136
 
137
/* Current target status.  */
138
static enum target_status or1k_status = TARGET_UNDEFINED;
139
 
140
/* The target vector.  */
141
struct target_ops or1k_dummy_ops, or1k_jtag_ops, or1k_sim_ops;
142
 
143
/* Currently active target description (if or1k_is_open == 1) */
144
static struct target_ops *current_ops;
145
 
146
/* Currently active or1k target operations.  */
147
static struct or1k_target_ops *current_or1k_target = NULL;
148
 
149
/* Set to 1 if the target is open.  */
150
static int or1k_is_open = 0;
151
 
152
/* Error last occured, zero = ok.  */
153 118 markom
int err = 0;
154 106 markom
 
155 362 markom
/* Nonzero, if we changed something (except DMR1 which is updated on every run anyway).  */
156 118 markom
int debug_regs_changed;
157
 
158 106 markom
/* Number of interrupts while waiting for process.  */
159
static int interrupt_count = 0;
160
 
161 113 markom
/* Reason of last stop.  */
162
static int hit_watchpoint = 0;
163 374 simons
static int hit_breakpoint = 0;
164 375 simons
static int new_pc_set = 0;
165 113 markom
 
166 106 markom
/* Current register values.  */
167 118 markom
unsigned int dmr1 = 0;
168
unsigned int dmr2 = 0;
169
unsigned int dsr = 0;
170
unsigned int drr = 0;
171 106 markom
 
172 118 markom
/* Current matchpoints.  */
173
unsigned int dvr[MAX_MATCHPOINTS];
174
struct dcr_struct dcr[MAX_MATCHPOINTS];
175 106 markom
 
176 362 markom
/* Number of matchpoint users */
177 118 markom
int matchpoint_user_count[MAX_MATCHPOINTS] = {0};
178
 
179 362 markom
/* Old SIGINT handler.  */
180
static void (*ofunc) PARAMS ((int));
181
 
182
 
183 106 markom
/* Handle low-level error that we can't recover from.  Note that just
184
   error()ing out from target_wait or some such low-level place will cause
185
   all hell to break loose--the rest of GDB will tend to get left in an
186
   inconsistent state.  */
187
 
188
static NORETURN void
189
or1k_error (char *string,...)
190
{
191
  va_list args;
192
 
193
  va_start (args, string);
194
 
195
  target_terminal_ours ();
196
  wrap_here ("");               /* Force out any buffered output */
197
  gdb_flush (gdb_stdout);
198
  if (error_pre_print)
199
    fprintf_filtered (gdb_stderr, error_pre_print);
200
  vfprintf_filtered (gdb_stderr, string, args);
201
  fprintf_filtered (gdb_stderr, "\n");
202
  va_end (args);
203
  gdb_flush (gdb_stderr);
204
 
205
  /* Clean up in such a way that or1k_close won't try to talk to the
206
     board (it almost surely won't work since we weren't able to talk to
207
     it).  */
208
  or1k_is_open = 0;
209
 
210
  printf_unfiltered ("Ending remote or1k debugging.\n");
211
  target_mourn_inferior ();
212
 
213
  return_to_top_level (RETURN_ERROR);
214
}
215
 
216
const char *
217
or1k_err_name (e)
218
     int e;
219
{
220
  return str_err[e];
221
}
222
 
223
/* putc_readable - print a character, displaying non-printable chars in
224
   ^x notation or in hex.  */
225
 
226
static void
227
fputc_readable (ch, file)
228
     int ch;
229
     struct ui_file *file;
230
{
231
  if (ch == '\n')
232
    fputc_unfiltered ('\n', file);
233
  else if (ch == '\r')
234
    fprintf_unfiltered (file, "\\r");
235
  else if (ch < 0x20)           /* ASCII control character */
236
    fprintf_unfiltered (file, "^%c", ch + '@');
237
  else if (ch >= 0x7f)          /* non-ASCII characters (rubout or greater) */
238
    fprintf_unfiltered (file, "[%02x]", ch & 0xff);
239
  else
240
    fputc_unfiltered (ch, file);
241
}
242
 
243
 
244
/* puts_readable - print a string, displaying non-printable chars in
245
   ^x notation or in hex.  */
246
 
247
static void
248
fputs_readable (string, file)
249
     char *string;
250
     struct ui_file *file;
251
{
252
  int c;
253
 
254
  while ((c = *string++) != '\0')
255
    fputc_readable (c, file);
256
}
257
 
258 113 markom
/* Sets scan chain.  */
259
 
260
static void
261
or1k_set_chain (chain)
262
     int chain;
263
{
264
  if (current_or1k_target != NULL && current_or1k_target->to_set_chain != NULL)
265
    current_or1k_target->to_set_chain (chain);
266
}
267
 
268 106 markom
/* Sets register/memory regno to data.  */
269
 
270 113 markom
static void
271 106 markom
or1k_write_reg (regno, data)
272
     unsigned int regno;
273 122 markom
     ULONGEST data;
274 106 markom
{
275 113 markom
  if (current_or1k_target != NULL && current_or1k_target->to_write_reg != NULL)
276
    current_or1k_target->to_write_reg (regno, data);
277 106 markom
}
278
 
279
/* Reads register/memory from regno.  */
280
 
281 122 markom
static ULONGEST
282 106 markom
or1k_read_reg (regno)
283
     unsigned int regno;
284
{
285 113 markom
  if (current_or1k_target != NULL && current_or1k_target->to_read_reg != NULL)
286
    return current_or1k_target->to_read_reg (regno);
287 106 markom
  else
288
    return 0x1234;
289
}
290
 
291 113 markom
/* Sets SPR register regno to data.  */
292
 
293
void
294
or1k_write_spr_reg (regno, data)
295
     unsigned int regno;
296
     unsigned int data;
297
{
298
  or1k_set_chain (SC_RISC_DEBUG);
299 362 markom
  or1k_write_reg (regno, (ULONGEST)data);
300 374 simons
  if (regno == PC_SPRNUM) {
301
    hit_breakpoint = 0;
302 375 simons
    new_pc_set = 1;
303 374 simons
  }
304 113 markom
}
305
 
306
/* Reads register SPR from regno.  */
307
 
308
unsigned int
309
or1k_read_spr_reg (regno)
310
     unsigned int regno;
311
{
312
  or1k_set_chain (SC_RISC_DEBUG);
313 362 markom
  return or1k_read_reg (regno);
314 113 markom
}
315
 
316 362 markom
/* Sets mem to data.  */
317
 
318
void
319
or1k_write_mem (addr, data)
320
     unsigned int addr;
321
     unsigned int data;
322
{
323
  or1k_set_chain (SC_WISHBONE);
324
  or1k_write_reg (addr, (ULONGEST)data);
325
}
326
 
327
/* Reads register SPR from regno.  */
328
 
329
unsigned int
330
or1k_read_mem (addr)
331
     unsigned int addr;
332
{
333
  or1k_set_chain (SC_WISHBONE);
334
  return or1k_read_reg (addr);
335
}
336
 
337 106 markom
/* Stalls the CPU.  */
338
 
339
static void
340
or1k_stall ()
341
{
342 113 markom
  int val;
343
  or1k_set_chain (SC_REGISTER);
344
  val = or1k_read_reg (JTAG_RISCOP);
345
  or1k_write_reg (JTAG_RISCOP, val | 1);
346 362 markom
  or1k_read_reg (JTAG_RISCOP);
347 118 markom
 
348
  /* Be cautious - disable trace.  */
349
  val = or1k_read_reg (JTAG_MODER);
350
  or1k_write_reg (JTAG_MODER, val & ~2);
351 106 markom
}
352
 
353
/* Unstalls the CPU.  */
354
 
355
static void
356
or1k_unstall ()
357
{
358 113 markom
  unsigned int val;
359 143 chris
 
360 207 chris
 
361 113 markom
  or1k_set_chain (SC_REGISTER);
362
  val = or1k_read_reg (JTAG_RISCOP);
363
  or1k_write_reg (JTAG_RISCOP, val & ~1);
364 362 markom
  or1k_read_reg (JTAG_RISCOP);
365 106 markom
}
366
 
367 113 markom
/* Resets the CPU and stalls it.  */
368 118 markom
 
369 106 markom
static void
370 113 markom
or1k_reset ()
371
{
372
  unsigned int val;
373 362 markom
  int i;
374
  debug ("%08x\n", or1k_read_reg (JTAG_RISCOP));
375 113 markom
  or1k_set_chain (SC_REGISTER);
376 118 markom
 
377
  /* Be cautious - disable trace.  */
378
  val = or1k_read_reg (JTAG_MODER);
379
  or1k_write_reg (JTAG_MODER, val & ~2);
380
 
381 113 markom
  val = or1k_read_reg (JTAG_RISCOP);
382
  val &= ~3;
383 118 markom
  /* Assert reset signal.  */
384
  or1k_write_reg (JTAG_RISCOP, val | 3);
385
 
386 362 markom
  /* Just do something */
387
  for (i = 0; i < 100; i++)
388
    or1k_read_reg (JTAG_RISCOP);
389
 
390 118 markom
  /* give it some time */
391
  usleep (1000);
392 125 chris
 
393 362 markom
  or1k_set_chain (SC_REGISTER);
394 118 markom
  /* Release reset signal, but keep in stall state.  */
395
  or1k_write_reg (JTAG_RISCOP, val | 1);
396 362 markom
  or1k_read_reg (JTAG_RISCOP);
397 113 markom
}
398
 
399 118 markom
/* Synchronizes debug registers in memory with those on target,
400
   if there is any change.  */
401
 
402 113 markom
static void
403 118 markom
or1k_commit_debug_registers ()
404
{
405
  int i;
406
  unsigned int u;
407
  if (!debug_regs_changed)
408
    return;
409
 
410
  /* Matchpoints (breakpoints, watchpoints).  */
411
  for (i = 0; i < NUM_MATCHPOINTS; i++)
412
    {
413
      unsigned int u;
414
      or1k_write_spr_reg (DVR0_SPRNUM + i, dvr[i]);
415
      memcpy (&u, &dcr[i], sizeof(dcr[i]));
416
      or1k_write_spr_reg (DCR0_SPRNUM + i, u);
417
    }
418
  or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
419
  or1k_write_spr_reg (DMR2_SPRNUM, dmr2);
420
 
421
  /* Trace dependent.  */
422
  or1k_set_chain (SC_REGISTER);
423
  memcpy (&u, &or1k_htrace.trig, sizeof(or1k_htrace.trig));
424
  or1k_write_reg (JTAG_TSEL, u);
425
  memcpy (&u, &or1k_htrace.qual, sizeof(or1k_htrace.qual));
426
  or1k_write_reg (JTAG_QSEL, u);
427
  memcpy (&u, &or1k_htrace.stop, sizeof(or1k_htrace.stop));
428
  or1k_write_reg (JTAG_SSEL, u);
429
  debug_regs_changed = 0;
430
  for (i = 0; i < NUM_RECORDS; i++)
431
    {
432
      memcpy (&u, &or1k_htrace.recwp[i], sizeof(or1k_htrace.recwp[i]));
433
      or1k_write_reg (JTAG_RECWP0 + i, u);
434
    }
435
  memcpy (&u, &or1k_htrace.recbp, sizeof(or1k_htrace.recbp));
436
  or1k_write_reg (JTAG_RECBP0, u);
437
  memcpy (&u, &or1k_htrace.moder, sizeof(or1k_htrace.moder));
438
  or1k_write_reg (JTAG_MODER, u);
439
}
440
 
441
static void
442 106 markom
or1k_set_undefined_cleanups (arg)
443
     PTR arg;
444
{
445
  or1k_status = TARGET_UNDEFINED;
446
}
447
 
448
/* Initialize a new connection to the or1k board, and make sure we are
449
   really connected.  */
450
 
451
static void
452
or1k_init (args)
453
     char *args;
454
{
455
  struct cleanup *old_cleanups = make_cleanup (or1k_set_undefined_cleanups, NULL);
456
  int i;
457 115 markom
  unsigned int tmp;
458 118 markom
  FILE *f;
459 106 markom
 
460
  /* What is this code doing here?  I don't see any way it can happen, and
461
     it might mean or1k_initializing didn't get cleared properly.
462
     So I'll make it a warning.  */
463
 
464
  if (or1k_status == TARGET_CONNECTING)
465
    {
466
      warning ("internal error: or1k_initialize called twice");
467
      return;
468
    }
469
 
470
  or1k_status = TARGET_CONNECTING;
471
  if (current_or1k_target != NULL && current_or1k_target->to_init != NULL)
472
    current_or1k_target->to_init (args);
473 122 markom
 
474 362 markom
  debug("%08x\n", read_pc ());
475
  or1k_stall ();
476
  debug("%08x\n", read_pc ());
477
  usleep (1000);
478
 
479 106 markom
  /* Determine implementation configuration.  */
480 113 markom
  or1k_implementation.VR = or1k_read_spr_reg (VR_SPRNUM);
481
  or1k_implementation.UPR = or1k_read_spr_reg (UPR_SPRNUM);
482 118 markom
 
483 115 markom
  /* Determine number of gpr_regs.  */
484
  tmp = or1k_read_spr_reg (CPUCFGR_SPRNUM);
485
  or1k_implementation.num_gpr_regs = ((tmp >> 4) & 1)?(16):(32);
486 118 markom
 
487 115 markom
  /* Is any vector or floating point support present? */
488
  or1k_implementation.vf_present = ((tmp >> 7) & 7) != 0;
489
  or1k_implementation.num_vfpr_regs = (or1k_implementation.vf_present)?(32):(0);
490 106 markom
 
491 115 markom
  /* Determine max number of supported matchpoints.  */
492
  tmp = or1k_read_spr_reg (DCFGR_SPRNUM);
493
  or1k_implementation.num_matchpoints = tmp & 7;
494 113 markom
  or1k_implementation.num_used_matchpoints = 0;
495 115 markom
  or1k_implementation.has_counters = tmp & 4 == 1;
496 106 markom
 
497
  /* Is implementation supported? */
498
 
499
  /* First we should have system and debug groups implemented. */
500
  if (or1k_implementation.VR & (1 << SPR_SYSTEM_GROUP) == 0)
501
    error ("System group should be available in the or1k implementation.");
502
  if (or1k_implementation.VR & (1 << SPR_DEBUG_GROUP) == 0)
503
    error ("Debug group should be available in the or1k implementation.");
504 115 markom
  if (or1k_implementation.has_counters)
505
    warning ("Counters not supported.");
506 106 markom
 
507
  /* Delete break, watch, catch points.  */
508
  for(i = 0; i < NUM_MATCHPOINTS; i++)
509 118 markom
    {
510
      memset (&dcr[i], 0, sizeof (dcr[i]));
511
      matchpoint_user_count[i] = 0;
512
    }
513 106 markom
 
514
  dmr1 = 0;
515
  dmr2 = 0;
516 118 markom
  memset (&or1k_htrace, 0, sizeof (or1k_htrace));
517
 
518
  /* RECSELDEPEND = 0 does not match our trace scheme. */
519
  or1k_htrace.moder.rec_sel_dep = 1;
520
 
521
  debug_regs_changed = 1;
522
  or1k_commit_debug_registers ();
523
 
524 106 markom
  if (err != 0)
525
    error ("Cannot connect.");
526
 
527 362 markom
  /* Enable exceptions */
528
  or1k_write_spr_reg (SR_SPRNUM, or1k_read_spr_reg(SR_SPRNUM) | 0x2);
529
 
530 106 markom
  /* Stop when breakpoint occurs.  */
531 372 markom
  or1k_write_spr_reg (DSR_SPRNUM, dsr = 0x2000);
532 106 markom
 
533
  do_cleanups (old_cleanups);
534
 
535
  /* This should cause an error if not connected.  */
536
  or1k_fetch_registers (-1);
537
 
538
  set_current_frame (create_new_frame (read_fp (), read_pc ()));
539
  select_frame (get_current_frame (), 0);
540 118 markom
 
541
  /* Just empty it.  */
542
  if ((f = fopen (TRACE_FILENAME, "wb+")) == NULL)
543
    error ("Cannot open trace file.");
544
  fclose (f);
545
  trace_size = 0;
546 363 markom
  or1k_status = TARGET_STOPPED;
547 106 markom
}
548
 
549
/* Kill the process running on the board.  */
550
 
551
void
552
or1k_kill ()
553
{
554
  if (or1k_status != TARGET_RUNNING)
555
    return;
556
  or1k_status = TARGET_UNDEFINED;
557 113 markom
  or1k_reset();
558
  or1k_status = TARGET_STOPPED;
559 106 markom
 
560
  inferior_pid = 0;
561
}
562
 
563
/* Open a connection to the remote board.  */
564
 
565
static void
566
or1k_open (name, from_tty)
567
     char *name;
568
     int from_tty;
569
{
570
  or1k_init (name);
571
 
572
  /* Switch to using remote target now.  */
573
  current_ops = current_or1k_target->gdb_ops;
574
  or1k_is_open = 1;
575
  push_target (current_ops);
576
 
577
  /* FIXME: Should we call start_remote here?  */
578
 
579
/* This is really the job of start_remote however, that makes an assumption
580
   that the target is about to print out a status message of some sort.  That
581
   doesn't happen here (in fact, it may not be possible to get the monitor to
582
   send the appropriate packet).  */
583
 
584
  flush_cached_frames ();
585
  registers_changed ();
586
  stop_pc = read_pc ();
587
  set_current_frame (create_new_frame (read_fp (), stop_pc));
588
  select_frame (get_current_frame (), 0);
589
  print_stack_frame (selected_frame, -1, 1);
590
}
591
 
592 362 markom
/* This is the generic stop called via the target vector. When a target
593
   interrupt is requested, either by the command line or the GUI, we
594
   will eventually end up here. */
595
static void
596
or1k_stop ()
597
{
598
  /* Send a break or a ^C, depending on user preference.  */
599
  debug ("remote_stop called\n");
600
 
601
  /* We should not stop the target immediately, since it can be in an
602
     unfinished state.  So we do a single step.  This should not affect
603
     on anything.  */
604
  or1k_stall ();
605
  /* HW STEP.  Set DMR1_ST.  */
606
  dmr1 |= DMR1_ST;
607
  or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
608
  dmr1 &= ~DMR1_ST;
609
  or1k_unstall ();
610
}
611
 
612 106 markom
/* Close a connection to the remote board.  */
613
 
614
static void
615
or1k_close (quitting)
616
     int quitting;
617
{
618
  if (or1k_is_open)
619
    {
620
      or1k_kill ();
621
      if (current_or1k_target != NULL && current_or1k_target->to_done != NULL)
622
        current_or1k_target->to_done ();
623
      current_or1k_target = NULL;
624
    }
625
  generic_mourn_inferior ();
626
}
627
 
628
/* Detach from the remote board.  */
629
 
630
static void
631
or1k_detach (args, from_tty)
632
     char *args;
633
     int from_tty;
634
{
635
  if (args)
636
    error ("Argument given to \"detach\" when remotely debugging.");
637
 
638
  pop_target ();
639
 
640
  or1k_close (1);
641
 
642
  if (from_tty)
643
    printf_unfiltered ("Ending remote or1k debugging.\n");
644
}
645
 
646 118 markom
/* Appends trace data to the trace file.  */
647
 
648
static void
649
or1k_read_trace ()
650
{
651
  struct htrace_data_struct data;
652 122 markom
  ULONGEST tmp;
653 118 markom
  int first = 1;
654
  FILE *fd;
655
  if ((fd = fopen (TRACE_FILENAME, "ab")) == NULL)
656
    {
657
      warning ("Cannot append to trace file.");
658
      return;
659
    }
660
 
661
  or1k_set_chain (SC_TRACE);
662
  while (1)
663
    {
664
      tmp = or1k_read_reg (0);
665
      memcpy (&data, &tmp, sizeof (data));
666
 
667
      /* Last record reached. */
668
      if (!data.valid)
669
        break;
670
      data.valid = first;
671
      first = 0;
672
      if (!fwrite (&data, sizeof (data), 1, fd))
673
        {
674
          warning ("Cannot write trace data");
675
          break;
676
        }
677
    }
678
  fclose (fd);
679
}
680
 
681 362 markom
/* ^C Interrupt handling */
682
 
683
/* Ask the user what to do when an interrupt is received.  */
684
static void
685
interrupt_query ()
686
{
687
  target_terminal_ours ();
688
 
689
  if (query ("Interrupted while waiting for the program.\n\
690
Give up (and stop debugging it)? "))
691
    {
692
      target_mourn_inferior ();
693
      return_to_top_level (RETURN_QUIT);
694
    }
695
 
696
  target_terminal_inferior ();
697
}
698
 
699
static void or1k_interrupt_twice (int signo);
700
 
701
 
702
/* The command line interface's stop routine. This function is installed
703
   as a signal handler for SIGINT. The first time a user requests a
704
   stop, we call remote_stop to send a break or ^C. If there is no
705
   response from the target (it didn't stop when the user requested it),
706
   we ask the user if he'd like to detach from the target. */
707
static void
708
or1k_interrupt (signo)
709
     int signo;
710
{
711
        debug ("interrupt");
712
  /* If this doesn't work, try more severe steps. */
713
  signal (signo, or1k_interrupt_twice);
714
 
715
  debug ("remote_interrupt called\n");
716
 
717
  interrupt_count++;
718
}
719
 
720
/* The user typed ^C twice.  */
721
 
722
static void
723
or1k_interrupt_twice (signo)
724
     int signo;
725
{
726
        debug ("interrupt2");
727
  signal (signo, ofunc);
728
  interrupt_query ();
729
  signal (signo, or1k_interrupt);
730
}
731
 
732 106 markom
/* Resume execution of the target process.  STEP says whether to single-step
733
   or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
734
   to the target, or zero for no signal.  */
735
 
736
static void
737
or1k_resume (pid, step, siggnal)
738
     int pid, step;
739
     enum target_signal siggnal;
740 362 markom
{
741 372 markom
  unsigned int pc;
742
  unsigned int ppc;
743
  unsigned int npc;
744
  unsigned int val;
745 375 simons
  unsigned int ppc_insn;
746 372 markom
 
747
  pc = read_pc();
748
  npc = or1k_read_spr_reg (PC_SPRNUM);
749
  ppc = or1k_read_spr_reg (PPC_SPRNUM);
750
  debug ("pc = %08x BP = %x npc = %08x ppc = %08x\n", pc, breakpoint_here_p (pc), npc, ppc);
751 362 markom
  debug ("resume %i, %i, %i\n",step, siggnal, or1k_status);
752 106 markom
  if (or1k_status != TARGET_STOPPED)
753
    if (or1k_status == TARGET_RUNNING)
754
      error ("Program is already running.");
755
    else
756
      error ("The program is not being run.");
757
 
758 150 chris
 
759 106 markom
  /* Clear reason register for later.  */
760 113 markom
  or1k_write_spr_reg (DRR_SPRNUM, 0);
761 106 markom
 
762 362 markom
  or1k_commit_debug_registers ();
763
 
764 375 simons
  ppc_insn = or1k_fetch_instruction(ppc);
765
 
766 374 simons
  /* Else clause added by CZ 26/06/01 */
767
  if (step)
768
    {
769 106 markom
      /* HW STEP.  Set DMR1_ST.  */
770
      dmr1 |= DMR1_ST;
771 113 markom
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
772 106 markom
      dmr1 &= ~DMR1_ST;
773 372 markom
 
774 375 simons
      if (new_pc_set)
775
        {
776 379 markom
          debug("resume: 1\n");
777 375 simons
          or1k_write_spr_reg (PC_SPRNUM, pc);
778
          new_pc_set = 0;
779
        }
780
      else if (insn_has_delay_slot (ppc_insn) && (ppc != pc))
781
        {
782
          /* Steping across delay slot insn - we have to reexcute branch insn */
783 379 markom
          debug("resume: 2\n");
784 374 simons
 
785 375 simons
          if(breakpoint_here_p (ppc))
786
              or1k_write_mem(ppc, ppc_insn);
787
 
788
          or1k_write_spr_reg (PC_SPRNUM, ppc);
789
 
790
          or1k_unstall ();
791
 
792
          or1k_set_chain (SC_REGISTER);
793
          val = or1k_read_reg (JTAG_RISCOP);
794
          do {
795
            val = or1k_read_reg (JTAG_RISCOP);
796
          } while ((val & 1) == 0);
797 379 markom
 
798
          new_pc_set = 0;
799 375 simons
        }
800
      else if (hit_breakpoint && ((ppc + 4) != npc))
801 374 simons
       {
802 379 markom
          debug("resume: 3\n");
803 374 simons
          /* Trapped on delay slot instruction. */
804
          /* Set PC to branch insn preceding delay slot. */
805
          or1k_write_spr_reg (PC_SPRNUM, ppc - 4);
806
 
807 372 markom
          or1k_unstall ();
808
 
809
          or1k_set_chain (SC_REGISTER);
810
          val = or1k_read_reg (JTAG_RISCOP);
811 374 simons
          do {
812 372 markom
            val = or1k_read_reg (JTAG_RISCOP);
813 374 simons
          } while ((val & 1) == 0);
814 379 markom
 
815
          new_pc_set = 0;
816 372 markom
        }
817 375 simons
      else
818 379 markom
        {
819
          debug("resume: 4\n");
820
          or1k_write_spr_reg (PC_SPRNUM, pc);
821 375 simons
 
822 379 markom
          new_pc_set = 0;
823
        }
824 375 simons
    }
825
  else
826
    {
827
      dmr1 &= ~DMR1_ST;
828
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
829
 
830
      if (new_pc_set)
831 374 simons
        {
832 379 markom
          debug("resume: 5\n");
833 375 simons
          or1k_write_spr_reg (PC_SPRNUM, pc);
834 379 markom
 
835 375 simons
          new_pc_set = 0;
836
        }
837
      else if (insn_has_delay_slot (ppc_insn) && !breakpoint_here_p (ppc))
838 379 markom
        {
839
          debug("resume: 6\n");
840 374 simons
          or1k_write_spr_reg (PC_SPRNUM, ppc);
841 379 markom
 
842
          new_pc_set = 0;
843
        }
844 375 simons
      else if (insn_has_delay_slot (ppc_insn) && breakpoint_here_p (ppc))
845
        {
846 379 markom
          debug("resume: 7\n");
847 375 simons
          or1k_write_mem(ppc, ppc_insn);
848
 
849
          dmr1 |= DMR1_ST;
850
          or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
851
          dmr1 &= ~DMR1_ST;
852
 
853
          or1k_write_spr_reg (PC_SPRNUM, ppc);
854 374 simons
 
855
          or1k_unstall ();
856 375 simons
 
857 374 simons
          or1k_set_chain (SC_REGISTER);
858
          val = or1k_read_reg (JTAG_RISCOP);
859
          do {
860
            val = or1k_read_reg (JTAG_RISCOP);
861
          } while ((val & 1) == 0);
862 375 simons
 
863
          or1k_write_mem(ppc, 0x21000001);
864
 
865
          or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
866 379 markom
 
867
          new_pc_set = 0;
868 374 simons
        }
869 375 simons
      else
870 379 markom
        {
871
          debug("resume: 8\n");
872
          or1k_write_spr_reg (PC_SPRNUM, pc);
873
 
874
          new_pc_set = 0;
875
        }
876 106 markom
    }
877
 
878 207 chris
  /* We can now continue normally, independent of step */
879 106 markom
  or1k_unstall ();
880
  or1k_status = TARGET_RUNNING;
881 362 markom
  debug ("-resume %i, %i, %i\n",step, siggnal, or1k_status);
882 106 markom
}
883
 
884
/* Wait until the remote stops, and return a wait status.  */
885
 
886
static int
887
or1k_wait (pid, status)
888
     int pid;
889
     struct target_waitstatus *status;
890
{
891 362 markom
  unsigned long val;
892
  unsigned long pc;
893 372 markom
  unsigned long ppc;
894 362 markom
  char buf[MAX_REGISTER_RAW_SIZE];
895 106 markom
  interrupt_count = 0;
896
 
897 362 markom
  debug ("wait %i %i\n", pid, or1k_status);
898 106 markom
  /* If we have not sent a single step or continue command, then the
899
     board is waiting for us to do something.  Return a status
900
     indicating that it is stopped.  */
901
  if (or1k_status != TARGET_RUNNING)
902
    {
903
      if (or1k_status != TARGET_STOPPED)
904
        error("Target in invalid state.");
905
      status->kind = TARGET_WAITKIND_STOPPED;
906
      status->value.sig = TARGET_SIGNAL_TRAP;
907
      return 0;
908
    }
909
 
910
  if (err)
911
    or1k_error ("Remote failure: %s", or1k_err_name (err));
912
 
913 362 markom
  /* Set new signal handler */
914
  ofunc = signal (SIGINT, or1k_interrupt);
915 106 markom
 
916 362 markom
  /* Wait for risc to stop.  */
917
  do {
918
    or1k_set_chain (SC_REGISTER);
919
    val = or1k_read_reg (JTAG_RISCOP);
920 372 markom
 
921 362 markom
    /* When we press Ctrl-C, interrupt count is set, but we must wait
922
         for or1k_read_reg to finish, otherwise we would interrupt transaction.  */
923
    if (interrupt_count)
924 372 markom
      or1k_stop ();
925 106 markom
 
926 362 markom
    usleep (10);
927
    debug ("%i", val);
928 372 markom
  } while ((val & 1) == 0);
929
 
930 362 markom
  drr = or1k_read_spr_reg (DRR_SPRNUM);
931 372 markom
 
932 362 markom
  /* Restore old INT signal handler */
933
  signal (SIGINT, ofunc);
934
 
935 372 markom
  /* Single step does not set trap exception, so we set it manually to simplify our code */
936
  dmr1 = or1k_read_spr_reg (DMR1_SPRNUM);
937
  if (dmr1 & DMR1_ST)
938
    drr |= DRR_TE;
939 362 markom
 
940
  status->kind = TARGET_WAITKIND_STOPPED;
941
 
942
  debug ("epcr0 = %08x\n", or1k_read_spr_reg (EPCR0_SPRNUM));
943
  debug ("drr = %08x\n", drr);
944
 
945 363 markom
  registers_changed ();
946 362 markom
  pc = read_pc ();
947 372 markom
  ppc = or1k_read_spr_reg (PPC_SPRNUM);
948 375 simons
  debug ("ppc = %08x\n", ppc);
949 362 markom
 
950 372 markom
  if (drr & DRR_TE)
951
    {
952
      /* If single step is not set, we should correct the pc.  */
953
      if (!(dmr1 & DMR1_ST))
954
        /* PC has already stepped over the l.trap instruction.  */
955
        pc = ppc;
956
      status->value.sig = TARGET_SIGNAL_TRAP;
957
      drr &= ~DRR_TE;
958
    }
959
  else if (drr & DRR_RSTE)
960
    {
961
      status->value.sig = TARGET_SIGNAL_REALTIME_33;
962
      drr &= ~DRR_RSTE;
963
    }
964 106 markom
  else if (drr & DRR_BUSEE)
965 372 markom
    {
966
      status->value.sig = TARGET_SIGNAL_BUS;
967
      drr &= ~DRR_BUSEE;
968
    }
969 106 markom
  else if (drr & DRR_AE)
970 372 markom
    {
971
      status->value.sig = TARGET_SIGNAL_REALTIME_36;
972
      drr &= ~DRR_AE;
973
    }
974 106 markom
  else if (drr & DRR_IIE)
975 372 markom
    {
976
      status->value.sig = TARGET_SIGNAL_ILL;
977
      drr &= ~DRR_IIE;
978
    }
979
  else if (drr & DRR_RE)
980
    {
981
      status->value.sig = TARGET_SIGNAL_REALTIME_39;
982
      drr &= ~DRR_RE;
983
    }
984
  else if (drr & DRR_IME)
985
    {
986
      status->value.sig = TARGET_SIGNAL_REALTIME_38;
987
      drr &= ~DRR_IME;
988
    }
989 106 markom
  else if (drr & DRR_DME)
990 372 markom
    {
991
      status->value.sig = TARGET_SIGNAL_REALTIME_37;
992
      drr &= ~DRR_DME;
993
    }
994
  else if (drr & DRR_DPFE)
995
    {
996
      status->value.sig = TARGET_SIGNAL_REALTIME_34;
997
      drr &= ~DRR_DPFE;
998
    }
999
  else if (drr & DRR_IPFE)
1000
    {
1001
      status->value.sig = TARGET_SIGNAL_REALTIME_35;
1002
      drr &= ~DRR_DPFE;
1003
    }
1004 106 markom
  else if (drr & DRR_SCE)
1005
    {
1006 372 markom
      status->value.sig = TARGET_SIGNAL_REALTIME_40;
1007
      drr &= ~DRR_SCE;
1008
    }
1009
  else if (drr & DRR_HPINTE)
1010
    {
1011
      status->value.sig = TARGET_SIGNAL_INT;
1012
      drr &= ~DRR_HPINTE;
1013
    }
1014
  else if (drr & DRR_LPINTE)
1015
    {
1016
      status->value.sig = TARGET_SIGNAL_INT;
1017
      drr &= ~DRR_LPINTE;
1018
    }
1019
  else
1020
    {
1021 106 markom
      status->value.sig = TARGET_SIGNAL_UNKNOWN;
1022
      warning ("Invalid exception occured.");
1023 372 markom
    }
1024 106 markom
 
1025 372 markom
  /* Update drr register */
1026
  or1k_write_spr_reg (DRR_SPRNUM, drr);
1027
 
1028 362 markom
  /* Write into PC flushes the pipeline! */
1029
  /* We got the number the register holds, but gdb expects to see a
1030
     value in the target byte ordering.  */
1031 372 markom
/*  write_pc (pc);
1032
*/
1033
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
1034
  supply_register (PC_REGNUM, buf);
1035 374 simons
 
1036
  hit_breakpoint = breakpoint_here_p (pc);
1037 372 markom
 
1038 363 markom
  /*or1k_write_spr_reg (PC_SPRNUM, pc);
1039 362 markom
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
1040 363 markom
  supply_register (PC_REGNUM, buf);*/
1041 362 markom
 
1042 113 markom
  /* Log remote stop.  */
1043 106 markom
  or1k_status = TARGET_STOPPED;
1044 113 markom
 
1045
  /* Determine what caused trap - breakpoint or watchpoint.  */
1046
  if (status->value.sig == TARGET_SIGNAL_TRAP)
1047
    {
1048
      /* Search all active breakpoints for a match.  */
1049
      CORE_ADDR pc = read_pc ();
1050
      int breakpoint = 0;
1051
      int i;
1052 150 chris
      unsigned char break_bytes[4] = BRK_INSTR_STRUCT;
1053
      unsigned long b_insn = ntohl(*((unsigned long*)break_bytes));
1054 151 chris
      unsigned long value = pc;
1055 143 chris
 
1056 113 markom
      for (i = 0; i < or1k_implementation.num_used_matchpoints; i++)
1057 118 markom
        if (dvr[i] == pc && dcr[i].dp && dcr[i].cc == CC_EQUAL
1058
            && !dcr[i].sc && dcr[i].ct == CT_FETCH)
1059 113 markom
          {
1060
            breakpoint = 1;
1061
            break;
1062
          }
1063
      hit_watchpoint = !breakpoint;
1064 143 chris
 
1065
      /* Cause the trap/breakpoint exception to be ignored. This is
1066
         the behavior of the simulator when the PC value is changed
1067
         by a write command. All pending exceptions are cleared and
1068 150 chris
         the simulator continues at the PC value specified. We need
1069
         to do this if the instruction at the current PC has the
1070
         value BRK_INSTR_STRUCT */
1071
 
1072 362 markom
      if(b_insn == or1k_read_mem((pc & 3)))
1073 150 chris
        {
1074
          or1k_write_spr_reg(PC_SPRNUM,value);
1075
        }
1076 113 markom
    }
1077
  else
1078
    hit_watchpoint = 0;
1079 106 markom
 
1080
  /* If the stop PC is in the _exit function, assume
1081
     we hit the 'break 0x3ff' instruction in _exit, so this
1082
     is not a normal breakpoint.  */
1083
  {
1084
    char *func_name;
1085
    CORE_ADDR func_start;
1086
    CORE_ADDR pc = read_pc ();
1087
 
1088
    find_pc_partial_function (pc, &func_name, &func_start, NULL);
1089
    if (func_name != NULL && strcmp (func_name, "_exit") == 0
1090
        && func_start == pc)
1091
      status->kind = TARGET_WAITKIND_EXITED;
1092
  }
1093 118 markom
 
1094
  or1k_read_trace ();
1095 362 markom
  debug ("-wait %i %i\n", pid, or1k_status);
1096 106 markom
  return 0;
1097
}
1098
 
1099 113 markom
/* Fetch a word from the target board.  All memory accesses to the
1100
   remote board are word aligned.  */
1101 106 markom
 
1102 118 markom
unsigned int
1103 106 markom
or1k_fetch_word (addr)
1104
     CORE_ADDR addr;
1105
{
1106 113 markom
  if (addr & 3)
1107
    {
1108
      int subaddr = addr & 3;
1109
      unsigned char buf[8];
1110
      unsigned int low, high;
1111
      addr >>= 2;
1112 362 markom
      low = or1k_read_mem (addr << 2);
1113
      high = or1k_read_reg ((addr + 1) << 2);
1114 113 markom
      memcpy (&buf[0], &low, 4);
1115
      memcpy (&buf[4], &high, 4);
1116
      memcpy (&low, &buf[subaddr], 4);
1117
      return low;
1118
    }
1119
  else
1120
    {
1121 362 markom
      return or1k_read_mem (addr);
1122 113 markom
    }
1123 106 markom
}
1124
 
1125
/* Store a word to the target board.  Returns errno code or zero for
1126 113 markom
   success.  All memory accesses to the remote board are word aligned.  */
1127 118 markom
 
1128 106 markom
static int
1129
or1k_store_word (addr, val)
1130
     CORE_ADDR addr;
1131
     unsigned int val;
1132
{
1133 113 markom
  if (addr & 3)
1134
    {
1135
      int subaddr = addr & 3;
1136
      unsigned char buf[8];
1137
      unsigned int low, high;
1138
      addr >>= 2;
1139 362 markom
      low = or1k_read_mem (addr << 2);
1140
      high = or1k_read_mem ((addr + 1) << 2);
1141 113 markom
      memcpy (&buf[0], &low, 4);
1142
      memcpy (&buf[4], &high, 4);
1143
      memcpy (&buf[subaddr], &val, 4);
1144
      memcpy (&low, &buf[0], 4);
1145
      memcpy (&high, &buf[4], 4);
1146 362 markom
      or1k_write_mem (addr << 2, low);
1147
      or1k_write_mem ((addr + 1) << 2, high);
1148 113 markom
    }
1149
  else
1150 362 markom
    {
1151
      or1k_write_mem (addr, val);
1152 113 markom
    }
1153 106 markom
  return err;
1154
}
1155
 
1156
/* Fetch the remote registers.  */
1157
 
1158
void
1159
or1k_fetch_registers (regno)
1160
     int regno;
1161
{
1162
  unsigned int val;
1163
 
1164
  if (regno == -1)
1165
    {
1166
      for (regno = 0; regno < NUM_REGS; regno++)
1167
        or1k_fetch_registers (regno);
1168
      return;
1169
    }
1170
 
1171
  if (regno >= NUM_REGS)
1172
    error("Invalid register number!");
1173
 
1174
  /* Convert to SPRNUM and read.  */
1175 113 markom
  val = or1k_read_spr_reg (REGNUM_TO_SPRNUM(regno));
1176 106 markom
 
1177
  {
1178
    char buf[MAX_REGISTER_RAW_SIZE];
1179
 
1180
    /* We got the number the register holds, but gdb expects to see a
1181
       value in the target byte ordering.  */
1182
    store_unsigned_integer (buf, REGISTER_RAW_SIZE (regno), val);
1183
    supply_register (regno, buf);
1184
  }
1185
  if (err)
1186 118 markom
    or1k_error ("Can't read register %d(%i): %s", regno,
1187 362 markom
                REGNUM_TO_SPRNUM(regno), or1k_err_name (err));
1188 106 markom
}
1189
 
1190
/* Fetch and return instruction from the specified location.  */
1191
 
1192
unsigned int
1193
or1k_fetch_instruction (addr)
1194
     CORE_ADDR addr;
1195
{
1196
  char buf[OR1K_INSTLEN];
1197
  int status;
1198
 
1199
  status = read_memory_nobpt (addr, buf, OR1K_INSTLEN);
1200
  if (status)
1201
    memory_error (status, addr);
1202
  return extract_unsigned_integer (buf, OR1K_INSTLEN);
1203
}
1204
 
1205 113 markom
/* Currently not needed.  */
1206
 
1207 106 markom
static void
1208
or1k_prepare_to_store ()
1209
{
1210
}
1211
 
1212
/* Store remote register(s).  */
1213
 
1214
static void
1215
or1k_store_registers (regno)
1216
     int regno;
1217
{
1218
  if (regno == -1)
1219
    {
1220
      for (regno = 0; regno < NUM_REGS; regno++)
1221
        or1k_store_registers (regno);
1222
      return;
1223
    }
1224
 
1225
  if (regno >= NUM_REGS)
1226
    error("Invalid register number!");
1227
 
1228 362 markom
  or1k_write_spr_reg (REGNUM_TO_SPRNUM(regno), read_register (regno));
1229 106 markom
  if (err)
1230 113 markom
    or1k_error ("Can't write register %d(%i): %s", regno, REGNUM_TO_SPRNUM(regno), or1k_err_name (err));
1231 106 markom
}
1232
 
1233
/* Read or write LEN bytes from inferior memory at MEMADDR,
1234
   transferring to or from debugger address MYADDR.  Write to inferior
1235
   if SHOULD_WRITE is nonzero.  Returns length of data written or
1236
   read; 0 for error.  Note that protocol gives us the correct value
1237
   for a longword, since it transfers values in ASCII.  We want the
1238
   byte values, so we have to swap the longword values.  */
1239
 
1240
static int
1241
or1k_xfer_memory (memaddr, myaddr, len, write, ignore)
1242
     CORE_ADDR memaddr;
1243
     char *myaddr;
1244
     int len;
1245
     int write;
1246
     struct target_ops *ignore;
1247
{
1248
  register int i;
1249
  /* Round starting address down to longword boundary.  */
1250
  register CORE_ADDR addr = memaddr & ~3;
1251
  /* Round ending address up; get number of longwords that makes.  */
1252
  register int count = (((memaddr + len) - addr) + 3) / 4;
1253
  /* Allocate buffer of that many longwords.  */
1254
  register char *buffer = alloca (count * 4);
1255
  int status;
1256
 
1257 143 chris
  int block_xfer_size = 256; /* CZ 21/06/01 ... number of 32 bit words */
1258
  int nBlocks = (count + block_xfer_size -1)/block_xfer_size;
1259
  int terminate = 0;  /* Terminate the printing of '*'s... */
1260
 
1261 362 markom
#ifdef DEBUG_JTAG
1262
  debug ("xfer_memory %s addr=%x, len=%i, \n", write?"write":"read", memaddr, len);
1263
  fflush(stdout);
1264
#endif
1265
 
1266
#if 0
1267 106 markom
  if (memaddr >= MEM_SPACE)
1268
    error("Invalid address");
1269 362 markom
#endif
1270 106 markom
 
1271 135 chris
  /* (CZ 21/06/01 -- because upper layers which know nothing about
1272
     Or1k or JTAG call this function directly, it is always necessary
1273
     to set the chain to point to the Debug Unit. Otherwise, it may
1274 143 chris
     be pointing to the Development Interface chain, in which case
1275 135 chris
     we're going to get bupkiss... */
1276
 
1277 106 markom
  if (write)
1278
    {
1279
      /* Fill start and end extra bytes of buffer with existing data.  */
1280
      if (addr != memaddr || len < 4)
1281
        {
1282
          /* Need part of initial word -- fetch it.  */
1283
          store_unsigned_integer (&buffer[0], 4, or1k_fetch_word (addr));
1284
        }
1285
 
1286
      if (count > 1)
1287
        {
1288
          /* Need part of last word -- fetch it.  FIXME: we do this even
1289
             if we don't need it.  */
1290
          store_unsigned_integer (&buffer[(count - 1) * 4], 4,
1291
                                  or1k_fetch_word (addr + (count - 1) * 4));
1292
        }
1293
 
1294
      /* Copy data to be written over corresponding part of buffer */
1295
      memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
1296
 
1297 143 chris
      /* CZ: rewrote the block transfer routines to make the code
1298
         a little more efficient for implementations that can handle
1299
         variable sized scan chains. Might be useful in the future.
1300
         Certainly makes downloads to the simulator more efficient. */
1301
      for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
1302 106 markom
        {
1303 143 chris
          int j;
1304
          int n = count < block_xfer_size ? count : block_xfer_size;
1305
          unsigned long *__buf;
1306
 
1307
          if(!(__buf = (unsigned long*)malloc(n*sizeof(unsigned long))))
1308 106 markom
            {
1309 143 chris
              errno = ERR_MEM;
1310
              return 0;
1311
            }
1312
 
1313
          for(j=0;j<n;j++)
1314
            __buf[j] = (unsigned long)extract_unsigned_integer(&buffer[(i * block_xfer_size +j)*4], 4);
1315 362 markom
          or1k_set_chain (SC_WISHBONE);
1316 143 chris
          status = or1k_store_block(addr,__buf,n);
1317
          free(__buf);
1318
          if(n == block_xfer_size)
1319
            {
1320 362 markom
              debug ("*");
1321 106 markom
              gdb_flush (gdb_stdout);
1322
            }
1323
          if (status)
1324
            {
1325
              errno = status;
1326
              return 0;
1327
            }
1328
          /* FIXME: Do we want a QUIT here?  */
1329
        }
1330 143 chris
      if (terminate)
1331 362 markom
        debug ("\n");
1332 106 markom
    }
1333
  else
1334
    {
1335 143 chris
      for(i=0;i<nBlocks;i++,count-=block_xfer_size,addr += block_xfer_size*4)
1336 106 markom
        {
1337 143 chris
          int j;
1338
          int n = count < block_xfer_size ? count : block_xfer_size;
1339
          unsigned long *__buf;
1340
 
1341 362 markom
    or1k_set_chain (SC_WISHBONE);
1342 143 chris
          __buf = (unsigned long*)malloc(n*sizeof(unsigned long));
1343
          status = or1k_load_block(addr,__buf,n);
1344
          if (!status)
1345
            for(j=0;j<n;j++)
1346
              store_unsigned_integer (&buffer[(i * block_xfer_size +j)*4], 4, __buf[j]);
1347
          else
1348
            errno = status;
1349
          free(__buf);
1350
 
1351
          if(status)
1352
            return 0;
1353 106 markom
        }
1354
      /* Copy appropriate bytes out of the buffer.  */
1355
      memcpy (myaddr, buffer + (memaddr & 3), len);
1356
    }
1357
  return len;
1358
}
1359
 
1360 143 chris
int or1k_load_block(CORE_ADDR addr,void* buffer,int nRegisters)
1361
{
1362
  int i=0;
1363 362 markom
  unsigned int regno = addr;
1364 143 chris
 
1365
  if (current_or1k_target != NULL && current_or1k_target->to_read_block != NULL)
1366
    return current_or1k_target->to_read_block (regno,buffer,nRegisters);
1367
  else
1368
    for(i=0;i<nRegisters;i++)
1369
      ((unsigned long*)buffer)[i] = 0x1234;
1370
  return 0;
1371
}
1372
 
1373
int or1k_store_block(CORE_ADDR addr,void* buffer,int nRegisters)
1374
{
1375 362 markom
  unsigned int regno = addr;
1376
 
1377 143 chris
  if (current_or1k_target != NULL && current_or1k_target->to_write_block != NULL)
1378
    return current_or1k_target->to_write_block (regno,buffer,nRegisters);
1379
  return 0;
1380
}
1381
 
1382 106 markom
/* Print info on this target.  */
1383
 
1384
static void
1385
or1k_files_info (ignore)
1386
     struct target_ops *ignore;
1387
{
1388
  char *file = "nothing";
1389
 
1390
  if (exec_bfd)
1391
    file = bfd_get_filename (exec_bfd);
1392
 
1393
  printf_filtered ("or1k_files_info: file \"%s\"\n", file);
1394
 
1395
  if (exec_bfd)
1396
    {
1397
      printf_filtered ("\tAttached to %s running program %s\n",
1398
                       target_shortname, file);
1399
    }
1400
  /* Print target info. */
1401
  printf_filtered ("Status: %s\n", status_name[or1k_status]);
1402
}
1403
 
1404
/* Tell whether we can support a hardware breakpoint.  */
1405 118 markom
 
1406 106 markom
static int
1407
or1k_can_use_hardware_breakpoint ()
1408
{
1409
  int i;
1410 118 markom
 
1411 106 markom
  /* Search for unused breakpoint.  */
1412 113 markom
  return or1k_implementation.num_used_matchpoints < or1k_implementation.num_matchpoints;
1413 106 markom
}
1414
 
1415
/* Insert a breakpoint.  On targets that don't have built-in breakpoint
1416
   support, we read the contents of the target location and stash it,
1417
   then overwrite it with a breakpoint instruction.  ADDR is the target
1418
   location in the target machine.  CONTENTS_CACHE is a pointer to
1419
   memory allocated for saving the target contents.  It is guaranteed
1420
   by the caller to be long enough to save sizeof BREAKPOINT bytes (this
1421
   is accomplished via BREAKPOINT_MAX).  */
1422
 
1423 113 markom
int
1424 106 markom
or1k_insert_breakpoint (addr, contents_cache)
1425
     CORE_ADDR addr;
1426
     char *contents_cache;
1427
{
1428
  if (or1k_can_use_hardware_breakpoint())
1429
    return set_breakpoint (addr);
1430
  else
1431
    return memory_insert_breakpoint (addr, contents_cache);
1432
}
1433
 
1434 113 markom
int
1435 106 markom
or1k_remove_breakpoint (addr, contents_cache)
1436
     CORE_ADDR addr;
1437
     char *contents_cache;
1438
{
1439
  /* First try to remove HW breakpoint at address */
1440
  if (clear_breakpoint (addr))
1441
    return memory_remove_breakpoint (addr, contents_cache);
1442
  else
1443
    return 0;
1444
}
1445
 
1446 113 markom
/* Tell whether this target can support a hardware breakpoint.  CNT
1447
   is the number of hardware breakpoints already installed.  This
1448
   implements the TARGET_CAN_USE_HARDWARE_WATCHPOINT macro.
1449
   Lower bound is estimated. !!! Can we estimate better? */
1450
 
1451
int
1452
or1k_can_use_hardware_watchpoint (bp_type, cnt)
1453
     enum bptype bp_type;
1454
     int cnt;
1455
{
1456
  /* Are there at least two matchpoints left for watch? - estimate lower bound  */
1457
  return cnt + ((bp_type == bp_hardware_watchpoint)?(1):(0))
1458
    <= or1k_implementation.num_matchpoints;
1459
}
1460
 
1461 118 markom
/* Moves matchpoint.  This is very tricky - we have to update
1462
   all references to matchpoint indexes.  We assume here that
1463
   matchpoint with index to is unused! */
1464
 
1465
static void
1466
move_matchpoint (int from, int to)
1467
{
1468
  int i, j, tmp, chaining;
1469
  if (matchpoint_user_count[to] != 0)
1470
    error ("Internal: Destination matchpoint still has users");
1471
  matchpoint_user_count[to] = matchpoint_user_count[from];
1472
  matchpoint_user_count[from] = 0;
1473
  debug_regs_changed = 1;
1474
 
1475
  dvr[to] = dvr[from];
1476
  dcr[to] = dcr[from];
1477
  dcr[from].dp = 0;
1478
 
1479
  /* Copy chaining bits.  */
1480
  chaining = dmr1 & (3 << (2 * from));
1481
  dmr1 &= ~(3 << (2 * to));
1482
  dmr1 |= chaining << (2 * to);
1483
  dmr1 &= ~(3 << (2 * from));
1484
 
1485
  /* Copy watchpoint bits */
1486
  tmp = dmr2 & (1 << from);
1487
  dmr2 &= 1 << to;
1488
  dmr2 |= tmp << to;
1489
  dmr2 &= 1 << from;
1490
 
1491
  /* Update hwatch table.  Here we assume that matchpoint
1492
     group is connected (it cannot be implemented in HW
1493
     otherwise), so if we move first, we will have to move
1494
     others later.  */
1495
  for (i = 0; i < num_hw_watches; i++)
1496
    if (or1k_hwatch[i].matchpoint_start == from)
1497
      or1k_hwatch[i].matchpoint_start = to;
1498
 
1499
  /* Update htrace struct.  */
1500
  tmp = or1k_htrace.trig.wp_trig & (1 << from);
1501
  or1k_htrace.trig.wp_trig &= 1 << to;
1502
  or1k_htrace.trig.wp_trig |= tmp << to;
1503
  or1k_htrace.trig.wp_trig &= 1 << from;
1504
 
1505
  tmp = or1k_htrace.qual.wp_trig & (1 << from);
1506
  or1k_htrace.qual.wp_trig &= 1 << to;
1507
  or1k_htrace.qual.wp_trig |= tmp << to;
1508
  or1k_htrace.qual.wp_trig &= 1 << from;
1509
 
1510
  tmp = or1k_htrace.stop.wp_trig & (1 << from);
1511
  or1k_htrace.stop.wp_trig &= 1 << to;
1512
  or1k_htrace.stop.wp_trig |= tmp << to;
1513
  or1k_htrace.stop.wp_trig &= 1 << from;
1514
 
1515
  for (i = 0; i < MAX_MATCHPOINTS; i++)
1516
    {
1517
      tmp = or1k_htrace.wp_record_uses[i] & (1 << from);
1518
      or1k_htrace.wp_record_uses[i] &= 1 << to;
1519
      or1k_htrace.wp_record_uses[i] |= tmp << to;
1520
      or1k_htrace.wp_record_uses[i] &= 1 << from;
1521
    }
1522
 
1523
  /* Do we need to move other references also? */
1524
}
1525
 
1526 113 markom
/* Sifts unused matchpoints to higher indexses.  */
1527
 
1528 118 markom
void
1529 113 markom
sift_matchpoints ()
1530
{
1531
  int i, first_free = 0;
1532
  for (i = 0; i < or1k_implementation.num_matchpoints; i++)
1533
    if (dcr[i].dp)
1534
      {
1535 118 markom
        /* Move references.  */
1536
        move_matchpoint (i, first_free);
1537
 
1538 113 markom
        first_free++;
1539
      }
1540 118 markom
 
1541
  /* Unused matchpoints should be disabled by move_matchpoint,
1542
     so we are done here.  */
1543 113 markom
}
1544
 
1545
/* Translates gdb watchpoint type into one in DCR register.  */
1546
 
1547
static int
1548
translate_type (gdb_type)
1549
     int gdb_type;
1550
{
1551
  switch (gdb_type)
1552
    {
1553
    case 0:
1554
      return CT_SDATA;
1555
    case 1:
1556
      return CT_LDATA;
1557
    case 2:
1558
      return CT_ADATA;
1559
    default:
1560
      error ("Invalid type.");
1561
    }
1562
}
1563
 
1564
/* Set a data watchpoint.  ADDR and LEN should be obvious.  TYPE is 0
1565
   for a write watchpoint, 1 for a read watchpoint, or 2 for a read/write
1566
   watchpoint. */
1567
 
1568
int
1569
or1k_insert_watchpoint (addr, len, type)
1570
     CORE_ADDR addr;
1571
     int len;
1572
     int type;
1573
{
1574
  int i;
1575 118 markom
 
1576 113 markom
  if (len < 1)
1577
    return -1;
1578
 
1579
  type = translate_type (type);
1580
 
1581
  /* Moves unused watchpoints to the top.  */
1582
  sift_matchpoints ();
1583 118 markom
 
1584 113 markom
  /* Place at first free matchpoint.  */
1585
  i = or1k_implementation.num_used_matchpoints;
1586
  dvr[i] = addr;
1587
  dcr[i].dp = 1;
1588
  dcr[i].cc = CC_GREATE;
1589
  dcr[i].sc = 0;
1590
  dcr[i].ct = type;
1591 118 markom
 
1592 113 markom
  /* Set && chaining here.  */
1593
  dmr1 &= ~(3 << (2 * i));
1594 118 markom
  dmr1 |= CHAINING_AND << (2 * i);
1595
 
1596 113 markom
  /* Set upper watchpoint bound.  */
1597
  i++;
1598
  dvr[i] = addr + len - 1;
1599
  dcr[i].dp = 1;
1600
  dcr[i].cc = CC_LESSE;
1601
  dcr[i].sc = 0;
1602
  dcr[i].ct = type;
1603 118 markom
 
1604 113 markom
  /* Matchpoints will cause breakpoints */
1605 118 markom
  dmr2 |= (1 << i);
1606 113 markom
  or1k_implementation.num_used_matchpoints += 2;
1607 118 markom
  debug_regs_changed = 1;
1608 113 markom
  return 0;
1609
}
1610
 
1611
/* Removes a data watchpoint.  ADDR and LEN should be obvious.  TYPE is 0
1612
   for a write watchpoint, 1 for a read watchpoint, or 2 for a read/write
1613
   watchpoint. */
1614 118 markom
 
1615 113 markom
int
1616
or1k_remove_watchpoint (addr, len, type)
1617
     CORE_ADDR addr;
1618
     int len;
1619
     int type;
1620
{
1621
  int i, found = -1;
1622 118 markom
 
1623 113 markom
  if (len < 1)
1624
    return -1;
1625
 
1626
  type = translate_type (type);
1627
 
1628
  /* Find the right one.  */
1629
  for (i = 0; i < or1k_implementation.num_used_matchpoints; i++)
1630
    if (dvr[i] == addr && dcr[i].dp && dcr[i].cc == CC_GREATE && !dcr[i].sc && dcr[i].ct == type
1631
        && dvr[i + 1] == addr + len - 1 && dcr[i + 1].dp && dcr[i + 1].cc == CC_LESSE
1632
        && !dcr[i + 1].sc && dcr[i + 1].ct == type)
1633
      {
1634
        found = i;
1635
        break;
1636
      }
1637
 
1638
  if (found < 0)
1639
    return -1;
1640
 
1641
  dcr[found].dp = 0;
1642
  dcr[found + 1].dp = 0;
1643
 
1644
  /* Matchpoints will not cause breakpoints anymore. */
1645 118 markom
  dmr2 &= ~(1 << i);
1646 113 markom
  or1k_implementation.num_used_matchpoints -= 2;
1647 118 markom
  debug_regs_changed = 1;
1648 113 markom
  return 0;
1649
}
1650
 
1651
int
1652
or1k_stopped_by_watchpoint (void)
1653
{
1654 143 chris
  /* For now, no watchpoints */
1655
  return 0;
1656
 
1657
  /* return hit_watchpoint; */
1658 113 markom
}
1659
 
1660 106 markom
/* Insert a breakpoint.  */
1661
 
1662
int
1663
set_breakpoint (addr)
1664
     CORE_ADDR addr;
1665
{
1666
  int i;
1667 118 markom
 
1668 106 markom
  /* Search for unused breakpoint.  */
1669
  for (i = 0; i < NUM_MATCHPOINTS; i++)
1670
    if (dcr[i].dp == 0) break;
1671
  if (i >= NUM_MATCHPOINTS) return 1;
1672
  dvr[i] = addr;
1673
  dcr[i].dp = 1;
1674
  dcr[i].cc = CC_EQUAL;
1675
  dcr[i].sc = 0;
1676
  dcr[i].ct = CT_FETCH;
1677 113 markom
  or1k_implementation.num_used_matchpoints++;
1678
 
1679
  /* No chaining here.  */
1680
  dmr1 &= ~(3 << (2*i));
1681 118 markom
 
1682 113 markom
  /* Matchpoints will cause breakpoints */
1683 118 markom
  dmr2 |= (1 << i);
1684
  debug_regs_changed = 1;
1685 106 markom
  return 0;
1686
}
1687
 
1688
/* Clear a breakpoint.  */
1689
 
1690
int
1691
clear_breakpoint (addr)
1692
     CORE_ADDR addr;
1693
{
1694
  int i;
1695 118 markom
 
1696 106 markom
  /* Search for matching breakpoint.  */
1697
  for (i = 0; i < NUM_MATCHPOINTS; i++)
1698
    if ((dcr[i].dp == 1) && (dvr[i] == addr) && (dcr[i].cc == CC_EQUAL)
1699
        && (dcr[i].sc == 0) && (dcr[i].ct == CT_FETCH)) break;
1700
 
1701
  if (i >= NUM_MATCHPOINTS) return 1;
1702
  dcr[i].dp = 0;
1703 118 markom
 
1704 113 markom
  /* Matchpoints will cause breakpoints */
1705 118 markom
  dmr2 &= ~(1 << i);
1706 113 markom
  or1k_implementation.num_used_matchpoints--;
1707 118 markom
  debug_regs_changed = 1;
1708 106 markom
  return 0;
1709
}
1710
 
1711
/* Start running on the target board.  */
1712
 
1713
static void
1714
or1k_create_inferior (execfile, args, env)
1715
     char *execfile;
1716
     char *args;
1717
     char **env;
1718
{
1719
  CORE_ADDR entry_pt;
1720
 
1721
  if (args && *args)
1722
    {
1723 118 markom
      warning ("Can't pass arguments to remote OR1K board; arguments ignored.");
1724
 
1725 106 markom
      /* And don't try to use them on the next "run" command.  */
1726
      execute_command ("set args", 0);
1727
    }
1728
 
1729
  if (execfile == 0 || exec_bfd == 0)
1730
    error ("No executable file specified");
1731
 
1732
  or1k_kill ();
1733
  remove_breakpoints ();
1734
 
1735
  entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);
1736
  init_wait_for_inferior ();
1737
 
1738
  /* FIXME: Should we set inferior_pid here?  */
1739 113 markom
 
1740 118 markom
  /* Needed to get correct instruction in cache */
1741
  insert_breakpoints ();
1742 106 markom
  clear_proceed_status ();
1743
  or1k_status = TARGET_STOPPED;
1744
  proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
1745
}
1746
 
1747
/* Clean up after a process.  Actually nothing to do.  */
1748
 
1749
static void
1750
or1k_mourn_inferior ()
1751
{
1752
  generic_mourn_inferior ();
1753
}
1754
 
1755
static void
1756
or1k_dummy_open (name, from_tty)
1757
     char *name;
1758
     int from_tty;
1759
{
1760
  target_preopen (from_tty);
1761
  if (or1k_is_open)
1762
    unpush_target (current_ops);
1763
  current_or1k_target = &or1k_target_dummy;
1764
  or1k_open (name, from_tty);
1765
}
1766
 
1767
static void
1768
or1k_jtag_open (name, from_tty)
1769
     char *name;
1770
     int from_tty;
1771
{
1772
  target_preopen (from_tty);
1773
  if (or1k_is_open)
1774
    unpush_target (current_ops);
1775
  current_or1k_target = &or1k_target_jtag;
1776
  or1k_open (name, from_tty);
1777
}
1778
 
1779
static void
1780
or1k_sim_open (name, from_tty)
1781
     char *name;
1782
     int from_tty;
1783
{
1784
  /* target_preopen (from_tty); - do we need this ? */
1785
  if (or1k_is_open)
1786
    unpush_target (current_ops);
1787
  current_or1k_target = &or1k_target_sim;
1788
  or1k_open (name, from_tty);
1789
}
1790
 
1791
/* Executes command on the target.  */
1792
 
1793
void
1794
or1k_sim_cmd (char *args, int from_tty)
1795
{
1796
  if (current_or1k_target != NULL && current_or1k_target->to_exec_command != NULL)
1797
    current_or1k_target->to_exec_command (args, from_tty);
1798
  else
1799
    error ("Command not supported on this target. ");
1800
}
1801
 
1802 113 markom
/* Displays matchpoints usage.  */
1803
 
1804 106 markom
void
1805 113 markom
info_matchpoints_command (char *args, int from_tty)
1806
{
1807
  int i;
1808
  for (i = 0; i < or1k_implementation.num_matchpoints; i++)
1809
    {
1810
      printf_filtered ("WP%i ", i);
1811
      if (dcr[i].dp)
1812
        {
1813
          int chaining = (dmr1 << 2*i) & 3;
1814
          printf_filtered ("= %s ", ct_names[dcr[i].ct]);
1815
          if (dcr[i]. sc)
1816
            printf_filtered ("s%s %i", cc_names[dcr[i].cc], (int)dvr[i]);
1817
          else
1818
            printf_filtered ("%s %u", cc_names[dcr[i].cc], (unsigned int)dvr[i]);
1819
          if (chaining)
1820
            printf_filtered ("%s WP%i", ch_names[chaining], i - 1);
1821
        }
1822
      else
1823
        printf_filtered ("NOT USED");
1824
      if ((dmr2 >> i) & 1)
1825
        printf_filtered (", causes breakpoint");
1826
      if ((dmr2 >> (i + 11)) & 1)
1827
        printf_filtered (", increments counter");
1828
      printf_filtered ("\n");
1829
    }
1830
}
1831 372 markom
static int
1832
insn_has_delay_slot (insn)
1833
     unsigned int insn;
1834
{
1835
  if (((insn >> 26) <= 4) || ((insn >> 26) == 17) || ((insn >> 26) == 18))
1836
    return 1;
1837
  else
1838
    return 0;
1839
}
1840 113 markom
 
1841
void
1842 106 markom
_initialize_remote_or1k ()
1843
{
1844
  /* Initialize the fields in or1k_ops that are common to all targets.  */
1845
  or1k_dummy_ops.to_close = or1k_close;
1846
  or1k_dummy_ops.to_detach = or1k_detach;
1847
  or1k_dummy_ops.to_resume = or1k_resume;
1848 362 markom
  or1k_dummy_ops.to_wait = or1k_wait;
1849 106 markom
  or1k_dummy_ops.to_fetch_registers = or1k_fetch_registers;
1850
  or1k_dummy_ops.to_store_registers = or1k_store_registers;
1851
  or1k_dummy_ops.to_prepare_to_store = or1k_prepare_to_store;
1852
  or1k_dummy_ops.to_xfer_memory = or1k_xfer_memory;
1853
  or1k_dummy_ops.to_files_info = or1k_files_info;
1854
  or1k_dummy_ops.to_insert_breakpoint = or1k_insert_breakpoint;
1855
  or1k_dummy_ops.to_remove_breakpoint = or1k_remove_breakpoint;
1856
  or1k_dummy_ops.to_kill = or1k_kill;
1857
  or1k_dummy_ops.to_load = generic_load;
1858
  or1k_dummy_ops.to_create_inferior = or1k_create_inferior;
1859
  or1k_dummy_ops.to_mourn_inferior = or1k_mourn_inferior;
1860
  or1k_dummy_ops.to_stratum = process_stratum;
1861 362 markom
  or1k_dummy_ops.to_stop = or1k_stop;
1862 118 markom
 
1863
  /* We can access memory while program is running.  */
1864
  or1k_dummy_ops.to_has_all_memory = 0;
1865
 
1866 106 markom
  or1k_dummy_ops.to_has_memory = 1;
1867
  or1k_dummy_ops.to_has_stack = 1;
1868
  or1k_dummy_ops.to_has_registers = 1;
1869
  or1k_dummy_ops.to_has_execution = 1;
1870
  or1k_dummy_ops.to_magic = OPS_MAGIC;
1871
 
1872
  /* Copy the common fields to all target vectors.  */
1873
  or1k_jtag_ops = or1k_sim_ops = or1k_dummy_ops;
1874 362 markom
 
1875
  /* Initialize target-specific fields in the target vectors adn add targets.  */
1876 106 markom
  or1k_jtag_ops.to_shortname = "jtag";
1877
  or1k_jtag_ops.to_longname = "Remote or1k debugging over JTAG port";
1878 125 chris
  or1k_jtag_ops.to_doc = "Debug a board using the OR1K remote debugging protocol"
1879
    " over a parallel line.\nThe argument is the parallel port it is connected "
1880
    "to, or, if it is formatted\nas a URL of the form jtag://<hostname>:<port>,"
1881
    " then the argument refers to\na remote JTAG proxy server.\n";
1882 362 markom
  or1k_jtag_ops.to_open = or1k_jtag_open;
1883 106 markom
  add_target (&or1k_jtag_ops);
1884
 
1885
  or1k_dummy_ops.to_shortname = "dummy";
1886
  or1k_dummy_ops.to_longname = "Dummy target";
1887
  or1k_dummy_ops.to_doc = "Actually no real target attached - more like /dev/null.\n";
1888
  or1k_dummy_ops.to_open = or1k_dummy_open;
1889
  add_target (&or1k_dummy_ops);
1890
 
1891
  or1k_sim_ops.to_shortname = "sim";
1892
  or1k_sim_ops.to_longname = "Remote or1k debugging using architecture simulator";
1893
  or1k_sim_ops.to_doc = "Debug using an architecture simulator.\n";
1894
  or1k_sim_ops.to_open = or1k_sim_open;
1895
  add_target (&or1k_sim_ops);
1896 113 markom
  add_info ("matchpoints", info_matchpoints_command, "Show current matchpoints allocation status.");
1897 106 markom
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.