bool bus_t::load(reg_t addr, size_t len, uint8_t* bytes)
{
- fprintf(stderr, "bus load(0x%lx, %ld)\n", addr, len);
auto it = devices.lower_bound(-addr);
- if (it == devices.end()) {
- fprintf(stderr, " -> false\n");
+ if (it == devices.end())
return false;
- }
return it->second->load(addr - -it->first, len, bytes);
}
return false;
return it->second->store(addr - -it->first, len, bytes);
}
+
+std::pair<reg_t, abstract_device_t*> bus_t::find_device(reg_t addr)
+{
+ auto it = devices.lower_bound(-addr);
+ if (it == devices.end() || addr < -it->first)
+ return std::make_pair((reg_t)0, (abstract_device_t*)NULL);
+ return std::make_pair(-it->first, it->second);
+}