openMSX
MSXMultiMemDevice.hh
Go to the documentation of this file.
1 #ifndef MSXMULTIMEMDEVICE_HH
2 #define MSXMULTIMEMDEVICE_HH
3 
4 #include "MSXMultiDevice.hh"
5 #include <vector>
6 
7 namespace openmsx {
8 
9 class MSXMultiMemDevice final : public MSXMultiDevice
10 {
11 public:
12  explicit MSXMultiMemDevice(const HardwareConfig& hwConf);
13  ~MSXMultiMemDevice() override;
14 
15  [[nodiscard]] bool canAdd(int base, int size);
16  void add(MSXDevice& device, int base, int size);
17  void remove(MSXDevice& device, int base, int size);
18  [[nodiscard]] bool empty() const { return ranges.size() == 1; }
19  [[nodiscard]] std::vector<MSXDevice*> getDevices() const;
20 
21  // MSXDevice
22  [[nodiscard]] const std::string& getName() const override;
23  void getNameList(TclObject& result) const override;
24  [[nodiscard]] byte readMem(word address, EmuTime::param time) override;
25  [[nodiscard]] byte peekMem(word address, EmuTime::param time) const override;
26  void writeMem(word address, byte value, EmuTime::param time) override;
27  [[nodiscard]] const byte* getReadCacheLine(word start) const override;
28  [[nodiscard]] byte* getWriteCacheLine(word start) const override;
29 
30 private:
31  struct Range {
32  Range(unsigned base_, unsigned size_, MSXDevice& device_);
33  bool operator==(const Range& other) const;
34 
35  unsigned base;
36  unsigned size;
37  MSXDevice* device;
38  };
39 
40  [[nodiscard]] const Range& searchRange(unsigned address) const;
41  [[nodiscard]] MSXDevice* searchDevice(unsigned address) const;
42 
43  std::vector<Range> ranges; // ordered (sentinel at the back)
44 };
45 
46 } // namespace openmsx
47 
48 #endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
MSXDevice(const MSXDevice &)=delete
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void add(MSXDevice &device, int base, int size)
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
MSXMultiMemDevice(const HardwareConfig &hwConf)
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
const std::string & getName() const override
Returns a human-readable name for this device.
bool canAdd(int base, int size)
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
std::vector< MSXDevice * > getDevices() const
void remove(MSXDevice &device, int base, int size)
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
void getNameList(TclObject &result) const override
Returns list of name(s) of this device.
This file implemented 3 utility functions:
Definition: Autofire.cc:9
bool operator==(const Event &x, const Event &y)
Definition: Event.cc:11
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
Definition: ranges.hh:22
size_t size(std::string_view utf8)