From 20793b36b79db337187964da3df397c1da576c23 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Thu, 1 Jun 2023 19:35:55 -0700 Subject: sim_t: Add list of ptrs to devices to sim_t --- riscv/sim.cc | 4 ++++ riscv/sim.h | 1 + 2 files changed, 5 insertions(+) diff --git a/riscv/sim.cc b/riscv/sim.cc index dcbd469..82619e7 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -123,6 +123,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, if (fdt_parse_clint(fdt, &clint_base, "riscv,clint0") == 0) { clint.reset(new clint_t(this, CPU_HZ / INSNS_PER_RTC_TICK, cfg->real_time_clint())); bus.add_device(clint_base, clint.get()); + devices.push_back(clint); } // pointer to wired interrupt controller @@ -134,6 +135,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, if (fdt_parse_plic(fdt, &plic_base, &plic_ndev, "riscv,plic0") == 0) { plic.reset(new plic_t(this, plic_ndev)); bus.add_device(plic_base, plic.get()); + devices.push_back(plic); intctrl = plic.get(); } @@ -146,6 +148,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, ns16550.reset(new ns16550_t(&bus, intctrl, NS16550_INTERRUPT_ID, ns16550_shift, ns16550_io_width)); bus.add_device(ns16550_base, ns16550.get()); + devices.push_back(ns16550); } //per core attribute @@ -376,6 +379,7 @@ void sim_t::set_rom() boot_rom.reset(new rom_device_t(rom)); bus.add_device(DEFAULT_RSTVEC, boot_rom.get()); + devices.push_back(boot_rom); } char* sim_t::addr_to_mem(reg_t paddr) { diff --git a/riscv/sim.h b/riscv/sim.h index e5a7303..3afeedd 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -70,6 +70,7 @@ private: std::string dts; std::string dtb; bool dtb_enabled; + std::vector> devices; std::shared_ptr boot_rom; std::shared_ptr clint; std::shared_ptr plic; -- cgit v1.1