1 #ifndef _RISCV_DEVICES_H
2 #define _RISCV_DEVICES_H
8 class abstract_device_t
{
10 virtual bool load(reg_t addr
, size_t len
, uint8_t* bytes
) = 0;
11 virtual bool store(reg_t addr
, size_t len
, const uint8_t* bytes
) = 0;
12 virtual ~abstract_device_t() {}
15 class bus_t
: public abstract_device_t
{
17 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
18 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
19 void add_device(reg_t addr
, abstract_device_t
* dev
);
22 std::map
<reg_t
, abstract_device_t
*> devices
;
25 class rom_device_t
: public abstract_device_t
{
27 rom_device_t(std::vector
<char> data
);
28 bool load(reg_t addr
, size_t len
, uint8_t* bytes
);
29 bool store(reg_t addr
, size_t len
, const uint8_t* bytes
);
31 std::vector
<char> data
;