| 1 |
#ifndef MSXMULTIMEMDEVICE_HH |
| 2 |
#define MSXMULTIMEMDEVICE_HH |
| 3 |
|
| 4 |
#include "MSXMultiDevice.hh" |
| 5 |
#include <span> |
| 6 |
#include <vector> |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
class MSXMultiMemDevice final : public MSXMultiDevice |
| 11 |
{ |
| 12 |
public: |
| 13 |
struct Range { |
| 14 |
Range(unsigned base_, unsigned size_, MSXDevice& device_); |
| 15 |
[[nodiscard]] constexpr bool operator==(const Range&) const = default; |
| 16 |
|
| 17 |
unsigned base; |
| 18 |
unsigned size; |
| 19 |
MSXDevice* device; |
| 20 |
}; |
| 21 |
|
| 22 |
public: |
| 23 |
explicit MSXMultiMemDevice(HardwareConfig& hwConf); |
| 24 |
~MSXMultiMemDevice() override; |
| 25 |
|
| 26 |
[[nodiscard]] bool canAdd(unsigned base, unsigned size); |
| 27 |
void add(MSXDevice& device, unsigned base, unsigned size); |
| 28 |
void remove(MSXDevice& device, unsigned base, unsigned size); |
| 29 |
[[nodiscard]] bool empty() const { return ranges.size() == 1; } |
| 30 |
[[nodiscard]] std::vector<MSXDevice*> getDevices() const; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
[[nodiscard]] std::span<const Range> getRanges() const { |
| 35 |
return {ranges.data(), ranges.size() - 1}; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
[[nodiscard]] const std::string& getName() const override; |
| 40 |
void getNameList(TclObject& result) const override; |
| 41 |
[[nodiscard]] uint8_t readMem(uint16_t address, EmuTime time) override; |
| 42 |
[[nodiscard]] uint8_t peekMem(uint16_t address, EmuTime time) const override; |
| 43 |
void writeMem(uint16_t address, uint8_t value, EmuTime time) override; |
| 44 |
[[nodiscard]] const uint8_t* getReadCacheLine(uint16_t start) const override; |
| 45 |
[[nodiscard]] uint8_t* getWriteCacheLine(uint16_t start) override; |
| 46 |
|
| 47 |
private: |
| 48 |
[[nodiscard]] const Range& searchRange(unsigned address) const; |
| 49 |
[[nodiscard]] MSXDevice* searchDevice(unsigned address) const; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
std::vector<Range> ranges; |
| 55 |
}; |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
#endif |