1 #ifndef MSXCPUINTERFACE_HH
2 #define MSXCPUINTERFACE_HH
100 int ps,
int ss,
int base,
int size);
102 int ps,
int ss,
int base,
int size);
127 return readMemSlow(address, time);
129 return visibleDevices[address >> 14]->
readMem(address, time);
138 writeMemSlow(address, value, time);
141 visibleDevices[address>>14]->
writeMem(address, value, time);
149 return IO_In[port & 0xFF]->
readIO(port, time);
157 IO_Out[port & 0xFF]->
writeIO(port, value, time);
218 void fillRWCache(
unsigned start,
unsigned size,
const byte* rData,
byte* wData,
int ps,
int ss);
219 void fillRCache (
unsigned start,
unsigned size,
const byte* rData,
int ps,
int ss);
220 void fillWCache (
unsigned start,
unsigned size,
byte* wData,
int ps,
int ss);
226 [[nodiscard]]
byte peekMem(
word address, EmuTime::param time)
const;
227 [[nodiscard]]
byte peekSlottedMem(
unsigned address, EmuTime::param time)
const;
230 EmuTime::param time);
235 std::span<
const std::unique_ptr<MSXDevice>> allowed)
const;
236 [[nodiscard]]
inline bool isExpanded(
int ps)
const {
return expanded[ps] != 0; }
246 void setWatchPoint(
const std::shared_ptr<WatchPoint>& watchPoint);
257 [[nodiscard]]
static bool isBreaked() {
return breaked; }
265 return !breakPoints.empty() || !conditions.empty();
270 if (conditions.empty() && (range.first == range.second)) {
287 template<
typename Archive>
288 void serialize(Archive& ar,
unsigned version);
291 byte readMemSlow(
word address, EmuTime::param time);
292 void writeMemSlow(
word address,
byte value, EmuTime::param time);
294 MSXDevice*& getDevicePtr(
byte port,
bool isIn);
296 void register_IO (
int port,
bool isIn,
300 int ps,
int ss,
int base,
int size);
302 int ps,
int ss,
int base,
int size);
304 int ps,
int ss,
int base,
int size);
308 BreakPoints::const_iterator> range);
312 void removeAllWatchPoints();
315 unsigned value = ~0u);
319 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
320 void write(
unsigned address,
byte value, EmuTime::param time)
override;
323 struct SlottedMemoryDebug final : SimpleDebuggable {
324 explicit SlottedMemoryDebug(MSXMotherBoard& motherBoard);
325 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
326 void write(
unsigned address,
byte value, EmuTime::param time)
override;
327 } slottedMemoryDebug;
329 struct IODebug final : SimpleDebuggable {
330 explicit IODebug(MSXMotherBoard& motherBoard);
331 [[nodiscard]]
byte read(
unsigned address, EmuTime::param time)
override;
332 void write(
unsigned address,
byte value, EmuTime::param time)
override;
335 struct SlotInfo final : InfoTopic {
336 explicit SlotInfo(InfoCommand& machineInfoCommand);
337 void execute(std::span<const TclObject> tokens,
338 TclObject& result)
const override;
339 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
342 struct SubSlottedInfo final : InfoTopic {
343 explicit SubSlottedInfo(InfoCommand& machineInfoCommand);
344 void execute(std::span<const TclObject> tokens,
345 TclObject& result)
const override;
346 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
349 struct ExternalSlotInfo final : InfoTopic {
350 explicit ExternalSlotInfo(InfoCommand& machineInfoCommand);
351 void execute(std::span<const TclObject> tokens,
352 TclObject& result)
const override;
353 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
356 struct IOInfo : InfoTopic {
357 IOInfo(InfoCommand& machineInfoCommand,
const char* name);
358 void helper(std::span<const TclObject> tokens,
359 TclObject& result,
MSXDevice** devices)
const;
360 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
364 struct IInfo final : IOInfo {
365 explicit IInfo(InfoCommand& machineInfoCommand)
366 : IOInfo(machineInfoCommand,
"input_port") {}
367 void execute(std::span<const TclObject> tokens,
368 TclObject& result)
const override;
370 struct OInfo final : IOInfo {
371 explicit OInfo(InfoCommand& machineInfoCommand)
372 : IOInfo(machineInfoCommand,
"output_port") {}
373 void execute(std::span<const TclObject> tokens,
374 TclObject& result)
const override;
383 void updateVisible(
int page);
384 inline void updateVisible(
int page,
int ps,
int ss);
385 void setSubSlot(
byte primSlot,
byte value);
387 std::unique_ptr<DummyDevice> dummyDevice;
390 MSXMotherBoard& motherBoard;
392 std::unique_ptr<VDPIODelay> delayDevice;
399 struct GlobalRwInfo {
402 [[nodiscard]] constexpr
bool operator==(
const GlobalRwInfo&)
const =
default;
404 std::vector<GlobalRwInfo> globalReads;
405 std::vector<GlobalRwInfo> globalWrites;
411 byte subSlotRegister[4];
412 byte primarySlotState[4];
413 byte secondarySlotState[4];
414 byte initialPrimarySlots;
415 unsigned expanded[4];
423 static inline bool breaked =
false;
429 template<
unsigned BEGIN,
unsigned END = BEGIN + 1>
432 [[nodiscard]]
unsigned begin()
const {
return BEGIN; }
433 [[nodiscard]]
unsigned end()
const {
return END; }
439 for (
auto i = ct_interval.begin(); i != ct_interval.end(); ++i) {
444 auto front_interval,
auto... tail_intervals)
451 template<
typename MSXDEVICE,
typename... CT_INTERVALS>
454 void execute(std::invocable<MSXCPUInterface&, MSXDevice&, unsigned>
auto action)
456 auto& dev =
static_cast<MSXDEVICE&
>(*this);
457 auto& cpu = dev.getCPUInterface();
459 [&](
unsigned addr) { action(cpu, dev, addr); },
464 template<
typename MSXDEVICE,
typename... CT_INTERVALS>
482 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)
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 testUnsetExpanded(int ps, std::span< const std::unique_ptr< MSXDevice >> allowed) const
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)
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 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)
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.
bool checkBreakPoints(unsigned pc)
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)
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
This file implemented 3 utility functions:
bool operator==(const Event &x, const Event &y)
constexpr bool PROFILE_CACHELINES
std::ostream & operator<<(std::ostream &os, EnumTypeName< CacheLineCounters >)
uint16_t word
16 bit unsigned integer
void foreach_ct_interval(std::invocable< unsigned > auto action, auto ct_interval)
auto equal_range(ForwardRange &&range, const T &value, Compare comp={})
size_t size(std::string_view utf8)
void execute(std::invocable< MSXCPUInterface &, MSXDevice &, unsigned > auto action)