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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [GdbServerSC.cpp] - Blame information for rev 74

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

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// SystemC GDB RSP server: implementation
4
 
5
// Copyright (C) 2008  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
// Contributor Julius Baxter <julius@orsoc.se>
9
 
10
// This file is part of the GDB interface to the cycle accurate model of the
11
// OpenRISC 1000 based system-on-chip, ORPSoC, built using Verilator.
12
 
13
// This program is free software: you can redistribute it and/or modify it
14
// under the terms of the GNU Lesser General Public License as published by
15
// the Free Software Foundation, either version 3 of the License, or (at your
16
// option) any later version.
17
 
18
// This program is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
21
// License for more details.
22
 
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
26
// ----------------------------------------------------------------------------
27
 
28
// $Id$
29
 
30
#include <iostream>
31
#include <iomanip>
32
 
33
#include "GdbServerSC.h"
34
#include "Utils.h"
35
 
36
#include <errno.h>
37
#include <fcntl.h>
38
extern int monitor_to_gdb_pipe[2][2]; // [0][] - monitor to gdb, [1][] - gdb to monitor, [][0] - read, [][1] - write
39
 
40
using std::cerr;
41
using std::dec;
42
using std::endl;
43
using std::hex;
44
 
45
using sc_core::sc_fifo;
46
using sc_core::sc_module_name;
47
using sc_core::sc_stop;
48
using sc_core::sc_time;
49
 
50
 
51
SC_HAS_PROCESS (GdbServerSC);
52
 
53
//-----------------------------------------------------------------------------
54
//! Constructor for the GDB RSP server.
55
 
56
//! We create a SC_THREAD which will act as the listener. Must be a
57
//! thread, since we need to wait for the actions to complete.
58
 
59
//! The current scan chain is marked as undefined.
60
 
61
//! This makes use of the Embecosm cycle accurate SystemC JTAG interface.
62
 
63
//! @see Embecosm Application Note 5 "Using JTAG with SystemC: Implementation
64
//!      of a Cycle Accurate Interface"
65
//!      (http://www.embecosm.com/download/ean5.html)
66
 
67
//! @todo We do not handle a user coded l.trap properly (i.e. one that is not
68
//!       a breakpoint). Effectively it is ignored, whereas we ought to set up
69
//!       the exception registers and redirect through the trap vector.
70
 
71
//! @param[in] name             Name of this module, passed to the parent
72
//!                             constructor. 
73
//! @param[in] _tapActionQueue  Pointer to fifo of actions to be performed by
74
//!                             the JTAG interface
75
//-----------------------------------------------------------------------------
76
GdbServerSC::GdbServerSC (sc_module_name        name,
77
                          uint32_t              _flashStart,
78
                          uint32_t              _flashEnd,
79
                          int                   rspPort,
80
                          sc_fifo<TapAction *> *tapActionQueue) :
81
  sc_module (name),
82
  flashStart (_flashStart),
83
  flashEnd (_flashEnd)
84
{
85
  pkt       = new RspPacket (RSP_PKT_MAX);
86
  rsp       = new RspConnection (rspPort);
87
  debugUnit = new DebugUnitSC ("debug-unit", tapActionQueue);
88
  mpHash    = new MpHash ();
89
 
90
  /* Setup the pipes between or1200 monitor module and GDB stub */
91
  pipe(monitor_to_gdb_pipe[0]);
92
  pipe(monitor_to_gdb_pipe[1]);
93
 
94
  // Set non-blocking reads
95
#ifdef O_NONBLOCK /* The POSIX way */
96
  fcntl (monitor_to_gdb_pipe[0][0], F_SETFL, O_NONBLOCK);
97
  fcntl (monitor_to_gdb_pipe[1][0], F_SETFL, O_NONBLOCK);
98
#elif defined (O_NDELAY)
99
  fcntl (monitor_to_gdb_pipe[0][0], F_SETFL, O_NDELAY);
100
  fcntl (monitor_to_gdb_pipe[1][0], F_SETFL, O_NDELAY);
101
#endif /* O_NONBLOCK */
102
 
103
  SC_THREAD (rspServer);
104
 
105
}       // GdbServerSC ()
106
 
107
 
108
//-----------------------------------------------------------------------------
109
//! Destructor
110
 
111
//! Free up data structures
112
//-----------------------------------------------------------------------------
113
GdbServerSC::~GdbServerSC ()
114
{
115
  delete  mpHash;
116
  delete  debugUnit;
117
  delete  rsp;
118
  delete  pkt;
119
 
120
}       // ~GdbServerSC
121
 
122
 
123
//-----------------------------------------------------------------------------
124
//! SystemC thread to listen for RSP requests
125
 
126
//! JTAG actions will be queued as appropriate. Runs forever
127
 
128
//! We don't allow any actions until the target is out of its startup mode
129
//! (where the ROM is mapped into RAM space). This is determined by seeing if
130
//! the PPC is still in flash memory.
131
 
132
//! Have to use a thread, since we will end up waiting for actions to
133
//! complete.
134
//-----------------------------------------------------------------------------
135
void
136
GdbServerSC::rspServer ()
137
{
138
  // Reset the debug unit, and wait for ORPSoC to be ready, by noting when it
139
  // accesses an address outside of flash. Note that we use NPC, not PPC since
140
  // at reset PPC is zero, and would trigger a false positive.
141
 
142
  debugUnit->resetDebugUnit ();
143
  rsp_sigval = TARGET_SIGNAL_NONE;
144
  /*
145
  uint32_t npc;
146
  do
147
    {
148
      npc = debugUnit->readSpr (SPR_NPC);
149
    }
150
  while ((flashStart <= npc) && (npc <= flashEnd));
151
  */
152
  debugUnit->stall ();
153
  targetStopped = true;
154
 
155
  // Make sure we are connected.
156
  while (!rsp->isConnected ())
157
    {
158
      // Reconnect and stall the processor on a new connection
159
      if (!rsp->rspConnect ())
160
        {
161
          // Serious failure. Must abort execution.
162
          cerr << "*** Unable to continue: ABORTING" << endl;
163
          sc_stop ();
164
        }
165
 
166
      // Stall the processor until we get a command to handle.
167
      if (!debugUnit->isStalled ())
168
        {
169
          debugUnit->stall ();
170
        }
171
 
172
      targetStopped = true;             // Processor now not running
173
    }
174
 
175
 
176
  // Loop processing commands forever
177
  while (true)
178
    {
179
      if (!rsp->isConnected())
180
        {
181
          sc_stop ();
182
          return;
183
        }
184
      // Wait until the target has stopped. In this simplified implementation,
185
      // the only reasons for stopping are hitting a breakpoint (l.trap),
186
      // hardware single stepping or hitting a non-breakpoint l.trap. This
187
      // last is not cleanly handled at the moment (we ought to redirect the
188
      // restart through the trap exception vector).
189
      while (!targetStopped)
190
        {
191
 
192
          /* First check to see if the or1200 monitor module wants us to stall*/
193
          if (checkMonitorPipe())
194
            break;
195
 
196
          rspCheckForException();
197
 
198
          if (debugUnit->isStalled())
199
            {
200
              targetStopped = true;
201
 
202
              // If it's a breakpoint, then we need to back up one
203
              // instruction, so on restart we execute the actual
204
              // instruction.
205
              uint32_t  ppc = debugUnit->readSpr (SPR_PPC);
206
 
207
              if (NULL != mpHash->lookup (BP_MEMORY, ppc) && rsp_sigval == TARGET_SIGNAL_TRAP)
208
                {
209
                  writeNpc (ppc);
210
                }
211
 
212
              // Tell the client we've stopped.
213
              rspReportException ();
214
            }
215
          else if (rsp->rspSocketPeek() > 0)
216
            {
217
              if (rsp->rspSocketPeek() == 0x03) // ETX, end of text control char
218
                {
219
                  // Got an interrupt command from GDB, this function should
220
                  // pull the packet off the socket and stall the processor.
221
                  // and then send a stop reply packet with signal 
222
                  // TARGET_SIGNAL_NONE.
223
                  rspInterrupt();
224
                  targetStopped = true;         // Processor now not running
225
                }
226
            }
227
        }
228
 
229
      // Get a RSP client request
230
      rspClientRequest ();
231
    }
232
}       // rspServer ()
233
 
234
 
235
//-----------------------------------------------------------------------------
236
//! Deal with a request from the GDB client session
237
 
238
//! In general, apart from the simplest requests, this function replies on
239
//! other functions to implement the functionality.
240
 
241
//! @note It is the responsibility of the recipient to delete the packet when
242
//!       it is finished with. It is permissible to reuse the packet for a
243
//!       reply.
244
 
245
//! @todo Is this the implementation of the 'D' packet really the intended
246
//!       meaning? Or does it just mean that only vAttach will be recognized
247
//!       after this?
248
 
249
//! @param[in] pkt  The received RSP packet
250
//-----------------------------------------------------------------------------
251
void
252
GdbServerSC::rspClientRequest ()
253
{
254
  if (!rsp->getPkt (pkt))
255
    {
256
      rsp->rspClose ();                 // Comms failure
257
      return;
258
    }
259 66 julius
  //Uncomment the next line for the RSP client to print out every packet it gets from GDB
260 63 julius
  //cerr << "rspClientRequest: " << pkt->data/*[0]*/ << endl;
261
  switch (pkt->data[0])
262
    {
263
    case '!':
264
      // Request for extended remote mode
265
      pkt->packStr ("OK");
266
      rsp->putPkt (pkt);
267
      return;
268
 
269
    case '?':
270
      // Return last signal ID
271
      rspReportException ();
272
      return;
273
 
274
    case 'A':
275
      // Initialization of argv not supported
276
      cerr << "Warning: RSP 'A' packet not supported: ignored" << endl;
277
      pkt->packStr ("E01");
278
      rsp->putPkt (pkt);
279
      return;
280
 
281
    case 'b':
282
      // Setting baud rate is deprecated
283
      cerr << "Warning: RSP 'b' packet is deprecated and not "
284
           << "supported: ignored" << endl;
285
      return;
286
 
287
    case 'B':
288
      // Breakpoints should be set using Z packets
289
      cerr << "Warning: RSP 'B' packet is deprecated (use 'Z'/'z' "
290
           << "packets instead): ignored" << endl;
291
      return;
292
 
293
    case 'c':
294
      // Continue
295
      rspContinue (EXCEPT_NONE);
296
      return;
297
 
298
    case 'C':
299
      // Continue with signal (in the packet)
300
      rspContinue ();
301
      return;
302
 
303
    case 'd':
304
      // Disable debug using a general query
305
      cerr << "Warning: RSP 'd' packet is deprecated (define a 'Q' "
306
           << "packet instead: ignored" << endl;
307
      return;
308
 
309
    case 'D':
310
      // Detach GDB. Do this by closing the client. The rules say that
311
      // execution should continue, so unstall the processor.
312
      pkt->packStr("OK");
313
      rsp->putPkt (pkt);
314
      rsp->rspClose ();
315
      //debugUnit->unstall ();      
316
      return;
317
 
318
    case 'F':
319
      // File I/O is not currently supported
320
      cerr << "Warning: RSP file I/O not currently supported: 'F' "
321
           << "packet ignored" << endl;
322
      return;
323
 
324
    case 'g':
325
      rspReadAllRegs ();
326
      return;
327
 
328
    case 'G':
329
      rspWriteAllRegs ();
330
      return;
331
 
332
    case 'H':
333
      // Set the thread number of subsequent operations. For now ignore
334
      // silently and just reply "OK"
335
      pkt->packStr ("OK");
336
      rsp->putPkt (pkt);
337
      return;
338
 
339
    case 'i':
340
    case 'I':
341
      // Single cycle step not currently supported. Mark the target as
342
      // running, so that next time it will be detected as stopped (it is
343
      // still stalled in reality) and an ack sent back to the client.
344
      cerr << "Warning: RSP cycle stepping not supported: target "
345
           << "stopped immediately" << endl;
346
      targetStopped = false;
347
      return;
348
 
349
    case 'k':
350
      // Kill request. Do nothing for now.
351
      return;
352
 
353
    case 'm':
354
      // Read memory (symbolic)
355
      rspReadMem ();
356
      return;
357
 
358
    case 'M':
359
      // Write memory (symbolic)
360
      rspWriteMem ();
361
      return;
362
 
363
    case 'p':
364
      // Read a register
365
      rspReadReg ();
366
      return;
367
 
368
    case 'P':
369
      // Write a register
370
      rspWriteReg ();
371
      return;
372
 
373
    case 'q':
374
      // Any one of a number of query packets
375
      rspQuery ();
376
      return;
377
 
378
    case 'Q':
379
      // Any one of a number of set packets
380
      rspSet ();
381
      return;
382
 
383
    case 'r':
384
      // Reset the system. Deprecated (use 'R' instead)
385
      cerr << "Warning: RSP 'r' packet is deprecated (use 'R' "
386
                << "packet instead): ignored" << endl;
387
      return;
388
 
389
    case 'R':
390
      // Restart the program being debugged.
391
      rspRestart ();
392
      return;
393
 
394
    case 's':
395
      // Single step one machine instruction.
396
      rspStep (EXCEPT_NONE);
397
      return;
398
 
399
    case 'S':
400
      // Single step one machine instruction.
401
      rspStep ();
402
      return;
403
 
404
    case 't':
405
      // Search. This is not well defined in the manual and for now we don't
406
      // support it. No response is defined.
407
      cerr << "Warning: RSP 't' packet not supported: ignored"
408
                << endl;
409
      return;
410
 
411
    case 'T':
412
      // Is the thread alive. We are bare metal, so don't have a thread
413
      // context. The answer is always "OK".
414
      pkt->packStr ("OK");
415
      rsp->putPkt (pkt);
416
      return;
417
 
418
    case 'v':
419
      // Any one of a number of packets to control execution
420
      rspVpkt ();
421
      return;
422
 
423
    case 'X':
424
      // Write memory (binary)
425
      rspWriteMemBin ();
426
      return;
427
 
428
    case 'z':
429
      // Remove a breakpoint/watchpoint.
430
      rspRemoveMatchpoint ();
431
      return;
432
 
433
    case 'Z':
434
      // Insert a breakpoint/watchpoint.
435
      rspInsertMatchpoint ();
436
      return;
437
 
438
    default:
439
      // Unknown commands are ignored
440
      cerr << "Warning: Unknown RSP request" << pkt->data << endl;
441
      return;
442
    }
443
}       // rspClientRequest ()
444
 
445
 
446
 
447
//-----------------------------------------------------------------------------
448
//! Check if processor is stalled. If it is, read the DRR and return the
449
//! target signal code.
450
//-----------------------------------------------------------------------------
451
void
452
GdbServerSC::rspCheckForException()
453
{
454
 
455
  uint32_t drr;
456
 
457
  if (!debugUnit->isStalled())
458
    {
459
      // Processor not stalled. Just return;
460
      return;
461
    }
462
 
463
  switch ((debugUnit->readSpr(SPR_DRR)&0xffffffff))
464
    {
465
    case SPR_DRR_RSTE:  rsp_sigval = TARGET_SIGNAL_PWR;  break;
466
    case SPR_DRR_BUSEE: rsp_sigval = TARGET_SIGNAL_BUS;  break;
467
    case SPR_DRR_DPFE:  rsp_sigval = TARGET_SIGNAL_SEGV; break;
468
    case SPR_DRR_IPFE:  rsp_sigval = TARGET_SIGNAL_SEGV; break;
469
    case SPR_DRR_TTE:   rsp_sigval = TARGET_SIGNAL_ALRM; break;
470
    case SPR_DRR_AE:    rsp_sigval = TARGET_SIGNAL_BUS;  break;
471
    case SPR_DRR_IIE:   rsp_sigval = TARGET_SIGNAL_ILL;  break;
472
    case SPR_DRR_IE:    rsp_sigval = TARGET_SIGNAL_INT;  break;
473
    case SPR_DRR_DME:   rsp_sigval = TARGET_SIGNAL_SEGV; break;
474
    case SPR_DRR_IME:   rsp_sigval = TARGET_SIGNAL_SEGV; break;
475
    case SPR_DRR_RE:    rsp_sigval = TARGET_SIGNAL_FPE;  break;
476
    case SPR_DRR_SCE:   rsp_sigval = TARGET_SIGNAL_USR2; break;
477
    case SPR_DRR_FPE:   rsp_sigval = TARGET_SIGNAL_FPE;  break;
478
    case SPR_DRR_TE:    rsp_sigval = TARGET_SIGNAL_TRAP; break;
479
 
480
    default:
481
      // This must be the case of single step (which does not set DRR)
482
      rsp_sigval = TARGET_SIGNAL_TRAP; break;
483
    }
484
 
485
  return;
486
}
487
 
488
//-----------------------------------------------------------------------------
489
//! Send a packet acknowledging an exception has occurred
490
 
491
//! The only signal we ever see in this implementation is TRAP.
492
//-----------------------------------------------------------------------------
493
void
494
GdbServerSC::rspReportException ()
495
{
496
  // Construct a signal received packet
497
  pkt->data[0] = 'S';
498
  pkt->data[1] = Utils::hex2Char (rsp_sigval >> 4);
499
  pkt->data[2] = Utils::hex2Char (rsp_sigval % 16);
500
  pkt->data[3] = '\0';
501
  pkt->setLen (strlen (pkt->data));
502
 
503
  rsp->putPkt (pkt);
504
 
505
}       // rspReportException ()
506
 
507
 
508
//-----------------------------------------------------------------------------
509
//! Handle a RSP continue request
510
 
511
//! This version is typically used for the 'c' packet, to continue without
512
//! signal, in which case EXCEPT_NONE is passed in as the exception to use.
513
 
514
//! At present other exceptions are not supported
515
 
516
//! @param[in] except  The OpenRISC 1000 exception to use
517
//-----------------------------------------------------------------------------
518
void
519
GdbServerSC::rspContinue (uint32_t   except)
520
{
521
  uint32_t  addr;                       // Address to continue from, if any
522
 
523
  // Reject all except 'c' packets
524
  if ('c' != pkt->data[0])
525
    {
526
      cerr << "Warning: Continue with signal not currently supported: "
527
           << "ignored" << endl;
528
      return;
529
    }
530
 
531
  // Get an address if we have one
532
  if (0 == strcmp ("c", pkt->data))
533
    {
534
      addr = readNpc ();                // Default uses current NPC
535
    }
536
  else if (1 != sscanf (pkt->data, "c%lx", &addr))
537
    {
538
      cerr << "Warning: RSP continue address " << pkt->data
539
                << " not recognized: ignored" << endl;
540
      addr = readNpc ();                // Default uses current NPC
541
    }
542
 
543
  rspContinue (addr, EXCEPT_NONE);
544
 
545
}       // rspContinue ()
546
 
547
 
548
//-----------------------------------------------------------------------------
549
//! Handle a RSP continue with signal request
550
 
551
//! @todo Currently does nothing. Will use the underlying generic continue
552
//!       function. 
553
//-----------------------------------------------------------------------------
554
void
555
GdbServerSC::rspContinue ()
556
{
557
  cerr << "RSP continue with signal '" << pkt->data
558
       << "' received" << endl;
559
 
560
}       // rspContinue ()
561
 
562
 
563
//-----------------------------------------------------------------------------
564
//! Generic processing of a continue request
565
 
566
//! The signal may be EXCEPT_NONE if there is no exception to be
567
//! handled. Currently the exception is ignored.
568
 
569
//! The single step flag is cleared in the debug registers and then the
570
//! processor is unstalled.
571
 
572
//! @param[in] addr    Address from which to step
573
//! @param[in] except  The exception to use (if any)                         
574
//-----------------------------------------------------------------------------
575
void
576
GdbServerSC::rspContinue (uint32_t  addr,
577
                          uint32_t  except)
578
{
579
  // Set the address as the value of the next program counter
580
  writeNpc (addr);
581
 
582
  /*
583
  // If we're continuing from a breakpoint, replace that instruction in the memory
584
  // ... actually no, I was wrong about this.
585
  if (NULL != mpHash->lookup (BP_MEMORY, addr) && rsp_sigval == TARGET_SIGNAL_TRAP)
586
    {
587
      MpEntry *entry = mpHash->lookup (BP_MEMORY, addr);
588
      debugUnit->writeMem32(entry->addr, entry->instr);
589
    }
590
  */
591
 
592
  // Clear Debug Reason Register and watchpoint break generation in Debug Mode
593
  // Register 2 for watchpoints that we triggered to stop this time.
594
  debugUnit->writeSpr (SPR_DRR,  0);
595
  if (rsp_sigval == TARGET_SIGNAL_TRAP)
596
    {
597
      /*
598
         Disable last trap generation on watchpoint if this is why we stopped
599
         last time.
600
      */
601
      uint32_t temp_dmr2 = debugUnit->readSpr (SPR_DMR2);
602
      if (temp_dmr2 & SPR_DMR2_WBS)
603
        {
604
          /*
605
             One of these breakpoints is responsible for our stopping, so
606
             disable it this time we start. GDB will send a packet re-enabling
607
             it next time we continue.
608
          */
609
          debugUnit->writeSpr (SPR_DMR2, temp_dmr2 & ~((temp_dmr2&SPR_DMR2_WBS)>>10));
610
        }
611
    }
612
 
613
  // Clear the single step trigger in Debug Mode Register 1 and set traps to
614
  // be handled by the debug unit in the Debug Stop Register
615
  debugUnit->andSpr (SPR_DMR1, ~SPR_DMR1_ST);
616
  debugUnit->orSpr ( SPR_DSR,  SPR_DSR_TE);
617
 
618
  // Unstall the processor. Note the GDB client is now waiting for a reply,
619
  // which it will get as soon as the processor stalls again.
620
  debugUnit->unstall ();
621
  targetStopped = false;
622
 
623
}       // rspContinue ()
624
 
625
 
626
 
627
//------------------------------------------------------------------------------
628
//!Handle an interrupt from GDB
629
 
630
//! Detect an interrupt from GDB and stall the processor                        
631
//------------------------------------------------------------------------------
632
void
633
GdbServerSC::rspInterrupt()
634
{
635
  unsigned char  c;
636
 
637
  c = rsp->getRspChar();
638
  if (c < 0)
639
    {
640
      // Had issues, just return
641
      return;
642
    }
643
 
644
  // Ensure this is a ETX control char (0x3), currently, we only call this
645
  // function when we've peeked and seen it, otherwise, ignore, return and pray
646
  // things go back to normal...
647
  if (c != 0x03)
648
    {
649
      cerr << "* Warning: Interrupt character expected but not found on socket" << endl;
650
      return;
651
    }
652
 
653
  // Otherwise, it's an interrupt packet, stall the processor, and upon return
654
  // to the main handle_rsp() loop, it will inform GDB.
655
 
656
  debugUnit->stall ();
657
 
658
  // Send a stop reply response, manually set rsp.sigval to TARGET_SIGNAL_NONE
659
  rsp_sigval = TARGET_SIGNAL_NONE;
660
  rspReportException();
661
 
662
  return;
663
 
664
}
665
 
666
//-----------------------------------------------------------------------------
667
//! Handle a RSP read all registers request
668
 
669
//! The registers follow the GDB sequence for OR1K: GPR0 through GPR31, PPC
670
//! (i.e. SPR PPC), NPC (i.e. SPR NPC) and SR (i.e. SPR SR). Each register is
671
//! returned as a sequence of bytes in target endian order.
672
 
673
//! Each byte is packed as a pair of hex digits.                             
674
//-----------------------------------------------------------------------------
675
void
676
GdbServerSC::rspReadAllRegs ()
677
{
678
  // The GPRs
679
  for (int  r = 0; r < max_gprs; r++)
680
    {
681
      Utils::reg2Hex (readGpr (r), &(pkt->data[r * 8]));
682
    }
683
 
684
  // PPC, NPC and SR
685
  Utils::reg2Hex (debugUnit->readSpr (SPR_PPC), &(pkt->data[PPC_REGNUM * 8]));
686
  Utils::reg2Hex (readNpc (),                   &(pkt->data[NPC_REGNUM * 8]));
687
  Utils::reg2Hex (debugUnit->readSpr (SPR_SR),  &(pkt->data[SR_REGNUM  * 8]));
688
 
689
  // Finalize the packet and send it
690
  pkt->data[NUM_REGS * 8] = 0;
691
  pkt->setLen (NUM_REGS * 8);
692
  rsp->putPkt (pkt);
693
 
694
}       // rspReadAllRegs ()
695
 
696
 
697
//-----------------------------------------------------------------------------
698
//! Handle a RSP write all registers request
699
 
700
//! The registers follow the GDB sequence for OR1K: GPR0 through GPR31, PPC
701
//! (i.e. SPR PPC), NPC (i.e. SPR NPC) and SR (i.e. SPR SR). Each register is
702
//! supplied as a sequence of bytes in target endian order.
703
 
704
//! Each byte is packed as a pair of hex digits.
705
 
706
//! @todo There is no error checking at present. Non-hex chars will generate a
707
//!       warning message, but there is no other check that the right amount
708
//!       of data is present. The result is always "OK".
709
//-----------------------------------------------------------------------------
710
void
711
GdbServerSC::rspWriteAllRegs ()
712
{
713
  // The GPRs
714
  for (int  r = 0; r < max_gprs; r++)
715
    {
716
      writeGpr (r, Utils::hex2Reg (&(pkt->data[r * 8])));
717
    }
718
 
719
  // PPC, NPC and SR
720
  debugUnit->writeSpr (SPR_PPC, Utils::hex2Reg (&(pkt->data[PPC_REGNUM * 8])));
721
  debugUnit->writeSpr (SPR_SR,  Utils::hex2Reg (&(pkt->data[SR_REGNUM  * 8])));
722
  writeNpc (                    Utils::hex2Reg (&(pkt->data[NPC_REGNUM * 8])));
723
 
724
  // Acknowledge (always OK for now).
725
  pkt->packStr ("OK");
726
  rsp->putPkt (pkt);
727
 
728
}       // rspWriteAllRegs ()
729
 
730
 
731
//-----------------------------------------------------------------------------
732
//! Handle a RSP read memory (symbolic) request
733
 
734
//! Syntax is:
735
 
736
//!   m<addr>,<length>:
737
 
738
//! The response is the bytes, lowest address first, encoded as pairs of hex
739
//! digits.
740
 
741
//! The length given is the number of bytes to be read.
742
//-----------------------------------------------------------------------------
743
void
744
GdbServerSC::rspReadMem ()
745
{
746
  unsigned int    addr;                 // Where to read the memory
747
  int             len;                  // Number of bytes to read
748
  int             off;                  // Offset into the memory
749
 
750
  if (2 != sscanf (pkt->data, "m%x,%x:", &addr, &len))
751
    {
752
      cerr << "Warning: Failed to recognize RSP read memory command: "
753
                << pkt->data << endl;
754
      pkt->packStr ("E01");
755
      rsp->putPkt (pkt);
756
      return;
757
    }
758
 
759
  // Make sure we won't overflow the buffer (2 chars per byte)
760
  if ((len * 2) >= pkt->getBufSize())
761
    {
762
      cerr << "Warning: Memory read " << pkt->data
763
           << " too large for RSP packet: truncated" << endl;
764
      len = (pkt->getBufSize() - 1) / 2;
765
    }
766
  //cerr << "rspReadMem: " << len << " bytes@0x"<< hex << addr << endl;
767
  // Refill the buffer with the reply
768
  for (off = 0; off < len; off++)
769
    {
770
      unsigned char  ch = debugUnit->readMem8 (addr + off);
771
 
772
      pkt->data[off * 2]     = Utils::hex2Char(ch >>   4);
773
      pkt->data[off * 2 + 1] = Utils::hex2Char(ch &  0xf);
774
    }
775
 
776
  pkt->data[off * 2] = '\0';                    // End of string
777
  pkt->setLen (strlen (pkt->data));
778
  rsp->putPkt (pkt);
779
 
780
}       // rsp_read_mem ()
781
 
782
 
783
//-----------------------------------------------------------------------------
784
//! Handle a RSP write memory (symbolic) request
785
 
786
//! Syntax is:
787
 
788
//!   m<addr>,<length>:<data>
789
 
790
//! The data is the bytes, lowest address first, encoded as pairs of hex
791
//! digits.
792
 
793
//! The length given is the number of bytes to be written.
794
//-----------------------------------------------------------------------------
795
void
796
GdbServerSC::rspWriteMem ()
797
{
798
  uint32_t  addr;                       // Where to write the memory
799
  int       len;                        // Number of bytes to write
800
 
801
  if (2 != sscanf (pkt->data, "M%x,%x:", &addr, &len))
802
    {
803
      cerr << "Warning: Failed to recognize RSP write memory "
804
                << pkt->data << endl;
805
      pkt->packStr ("E01");
806
      rsp->putPkt (pkt);
807
      return;
808
    }
809
 
810
  // Find the start of the data and check there is the amount we expect.
811
  char *symDat = (char *)(memchr (pkt->data, ':', pkt->getBufSize())) + 1;
812
  int   datLen = pkt->getLen() - (symDat - pkt->data);
813
 
814
  // Sanity check
815
  if (len * 2 != datLen)
816
    {
817
      cerr << "Warning: Write of " << len * 2 << "digits requested, but "
818
                << datLen << " digits supplied: packet ignored" << endl;
819
      pkt->packStr ("E01");
820
      rsp->putPkt (pkt);
821
      return;
822
    }
823
 
824
  // Write the bytes to memory (no check the address is OK here)
825
  for (int  off = 0; off < len; off++)
826
    {
827
      uint8_t  nyb1 = Utils::char2Hex (symDat[off * 2]);
828
      uint8_t  nyb2 = Utils::char2Hex (symDat[off * 2 + 1]);
829
 
830
      if (!debugUnit->writeMem8 (addr + off, (nyb1 << 4) | nyb2))
831
        {
832
          pkt->packStr ("E01");
833
          rsp->putPkt (pkt);
834
          return;
835
        }
836
    }
837
 
838
  pkt->packStr ("OK");
839
  rsp->putPkt (pkt);
840
 
841
}       // rspWriteMem ()
842
 
843
 
844
//-----------------------------------------------------------------------------
845
//! Read a single register
846
 
847
//! The registers follow the GDB sequence for OR1K: GPR0 through GPR31, PC
848
//! (i.e. SPR NPC) and SR (i.e. SPR SR). The register is returned as a
849
//! sequence of bytes in target endian order.
850
 
851
//! Each byte is packed as a pair of hex digits.
852
//-----------------------------------------------------------------------------
853
void
854
GdbServerSC::rspReadReg ()
855
{
856
  unsigned int  regNum;
857
 
858
  // Break out the fields from the data
859
  if (1 != sscanf (pkt->data, "p%x", &regNum))
860
    {
861
      cerr << "Warning: Failed to recognize RSP read register command: "
862
                << pkt->data << endl;
863
      pkt->packStr ("E01");
864
      rsp->putPkt (pkt);
865
      return;
866
    }
867
 
868
  // Get the relevant register
869
  if (regNum < max_gprs)
870
    {
871
      Utils::Utils::reg2Hex (readGpr (regNum), pkt->data);
872
    }
873
  else if (PPC_REGNUM == regNum)
874
    {
875
      Utils::Utils::reg2Hex (debugUnit->readSpr (SPR_PPC), pkt->data);
876
    }
877
  else if (NPC_REGNUM == regNum)
878
    {
879
      Utils::Utils::reg2Hex (readNpc (), pkt->data);
880
    }
881
  else if (SR_REGNUM == regNum)
882
    {
883
      Utils::Utils::reg2Hex (debugUnit->readSpr (SPR_SR), pkt->data);
884
    }
885
  else
886
    {
887
      // Error response if we don't know the register
888
      cerr << "Warning: Attempt to read unknown register" << regNum
889
                << ": ignored" << endl;
890
      pkt->packStr ("E01");
891
      rsp->putPkt (pkt);
892
      return;
893
    }
894
 
895
  pkt->setLen (strlen (pkt->data));
896
  rsp->putPkt (pkt);
897
 
898
}       // rspWriteReg ()
899
 
900
 
901
//-----------------------------------------------------------------------------
902
//! Write a single register
903
 
904
//! The registers follow the GDB sequence for OR1K: GPR0 through GPR31, PC
905
//! (i.e. SPR NPC) and SR (i.e. SPR SR). The register is specified as a
906
//! sequence of bytes in target endian order.
907
 
908
//! Each byte is packed as a pair of hex digits.
909
//-----------------------------------------------------------------------------
910
void
911
GdbServerSC::rspWriteReg ()
912
{
913
  unsigned int  regNum;
914
  char          valstr[9];              // Allow for EOS on the string
915
 
916
  // Break out the fields from the data
917
  if (2 != sscanf (pkt->data, "P%x=%8s", &regNum, valstr))
918
    {
919
      cerr << "Warning: Failed to recognize RSP write register command "
920
           << pkt->data << endl;
921
      pkt->packStr ("E01");
922
      rsp->putPkt (pkt);
923
      return;
924
    }
925
 
926
  // Set the relevant register
927
  if (regNum < max_gprs)
928
    {
929
      writeGpr (regNum, Utils::hex2Reg (valstr));
930
    }
931
  else if (PPC_REGNUM == regNum)
932
    {
933
      debugUnit->writeSpr (SPR_PPC, Utils::hex2Reg (valstr));
934
    }
935
  else if (NPC_REGNUM == regNum)
936
    {
937
      writeNpc (Utils::hex2Reg (valstr));
938
    }
939
  else if (SR_REGNUM == regNum)
940
    {
941
      debugUnit->writeSpr (SPR_SR, Utils::hex2Reg (valstr));
942
    }
943
  else
944
    {
945
      // Error response if we don't know the register
946
      cerr << "Warning: Attempt to write unknown register " << regNum
947
                << ": ignored" << endl;
948
      pkt->packStr ("E01");
949
      rsp->putPkt (pkt);
950
      return;
951
    }
952
 
953
  pkt->packStr ("OK");
954
  rsp->putPkt (pkt);
955
 
956
}       // rspWriteReg ()
957
 
958
 
959
//-----------------------------------------------------------------------------
960
//! Handle a RSP query request
961
//-----------------------------------------------------------------------------
962
void
963
GdbServerSC::rspQuery ()
964
{
965
  if (0 == strcmp ("qC", pkt->data))
966
    {
967
      // Return the current thread ID (unsigned hex). A null response
968
      // indicates to use the previously selected thread. We use the constant
969
      // OR1KSIM_TID to represent our single thread of control.
970
      sprintf (pkt->data, "QC%x", OR1KSIM_TID);
971
      pkt->setLen (strlen (pkt->data));
972
      rsp->putPkt (pkt);
973
    }
974
  else if (0 == strncmp ("qCRC", pkt->data, strlen ("qCRC")))
975
    {
976
      // Return CRC of memory area
977
      cerr << "Warning: RSP CRC query not supported" << endl;
978
      pkt->packStr ("E01");
979
      rsp->putPkt (pkt);
980
    }
981
  else if (0 == strcmp ("qfThreadInfo", pkt->data))
982
    {
983
      // Return info about active threads. We return just the constant
984
      // OR1KSIM_TID to represent our single thread of control.
985
      sprintf (pkt->data, "m%x", OR1KSIM_TID);
986
      pkt->setLen (strlen (pkt->data));
987
      rsp->putPkt (pkt);
988
    }
989
  else if (0 == strcmp ("qsThreadInfo", pkt->data))
990
    {
991
      // Return info about more active threads. We have no more, so return the
992
      // end of list marker, 'l'
993
      pkt->packStr ("l");
994
      rsp->putPkt (pkt);
995
    }
996
  else if (0 == strncmp ("qGetTLSAddr:", pkt->data, strlen ("qGetTLSAddr:")))
997
    {
998
      // We don't support this feature
999
      pkt->packStr ("");
1000
      rsp->putPkt (pkt);
1001
    }
1002
  else if (0 == strncmp ("qL", pkt->data, strlen ("qL")))
1003
    {
1004
      // Deprecated and replaced by 'qfThreadInfo'
1005
      cerr << "Warning: RSP qL deprecated: no info returned" << endl;
1006
      pkt->packStr ("qM001");
1007
      rsp->putPkt (pkt);
1008
    }
1009
  else if (0 == strcmp ("qOffsets", pkt->data))
1010
    {
1011
      // Report any relocation
1012
      pkt->packStr ("Text=0;Data=0;Bss=0");
1013
      rsp->putPkt (pkt);
1014
    }
1015
  else if (0 == strncmp ("qP", pkt->data, strlen ("qP")))
1016
    {
1017
      // Deprecated and replaced by 'qThreadExtraInfo'
1018
      cerr << "Warning: RSP qP deprecated: no info returned" << endl;
1019
      pkt->packStr ("");
1020
      rsp->putPkt (pkt);
1021
    }
1022
  else if (0 == strncmp ("qRcmd,", pkt->data, strlen ("qRcmd,")))
1023
    {
1024
      // This is used to interface to commands to do "stuff"
1025
      rspCommand ();
1026
    }
1027
  else if (0 == strncmp ("qSupported", pkt->data, strlen ("qSupported")))
1028
    {
1029
      // Report a list of the features we support. For now we just ignore any
1030
      // supplied specific feature queries, but in the future these may be
1031
      // supported as well. Note that the packet size allows for 'G' + all the
1032
      // registers sent to us, or a reply to 'g' with all the registers and an
1033
      // EOS so the buffer is a well formed string.
1034
      sprintf (pkt->data, "PacketSize=%x", pkt->getBufSize());
1035
      pkt->setLen (strlen (pkt->data));
1036
      rsp->putPkt (pkt);
1037
    }
1038
  else if (0 == strncmp ("qSymbol:", pkt->data, strlen ("qSymbol:")))
1039
    {
1040
      // Offer to look up symbols. Nothing we want (for now). TODO. This just
1041
      // ignores any replies to symbols we looked up, but we didn't want to
1042
      // do that anyway!
1043
      pkt->packStr ("OK");
1044
      rsp->putPkt (pkt);
1045
    }
1046
  else if (0 == strncmp ("qThreadExtraInfo,", pkt->data,
1047
                         strlen ("qThreadExtraInfo,")))
1048
    {
1049
      // Report that we are runnable, but the text must be hex ASCI
1050
      // digits. For now do this by steam, reusing the original packet
1051
      sprintf (pkt->data, "%02x%02x%02x%02x%02x%02x%02x%02x%02x",
1052
               'R', 'u', 'n', 'n', 'a', 'b', 'l', 'e', 0);
1053
      pkt->setLen (strlen (pkt->data));
1054
      rsp->putPkt (pkt);
1055
    }
1056
  else if (0 == strncmp ("qXfer:", pkt->data, strlen ("qXfer:")))
1057
    {
1058
      // For now we support no 'qXfer' requests, but these should not be
1059
      // expected, since they were not reported by 'qSupported'
1060
      cerr << "Warning: RSP 'qXfer' not supported: ignored" << endl;
1061
      pkt->packStr ("");
1062
      rsp->putPkt (pkt);
1063
    }
1064
  else
1065
    {
1066
      cerr << "Unrecognized RSP query: ignored" << endl;
1067
    }
1068
}       // rspQuery ()
1069
 
1070
 
1071
//-----------------------------------------------------------------------------
1072
//! Handle a RSP qRcmd request
1073
 
1074
//! The actual command follows the "qRcmd," in ASCII encoded to hex
1075
//-----------------------------------------------------------------------------
1076
void
1077
GdbServerSC::rspCommand ()
1078
{
1079
  char  cmd[RSP_PKT_MAX];
1080
 
1081
  Utils::hex2Ascii (cmd, &(pkt->data[strlen ("qRcmd,")]));
1082
 
1083
  // Work out which command it is
1084
  if (0 == strncmp ("readspr ", cmd, strlen ("readspr")))
1085
    {
1086
      unsigned int       sprNum;
1087
 
1088
      // Parse and return error if we fail
1089
      if( 1 != sscanf (cmd, "readspr %4x", &sprNum))
1090
        {
1091
          cerr << "Warning: qRcmd " << cmd
1092
                    << "not recognized: ignored" << endl;
1093
          pkt->packStr ("E01");
1094
          rsp->putPkt (pkt);
1095
          return;
1096
        }
1097
 
1098
      // SPR out of range
1099
      if (sprNum > MAX_SPRS)
1100
        {
1101
          cerr <<  "Warning: qRcmd readspr " << hex << sprNum
1102
                    << dec << " too large: ignored" << endl;
1103
          pkt->packStr ("E01");
1104
          rsp->putPkt (pkt);
1105
          return;
1106
        }
1107
 
1108
      // Construct the reply
1109
      sprintf (cmd, "%8lx", debugUnit->readSpr (sprNum));
1110
      Utils::ascii2Hex (pkt->data, cmd);
1111
      pkt->setLen (strlen (pkt->data));
1112
      rsp->putPkt (pkt);
1113
    }
1114
  else if (0 == strncmp ("writespr ", cmd, strlen ("writespr")))
1115
    {
1116
      unsigned int  sprNum;
1117
      uint32_t      val;
1118
 
1119
      // Parse and return error if we fail
1120
      if( 2 != sscanf (cmd, "writespr %4x %8lx", &sprNum, &val))
1121
        {
1122
          cerr << "Warning: qRcmd " << cmd << " not recognized: ignored"
1123
                    << endl;
1124
          pkt->packStr ("E01");
1125
          rsp->putPkt (pkt);
1126
          return;
1127
        }
1128
 
1129
      // SPR out of range
1130
      if (sprNum > MAX_SPRS)
1131
        {
1132
          cerr <<  "Warning: qRcmd writespr " << hex << sprNum
1133
                    << dec << " too large: ignored" << endl;
1134
          pkt->packStr ("E01");
1135
          rsp->putPkt (pkt);
1136
          return;
1137
        }
1138
 
1139
      // Update the SPR and reply "OK"
1140
      debugUnit->writeSpr (sprNum, val);
1141
      pkt->packStr ("OK");
1142
      rsp->putPkt (pkt);
1143
    }
1144
 
1145
}       // rspCommand ()
1146
 
1147
 
1148
//-----------------------------------------------------------------------------
1149
//! Handle a RSP set request
1150
//-----------------------------------------------------------------------------
1151
void
1152
GdbServerSC::rspSet ()
1153
{
1154
  if (0 == strncmp ("QPassSignals:", pkt->data, strlen ("QPassSignals:")))
1155
    {
1156
      // Passing signals not supported
1157
      pkt->packStr ("");
1158
      rsp->putPkt (pkt);
1159
    }
1160
  else if ((0 == strncmp ("QTDP",    pkt->data, strlen ("QTDP")))   ||
1161
           (0 == strncmp ("QFrame",  pkt->data, strlen ("QFrame"))) ||
1162
           (0 == strcmp  ("QTStart", pkt->data))                    ||
1163
           (0 == strcmp  ("QTStop",  pkt->data))                    ||
1164
           (0 == strcmp  ("QTinit",  pkt->data))                    ||
1165
           (0 == strncmp ("QTro",    pkt->data, strlen ("QTro"))))
1166
    {
1167
      // All tracepoint features are not supported. This reply is really only
1168
      // needed to 'QTDP', since with that the others should not be
1169
      // generated.
1170
      pkt->packStr ("");
1171
      rsp->putPkt (pkt);
1172
    }
1173
  else
1174
    {
1175
      cerr << "Unrecognized RSP set request: ignored" << endl;
1176
      delete  pkt;
1177
    }
1178
}       // rspSet ()
1179
 
1180
 
1181
//-----------------------------------------------------------------------------
1182
//! Handle a RSP restart request
1183
 
1184
//! For now we just put the program counter back to the reset vector. If we
1185
//! supported the vRun request, we should use the address specified
1186
//! there. There is no point in unstalling the processor, since we'll never
1187
//! get control back.
1188
//-----------------------------------------------------------------------------
1189
void
1190
GdbServerSC::rspRestart ()
1191
{
1192
  writeNpc (EXCEPT_RESET);
1193
 
1194
}       // rspRestart ()
1195
 
1196
 
1197
//-----------------------------------------------------------------------------
1198
//! Handle a RSP step request
1199
 
1200
//! This version is typically used for the 's' packet, to continue without
1201
//! signal, in which case EXCEPT_NONE is passed in as the exception to use.
1202
 
1203
//! @param[in] except  The exception to use. Only EXCEPT_NONE should be set
1204
//!                    this way.
1205
//-----------------------------------------------------------------------------
1206
void
1207
GdbServerSC::rspStep (uint32_t   except)
1208
{
1209
  uint32_t  addr;               // The address to step from, if any
1210
 
1211
  // Reject all except 's' packets
1212
  if ('s' != pkt->data[0])
1213
    {
1214
      cerr << "Warning: Step with signal not currently supported: "
1215
           << "ignored" << endl;
1216
      return;
1217
    }
1218
 
1219
  if (0 == strcmp ("s", pkt->data))
1220
    {
1221
      addr = readNpc ();                // Default uses current NPC
1222
    }
1223
  else if (1 != sscanf (pkt->data, "s%lx", &addr))
1224
    {
1225
      cerr << "Warning: RSP step address " << pkt->data
1226
           << " not recognized: ignored" << endl;
1227
      addr = readNpc ();                // Default uses current NPC
1228
    }
1229
 
1230
  rspStep (addr, EXCEPT_NONE);
1231
 
1232
}       // rspStep ()
1233
 
1234
 
1235
//-----------------------------------------------------------------------------
1236
//! Handle a RSP step with signal request
1237
 
1238
//! @todo Currently null. Will use the underlying generic step function.
1239
//-----------------------------------------------------------------------------
1240
void
1241
GdbServerSC::rspStep ()
1242
{
1243
  cerr << "RSP step with signal '" << pkt->data << "' received" << endl;
1244
 
1245
}       // rspStep ()
1246
 
1247
 
1248
//-----------------------------------------------------------------------------
1249
//! Generic processing of a step request
1250
 
1251
//! The signal may be EXCEPT_NONE if there is no exception to be
1252
//! handled. Currently the exception is ignored.
1253
 
1254
//! The single step flag is set in the debug registers and then the processor
1255
//! is unstalled.
1256
 
1257
//! @todo There appears to be a bug in the ORPSoC debug unit, whereby multiple
1258
//!       single steps make a mess of the pipeline, leading to multiple
1259
//!       executions of the same instruction. A fix would be to use l.trap (as
1260
//!       for continue) for any consecutive calls to step.
1261
 
1262
//! @param[in] addr    Address from which to step
1263
//! @param[in] except  The exception to use (if any)                         
1264
//-----------------------------------------------------------------------------
1265
void
1266
GdbServerSC::rspStep (uint32_t  addr,
1267
                      uint32_t  except)
1268
{
1269
  // Set the address as the value of the next program counter
1270
  writeNpc (addr);
1271
 
1272
  /*
1273
  // If we're continuing from a breakpoint, replace that instruction in the memory
1274
  // ... actually no, I was wrong about this.
1275
  if (NULL != mpHash->lookup (BP_MEMORY, addr) && rsp_sigval == TARGET_SIGNAL_TRAP)
1276
    {
1277
      MpEntry *entry = mpHash->lookup (BP_MEMORY, addr);
1278
      debugUnit->writeMem32(entry->addr, entry->instr);
1279
    }
1280
  */
1281
 
1282
  // Clear Debug Reason Register and watchpoint break generation in Debug Mode
1283
  // Register 2 for watchpoints that we triggered to stop this time.
1284
  debugUnit->writeSpr (SPR_DRR,  0);
1285
  if (rsp_sigval == TARGET_SIGNAL_TRAP)
1286
    {
1287
      /*
1288
         Disable last trap generation on watchpoint if this is why we stopped
1289
         last time.
1290
      */
1291
      uint32_t temp_dmr2 = debugUnit->readSpr (SPR_DMR2);
1292
      if (temp_dmr2 & SPR_DMR2_WBS)
1293
        {
1294
          /*
1295
             One of these breakpoints is responsible for our stopping, so
1296
             disable it this time we start. GDB will send a packet re-enabling
1297
             it next time we continue.
1298
          */
1299
          debugUnit->writeSpr (SPR_DMR2, temp_dmr2 & ~((temp_dmr2&SPR_DMR2_WBS)>>10));
1300
        }
1301
    }
1302
 
1303
  // Set the single step trigger in Debug Mode Register 1 and set traps to be
1304
  // handled by the debug unit in the Debug Stop Register
1305
  debugUnit->orSpr (SPR_DMR1, SPR_DMR1_ST);
1306
  debugUnit->orSpr (SPR_DSR,  SPR_DSR_TE);
1307
 
1308
  // Unstall the processor. Note the GDB client is now waiting for a reply,
1309
  // which it will get as soon as the processor stalls again.
1310
  debugUnit->unstall ();
1311
  targetStopped = false;
1312
 
1313
}       // rspStep ()
1314
 
1315
 
1316
//-----------------------------------------------------------------------------
1317
//! Handle a RSP 'v' packet
1318
 
1319
//! These are commands associated with executing the code on the target
1320
//-----------------------------------------------------------------------------
1321
void
1322
GdbServerSC::rspVpkt ()
1323
{
1324
  if (0 == strncmp ("vAttach;", pkt->data, strlen ("vAttach;")))
1325
    {
1326
      // Attaching is a null action, since we have no other process. We just
1327
      // return a stop packet (using TRAP) to indicate we are stopped.
1328
      pkt->packStr ("S05");
1329
      rsp->putPkt (pkt);
1330
      return;
1331
    }
1332
  else if (0 == strcmp ("vCont?", pkt->data))
1333
    {
1334
      // For now we don't support this.
1335
      pkt->packStr ("");
1336
      rsp->putPkt (pkt);
1337
      return;
1338
    }
1339
  else if (0 == strncmp ("vCont", pkt->data, strlen ("vCont")))
1340
    {
1341
      // This shouldn't happen, because we've reported non-support via vCont?
1342
      // above
1343
      cerr << "Warning: RSP vCont not supported: ignored" << endl;
1344
      return;
1345
    }
1346
  else if (0 == strncmp ("vFile:", pkt->data, strlen ("vFile:")))
1347
    {
1348
      // For now we don't support this.
1349
      cerr << "Warning: RSP vFile not supported: ignored" << endl;
1350
      pkt->packStr ("");
1351
      rsp->putPkt (pkt);
1352
      return;
1353
    }
1354
  else if (0 == strncmp ("vFlashErase:", pkt->data, strlen ("vFlashErase:")))
1355
    {
1356
      // For now we don't support this.
1357
      cerr << "Warning: RSP vFlashErase not supported: ignored" << endl;
1358
      pkt->packStr ("E01");
1359
      rsp->putPkt (pkt);
1360
      return;
1361
    }
1362
  else if (0 == strncmp ("vFlashWrite:", pkt->data, strlen ("vFlashWrite:")))
1363
    {
1364
      // For now we don't support this.
1365
      cerr << "Warning: RSP vFlashWrite not supported: ignored" << endl;
1366
      pkt->packStr ("E01");
1367
      rsp->putPkt (pkt);
1368
      return;
1369
    }
1370
  else if (0 == strcmp ("vFlashDone", pkt->data))
1371
    {
1372
      // For now we don't support this.
1373
      cerr << "Warning: RSP vFlashDone not supported: ignored" << endl;;
1374
      pkt->packStr ("E01");
1375
      rsp->putPkt (pkt);
1376
      return;
1377
    }
1378
  else if (0 == strncmp ("vRun;", pkt->data, strlen ("vRun;")))
1379
    {
1380
      // We shouldn't be given any args, but check for this
1381
      if (pkt->getLen () > strlen ("vRun;"))
1382
        {
1383
          cerr << "Warning: Unexpected arguments to RSP vRun "
1384
            "command: ignored" << endl;
1385
        }
1386
 
1387
      // Restart the current program. However unlike a "R" packet, "vRun"
1388
      // should behave as though it has just stopped. We use signal 5 (TRAP).
1389
      rspRestart ();
1390
      pkt->packStr ("S05");
1391
      rsp->putPkt (pkt);
1392
    }
1393
  else
1394
    {
1395
      cerr << "Warning: Unknown RSP 'v' packet type " << pkt->data
1396
           << ": ignored" << endl;
1397
      pkt->packStr ("E01");
1398
      rsp->putPkt (pkt);
1399
      return;
1400
    }
1401
}       // rspVpkt ()
1402
 
1403
 
1404
//-----------------------------------------------------------------------------
1405
//! Handle a RSP write memory (binary) request
1406
 
1407
//! Syntax is:
1408
 
1409
//!   X<addr>,<length>:
1410
 
1411
//! Followed by the specified number of bytes as raw binary. Response should be
1412
//! "OK" if all copied OK, E<nn> if error <nn> has occurred.
1413
 
1414
//! The length given is the number of bytes to be written. The data buffer has
1415
//! already been unescaped, so will hold this number of bytes.
1416
 
1417
//! The data is in model-endian format, so no transformation is needed.
1418
//-----------------------------------------------------------------------------
1419
void
1420
GdbServerSC::rspWriteMemBin ()
1421
{
1422
  uint32_t  addr;                       // Where to write the memory
1423
  int       len;                        // Number of bytes to write
1424
 
1425
  if (2 != sscanf (pkt->data, "X%x,%x:", &addr, &len))
1426
    {
1427
      cerr << "Warning: Failed to recognize RSP write memory command: %s"
1428
           << pkt->data << endl;
1429
      pkt->packStr ("E01");
1430
      rsp->putPkt (pkt);
1431
      return;
1432
    }
1433
 
1434
  // Find the start of the data and "unescape" it. Bindat must be unsigned, or
1435
  // all sorts of horrible sign extensions will happen when val is computed
1436
  // below!
1437
  uint8_t *bindat = (uint8_t *)(memchr (pkt->data, ':',
1438
                                        pkt->getBufSize ())) + 1;
1439
  int   off       = (char *)bindat - pkt->data;
1440
  int   newLen    = Utils::rspUnescape ((char *)bindat, pkt->getLen () - off);
1441
 
1442
  // Sanity check
1443
  if (newLen != len)
1444
    {
1445
      int  minLen = len < newLen ? len : newLen;
1446
 
1447
      cerr << "Warning: Write of " << len << " bytes requested, but "
1448
           << newLen << " bytes supplied. " << minLen << " will be written"
1449
           << endl;
1450
      len = minLen;
1451
    }
1452
 
1453
  // Write the bytes to memory. More efficent to do this in 32-bit chunks
1454
  int  startBytes = addr & 0x3;
1455
  int  endBytes   = (addr + len) & 0x3;
1456
 
1457
  // First partial word. Access bindat in an endian independent fashion.
1458
  for (off = 0 ; off < startBytes ; off++)
1459
    {
1460
      if (!debugUnit->writeMem8 (addr + off, bindat[off]))
1461
        {
1462
          pkt->packStr ("E01");
1463
          rsp->putPkt (pkt);
1464
          return;
1465
        }
1466
    }
1467
 
1468
  // The bulk as words. Convert to model endian before writing.
1469
  for (off = startBytes; off < len; off += 4)
1470
    {
1471
      uint32_t val = *((uint32_t *)(&(bindat[off])));
1472
 
1473
      if (!debugUnit->writeMem32 (addr + off, Utils::htotl (val)))
1474
        {
1475
          pkt->packStr ("E01");
1476
          rsp->putPkt (pkt);
1477
          return;
1478
        }
1479
    }
1480
 
1481
  // Last partial word. Access bindat in an endian independent fashion.
1482
  for (off = len - endBytes; off < len ; off++)
1483
    {
1484
      uint32_t  base = (addr + len) & 0xfffffffc;
1485
 
1486
      if (!debugUnit->writeMem8 (base + off, bindat[off]))
1487
        {
1488
          pkt->packStr ("E01");
1489
          rsp->putPkt (pkt);
1490
          return;
1491
        }
1492
    }
1493
 
1494
  pkt->packStr ("OK");
1495
  rsp->putPkt (pkt);
1496
 
1497
}       // rspWriteMemBin ()
1498
 
1499
 
1500
//-----------------------------------------------------------------------------
1501
//! Handle a RSP remove breakpoint or matchpoint request
1502
 
1503
//! For now only memory breakpoints are implemented, which are implemented by
1504
//! substituting a breakpoint at the specified address. The implementation must
1505
//! cope with the possibility of duplicate packets.
1506
 
1507
//! @todo This doesn't work with icache/immu yet
1508
//-----------------------------------------------------------------------------
1509
void
1510
GdbServerSC::rspRemoveMatchpoint ()
1511
{
1512
  MpType     type;                      // What sort of matchpoint
1513
  uint32_t   addr;                      // Address specified
1514
  uint32_t   instr;                     // Instruction value found
1515
  int        len;                       // Matchpoint length (not used)
1516
 
1517
  // Break out the instruction
1518
  if (3 != sscanf (pkt->data, "z%1d,%lx,%1d", (int *)&type, &addr, &len))
1519
    {
1520
      cerr << "Warning: RSP matchpoint deletion request not "
1521
           << "recognized: ignored" << endl;
1522
      pkt->packStr ("E01");
1523
      rsp->putPkt (pkt);
1524
      return;
1525
    }
1526
 
1527
  // Sanity check that the length is 4
1528
  if (4 != len)
1529
    {
1530
      cerr << "Warning: RSP matchpoint deletion length " << len
1531
           << "not valid: 4 assumed" << endl;
1532
      len = 4;
1533
    }
1534
 
1535
  // Sort out the type of matchpoint
1536
  switch (type)
1537
    {
1538
    case BP_MEMORY:
1539
      // Memory breakpoint - replace the original instruction.
1540
      if (mpHash->remove (type, addr, &instr))
1541
        {
1542
          //cerr << "rspRemoveMatchpoint at 0x" << hex << addr << " restoring instruction: 0x" << hex << instr <<endl;
1543
          debugUnit->writeMem32 (addr, instr);
1544
        }
1545
 
1546
      pkt->packStr ("OK");
1547
      rsp->putPkt (pkt);
1548
      return;
1549
 
1550
    case BP_HARDWARE:
1551
      int off;
1552
      for (off=0;off<8;off++)
1553
        if ((debugUnit->readSpr (SPR_DCR0+off) == (0x23)) &&
1554
            (debugUnit->readSpr (SPR_DVR0+off) == addr))
1555
          break;
1556
      if (off > 7)
1557
        {
1558
          pkt->packStr ("E02"); // Failed ot find breakpoint
1559
          rsp->putPkt (pkt);
1560
          return;
1561
        }
1562
      // Clear DCR's CT and DVR, WGB bit
1563
      debugUnit->writeSpr (SPR_DCR0+off,0);
1564
      debugUnit->writeSpr (SPR_DVR0+off,0);
1565
      debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2) & ~((1<<off)<<SPR_DMR2_WGB_SHIFT));
1566
      pkt->packStr ("OK");
1567
      rsp->putPkt (pkt);
1568
      return;
1569
 
1570
    case WP_WRITE:
1571
      {
1572
        int off;
1573
        for (off=0;off<8;off++)
1574
          {
1575
            if ((debugUnit->readSpr (SPR_DCR0+off) == (0x63)) &&
1576
                (debugUnit->readSpr (SPR_DVR0+off) == addr))
1577
              break;
1578
          }
1579
        if (off > 7)
1580
          {
1581
            pkt->packStr ("E02"); // Failed ot find breakpoint
1582
            rsp->putPkt (pkt);
1583
          return;
1584
          }
1585
 
1586
        // Clear DCR's CT and DVR, WGB bit
1587
        debugUnit->writeSpr (SPR_DCR0+off,0);
1588
        debugUnit->writeSpr (SPR_DVR0+off,0);
1589
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2) & ~((1<<off)<<SPR_DMR2_WGB_SHIFT));
1590
        pkt->packStr ("OK");
1591
        rsp->putPkt (pkt);
1592
        return;
1593
      }
1594
 
1595
    case WP_READ:
1596
      {
1597
        int off;
1598
        for (off=0;off<8;off++)
1599
          {
1600
            if ((debugUnit->readSpr (SPR_DCR0+off) == (0x43)) &&
1601
                (debugUnit->readSpr (SPR_DVR0+off) == addr))
1602
              break;
1603
          }
1604
        if (off > 7)
1605
          {
1606
            pkt->packStr ("E02"); // Failed ot find breakpoint
1607
            rsp->putPkt (pkt);
1608
          return;
1609
          }
1610
 
1611
        // Clear DCR's CT and DVR, WGB bit
1612
        debugUnit->writeSpr (SPR_DCR0+off,0);
1613
        debugUnit->writeSpr (SPR_DVR0+off,0);
1614
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2) & ~((1<<off)<<SPR_DMR2_WGB_SHIFT));
1615
        pkt->packStr ("OK");
1616
        rsp->putPkt (pkt);
1617
        return;
1618
      }
1619
 
1620
    case WP_ACCESS:
1621
      {
1622
        int off;
1623
        for (off=0;off<8;off++)
1624
          {
1625
            //printf("WP_ACCESS remove check off=%d DCR=0x%.8x DVR=0x%.8x\n",
1626
            //off,debugUnit->readSpr (SPR_DCR0+off),debugUnit->readSpr (SPR_DVR0+off));
1627
            if ((debugUnit->readSpr (SPR_DCR0+off) == (0xc3)) &&
1628
                (debugUnit->readSpr (SPR_DVR0+off) == addr))
1629
              break;
1630
          }
1631
        if (off > 7)
1632
          {
1633
            //printf("rspRemoveWatchpoint: WP_ACCESS remove ERROR, regpair %d for 0x%.8x\n",off, addr);
1634
            pkt->packStr ("E02"); // Failed ot find breakpoint
1635
            rsp->putPkt (pkt);
1636
          return;
1637
          }
1638
        //printf("rspRemoveWatchpoint: WP_ACCESS remove, regpair %d for 0x%.8x\n",off, addr);
1639
 
1640
        // Clear DCR's CT and DVR, WGB bit
1641
        debugUnit->writeSpr (SPR_DCR0+off,0);
1642
        debugUnit->writeSpr (SPR_DVR0+off,0);
1643
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2) & ~((1<<off)<<SPR_DMR2_WGB_SHIFT));
1644
        pkt->packStr ("OK");
1645
        rsp->putPkt (pkt);
1646
        return;
1647
      }
1648
    default:
1649
      cerr << "Warning: RSP matchpoint type " << type
1650
           << " not recognized: ignored" << endl;
1651
      pkt->packStr ("E01");
1652
      rsp->putPkt (pkt);
1653
      return;
1654
    }
1655
}       // rspRemoveMatchpoint ()
1656
 
1657
 
1658
//---------------------------------------------------------------------------*/
1659
//! Handle a RSP insert breakpoint or matchpoint request
1660
 
1661
//! For now only memory breakpoints are implemented, which are implemented by
1662
//! substituting a breakpoint at the specified address. The implementation must
1663
//! cope with the possibility of duplicate packets.
1664
 
1665
//! @todo This doesn't work with icache/immu yet
1666
//---------------------------------------------------------------------------*/
1667
void
1668
GdbServerSC::rspInsertMatchpoint ()
1669
{
1670
  MpType    type;                       // What sort of matchpoint
1671
  uint32_t  addr;                       // Address specified
1672
  int       len;                        // Matchpoint length (not used)
1673
 
1674
  // Break out the instruction
1675
  if (3 != sscanf (pkt->data, "Z%1d,%lx,%1d", (int *)&type, &addr, &len))
1676
    {
1677
      cerr << "Warning: RSP matchpoint insertion request not "
1678
           << "recognized: ignored" << endl;
1679
      pkt->packStr ("E01");
1680
      rsp->putPkt (pkt);
1681
      return;
1682
    }
1683
 
1684
  // Sanity check that the length is 4
1685
  if (4 != len)
1686
    {
1687
      cerr << "Warning: RSP matchpoint insertion length " << len
1688
           << "not valid: 4 assumed" << endl;
1689
      len = 4;
1690
    }
1691
 
1692
  // Sort out the type of matchpoint
1693
  switch (type)
1694
    {
1695
    case BP_MEMORY:
1696
      // Memory breakpoint - substitute a TRAP instruction
1697
      mpHash->add (type, addr, debugUnit->readMem32 (addr));
1698
      debugUnit->writeMem32 (addr, OR1K_TRAP_INSTR);
1699
      pkt->packStr ("OK");
1700
      rsp->putPkt (pkt);
1701
      return;
1702
 
1703
    case BP_HARDWARE:
1704
      {
1705
        int off;
1706
        for (off=0;off<8;off++)
1707
          if (!(debugUnit->readSpr (SPR_DCR0+off) & SPR_DCR_CT_MASK))
1708
            break;
1709
        if (off > 7)
1710
          {
1711
            pkt->packStr ("");          // No room
1712
            rsp->putPkt (pkt);
1713
            return;
1714
          }
1715
        // CC = equal, CT = Instruction fetch EA, set WGB bit
1716
        debugUnit->writeSpr (SPR_DCR0+off,0x22);
1717
        debugUnit->writeSpr (SPR_DVR0+off,addr);
1718
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2)|((1<<off)<<SPR_DMR2_WGB_SHIFT));
1719
        pkt->packStr ("OK");
1720
        rsp->putPkt (pkt);
1721
        return;
1722
      }
1723
 
1724
    case WP_WRITE:
1725
      {
1726
        int off;
1727
        for (off=0;off<8;off++)
1728
          if (!(debugUnit->readSpr (SPR_DCR0+off) & SPR_DCR_CT_MASK))
1729
            break;
1730
        //printf("rspInsertWatchpoint: WP_WRITE, regpair %d for 0x%.8x\n",off, addr);
1731
        if (off > 7)
1732
          {
1733
            pkt->packStr ("");          // No room
1734
            rsp->putPkt (pkt);
1735
            return;
1736
          }
1737
        // CC = equal, CT = Store EA, set WGB bit
1738
        debugUnit->writeSpr (SPR_DCR0+off,0x62);
1739
        debugUnit->writeSpr (SPR_DVR0+off,addr);
1740
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2)|((1<<off)<<SPR_DMR2_WGB_SHIFT));
1741
        pkt->packStr ("OK");
1742
        rsp->putPkt (pkt);
1743
        return;
1744
      }
1745
 
1746
    case WP_READ:
1747
      {
1748
        int off;
1749
        for (off=0;off<8;off++)
1750
          if (!(debugUnit->readSpr (SPR_DCR0+off) & SPR_DCR_CT_MASK))
1751
            break;
1752
        //printf("rspInsertWatchpoint: WP_WRITE, regpair %d for 0x%.8x\n",off, addr);
1753
        if (off > 7)
1754
          {
1755
            pkt->packStr ("");          // No room
1756
            rsp->putPkt (pkt);
1757
            return;
1758
          }
1759
        // CC = equal, CT = Load EA, set WGB bit
1760
        debugUnit->writeSpr (SPR_DCR0+off,0x42);
1761
        debugUnit->writeSpr (SPR_DVR0+off,addr);
1762
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2)|((1<<off)<<SPR_DMR2_WGB_SHIFT));
1763
        pkt->packStr ("OK");
1764
        rsp->putPkt (pkt);
1765
        return;
1766
      }
1767
 
1768
      pkt->packStr ("");                // Not supported
1769
      rsp->putPkt (pkt);
1770
      return;
1771
 
1772
    case WP_ACCESS:
1773
      {
1774
        int off;
1775
        for (off=0;off<8;off++)
1776
          if (!(debugUnit->readSpr (SPR_DCR0+off) & SPR_DCR_CT_MASK))
1777
            break;
1778
        //printf("rspInsertWatchpoint: WP_ACCESS, regpair %d for 0x%.8x\n",off, addr);
1779
        if (off > 7)
1780
          {
1781
            pkt->packStr ("");          // No room
1782
            rsp->putPkt (pkt);
1783
            return;
1784
          }
1785
        // CC = equal, CT = Load/Store EA, set WGB bit
1786
        debugUnit->writeSpr (SPR_DCR0+off,0xc2);
1787
        debugUnit->writeSpr (SPR_DVR0+off,addr);
1788
        debugUnit->writeSpr (SPR_DMR2,debugUnit->readSpr (SPR_DMR2)|((1<<off)<<SPR_DMR2_WGB_SHIFT));
1789
        pkt->packStr ("OK");
1790
        rsp->putPkt (pkt);
1791
        return;
1792
      }
1793
 
1794
    default:
1795
      cerr << "Warning: RSP matchpoint type " << type
1796
           << "not recognized: ignored"<< endl;
1797
      pkt->packStr ("E01");
1798
      rsp->putPkt (pkt);
1799
      return;
1800
    }
1801
}       // rspInsertMatchpoint ()
1802
 
1803
 
1804
//-----------------------------------------------------------------------------
1805
//! Read the value of the Next Program Counter (a SPR)
1806
 
1807
//! A convenience routine.
1808
 
1809
//! Setting the NPC flushes the pipeline, so subsequent reads will return
1810
//! zero until the processor has refilled the pipeline. This will not be
1811
//! happening if the processor is stalled (as it is when GDB had control).
1812
 
1813
//! However for debugging we always want to know what the effective value of
1814
//! the NPC will be (i.e. the value that will be used once the pipeline has
1815
//! refilled). Fortunately SPR cacheing in the debug unit silently solves this
1816
//! for us.
1817
 
1818
//! @return  The value of the NPC
1819
//-----------------------------------------------------------------------------
1820
uint32_t
1821
GdbServerSC::readNpc ()
1822
{
1823
  return debugUnit->readSpr (SPR_NPC);
1824
 
1825
}       // readNpc ()
1826
 
1827
 
1828
//-----------------------------------------------------------------------------
1829
//! Write the value of the Next Program Counter (a SPR)
1830
 
1831
//! A convenience function.
1832
 
1833
//! Setting the NPC flushes the pipeline, so subsequent reads will return
1834
//! zero until the processor has refilled the pipeline. This will not be
1835
//! happening if the processor is stalled (as it is when GDB had control).
1836
 
1837
//! However for debugging we always want to know what the effective value of
1838
//! the NPC will be (i.e. the value that will be used once the pipeline has
1839
//! refilled). Fortunately SPR cacheing in the debug unit silently solves this
1840
//! for us.
1841
 
1842
//! There is one other caveat for the NPC. We do not wish to write it (whether
1843
//! or not it is cached) if it has not changed. So unlike all other SPRs we
1844
//! always read it first before writing.
1845
 
1846
//! @param[in]  The address to write into the NPC
1847
//-----------------------------------------------------------------------------
1848
void
1849
GdbServerSC::writeNpc (uint32_t  addr)
1850
{
1851
  if (addr != readNpc())
1852
    {
1853
      debugUnit->writeSpr (SPR_NPC,  addr);
1854
    }
1855
}       // writeNpc ()
1856
 
1857
 
1858
//-----------------------------------------------------------------------------
1859
//! Read the value of an OpenRISC 1000 General Purpose Register
1860
 
1861
//! A convenience function. This is just a wrapper for reading a SPR, since
1862
//! the GPR's are mapped into SPR space
1863
 
1864
//! @param[in]  regNum  The GPR to read
1865
 
1866
//! @return  The value of the GPR
1867
//-----------------------------------------------------------------------------
1868
uint32_t
1869
GdbServerSC::readGpr (int  regNum)
1870
{
1871
  return  debugUnit->readSpr (SPR_GPR0 + regNum);
1872
 
1873
}       // readGpr ()
1874
 
1875
 
1876
//-----------------------------------------------------------------------------
1877
//! Write the value of an OpenRISC 1000 General Purpose Register
1878
 
1879
//! A convenience function. This is just a wrapper for writing a SPR, since
1880
//! the GPR's are mapped into SPR space
1881
 
1882
//! @param[in]  regNum  The GPR to read
1883
 
1884
//! @return  The value of the GPR
1885
//-----------------------------------------------------------------------------
1886
void
1887
GdbServerSC::writeGpr (int       regNum,
1888
                       uint32_t  value)
1889
{
1890
  debugUnit->writeSpr (SPR_GPR0 + regNum, value);
1891
 
1892
}       // writeGpr ()
1893
 
1894
//-----------------------------------------------------------------------------
1895
//! Check if we received anything via the pipe from the or1200 monitor
1896
 
1897
//! We stall the processor, and behave in a manner similar to if an interrupt
1898
//! had been received. Perhaps the sigval should be set differently/more
1899
//! more appropriately.
1900
//! Read from the pipe should be NON-blocking.
1901
 
1902
//! @return  false if nothing received, else true
1903
//-----------------------------------------------------------------------------
1904
bool
1905
GdbServerSC::checkMonitorPipe ()
1906
{
1907
  char readChar;
1908
  int n = read(monitor_to_gdb_pipe[0][0], &readChar, sizeof(char));
1909
  if (!( ((n < 0) && (errno == EAGAIN)) || (n==0) ) && !targetStopped)
1910
    {
1911
      debugUnit->stall ();
1912
      // Send a stop reply response, manually set rsp.sigval to TARGET_SIGNAL_NONE
1913
      rsp_sigval = TARGET_SIGNAL_NONE;
1914
      rspReportException();
1915
      targetStopped = true;             // Processor now not running
1916
      write(monitor_to_gdb_pipe[1][1],&readChar,sizeof(char));
1917
      return true;
1918
    }
1919
 
1920
  return false;
1921
 
1922
}       // checkMonitorPipe ()

powered by: WebSVN 2.1.0

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