Browse Source

declare socket properties in sim_t

pull/700/head
Elmar Melcher 5 years ago
committed by emelcher
parent
commit
e30c9c90ef
  1. 2
      riscv/debug_module.cc
  2. 2
      riscv/interactive.cc
  3. 8
      riscv/sim.cc
  4. 38
      riscv/sim.h
  5. 11
      spike_main/spike.cc

2
riscv/debug_module.cc

@ -1,10 +1,10 @@
#include <cassert>
#include "sim.h"
#include "debug_module.h"
#include "debug_defines.h"
#include "opcodes.h"
#include "mmu.h"
#include "sim.h"
#include "debug_rom/debug_rom.h"
#include "debug_rom_defines.h"

2
riscv/interactive.cc

@ -1,8 +1,8 @@
// See LICENSE for license details.
#include "sim.h"
#include "decode.h"
#include "disasm.h"
#include "sim.h"
#include "mmu.h"
#include <sys/mman.h>
#include <termios.h>

8
riscv/sim.cc

@ -36,7 +36,11 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch,
std::vector<int> const hartids,
const debug_module_config_t &dm_config,
const char *log_path,
bool dtb_enabled, const char *dtb_file)
bool dtb_enabled, const char *dtb_file
#ifdef HAVE_BOOST_ASIO
, io_service *io_service_ptr_ctor, tcp::acceptor *acceptor_ptr_ctor // option -s
#endif
)
: htif_t(args),
mems(mems),
plugin_devices(plugin_devices),
@ -48,6 +52,7 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch,
dtb_file(dtb_file ? dtb_file : ""),
dtb_enabled(dtb_enabled),
log_file(log_path),
sout(nullptr),
current_step(0),
current_proc(0),
debug(false),
@ -57,6 +62,7 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch,
debug_module(this, dm_config)
{
signal(SIGINT, &handle_signal);
sout.rdbuf(cerr.rdbuf()); // debug output goes to stderr by default
for (auto& x : mems)
bus.add_device(x.first, x.second);

38
riscv/sim.h

@ -3,6 +3,24 @@
#ifndef _RISCV_SIM_H
#define _RISCV_SIM_H
#include "config.h"
#ifdef HAVE_BOOST_ASIO
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <boost/asio.hpp>
// namespace boost::asio does not work for all environments
using boost::asio::ip::tcp;
using boost::asio::io_service;
using boost::asio::streambuf;
// using boost::asio::write does not work either
using boost::asio::transfer_all;
using boost::asio::buffer_cast;
using boost::erase_all;
using boost::regex;
using boost::regex_replace;
#endif
#include "debug_module.h"
#include "devices.h"
#include "log_file.h"
@ -16,6 +34,10 @@
#include <memory>
#include <sys/types.h>
using std::ostream;
using std::string;
using std::cerr;
class mmu_t;
class remote_bitbang_t;
@ -30,7 +52,11 @@ public:
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
const std::vector<std::string>& args, const std::vector<int> hartids,
const debug_module_config_t &dm_config, const char *log_path,
bool dtb_enabled, const char *dtb_file);
bool dtb_enabled, const char *dtb_file
#ifdef HAVE_BOOST_ASIO
, io_service *io_service_ptr_ctor, tcp::acceptor *acceptor_ptr_ctor // option -s
#endif
);
~sim_t();
// run the simulation to completion
@ -75,6 +101,16 @@ private:
bus_t bus;
log_file_t log_file;
#ifdef HAVE_BOOST_ASIO
// the following are needed for command socket interface
boost::asio::io_service *io_service_ptr;
tcp::acceptor *acceptor_ptr;
tcp::socket *socket_ptr;
string rin(streambuf *bout_ptr); // read input command string
void wout(streambuf *bout_ptr); // write output to socket
#endif
ostream sout; // used for socket and terminal interface
processor_t* get_core(const std::string& i);
void step(size_t n); // step through simulation
static const size_t INTERLEAVE = 5000;

11
spike_main/spike.cc

@ -395,9 +395,18 @@ int main(int argc, char** argv)
}
}
#ifdef HAVE_BOOST_ASIO
boost::asio::io_service *io_service_ptr = NULL; // needed for socket command interface option -s
tcp::acceptor *acceptor_ptr = NULL;
#endif
sim_t s(isa, priv, varch, nprocs, halted, real_time_clint,
initrd_start, initrd_end, bootargs, start_pc, mems, plugin_devices, htif_args,
std::move(hartids), dm_config, log_path, dtb_enabled, dtb_file);
std::move(hartids), dm_config, log_path, dtb_enabled, dtb_file
#ifdef HAVE_BOOST_ASIO
, io_service_ptr, acceptor_ptr
#endif
);
std::unique_ptr<remote_bitbang_t> remote_bitbang((remote_bitbang_t *) NULL);
std::unique_ptr<jtag_dtm_t> jtag_dtm(
new jtag_dtm_t(&s.debug_module, dmi_rti));

Loading…
Cancel
Save