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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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