diff options
author | Jerry Zhao <jerryz123@berkeley.edu> | 2022-12-11 10:56:56 -0800 |
---|---|---|
committer | Jerry Zhao <jerryz123@berkeley.edu> | 2022-12-13 12:21:11 -0800 |
commit | 68a3039598dc418b0fd25e971746bee31e28b3ea (patch) | |
tree | 71b301b7463dccf5dae0f037684f8700bd155eb8 /riscv/sim.cc | |
parent | 572d5e44097d9e37c1233a8df4b6bba0c387363c (diff) | |
download | spike-68a3039598dc418b0fd25e971746bee31e28b3ea.zip spike-68a3039598dc418b0fd25e971746bee31e28b3ea.tar.gz spike-68a3039598dc418b0fd25e971746bee31e28b3ea.tar.bz2 |
Move boost asio socket interface to socketif_t
This reduces dependencies on config.h in sim.h
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r-- | riscv/sim.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc index bb1d76b..8a65797 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -1,5 +1,6 @@ // See LICENSE for license details. +#include "config.h" #include "sim.h" #include "mmu.h" #include "dts.h" @@ -7,6 +8,7 @@ #include "byteorder.h" #include "platform.h" #include "libfdt.h" +#include "socketif.h" #include <fstream> #include <map> #include <iostream> @@ -35,9 +37,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, const debug_module_config_t &dm_config, const char *log_path, bool dtb_enabled, const char *dtb_file, -#ifdef HAVE_BOOST_ASIO - boost::asio::io_service *io_service_ptr, boost::asio::ip::tcp::acceptor *acceptor_ptr, // option -s -#endif + bool socket_enabled, FILE *cmd_file) // needed for command line option --cmd : htif_t(args), isa(cfg->isa(), cfg->priv()), @@ -49,10 +49,6 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, dtb_enabled(dtb_enabled), log_file(log_path), cmd_file(cmd_file), -#ifdef HAVE_BOOST_ASIO - io_service_ptr(io_service_ptr), // socket interface - acceptor_ptr(acceptor_ptr), -#endif sout_(nullptr), current_step(0), current_proc(0), @@ -74,6 +70,21 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, debug_module.add_device(&bus); + socketif = NULL; +#ifdef HAVE_BOOST_ASIO + if (socket_enabled) { + socketif = new socketif_t(); + } +#else + if (socket_enabled) { + fputs("Socket support requires compilation with boost asio; " + "please rebuild the riscv-isa-sim project using " + "\"configure --with-boost-asio\".\n", + stderr); + abort(); + } +#endif + #ifndef RISCV_ENABLE_DUAL_ENDIAN if (cfg->endianness != memif_endianness_little) { fputs("Big-endian support has not been prroperly enabled; " |