openMSX
|
#include <MSXCPU.hh>
Public Types | |
enum | CPUType { CPU_Z80 , CPU_R800 } |
Public Member Functions | |
MSXCPU (MSXMotherBoard &motherboard) | |
~MSXCPU () | |
void | doReset (EmuTime::param time) |
Reset CPU. More... | |
void | setActiveCPU (CPUType cpu) |
Switch between Z80/R800. More... | |
void | setDRAMmode (bool dram) |
Sets DRAM or ROM mode (influences memory access speed for R800). More... | |
void | updateVisiblePage (byte page, byte primarySlot, byte secondarySlot) |
Inform CPU of bank switch. More... | |
void | invalidateAllSlotsRWCache (word start, unsigned size) |
Invalidate the CPU its cache for the interval [start, start + size) For example MSXMemoryMapper and MSXGameCartridge need to call this method when a 'memory switch' occurs. More... | |
void | invalidateRWCache (unsigned start, unsigned size, int ps, int ss, const byte *disallowRead, const byte *disallowWrite) |
Similar to the method above, but only invalidates one specific slot. More... | |
void | invalidateRCache (unsigned start, unsigned size, int ps, int ss, const byte *disallowRead) |
void | invalidateWCache (unsigned start, unsigned size, int ps, int ss, const byte *disallowWrite) |
void | fillRWCache (unsigned start, unsigned size, const byte *rData, byte *wData, int ps, int ss, const byte *disallowRead, const byte *disallowWrite) |
Fill the read and write cache lines for a specific slot with the specified value. More... | |
void | fillRCache (unsigned start, unsigned size, const byte *rData, int ps, int ss, const byte *disallowRead) |
void | fillWCache (unsigned start, unsigned size, byte *wData, int ps, int ss, const byte *disallowWrite) |
void | raiseIRQ () |
This method raises a maskable interrupt. More... | |
void | lowerIRQ () |
This methods lowers the maskable interrupt again. More... | |
void | raiseNMI () |
This method raises a non-maskable interrupt. More... | |
void | lowerNMI () |
This methods lowers the non-maskable interrupt again. More... | |
bool | isM1Cycle (unsigned address) const |
Should only be used from within a MSXDevice::readMem() method. More... | |
void | exitCPULoopSync () |
See CPUCore::exitCPULoopsync() More... | |
void | exitCPULoopAsync () |
See CPUCore::exitCPULoopAsync() More... | |
bool | isR800Active () const |
Is the R800 currently active? More... | |
void | setZ80Freq (unsigned freq) |
Switch the Z80 clock freq. More... | |
void | setInterface (MSXCPUInterface *interf) |
void | disasmCommand (Interpreter &interp, span< const TclObject > tokens, TclObject &result) const |
void | setPaused (bool paused) |
(un)pause CPU. More... | |
void | setNextSyncPoint (EmuTime::param time) |
void | wait (EmuTime::param time) |
EmuTime | waitCyclesZ80 (EmuTime::param time, unsigned cycles) |
EmuTime | waitCyclesR800 (EmuTime::param time, unsigned cycles) |
CPURegs & | getRegisters () |
template<typename Archive > | |
void | serialize (Archive &ar, unsigned version) |
Friends | |
class | MSXMotherBoard |
|
explicit |
Definition at line 21 of file MSXCPU.cc.
References openmsx::Subject< T >::attach(), openmsx::MSXMotherBoard::getDebugger(), openmsx::MSXMotherBoard::getScheduler(), openmsx::Debugger::setCPU(), and openmsx::Scheduler::setCPU().
openmsx::MSXCPU::~MSXCPU | ( | ) |
Definition at line 62 of file MSXCPU.cc.
References openmsx::Subject< T >::detach(), openmsx::MSXMotherBoard::getDebugger(), openmsx::MSXMotherBoard::getScheduler(), openmsx::Debugger::setCPU(), and openmsx::Scheduler::setCPU().
void openmsx::MSXCPU::disasmCommand | ( | Interpreter & | interp, |
span< const TclObject > | tokens, | ||
TclObject & | result | ||
) | const |
void openmsx::MSXCPU::doReset | ( | EmuTime::param | time | ) |
Reset CPU.
Requires CPU is not in the middle of an instruction, so exitCPULoop was called and execute() method returned.
Definition at line 82 of file MSXCPU.cc.
References invalidateAllSlotsRWCache().
Referenced by openmsx::MSXMotherBoard::doReset(), and openmsx::MSXMotherBoard::powerUp().
void openmsx::MSXCPU::exitCPULoopAsync | ( | ) |
See CPUCore::exitCPULoopAsync()
Definition at line 133 of file MSXCPU.cc.
Referenced by openmsx::MSXMotherBoard::exitCPULoopAsync().
void openmsx::MSXCPU::exitCPULoopSync | ( | ) |
See CPUCore::exitCPULoopsync()
Definition at line 128 of file MSXCPU.cc.
Referenced by openmsx::MSXCPUInterface::doBreak(), openmsx::MSXMotherBoard::exitCPULoopSync(), and setActiveCPU().
void openmsx::MSXCPU::fillRCache | ( | unsigned | start, |
unsigned | size, | ||
const byte * | rData, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowRead | ||
) |
Definition at line 274 of file MSXCPU.cc.
References utf8::unchecked::size().
Referenced by openmsx::MSXCPUInterface::fillRCache().
void openmsx::MSXCPU::fillRWCache | ( | unsigned | start, |
unsigned | size, | ||
const byte * | rData, | ||
byte * | wData, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowRead, | ||
const byte * | disallowWrite | ||
) |
Fill the read and write cache lines for a specific slot with the specified value.
Except for the lines where the corresponding 'disallow{Read,Write}' array is non-zero, those lines are marked non-cacheable. This is useful on e.g. a memory mapper bank switch because:
Definition at line 269 of file MSXCPU.cc.
References utf8::unchecked::size().
Referenced by openmsx::MSXCPUInterface::fillRWCache().
void openmsx::MSXCPU::fillWCache | ( | unsigned | start, |
unsigned | size, | ||
byte * | wData, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowWrite | ||
) |
Definition at line 279 of file MSXCPU.cc.
References utf8::unchecked::size().
Referenced by openmsx::MSXCPUInterface::fillWCache().
void openmsx::MSXCPU::invalidateAllSlotsRWCache | ( | word | start, |
unsigned | size | ||
) |
Invalidate the CPU its cache for the interval [start, start + size) For example MSXMemoryMapper and MSXGameCartridge need to call this method when a 'memory switch' occurs.
Definition at line 180 of file MSXCPU.cc.
References openmsx::InvalidateAllSlots, openmsx::CacheLine::SIZE, utf8::unchecked::size(), ProfileCounters< ENABLED, ENUM >::tick(), and xrange().
Referenced by openmsx::MSXCPUInterface::changeExpanded(), doReset(), openmsx::MSXCPUInterface::registerGlobalRead(), openmsx::MSXCPUInterface::registerGlobalWrite(), openmsx::PanasonicMemory::setDRAM(), openmsx::MSXCPUInterface::unregisterGlobalRead(), openmsx::MSXCPUInterface::unregisterGlobalWrite(), and openmsx::CheckedRam::write().
void openmsx::MSXCPU::invalidateRCache | ( | unsigned | start, |
unsigned | size, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowRead | ||
) |
Definition at line 256 of file MSXCPU.cc.
Referenced by openmsx::MSXCPUInterface::invalidateRCache().
void openmsx::MSXCPU::invalidateRWCache | ( | unsigned | start, |
unsigned | size, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowRead, | ||
const byte * | disallowWrite | ||
) |
Similar to the method above, but only invalidates one specific slot.
One small tweak: lines that are in 'disallowRead/Write' are immediately marked as 'non-cacheable' instead of (first) as 'unknown'.
Definition at line 249 of file MSXCPU.cc.
Referenced by openmsx::MSXCPUInterface::invalidateRWCache().
void openmsx::MSXCPU::invalidateWCache | ( | unsigned | start, |
unsigned | size, | ||
int | ps, | ||
int | ss, | ||
const byte * | disallowWrite | ||
) |
Definition at line 262 of file MSXCPU.cc.
Referenced by openmsx::MSXCPUInterface::invalidateWCache().
bool openmsx::MSXCPU::isM1Cycle | ( | unsigned | address | ) | const |
Should only be used from within a MSXDevice::readMem() method.
Returns true if that read was the first byte of an instruction (the Z80 M1 pin is active). This implementation is not 100% accurate, but good enough for now.
Definition at line 306 of file MSXCPU.cc.
Referenced by openmsx::RomRamFile::readMem().
|
inline |
void openmsx::MSXCPU::lowerIRQ | ( | ) |
This methods lowers the maskable interrupt again.
A device may never call this method more often than it called the method raiseIRQ(). Before using this method take a look at IRQHelper.
Definition at line 290 of file MSXCPU.cc.
Referenced by openmsx::IRQSource::lower(), and openmsx::OptionalIRQ::lower().
void openmsx::MSXCPU::lowerNMI | ( | ) |
This methods lowers the non-maskable interrupt again.
A device may never call this method more often than it called the method raiseNMI(). Before using this method take a look at IRQHelper.
Definition at line 300 of file MSXCPU.cc.
Referenced by openmsx::OptionalIRQ::lower().
void openmsx::MSXCPU::raiseIRQ | ( | ) |
This method raises a maskable interrupt.
A device may call this method more than once. If the device wants to lower the interrupt again it must call the lowerIRQ() method exactly as many times. Before using this method take a look at IRQHelper.
Definition at line 285 of file MSXCPU.cc.
Referenced by openmsx::IRQSource::raise(), and openmsx::OptionalIRQ::raise().
void openmsx::MSXCPU::raiseNMI | ( | ) |
This method raises a non-maskable interrupt.
A device may call this method more than once. If the device wants to lower the interrupt again it must call the lowerNMI() method exactly as many times. Before using this method take a look at IRQHelper.
Definition at line 295 of file MSXCPU.cc.
Referenced by openmsx::OptionalIRQ::raise().
void openmsx::MSXCPU::serialize | ( | Archive & | ar, |
unsigned | version | ||
) |
void openmsx::MSXCPU::setActiveCPU | ( | CPUType | cpu | ) |
Switch between Z80/R800.
Definition at line 92 of file MSXCPU.cc.
References CPU_R800, CPU_Z80, and exitCPULoopSync().
void openmsx::MSXCPU::setDRAMmode | ( | bool | dram | ) |
void openmsx::MSXCPU::setInterface | ( | MSXCPUInterface * | interf | ) |
Definition at line 75 of file MSXCPU.cc.
Referenced by openmsx::MSXCPUInterface::MSXCPUInterface(), and openmsx::MSXCPUInterface::~MSXCPUInterface().
void openmsx::MSXCPU::setNextSyncPoint | ( | EmuTime::param | time | ) |
void openmsx::MSXCPU::setPaused | ( | bool | paused | ) |
(un)pause CPU.
During pause the CPU executes NOP instructions continuously (just like during HALT). Used by turbor hw pause.
Definition at line 361 of file MSXCPU.cc.
Referenced by openmsx::MSXMotherBoard::pause(), and openmsx::MSXMotherBoard::unpause().
void openmsx::MSXCPU::setZ80Freq | ( | unsigned | freq | ) |
Switch the Z80 clock freq.
Definition at line 312 of file MSXCPU.cc.
Referenced by openmsx::MSXCielTurbo::writeIO(), and openmsx::MSXMatsushita::writeSwitchedIO().
Inform CPU of bank switch.
This will invalidate memory cache and update memory timings on R800.
Definition at line 162 of file MSXCPU.cc.
References openmsx::CacheLine::SIZE.
EmuTime openmsx::MSXCPU::waitCyclesR800 | ( | EmuTime::param | time, |
unsigned | cycles | ||
) |
Definition at line 329 of file MSXCPU.cc.
Referenced by openmsx::TurboRFDC::readMem(), and openmsx::TurboRFDC::writeMem().
EmuTime openmsx::MSXCPU::waitCyclesZ80 | ( | EmuTime::param | time, |
unsigned | cycles | ||
) |
Definition at line 323 of file MSXCPU.cc.
Referenced by openmsx::VDP::writeIO().
|
friend |