orca-sim
RspServer.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * This file is part of project ORCA. More information on the project
3  * can be found at the following repositories at GitHub's website.
4  *
5  * http://https://github.com/andersondomingues/orca-sim
6  * http://https://github.com/andersondomingues/orca-software
7  * http://https://github.com/andersondomingues/orca-mpsoc
8  * http://https://github.com/andersondomingues/orca-tools
9  *
10  * Copyright (C) 2018-2020 Anderson Domingues, <ti.andersondomingues@gmail.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 ******************************************************************************/
26 #ifndef ORCASIM_GDBRSP_INCLUDE_RSPSERVER_HPP_
27 #define ORCASIM_GDBRSP_INCLUDE_RSPSERVER_HPP_
28 
29 // base API includes
30 #include <iostream>
31 #include <list>
32 #include <string>
33 
34 // in-package includes
35 #include "UdpAsyncServer.hpp"
36 
37 // off-package includes
38 #include "GdbProcessorState.hpp"
39 #include "MemoryType.hpp"
40 #include "Memory.hpp"
41 
42 #define RSP_BUFFER_SIZE 5000
43 #define RSP_EMPTY_RESPONSE ""
44 
47 
48 namespace orcasim::gdbrsp {
49 
50 template <typename T>
51 class RspServer{
52  private:
53  // upd server instance, see UdpServe.h
55 
56  // ip address and udp port for THIS processor
57  std::string _ipaddr;
58  int _udpport;
59 
60  // state of the target processor and memory reference
63 
64  // output and input buffers
67 
68  // list of breakpoints
69  std::list<T>* _bp_list;
70 
71  public:
75  RspServer(GdbProcessorState<T>* state, Memory* mem, std::string ipaddr,
76  uint32_t udpport);
77 
81  ~RspServer();
82 
87  int Ack();
88  int Nack();
89 
90  int Receive();
91  int UpdateCpuState();
92 
93  uint8_t Checksum(char* buffer, int size);
94  int Respond(std::string data);
95 
99  int Handle_v(char*);
100  int Handle_X(char*);
101  int Handle_q(char*);
102  int Handle_Q(char*);
103  int Handle_g(char*);
104  int Handle_Question(char*);
105  int Handle_c(char*);
106  int Handle_C(char*);
107  int Handle_s(char*);
108  int Handle_S(char*);
109  int Handle_H(char*);
110  int Handle_k(char*);
111  int Handle_m(char*);
112  int Handle_M(char*);
113  int Handle_p(char*);
114  int Handle_P(char*);
115  int Handle_Z(char*);
116  int Handle_z(char*);
117 };
118 
119 // template instantiation
120 template class RspServer<uint8_t>;
121 template class RspServer<uint16_t>;
122 template class RspServer<uint32_t>;
123 template class RspServer<uint64_t>;
124 
125 template class RspServer<int8_t>;
126 template class RspServer<int16_t>;
127 template class RspServer<int32_t>;
128 template class RspServer<int64_t>;
129 
130 } // namespace orcasim::gdbrsp
131 #endif // ORCASIM_GDBRSP_INCLUDE_RSPSERVER_HPP_
132 
char _input_buffer[RSP_BUFFER_SIZE]
Definition: RspServer.hpp:66
char _output_buffer[RSP_BUFFER_SIZE]
Definition: RspServer.hpp:65
This class implements an asynchonous udp server.
RspServer(GdbProcessorState< T > *state, Memory *mem, std::string ipaddr, uint32_t udpport)
Ctor.
Definition: RspServer.cpp:38
int Handle_v(char *)
Message handlers.
Definition: RspServer.cpp:299
std::list< T > * _bp_list
Definition: RspServer.hpp:69
UdpAsyncServer * _server
Definition: RspServer.hpp:54
int Ack()
Query for a message.
Definition: RspServer.cpp:101
int Respond(std::string data)
Definition: RspServer.cpp:73
This class models a memory module.
Definition: Memory.hpp:55
uint8_t Checksum(char *buffer, int size)
Definition: RspServer.cpp:63
GdbProcessorState< T > * _state
Definition: RspServer.hpp:61
#define RSP_BUFFER_SIZE
Definition: RspServer.hpp:42
Defines a generic state model for use within processor models.