1 #ifndef MSXCPUINTERFACE_HH
2 #define MSXCPUINTERFACE_HH
27 class CartridgeSlotManager;
34 return x.getAddress() < y;
113 int ps,
int ss,
int base,
int size);
115 int ps,
int ss,
int base,
int size);
140 return readMemSlow(address, time);
142 return visibleDevices[address >> 14]->
readMem(address, time);
151 writeMemSlow(address, value, time);
154 visibleDevices[address>>14]->
writeMem(address, value, time);
162 return IO_In[port & 0xFF]->
readIO(port, time);
170 IO_Out[port & 0xFF]->
writeIO(port, value, time);
231 void fillRWCache(
unsigned start,
unsigned size,
const byte* rData,
byte* wData,
int ps,
int ss);
232 void fillRCache (
unsigned start,
unsigned size,
const byte* rData,
int ps,
int ss);
233 void fillWCache (
unsigned start,
unsigned size,
byte* wData,
int ps,
int ss);
239 [[nodiscard]]
byte peekMem(
word address, EmuTime::param time)
const;
240 [[nodiscard]]
byte peekSlottedMem(
unsigned address, EmuTime::param time)
const;
243 EmuTime::param time);
248 span<
const std::unique_ptr<MSXDevice>> allowed)
const;
249 [[nodiscard]]
inline bool isExpanded(
int ps)
const {
return expanded[ps] != 0; }
259 void setWatchPoint(
const std::shared_ptr<WatchPoint>& watchPoint);
270 [[nodiscard]]
static bool isBreaked() {
return breaked; }
278 return !breakPoints.empty() || !conditions.empty();
283 if (conditions.empty() && (range.first == range.second)) {
300 template<
typename Archive>
301 void serialize(Archive& ar,
unsigned version);
304 byte readMemSlow(
word address, EmuTime::param time);
305 void writeMemSlow(
word address,
byte value, EmuTime::param time);
307 MSXDevice*& getDevicePtr(
byte port,
bool isIn);
309 void register_IO (
int port,
bool isIn,
313 int ps,
int ss,
int base,
int size);
315 int ps,
int ss,
int base,
int size);
317 int ps,
int ss,
int base,
int size);
321 BreakPoints::const_iterator> range,
326 void removeAllWatchPoints();
329 unsigned value = ~0u);
333 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
334 void write(
unsigned address,
byte value, EmuTime::param time)
override;
337 struct SlottedMemoryDebug final : SimpleDebuggable {
338 explicit SlottedMemoryDebug(MSXMotherBoard& motherBoard);
339 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
340 void write(
unsigned address,
byte value, EmuTime::param time)
override;
341 } slottedMemoryDebug;
343 struct IODebug final : SimpleDebuggable {
344 explicit IODebug(MSXMotherBoard& motherBoard);
345 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
346 void write(
unsigned address,
byte value, EmuTime::param time)
override;
349 struct SlotInfo final : InfoTopic {
350 explicit SlotInfo(InfoCommand& machineInfoCommand);
352 TclObject& result)
const override;
353 [[nodiscard]] std::string help(
const std::vector<std::string>& tokens)
const override;
356 struct SubSlottedInfo final : InfoTopic {
357 explicit SubSlottedInfo(InfoCommand& machineInfoCommand);
359 TclObject& result)
const override;
360 [[nodiscard]] std::string help(
const std::vector<std::string>& tokens)
const override;
363 struct ExternalSlotInfo final : InfoTopic {
364 explicit ExternalSlotInfo(InfoCommand& machineInfoCommand);
366 TclObject& result)
const override;
367 [[nodiscard]] std::string help(
const std::vector<std::string>& tokens)
const override;
370 struct IOInfo : InfoTopic {
371 IOInfo(InfoCommand& machineInfoCommand,
const char* name);
373 TclObject& result,
MSXDevice** devices)
const;
374 [[nodiscard]] std::string help(
const std::vector<std::string>& tokens)
const override;
378 struct IInfo final : IOInfo {
379 explicit IInfo(InfoCommand& machineInfoCommand)
380 : IOInfo(machineInfoCommand,
"input_port") {}
382 TclObject& result)
const override;
384 struct OInfo final : IOInfo {
385 explicit OInfo(InfoCommand& machineInfoCommand)
386 : IOInfo(machineInfoCommand,
"output_port") {}
388 TclObject& result)
const override;
397 void updateVisible(
int page);
398 inline void updateVisible(
int page,
int ps,
int ss);
399 void setSubSlot(
byte primSlot,
byte value);
401 std::unique_ptr<DummyDevice> dummyDevice;
404 MSXMotherBoard& motherBoard;
406 std::unique_ptr<VDPIODelay> delayDevice;
413 struct GlobalRwInfo {
416 [[nodiscard]]
bool operator==(
const GlobalRwInfo& rhs)
const {
417 return (device == rhs.device) &&
421 std::vector<GlobalRwInfo> globalReads;
422 std::vector<GlobalRwInfo> globalWrites;
428 byte subSlotRegister[4];
429 byte primarySlotState[4];
430 byte secondarySlotState[4];
431 byte initialPrimarySlots;
432 unsigned expanded[4];
440 static inline bool breaked =
false;
446 template<
unsigned BEGIN,
unsigned END = BEGIN + 1>
449 [[nodiscard]]
unsigned begin()
const {
return BEGIN; }
450 [[nodiscard]]
unsigned end()
const {
return END; }
454 template<
typename ACTION,
typename CT_INTERVAL>
457 for (
auto i = interval.begin(); i != interval.end(); ++i) {
461 template<
typename ACTION,
typename CT_INTERVAL,
typename... CT_INTERVALS>
469 template<
typename MSXDEVICE,
typename... CT_INTERVALS>
472 template<
typename ACTION>
475 auto& dev =
static_cast<MSXDEVICE&
>(*this);
476 auto& cpu = dev.getCPUInterface();
478 [&](
unsigned addr) { action(cpu, dev, addr); },
483 template<
typename MSXDEVICE,
typename... CT_INTERVALS>
501 template<
typename MSXDEVICE,
typename... CT_INTERVALS>
void tick(CacheLineCounters e) const
Base class for CPU breakpoints.
General debugger condition Like breakpoints, but not tied to a specifc address.
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
void setWatchPoint(const std::shared_ptr< WatchPoint > &watchPoint)
void invalidateRWCache(word start, unsigned size, int ps, int ss)
static void insertBreakPoint(BreakPoint bp)
DummyDevice & getDummyDevice()
std::vector< DebugCondition > Conditions
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
void fillWCache(unsigned start, unsigned size, byte *wData, int ps, int ss)
void unregister_IO_In(byte port, MSXDevice *device)
void writeIO(word port, byte value, EmuTime::param time)
This writes a byte to the given IO-port.
bool replace_IO_Out(byte port, MSXDevice *oldDevice, MSXDevice *newDevice)
void changeExpanded(bool newExpanded)
static void removeCondition(const DebugCondition &cond)
byte peekMem(word address, EmuTime::param time) const
Peek memory location.
static const BreakPoints & getBreakPoints()
byte readIO(word port, EmuTime::param time)
This read a byte from the given IO-port.
const WatchPoints & getWatchPoints() const
void testUnsetExpanded(int ps, span< const std::unique_ptr< MSXDevice >> allowed) const
static bool checkBreakPoints(unsigned pc, MSXMotherBoard &motherBoard)
void writeSlottedMem(unsigned address, byte value, EmuTime::param time)
void setPrimarySlots(byte value)
void invalidateRCache(word start, unsigned size, int ps, int ss)
void unregisterGlobalWrite(MSXDevice &device, word address)
byte * getWriteCacheLine(word start) const
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void unregisterGlobalRead(MSXDevice &device, word address)
byte peekSlottedMem(unsigned address, EmuTime::param time) const
void removeWatchPoint(std::shared_ptr< WatchPoint > watchPoint)
std::vector< std::shared_ptr< WatchPoint > > WatchPoints
byte readMem(word address, EmuTime::param time)
This reads a byte from the currently selected device.
void fillRWCache(unsigned start, unsigned size, const byte *rData, byte *wData, int ps, int ss)
MSXCPUInterface & operator=(const MSXCPUInterface &)=delete
void reset()
Reset (the slot state)
static void setCondition(DebugCondition cond)
void registerMemDevice(MSXDevice &device, int ps, int ss, int base, int size)
Devices can register themself in the MSX slotstructure.
void invalidateWCache(word start, unsigned size, int ps, int ss)
void unsetExpanded(int ps)
bool isFastForward() const
byte readIRQVector()
CPU uses this method to read 'extra' data from the databus used in interrupt routines.
void serialize(Archive &ar, unsigned version)
void unregisterMemDevice(MSXDevice &device, int ps, int ss, int base, int size)
const byte * getReadCacheLine(word start) const
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void registerGlobalRead(MSXDevice &device, word address)
(Un)register global read.
void writeMem(word address, byte value, EmuTime::param time)
This writes a byte to the currently selected device.
byte readSlottedMem(unsigned address, EmuTime::param time)
static void removeBreakPoint(const BreakPoint &bp)
void unregister_IO_Out(byte port, MSXDevice *device)
void registerGlobalWrite(MSXDevice &device, word address)
(Un)register global writes.
std::vector< BreakPoint > BreakPoints
static bool anyBreakPoints()
bool replace_IO_In(byte port, MSXDevice *oldDevice, MSXDevice *newDevice)
These methods replace a previously registered device with a new one.
static const Conditions & getConditions()
void setFastForward(bool fastForward_)
MSXCPUInterface(const MSXCPUInterface &)=delete
void fillRCache(unsigned start, unsigned size, const byte *rData, int ps, int ss)
bool isExpanded(int ps) const
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
virtual const byte * getReadCacheLine(word start) const
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
virtual void writeIO(word port, byte value, EmuTime::param time)
Write a byte to a given IO port at a certain time to this device.
virtual byte readMem(word address, EmuTime::param time)
Read a byte from a location at a certain time from this device.
virtual void writeMem(word address, byte value, EmuTime::param time)
Write a given byte to a given location at a certain time to this device.
virtual byte * getWriteCacheLine(word start) const
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
virtual byte readIO(word port, EmuTime::param time)
Read a byte from an IO port at a certain time from this device.
byte read(unsigned address) override
void write(unsigned address, byte value) override
constexpr bool operator==(PoolIndex i, PoolIndex j)
This file implemented 3 utility functions:
constexpr bool PROFILE_CACHELINES
void foreach_ct_interval(ACTION action, CT_INTERVAL interval)
std::ostream & operator<<(std::ostream &os, EnumTypeName< CacheLineCounters >)
uint16_t word
16 bit unsigned integer
constexpr KeyMatrixPosition x
Keyboard bindings.
auto equal_range(ForwardRange &&range, const T &value)
size_t size(std::string_view utf8)
bool operator()(const BreakPoint &x, word y) const
bool operator()(const BreakPoint &x, const BreakPoint &y) const
bool operator()(word x, const BreakPoint &y) const
void execute(ACTION action)