Browse Source

sim_t: change plugin_devices to a vec of shared_ptrs

pull/1374/head
Jerry Zhao 3 years ago
parent
commit
426a33e774
  1. 2
      ci-tests/testlib.c
  2. 4
      riscv/sim.cc
  3. 4
      riscv/sim.h
  4. 7
      spike_main/spike.cc

2
ci-tests/testlib.c

@ -28,7 +28,7 @@ int main()
hartids,
false,
4);
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices;
std::vector<std::pair<reg_t, std::shared_ptr<abstract_device_t>>> plugin_devices;
std::vector<std::string> htif_args {"pk", "hello"};
debug_module_config_t dm_config = {
.progbufsize = 2,

4
riscv/sim.cc

@ -34,7 +34,7 @@ const size_t sim_t::INTERLEAVE;
sim_t::sim_t(const cfg_t *cfg, bool halted,
std::vector<std::pair<reg_t, mem_t*>> mems,
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
std::vector<std::pair<reg_t, std::shared_ptr<abstract_device_t>>> plugin_devices,
const std::vector<std::string>& args,
const debug_module_config_t &dm_config,
const char *log_path,
@ -67,7 +67,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
bus.add_device(x.first, x.second);
for (auto& x : plugin_devices)
bus.add_device(x.first, x.second);
bus.add_device(x.first, x.second.get());
debug_module.add_device(&bus);

4
riscv/sim.h

@ -27,7 +27,7 @@ class sim_t : public htif_t, public simif_t
public:
sim_t(const cfg_t *cfg, bool halted,
std::vector<std::pair<reg_t, mem_t*>> mems,
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
std::vector<std::pair<reg_t, std::shared_ptr<abstract_device_t>>> plugin_devices,
const std::vector<std::string>& args,
const debug_module_config_t &dm_config, const char *log_path,
bool dtb_enabled, const char *dtb_file,
@ -63,7 +63,7 @@ private:
isa_parser_t isa;
const cfg_t * const cfg;
std::vector<std::pair<reg_t, mem_t*>> mems;
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices;
std::vector<std::pair<reg_t, std::shared_ptr<abstract_device_t>>> plugin_devices;
std::vector<processor_t*> procs;
std::map<size_t, processor_t*> harts;
std::pair<reg_t, reg_t> initrd_range;

7
spike_main/spike.cc

@ -336,7 +336,7 @@ int main(int argc, char** argv)
bool dtb_enabled = true;
const char* kernel = NULL;
reg_t kernel_offset, kernel_size;
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices;
std::vector<std::pair<reg_t, std::shared_ptr<abstract_device_t>>> plugin_devices;
std::unique_ptr<icache_sim_t> ic;
std::unique_ptr<dcache_sim_t> dc;
std::unique_ptr<cache_sim_t> l2;
@ -416,7 +416,7 @@ int main(int argc, char** argv)
std::string args(avail, '\0');
stream.readsome(&args[0], avail);
plugin_devices.emplace_back(base, new mmio_plugin_device_t(name, args));
plugin_devices.emplace_back(base, std::make_shared<mmio_plugin_device_t>(name, args));
};
option_parser_t parser;
@ -602,8 +602,5 @@ int main(int argc, char** argv)
for (auto& mem : mems)
delete mem.second;
for (auto& plugin_device : plugin_devices)
delete plugin_device.second;
return return_code;
}

Loading…
Cancel
Save