aboutsummaryrefslogtreecommitdiff
path: root/spike_main
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2023-12-03 17:13:36 -0800
committerJerry Zhao <jerryz123@berkeley.edu>2023-12-03 17:13:36 -0800
commit5d641a31dfa4f1531781bb56d27c39f9ef47c441 (patch)
tree9203fcd892e975a50b212c6ddc38492a1c1787dc /spike_main
parent10dd730785d56fe233e77b0e4183d45604c4967b (diff)
downloadriscv-isa-sim-device_flags.zip
riscv-isa-sim-device_flags.tar.gz
riscv-isa-sim-device_flags.tar.bz2
Allow device flags after --device cmdline argdevice_flags
Diffstat (limited to 'spike_main')
-rw-r--r--spike_main/spike.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/spike_main/spike.cc b/spike_main/spike.cc
index 8fd9104..5b0f175 100644
--- a/spike_main/spike.cc
+++ b/spike_main/spike.cc
@@ -52,6 +52,7 @@ static void help(int exit_code = 1)
fprintf(stderr, " --big-endian Use a big-endian memory system.\n");
fprintf(stderr, " --misaligned Support misaligned memory accesses\n");
fprintf(stderr, " --device=<name> Attach MMIO plugin device from an --extlib library\n");
+ fprintf(stderr, " Device-specific flags can also be passed with --device=<name>,args\n");
fprintf(stderr, " --log-cache-miss Generate a log of cache miss\n");
fprintf(stderr, " --log-commits Generate a log of commits info\n");
fprintf(stderr, " --extension=<name> Specify RoCC Extension\n");
@@ -374,11 +375,22 @@ int main(int argc, char** argv)
/*default_trigger_count=*/4);
auto const device_parser = [&plugin_device_factories](const char *s) {
- const std::string name(s);
- if (name.empty()) throw std::runtime_error("Plugin name is empty.");
- auto it = mmio_device_map().find(name);
- if (it == mmio_device_map().end()) throw std::runtime_error("Plugin \"" + name + "\" not found in loaded extlibs.");
+ const std::string arg(s);
+ std::string device_name;
+ std::string device_flags;
+ size_t comma_idx = arg.find(',');
+ if (comma_idx != std::string::npos) {
+ device_name = arg;
+ device_flags = "";
+ } else {
+ device_name = arg.substr(0, comma_idx);
+ device_flags = arg.substr(comma_idx + 1);
+ }
+ if (device_name.empty()) throw std::runtime_error("Plugin name is empty.");
+ auto it = mmio_device_map().find(device_name);
+ if (it == mmio_device_map().end()) throw std::runtime_error("Plugin \"" + device_name + "\" not found in loaded extlibs.");
plugin_device_factories.push_back(it->second);
+ it->second->set_flags(device_flags);
};
option_parser_t parser;