Browse Source

Avoid using bus_t::find_device without len arg

pull/1946/head
Andrew Waterman 1 year ago
parent
commit
c8f6f29a11
  1. 3
      riscv/sim.cc
  2. 7
      riscv/sim.h

3
riscv/sim.cc

@ -406,9 +406,8 @@ void sim_t::set_rom()
char* sim_t::addr_to_mem(reg_t paddr) {
if (!paddr_ok(paddr))
return NULL;
auto desc = bus.find_device(paddr);
auto desc = bus.find_device(paddr >> PGSHIFT << PGSHIFT, PGSIZE);
if (auto mem = dynamic_cast<abstract_mem_t*>(desc.second))
if (paddr - desc.first < mem->size())
return mem->contents(paddr - desc.first);
return NULL;
}

7
riscv/sim.h

@ -100,8 +100,13 @@ private:
remote_bitbang_t* remote_bitbang;
std::optional<std::function<void()>> next_interactive_action;
// memory-mapped I/O routines
// If padd corresponds to memory (as opposed to an I/O device), return a
// host pointer corresponding to paddr.
// For these purposes, only memories that include the entire base page
// surrounding paddr are considered; smaller memories are treated as I/O.
virtual char* addr_to_mem(reg_t paddr) override;
// memory-mapped I/O routines
virtual bool mmio_load(reg_t paddr, size_t len, uint8_t* bytes) override;
virtual bool mmio_store(reg_t paddr, size_t len, const uint8_t* bytes) override;
void set_rom();

Loading…
Cancel
Save