aboutsummaryrefslogtreecommitdiff
path: root/spike_main
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2022-04-11 10:59:20 +0100
committerRupert Swarbrick <rswarbrick@lowrisc.org>2022-04-12 11:10:45 +0100
commit61b4f61a857de65d1a341f55597bfceeb7b7690d (patch)
treee4537514b7522fba146bf3aeb1bb27b7fd34c3c9 /spike_main
parente4aaed1b7b08998a6b6aefa34f7c575e292dde62 (diff)
downloadriscv-isa-sim-61b4f61a857de65d1a341f55597bfceeb7b7690d.zip
riscv-isa-sim-61b4f61a857de65d1a341f55597bfceeb7b7690d.tar.gz
riscv-isa-sim-61b4f61a857de65d1a341f55597bfceeb7b7690d.tar.bz2
Move hartids into cfg_t
The only slightly difficult thing here is that hartids will always be considered "overridden" by the time we get to sim_t::sim_t (either overridden by a command line argument, or overridden when we set default hartids just before the constructor). To allow downstream code to distinguish between "I picked IDs 0, 1, 2, 3 because the user asked for 4 processors" and "The user explicitly asked for IDs 0, 1, 2, 3", we have an extra explicit_hartids field.
Diffstat (limited to 'spike_main')
-rw-r--r--spike_main/spike.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/spike_main/spike.cc b/spike_main/spike.cc
index a3c18d1..12b8dc0 100644
--- a/spike_main/spike.cc
+++ b/spike_main/spike.cc
@@ -272,13 +272,13 @@ int main(int argc, char** argv)
.support_haltgroups = true,
.support_impebreak = true
};
- std::vector<int> hartids;
cfg_t cfg(/*default_initrd_bounds=*/std::make_pair((reg_t)0, (reg_t)0),
/*default_bootargs=*/nullptr,
/*default_nprocs=*/1,
/*default_isa=*/DEFAULT_ISA,
/*default_priv=*/DEFAULT_PRIV,
- /*default_mem_layout=*/parse_mem_layout("2048"));
+ /*default_mem_layout=*/parse_mem_layout("2048"),
+ /*default_hartids=*/std::vector<int>());
auto const device_parser = [&plugin_devices](const char *s) {
const std::string str(s);
@@ -338,7 +338,10 @@ int main(int argc, char** argv)
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){cfg.start_pc = strtoull(s, 0, 0);});
- parser.option(0, "hartids", 1, [&](const char* s){hartids = parse_hartids(s);});
+ parser.option(0, "hartids", 1, [&](const char* s){
+ cfg.hartids = parse_hartids(s);
+ cfg.explicit_hartids = true;
+ });
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));});
parser.option(0, "l2", 1, [&](const char* s){l2.reset(cache_sim_t::construct(s, "L2$"));});
@@ -458,25 +461,28 @@ int main(int argc, char** argv)
}
#endif
- if (!hartids.empty()) {
- if (cfg.nprocs.overridden() && (cfg.nprocs() != hartids.size())) {
+ if (cfg.explicit_hartids) {
+ if (cfg.nprocs.overridden() && (cfg.nprocs() != cfg.hartids().size())) {
std::cerr << "Number of specified hartids ("
- << hartids.size()
+ << cfg.hartids().size()
<< ") doesn't match specified number of processors ("
<< cfg.nprocs() << ").\n";
exit(1);
}
} else {
- // Set default set of hartids based on nprocs
- hartids.reserve(cfg.nprocs());
+ // Set default set of hartids based on nprocs, but don't set the
+ // explicit_hartids flag (which means that downstream code can know that
+ // we've only set the number of harts, not explicitly chosen their IDs).
+ std::vector<int> default_hartids;
+ default_hartids.reserve(cfg.nprocs());
for (size_t i = 0; i < cfg.nprocs(); ++i) {
- hartids.push_back(i);
+ default_hartids.push_back(i);
}
+ cfg.hartids = default_hartids;
}
sim_t s(&cfg, varch, halted, real_time_clint,
- mems, plugin_devices, htif_args,
- std::move(hartids), dm_config, log_path, dtb_enabled, dtb_file,
+ mems, plugin_devices, htif_args, dm_config, log_path, dtb_enabled, dtb_file,
#ifdef HAVE_BOOST_ASIO
io_service_ptr, acceptor_ptr,
#endif