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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [remote-or1k.c] - Blame information for rev 1183

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

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

powered by: WebSVN 2.1.0

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