aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.cc
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2021-02-03 17:57:47 -0800
committerAndrew Waterman <andrew@sifive.com>2021-02-04 03:26:19 -0800
commit716245f5147995575b927a094c664a32f9335c4c (patch)
tree3693392d39a2415847a0954844a18c15a30d5997 /riscv/sim.cc
parentf8fc5d8c04c1c85e4bf968ed774128bae177d813 (diff)
downloadspike-716245f5147995575b927a094c664a32f9335c4c.zip
spike-716245f5147995575b927a094c664a32f9335c4c.tar.gz
spike-716245f5147995575b927a094c664a32f9335c4c.tar.bz2
Fix --kernel and --initrd options w.r.t. sparse mem_t implementation
For some reason, the old accessors for the non-sparse version were left dangling. These methods are used by the --kernel and --initrd options, and so those options were just broken. This also fixes a memory leak and refactors the implementation a bit.
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r--riscv/sim.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 73d2b45..e9e61c5 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -353,7 +353,7 @@ char* sim_t::addr_to_mem(reg_t addr) {
auto desc = bus.find_device(addr);
if (auto mem = dynamic_cast<mem_t*>(desc.second))
if (addr - desc.first < mem->size())
- return mem->contents(addr);
+ return mem->contents(addr - desc.first);
return NULL;
}