2010-12-28 01:53:15 +00:00
|
|
|
struct Memory {
|
|
|
|
~Memory();
|
2015-11-21 07:36:48 +00:00
|
|
|
|
|
|
|
auto operator[](uint addr) -> uint8&;
|
|
|
|
auto allocate(uint size) -> void;
|
|
|
|
auto copy(const uint8* data, uint size) -> void;
|
|
|
|
auto free() -> void;
|
|
|
|
|
|
|
|
uint8* data = nullptr;
|
|
|
|
uint size = 0;
|
2010-12-28 01:53:15 +00:00
|
|
|
};
|
|
|
|
|
2010-12-29 11:03:42 +00:00
|
|
|
struct MMIO {
|
2015-11-21 07:36:48 +00:00
|
|
|
virtual auto mmio_read(uint16 addr) -> uint8 = 0;
|
|
|
|
virtual auto mmio_write(uint16 addr, uint8 data) -> void = 0;
|
2010-12-29 11:03:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Unmapped : MMIO {
|
2016-01-08 09:23:46 +00:00
|
|
|
auto mmio_read(uint16) -> uint8 { return 0xff; }
|
2015-11-21 07:36:48 +00:00
|
|
|
auto mmio_write(uint16, uint8) -> void {}
|
2010-12-29 11:03:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Bus {
|
2015-11-21 07:36:48 +00:00
|
|
|
auto read(uint16 addr) -> uint8;
|
|
|
|
auto write(uint16 addr, uint8 data) -> void;
|
|
|
|
auto power() -> void;
|
2010-12-28 01:53:15 +00:00
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
MMIO* mmio[65536];
|
2010-12-28 01:53:15 +00:00
|
|
|
};
|
|
|
|
|
2010-12-29 11:03:42 +00:00
|
|
|
extern Unmapped unmapped;
|
2010-12-28 01:53:15 +00:00
|
|
|
extern Bus bus;
|