aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.cc
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2022-02-19 00:02:11 +0000
committerRupert Swarbrick <rswarbrick@gmail.com>2022-03-18 15:30:41 +0000
commitb742ddc66fd4ccb6cec98cbd8ebb705fe93ca735 (patch)
treea5c2f32b7c7996732f72b8142971610eb68f2a67 /riscv/sim.cc
parent1fea2afbf46d2641d77f2db3d6108e0897431a84 (diff)
downloadspike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.zip
spike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.tar.gz
spike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.tar.bz2
Initial step towards factoring out command line configuration
This commit defines a "cfg_t" structure, which currently just holds the initrd address range. It will be augmented in future commits to hold other configuration arguments as well. To represent a configuration argument, we define an arg_t base class. This holds a current value, together with a flag that tells us whether the value has been updated from the default. The idea is that in future we're going to use that flag when reading a DTB file: if an argument has actually been specified on the command line, we need to take it into account; if not, we can ignore the default and use the DTB file's supplied value.
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r--riscv/sim.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 064a493..9bfa17a 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -28,9 +28,9 @@ static void handle_signal(int sig)
signal(sig, &handle_signal);
}
-sim_t::sim_t(const char* isa_string, const char* priv, const char* varch,
- size_t nprocs, bool halted, bool real_time_clint,
- reg_t initrd_start, reg_t initrd_end, const char* bootargs,
+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, const char* bootargs,
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,
@@ -44,11 +44,10 @@ sim_t::sim_t(const char* isa_string, const char* priv, const char* varch,
FILE *cmd_file) // needed for command line option --cmd
: htif_t(args),
isa(isa_string, priv),
+ cfg(cfg),
mems(mems),
plugin_devices(plugin_devices),
procs(std::max(nprocs, size_t(1))),
- initrd_start(initrd_start),
- initrd_end(initrd_end),
bootargs(bootargs),
start_pc(start_pc),
dtb_file(dtb_file ? dtb_file : ""),
@@ -312,7 +311,10 @@ void sim_t::make_dtb()
dtb = strstream.str();
} else {
- dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, bootargs, procs, mems);
+ std::pair<reg_t, reg_t> initrd_bounds = cfg->initrd_bounds();
+ dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ,
+ initrd_bounds.first, initrd_bounds.second,
+ bootargs, procs, mems);
dtb = dts_compile(dts);
}