Remove MTIME[CMP]; add RTC device
[riscv-isa-sim.git] / riscv / devices.cc
1 #include "devices.h"
2
3 void bus_t::add_device(reg_t addr, abstract_device_t* dev)
4 {
5 devices[-addr] = dev;
6 }
7
8 bool bus_t::load(reg_t addr, size_t len, uint8_t* bytes)
9 {
10 auto it = devices.lower_bound(-addr);
11 if (it == devices.end())
12 return false;
13 return it->second->load(addr - -it->first, len, bytes);
14 }
15
16 bool bus_t::store(reg_t addr, size_t len, const uint8_t* bytes)
17 {
18 auto it = devices.lower_bound(-addr);
19 if (it == devices.end())
20 return false;
21 return it->second->store(addr - -it->first, len, bytes);
22 }