aboutsummaryrefslogtreecommitdiff
path: root/riscv/devices.cc
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/devices.cc')
-rw-r--r--riscv/devices.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/riscv/devices.cc b/riscv/devices.cc
index c7a63b0..af4dc7d 100644
--- a/riscv/devices.cc
+++ b/riscv/devices.cc
@@ -20,3 +20,14 @@ bool bus_t::store(reg_t addr, size_t len, const uint8_t* bytes)
return false;
return it->second->store(addr - -it->first, len, bytes);
}
+
+bus_t::descriptor bus_t::find_device(reg_t addr)
+{
+ auto it = devices.lower_bound(-addr);
+ if (it == devices.end()) {
+ bus_t::descriptor desc = {0, 0};
+ return desc;
+ }
+ bus_t::descriptor desc = {-it->first, it->second};
+ return desc;
+}