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
7namespace openmsx {
8
9class MSXMultiMemDevice final : public MSXMultiDevice
10{
11public:
12 explicit MSXMultiMemDevice(const HardwareConfig& hwConf);
13 ~MSXMultiMemDevice() override;
14
15 [[nodiscard]] bool canAdd(unsigned base, unsigned size);
16 void add(MSXDevice& device, unsigned base, unsigned size);
17 void remove(MSXDevice& device, unsigned base, unsigned 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
30private:
31 struct Range {
32 Range(unsigned base_, unsigned size_, MSXDevice& device_);
33 [[nodiscard]] constexpr bool operator==(const Range&) const = default;
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:36
void add(MSXDevice &device, unsigned base, unsigned size)
bool canAdd(unsigned base, unsigned size)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
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.
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 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 remove(MSXDevice &device, unsigned base, unsigned size)
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 BooleanInput &x, const BooleanInput &y)
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29