diff options
author | Rupert Swarbrick <rswarbrick@lowrisc.org> | 2022-03-24 22:00:46 +0000 |
---|---|---|
committer | Rupert Swarbrick <rswarbrick@lowrisc.org> | 2022-04-12 11:10:17 +0100 |
commit | 970466e6ebcf4957f131fde8b62ca10fb70b2bd6 (patch) | |
tree | 9d52c0ed159359019e2ed83f4e81acd48aa6321f | |
parent | 057139ab90b8e03b71825e8f2be7cab58fef0f90 (diff) | |
download | spike-970466e6ebcf4957f131fde8b62ca10fb70b2bd6.zip spike-970466e6ebcf4957f131fde8b62ca10fb70b2bd6.tar.gz spike-970466e6ebcf4957f131fde8b62ca10fb70b2bd6.tar.bz2 |
Move start_pc into cfg_t
-rw-r--r-- | riscv/cfg.h | 2 | ||||
-rw-r--r-- | riscv/sim.cc | 5 | ||||
-rw-r--r-- | riscv/sim.h | 3 | ||||
-rw-r--r-- | spike_main/spike.cc | 5 |
4 files changed, 7 insertions, 8 deletions
diff --git a/riscv/cfg.h b/riscv/cfg.h index e844738..1e08f80 100644 --- a/riscv/cfg.h +++ b/riscv/cfg.h @@ -2,6 +2,7 @@ #ifndef _RISCV_CFG_H #define _RISCV_CFG_H +#include <optional> #include "decode.h" #include "mmu.h" #include <cassert> @@ -70,6 +71,7 @@ public: cfg_arg_t<const char *> isa; cfg_arg_t<const char *> priv; cfg_arg_t<std::vector<mem_cfg_t>> mem_layout; + std::optional<reg_t> start_pc; }; #endif diff --git a/riscv/sim.cc b/riscv/sim.cc index 90fa210..4e3dd40 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -29,7 +29,7 @@ static void handle_signal(int sig) } sim_t::sim_t(const cfg_t *cfg, const char* varch, bool halted, bool real_time_clint, - reg_t start_pc, std::vector<std::pair<reg_t, mem_t*>> mems, + std::vector<std::pair<reg_t, mem_t*>> mems, std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices, const std::vector<std::string>& args, std::vector<int> const hartids, @@ -46,7 +46,6 @@ sim_t::sim_t(const cfg_t *cfg, const char* varch, bool halted, bool real_time_cl mems(mems), plugin_devices(plugin_devices), procs(std::max(cfg->nprocs(), size_t(1))), - start_pc(start_pc), dtb_file(dtb_file ? dtb_file : ""), dtb_enabled(dtb_enabled), log_file(log_path), @@ -334,7 +333,7 @@ void sim_t::set_rom() { const int reset_vec_size = 8; - start_pc = start_pc == reg_t(-1) ? get_entry_point() : start_pc; + reg_t start_pc = cfg->start_pc.value_or(get_entry_point()); uint32_t reset_vec[reset_vec_size] = { 0x297, // auipc t0,0x0 diff --git a/riscv/sim.h b/riscv/sim.h index fc20a2c..6acc440 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -33,7 +33,7 @@ class sim_t : public htif_t, public simif_t { public: sim_t(const cfg_t *cfg, const char* varch, bool halted, bool real_time_clint, - reg_t start_pc, std::vector<std::pair<reg_t, mem_t*>> mems, + std::vector<std::pair<reg_t, mem_t*>> mems, 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, @@ -76,7 +76,6 @@ private: mmu_t* debug_mmu; // debug port into main memory std::vector<processor_t*> procs; std::pair<reg_t, reg_t> initrd_range; - reg_t start_pc; std::string dts; std::string dtb; std::string dtb_file; diff --git a/spike_main/spike.cc b/spike_main/spike.cc index 3080efb..7791fbf 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -232,7 +232,6 @@ int main(int argc, char** argv) bool real_time_clint = false; const char* kernel = NULL; reg_t kernel_offset, kernel_size; - reg_t start_pc = reg_t(-1); std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices; std::unique_ptr<icache_sim_t> ic; std::unique_ptr<dcache_sim_t> dc; @@ -335,7 +334,7 @@ int main(int argc, char** argv) // I wanted to use --halted, but for some reason that doesn't work. parser.option('H', 0, 0, [&](const char* s){halted = true;}); parser.option(0, "rbb-port", 1, [&](const char* s){use_rbb = true; rbb_port = atoul_safe(s);}); - parser.option(0, "pc", 1, [&](const char* s){start_pc = strtoull(s, 0, 0);}); + parser.option(0, "pc", 1, [&](const char* s){cfg.start_pc = strtoull(s, 0, 0);}); parser.option(0, "hartids", 1, hartids_parser); parser.option(0, "ic", 1, [&](const char* s){ic.reset(new icache_sim_t(s));}); parser.option(0, "dc", 1, [&](const char* s){dc.reset(new dcache_sim_t(s));}); @@ -457,7 +456,7 @@ int main(int argc, char** argv) #endif sim_t s(&cfg, varch, halted, real_time_clint, - start_pc, mems, plugin_devices, htif_args, + mems, plugin_devices, htif_args, std::move(hartids), dm_config, log_path, dtb_enabled, dtb_file, #ifdef HAVE_BOOST_ASIO io_service_ptr, acceptor_ptr, |