| 1 |
63 |
julius |
// ----------------------------------------------------------------------------
|
| 2 |
|
|
|
| 3 |
|
|
// Remote Serial Protocol connection: definition
|
| 4 |
|
|
|
| 5 |
|
|
// Copyright (C) 2008 Embecosm Limited <info@embecosm.com>
|
| 6 |
|
|
|
| 7 |
|
|
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
| 8 |
|
|
|
| 9 |
|
|
// This file is part of the cycle accurate model of the OpenRISC 1000 based
|
| 10 |
|
|
// system-on-chip, ORPSoC, built using Verilator.
|
| 11 |
|
|
|
| 12 |
|
|
// This program is free software: you can redistribute it and/or modify it
|
| 13 |
|
|
// under the terms of the GNU Lesser General Public License as published by
|
| 14 |
|
|
// the Free Software Foundation, either version 3 of the License, or (at your
|
| 15 |
|
|
// option) any later version.
|
| 16 |
|
|
|
| 17 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
| 18 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
| 20 |
|
|
// License for more details.
|
| 21 |
|
|
|
| 22 |
|
|
// You should have received a copy of the GNU Lesser General Public License
|
| 23 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 24 |
|
|
|
| 25 |
|
|
// ----------------------------------------------------------------------------
|
| 26 |
|
|
|
| 27 |
|
|
// $Id: RspConnection.h 326 2009-03-07 16:47:31Z jeremy $
|
| 28 |
|
|
|
| 29 |
|
|
#ifndef RSP_CONNECTION__H
|
| 30 |
|
|
#define RSP_CONNECTION__H
|
| 31 |
|
|
|
| 32 |
|
|
#include "RspPacket.h"
|
| 33 |
|
|
|
| 34 |
|
|
//! The default service to use if port number = 0 and no service specified
|
| 35 |
|
|
#define DEFAULT_RSP_SERVICE "or1ksim-rsp"
|
| 36 |
|
|
|
| 37 |
|
|
//-----------------------------------------------------------------------------
|
| 38 |
|
|
//! Class implementing the RSP connection listener
|
| 39 |
|
|
|
| 40 |
|
|
//! RSP requests received from TCP/IP are queued on the output FIFO for
|
| 41 |
|
|
//! processing by the GDB server. Packets read from the input FIFO from the
|
| 42 |
|
|
//! GDB server are sent back via TCP/IP.
|
| 43 |
|
|
|
| 44 |
|
|
//! The packets are received serially, ie. a new packet is not sent until the
|
| 45 |
|
|
//! previous ones have been dealt with. Some packets need no reply, so they
|
| 46 |
|
|
//! will be sent one after the other. But for packets that need a reply (which
|
| 47 |
|
|
//! may be one or several packets), new packets are not sent until the reply
|
| 48 |
|
|
//! from the previous one is received.
|
| 49 |
|
|
|
| 50 |
|
|
//! The upshot of this is that we can avoid any risk of deadlock by always
|
| 51 |
|
|
//! giving priority to any outgoing reply packets.
|
| 52 |
|
|
|
| 53 |
|
|
//! Two threads are used, one to listen for TCP/IP connections from the
|
| 54 |
|
|
//! client, the other to look for FIFO packets from the GDB server to write
|
| 55 |
|
|
//! back to the client. Both must be non-blocking in the SystemC sense
|
| 56 |
|
|
//! (i.e. allow other SystemC threads to run).
|
| 57 |
|
|
//-----------------------------------------------------------------------------
|
| 58 |
462 |
julius |
class RspConnection {
|
| 59 |
63 |
julius |
public:
|
| 60 |
|
|
|
| 61 |
462 |
julius |
// Constructors and destructor
|
| 62 |
|
|
RspConnection(int _portNum);
|
| 63 |
|
|
RspConnection(const char *_serviceName = DEFAULT_RSP_SERVICE);
|
| 64 |
|
|
~RspConnection();
|
| 65 |
63 |
julius |
|
| 66 |
462 |
julius |
// Public interface: manage client connections
|
| 67 |
|
|
bool rspConnect();
|
| 68 |
|
|
void rspClose();
|
| 69 |
|
|
bool isConnected();
|
| 70 |
|
|
char rspSocketPeek();
|
| 71 |
63 |
julius |
|
| 72 |
462 |
julius |
// Public interface: get packets from the stream and put them out
|
| 73 |
|
|
bool getPkt(RspPacket * pkt);
|
| 74 |
|
|
bool putPkt(RspPacket * pkt);
|
| 75 |
|
|
|
| 76 |
|
|
int getRspChar();
|
| 77 |
|
|
|
| 78 |
63 |
julius |
private:
|
| 79 |
|
|
|
| 80 |
462 |
julius |
// Generic initializer
|
| 81 |
|
|
void rspInit(int _portNum, const char *_serviceName);
|
| 82 |
63 |
julius |
|
| 83 |
462 |
julius |
// Internal routines to handle individual chars
|
| 84 |
|
|
bool putRspChar(char c);
|
| 85 |
|
|
//int getRspChar ();
|
| 86 |
63 |
julius |
|
| 87 |
462 |
julius |
//! The port number to listen on
|
| 88 |
|
|
int portNum;
|
| 89 |
63 |
julius |
|
| 90 |
462 |
julius |
//! The service name to listen on
|
| 91 |
|
|
const char *serviceName;
|
| 92 |
63 |
julius |
|
| 93 |
462 |
julius |
//! The client file descriptor
|
| 94 |
|
|
int clientFd;
|
| 95 |
63 |
julius |
|
| 96 |
462 |
julius |
}; // RspConnection ()
|
| 97 |
63 |
julius |
|
| 98 |
462 |
julius |
#endif // RSP_CONNECTION__H
|