diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-03-16 12:12:30 +0000 |
---|---|---|
committer | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-03-18 15:31:11 +0000 |
commit | c13e33a363cf341e12b39366b740cb3e35bca69e (patch) | |
tree | b899db9bad1d1478a523a6daf6d8db11f856efd1 /riscv | |
parent | 2da3ce5d4cc04b96d3de128d904820bba6d962d1 (diff) | |
download | spike-c13e33a363cf341e12b39366b740cb3e35bca69e.zip spike-c13e33a363cf341e12b39366b740cb3e35bca69e.tar.gz spike-c13e33a363cf341e12b39366b740cb3e35bca69e.tar.bz2 |
Fold nprocs parameter into cfg_t
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/cfg.h | 6 | ||||
-rw-r--r-- | riscv/sim.cc | 16 | ||||
-rw-r--r-- | riscv/sim.h | 2 |
3 files changed, 13 insertions, 11 deletions
diff --git a/riscv/cfg.h b/riscv/cfg.h index b2f8a94..26a68b5 100644 --- a/riscv/cfg.h +++ b/riscv/cfg.h @@ -29,13 +29,15 @@ class cfg_t { public: cfg_t(std::pair<reg_t, reg_t> default_initrd_bounds, - const char *default_bootargs) + const char *default_bootargs, size_t default_nprocs) : initrd_bounds(default_initrd_bounds), - bootargs(default_bootargs) + bootargs(default_bootargs), + nprocs(default_nprocs) {} cfg_arg_t<std::pair<reg_t, reg_t>> initrd_bounds; cfg_arg_t<const char *> bootargs; + cfg_arg_t<size_t> nprocs; }; #endif diff --git a/riscv/sim.cc b/riscv/sim.cc index e825011..b0cfe8f 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -30,7 +30,7 @@ static void handle_signal(int sig) sim_t::sim_t(const cfg_t *cfg, const char* isa_string, const char* priv, const char* varch, - size_t nprocs, bool halted, bool real_time_clint, + 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, abstract_device_t*>> plugin_devices, const std::vector<std::string>& args, @@ -47,7 +47,7 @@ sim_t::sim_t(const cfg_t *cfg, cfg(cfg), mems(mems), plugin_devices(plugin_devices), - procs(std::max(nprocs, size_t(1))), + procs(std::max(cfg->nprocs(), size_t(1))), start_pc(start_pc), dtb_file(dtb_file ? dtb_file : ""), dtb_enabled(dtb_enabled), @@ -80,15 +80,15 @@ sim_t::sim_t(const cfg_t *cfg, debug_mmu = new mmu_t(this, NULL); - if (! (hartids.empty() || hartids.size() == nprocs)) { + if (! (hartids.empty() || hartids.size() == nprocs())) { std::cerr << "Number of specified hartids (" << hartids.size() << ") doesn't match number of processors (" - << nprocs << ").\n"; + << nprocs() << ").\n"; exit(1); } - for (size_t i = 0; i < nprocs; i++) { + for (size_t i = 0; i < nprocs(); i++) { int hart_id = hartids.empty() ? i : hartids[i]; procs[i] = new processor_t(isa, varch, this, hart_id, halted, log_file.get(), sout_); @@ -121,7 +121,7 @@ sim_t::sim_t(const cfg_t *cfg, for (cpu_offset = fdt_get_first_subnode(fdt, cpu_offset); cpu_offset >= 0; cpu_offset = fdt_get_next_subnode(fdt, cpu_offset)) { - if (cpu_idx >= nprocs) + if (cpu_idx >= nprocs()) break; //handle pmp @@ -171,11 +171,11 @@ sim_t::sim_t(const cfg_t *cfg, cpu_idx++; } - if (cpu_idx != nprocs) { + if (cpu_idx != nprocs()) { std::cerr << "core number in dts (" << cpu_idx << ") doesn't match it in command line (" - << nprocs << ").\n"; + << nprocs() << ").\n"; exit(1); } } diff --git a/riscv/sim.h b/riscv/sim.h index 1bb3597..5cd4c20 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* isa, const char* priv, const char* varch, size_t _nprocs, + const char* isa, const char* priv, 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, abstract_device_t*>> plugin_devices, |