openMSX
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
openmsx::MSXMemoryMapper Class Reference

#include <MSXMemoryMapper.hh>

Inheritance diagram for openmsx::MSXMemoryMapper:
Inheritance graph
[legend]
Collaboration diagram for openmsx::MSXMemoryMapper:
Collaboration graph
[legend]

Public Member Functions

 MSXMemoryMapper (const DeviceConfig &config)
 
virtual ~MSXMemoryMapper ()
 
byte getSelectedSegment (byte page) const override
 Returns the currently selected segment for the given page. More...
 
unsigned getSizeInBlocks ()
 
void reset (EmuTime::param time) override
 This method is called on reset. More...
 
void powerUp (EmuTime::param time) override
 This method is called when MSX is powered up. More...
 
byte readIO (word port, EmuTime::param time) override
 Read a byte from an IO port at a certain time from this device. More...
 
byte peekIO (word port, EmuTime::param time) const override
 Read a byte from a given IO port. More...
 
void writeIO (word port, byte value, EmuTime::param time) override
 Write a byte to a given IO port at a certain time to this device. More...
 
byte readMem (word address, EmuTime::param time) override
 Read a byte from a location at a certain time from this device. More...
 
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. More...
 
const bytegetReadCacheLine (word start) const override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading. More...
 
bytegetWriteCacheLine (word start) const override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing. More...
 
byte peekMem (word address, EmuTime::param time) const override
 Read a byte from a given memory location. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const MSXDevice &)=delete
 
MSXDeviceoperator= (const MSXDevice &)=delete
 
virtual ~MSXDevice ()=0
 
const HardwareConfiggetHardwareConfig () const
 Returns the hardwareconfig this device belongs to. More...
 
void testRemove (Devices alreadyRemoved) const
 Checks whether this device can be removed (no other device has a reference to it). More...
 
virtual byte readIRQVector ()
 Gets IRQ vector used in IM2. More...
 
virtual void powerDown (EmuTime::param time)
 This method is called when MSX is powered down. More...
 
virtual std::string getName () const
 Returns a human-readable name for this device. More...
 
virtual void getNameList (TclObject &result) const
 Returns list of name(s) of this device. More...
 
void getDeviceInfo (TclObject &result) const
 Get device info. More...
 
void getVisibleMemRegion (unsigned &base, unsigned &size) const
 Returns the range where this device is visible in memory. More...
 
virtual void globalWrite (word address, byte value, EmuTime::param time)
 Global writes. More...
 
virtual void globalRead (word address, EmuTime::param time)
 Global reads. More...
 
void invalidateMemCache (word start, unsigned size)
 Invalidate CPU memory-mapping cache. More...
 
MSXMotherBoardgetMotherBoard () const
 Get the mother board this device belongs to. More...
 
const XMLElementgetDeviceConfig () const
 Get the configuration section for this device. More...
 
const DeviceConfiggetDeviceConfig2 () const
 
const DevicesgetReferences () const
 Get the device references that are specified for this device. More...
 
EmuTime::param getCurrentTime () const
 
MSXCPUgetCPU () const
 
MSXCPUInterfacegetCPUInterface () const
 
SchedulergetScheduler () const
 
CliCommgetCliComm () const
 
ReactorgetReactor () const
 
CommandControllergetCommandController () const
 
PluggingControllergetPluggingController () const
 
LedStatusgetLedStatus () const
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::MSXMapperIOClient< MSXMemoryMapper >
 MSXMapperIOClient ()
 
 ~MSXMapperIOClient ()
 

Protected Member Functions

unsigned calcAddress (word address) const
 Converts a Z80 address to a RAM address. More...
 
- Protected Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const DeviceConfig &config, const std::string &name)
 Every MSXDevice has a config entry; this constructor gets some device properties from that config entry. More...
 
 MSXDevice (const DeviceConfig &config)
 
virtual void init ()
 
virtual void getExtraDeviceInfo (TclObject &result) const
 
- Protected Member Functions inherited from openmsx::MSXMemoryMapperInterface
 ~MSXMemoryMapperInterface ()=default
 

Protected Attributes

CheckedRam checkedRam
 
byte registers [4]
 

Additional Inherited Members

- Public Types inherited from openmsx::MSXDevice
using Devices = std::vector< MSXDevice * >
 
- Static Public Attributes inherited from openmsx::MSXDevice
static byte unmappedRead [0x10000]
 
static byte unmappedWrite [0x10000]
 

Detailed Description

Definition at line 11 of file MSXMemoryMapper.hh.

Constructor & Destructor Documentation

◆ MSXMemoryMapper()

openmsx::MSXMemoryMapper::MSXMemoryMapper ( const DeviceConfig config)
explicit

Definition at line 26 of file MSXMemoryMapper.cc.

◆ ~MSXMemoryMapper()

openmsx::MSXMemoryMapper::~MSXMemoryMapper ( )
virtual

Definition at line 33 of file MSXMemoryMapper.cc.

Member Function Documentation

◆ calcAddress()

unsigned openmsx::MSXMemoryMapper::calcAddress ( word  address) const
protected

Converts a Z80 address to a RAM address.

Parameters
addressIndex in Z80 address space.
Returns
Index in RAM address space.

Definition at line 69 of file MSXMemoryMapper.cc.

References checkedRam, openmsx::CheckedRam::getSize(), and registers.

Referenced by getReadCacheLine(), getSizeInBlocks(), openmsx::PanasonicRam::getWriteCacheLine(), getWriteCacheLine(), peekMem(), readMem(), openmsx::PanasonicRam::writeMem(), and writeMem().

◆ getReadCacheLine()

const byte * openmsx::MSXMemoryMapper::getReadCacheLine ( word  start) const
overridevirtual

Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.

If it is, a pointer to a buffer containing this interval must be returned. If not, a null pointer must be returned. Cacheable for reading means the data may be read directly from the buffer, thus bypassing the readMem() method, and thus also ignoring EmuTime. The default implementation always returns a null pointer. The start of the interval is CacheLine::SIZE aligned.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 92 of file MSXMemoryMapper.cc.

References calcAddress(), checkedRam, and openmsx::CheckedRam::getReadCacheLine().

Referenced by openmsx::MusicalMemoryMapper::getReadCacheLine(), and getSizeInBlocks().

◆ getSelectedSegment()

byte openmsx::MSXMemoryMapper::getSelectedSegment ( byte  page) const
inlineoverridevirtual

Returns the currently selected segment for the given page.

Parameters
pageZ80 address page (0-3).

Implements openmsx::MSXMemoryMapperInterface.

Definition at line 21 of file MSXMemoryMapper.hh.

References registers.

Referenced by openmsx::MusicalMemoryMapper::writeIO().

◆ getSizeInBlocks()

unsigned openmsx::MSXMemoryMapper::getSizeInBlocks ( )
inline

◆ getWriteCacheLine()

byte * openmsx::MSXMemoryMapper::getWriteCacheLine ( word  start) const
overridevirtual

Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.

If it is, a pointer to a buffer containing this interval must be returned. If not, a null pointer must be returned. Cacheable for writing means the data may be written directly to the buffer, thus bypassing the writeMem() method, and thus also ignoring EmuTime. The default implementation always returns a null pointer. The start of the interval is CacheLine::SIZE aligned.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper, and openmsx::PanasonicRam.

Definition at line 97 of file MSXMemoryMapper.cc.

References calcAddress(), checkedRam, and openmsx::CheckedRam::getWriteCacheLine().

Referenced by getSizeInBlocks(), and openmsx::MusicalMemoryMapper::getWriteCacheLine().

◆ peekIO()

byte openmsx::MSXMemoryMapper::peekIO ( word  port,
EmuTime::param  time 
) const
overridevirtual

Read a byte from a given IO port.

Reading via this method has no side effects (doesn't change the device status). If save reading is not possible this method returns 0xFF. This method is not used by the emulation. It can however be used by a debugger. The default implementation just returns 0xFF.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 57 of file MSXMemoryMapper.cc.

References checkedRam, openmsx::CheckedRam::getSize(), Math::powerOfTwo(), and registers.

Referenced by getSizeInBlocks(), openmsx::MusicalMemoryMapper::peekIO(), and readIO().

◆ peekMem()

byte openmsx::MSXMemoryMapper::peekMem ( word  address,
EmuTime::param  time 
) const
overridevirtual

Read a byte from a given memory location.

Reading memory via this method has no side effects (doesn't change the device status). If save reading is not possible this method returns 0xFF. This method is not used by the emulation. It can however be used by a debugger. The default implementation uses the cache mechanism (getReadCacheLine() method). If a certain region is not cacheable you cannot read it by default, Override this method if you want to improve this behaviour.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 77 of file MSXMemoryMapper.cc.

References calcAddress(), checkedRam, and openmsx::CheckedRam::peek().

Referenced by getSizeInBlocks(), and openmsx::MusicalMemoryMapper::peekMem().

◆ powerUp()

void openmsx::MSXMemoryMapper::powerUp ( EmuTime::param  time)
overridevirtual

This method is called when MSX is powered up.

The default implementation calls reset(), this is usually ok.

Parameters
timeThe moment in time the power up occurs.

Reimplemented from openmsx::MSXDevice.

Definition at line 37 of file MSXMemoryMapper.cc.

References checkedRam, openmsx::CheckedRam::clear(), and reset().

Referenced by getSizeInBlocks().

◆ readIO()

byte openmsx::MSXMemoryMapper::readIO ( word  port,
EmuTime::param  time 
)
overridevirtual

Read a byte from an IO port at a certain time from this device.

The default implementation returns 255.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 52 of file MSXMemoryMapper.cc.

References peekIO().

Referenced by getSizeInBlocks(), and openmsx::MusicalMemoryMapper::readIO().

◆ readMem()

byte openmsx::MSXMemoryMapper::readMem ( word  address,
EmuTime::param  time 
)
overridevirtual

Read a byte from a location at a certain time from this device.

The default implementation returns 255.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 82 of file MSXMemoryMapper.cc.

References calcAddress(), checkedRam, and openmsx::CheckedRam::read().

Referenced by getSizeInBlocks(), and openmsx::MusicalMemoryMapper::readMem().

◆ reset()

void openmsx::MSXMemoryMapper::reset ( EmuTime::param  time)
overridevirtual

This method is called on reset.

Default implementation does nothing.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 43 of file MSXMemoryMapper.cc.

References registers.

Referenced by getSizeInBlocks(), and powerUp().

◆ serialize()

template<typename Archive >
void openmsx::MSXMemoryMapper::serialize ( Archive &  ar,
unsigned  version 
)

Definition at line 126 of file MSXMemoryMapper.cc.

References checkedRam, openmsx::CheckedRam::getUncheckedRam(), and registers.

Referenced by getSizeInBlocks().

◆ writeIO()

void openmsx::MSXMemoryMapper::writeIO ( word  port,
byte  value,
EmuTime::param  time 
)
overridevirtual

Write a byte to a given IO port at a certain time to this device.

The default implementation ignores the write (does nothing)

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper.

Definition at line 63 of file MSXMemoryMapper.cc.

References checkedRam, openmsx::CheckedRam::getSize(), Math::powerOfTwo(), and registers.

Referenced by getSizeInBlocks(), openmsx::MusicalMemoryMapper::writeIO(), and openmsx::MusicalMemoryMapper::writeMem().

◆ writeMem()

void openmsx::MSXMemoryMapper::writeMem ( word  address,
byte  value,
EmuTime::param  time 
)
overridevirtual

Write a given byte to a given location at a certain time to this device.

The default implementation ignores the write (does nothing).

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::MusicalMemoryMapper, and openmsx::PanasonicRam.

Definition at line 87 of file MSXMemoryMapper.cc.

References calcAddress(), checkedRam, and openmsx::CheckedRam::write().

Referenced by getSizeInBlocks(), and openmsx::MusicalMemoryMapper::writeMem().

Member Data Documentation

◆ checkedRam

CheckedRam openmsx::MSXMemoryMapper::checkedRam
protected

◆ registers

byte openmsx::MSXMemoryMapper::registers[4]
protected

The documentation for this class was generated from the following files: