openMSX
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
openmsx::RomBlocks< BANK_SIZE_ > Class Template Reference

#include <RomBlocks.hh>

Inheritance diagram for openmsx::RomBlocks< BANK_SIZE_ >:
Inheritance graph
[legend]
Collaboration diagram for openmsx::RomBlocks< BANK_SIZE_ >:
Collaboration graph
[legend]

Public Member Functions

unsigned getBaseSizeAlignment () const override
 The 'base' and 'size' attribute values need to be at least aligned to CacheLine::SIZE.
 
byte readMem (word address, EmuTime::param time) override
 Read a byte from a location at a certain time from this device.
 
byte peekMem (word address, EmuTime::param time) const override
 Read a byte from a given memory location.
 
const bytegetReadCacheLine (word address) const override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::MSXRom
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.
 
bytegetWriteCacheLine (word address) override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
 
void getExtraDeviceInfo (TclObject &result) const override
 
void getInfo (TclObject &result) const
 Add dict values with info to result.
 
RomType getRomType () const
 
- Public Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const MSXDevice &)=delete
 
 MSXDevice (MSXDevice &&)=delete
 
MSXDeviceoperator= (const MSXDevice &)=delete
 
MSXDeviceoperator= (MSXDevice &&)=delete
 
virtual ~MSXDevice ()=0
 
const HardwareConfiggetHardwareConfig () const
 Returns the hardwareconfig this device belongs to.
 
void testRemove (std::span< const std::unique_ptr< MSXDevice > > removed) const
 Checks whether this device can be removed (no other device has a reference to it).
 
virtual void reset (EmuTime::param time)
 This method is called on reset.
 
virtual byte readIRQVector ()
 Gets IRQ vector used in IM2.
 
virtual void powerDown (EmuTime::param time)
 This method is called when MSX is powered down.
 
virtual void powerUp (EmuTime::param time)
 This method is called when MSX is powered up.
 
virtual const std::string & getName () const
 Returns a human-readable name for this device.
 
virtual void getNameList (TclObject &result) const
 Returns list of name(s) of this device.
 
void getDeviceInfo (TclObject &result) const
 Get device info.
 
void getVisibleMemRegion (unsigned &base, unsigned &size) const
 Returns the range where this device is visible in memory.
 
virtual byte readIO (word port, EmuTime::param time)
 Read a byte from an IO port at a certain time from this device.
 
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 peekIO (word port, EmuTime::param time) const
 Read a byte from a given IO port.
 
virtual void globalWrite (word address, byte value, EmuTime::param time)
 Global writes.
 
virtual void globalRead (word address, EmuTime::param time)
 Global reads.
 
void invalidateDeviceRWCache ()
 Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is located in.
 
void invalidateDeviceRCache ()
 
void invalidateDeviceWCache ()
 
void invalidateDeviceRWCache (unsigned start, unsigned size)
 
void invalidateDeviceRCache (unsigned start, unsigned size)
 
void invalidateDeviceWCache (unsigned start, unsigned size)
 
void fillDeviceRWCache (unsigned start, unsigned size, byte *rwData)
 Calls MSXCPUInterface::fillXXCache() for the specific (part of) the slot that this device is located in.
 
void fillDeviceRWCache (unsigned start, unsigned size, const byte *rData, byte *wData)
 
void fillDeviceRCache (unsigned start, unsigned size, const byte *rData)
 
void fillDeviceWCache (unsigned start, unsigned size, byte *wData)
 
MSXMotherBoardgetMotherBoard () const
 Get the mother board this device belongs to.
 
const XMLElementgetDeviceConfig () const
 Get the configuration section for this device.
 
const DeviceConfiggetDeviceConfig2 () const
 
const DevicesgetReferences () const
 Get the device references that are specified for this device.
 
EmuTime::param getCurrentTime () const
 
MSXCPUgetCPU () const
 
MSXCPUInterfacegetCPUInterface () const
 
SchedulergetScheduler () const
 
MSXCliCommgetCliComm () const
 
ReactorgetReactor () const
 
CommandControllergetCommandController () const
 
PluggingControllergetPluggingController () const
 
LedStatusgetLedStatus () const
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Static Public Attributes

static constexpr unsigned BANK_SIZE = BANK_SIZE_
 
static constexpr unsigned NUM_BANKS = 0x10000 / BANK_SIZE
 
static constexpr unsigned BANK_MASK = BANK_SIZE - 1
 
- Static Public Attributes inherited from openmsx::MSXDevice
static std::array< byte, 0x10000 > unmappedRead
 
static std::array< byte, 0x10000 > unmappedWrite
 

Protected Member Functions

 RomBlocks (const DeviceConfig &config, Rom &&rom, unsigned debugBankSizeShift=0)
 Constructor.
 
 ~RomBlocks () override
 
void setUnmapped (unsigned region)
 Select 'unmapped' memory for this region.
 
void setBank (unsigned region, const byte *adr, byte block)
 Sets the memory visible for reading in a certain region.
 
void setRom (unsigned region, unsigned block)
 Selects a block of the ROM image for reading in a certain region.
 
void setBlockMask (int mask)
 Sets a mask for the block numbers.
 
void setExtraMemory (std::span< const byte > mem)
 Inform this base class of extra mappable memory block.
 
- Protected Member Functions inherited from openmsx::MSXRom
 MSXRom (const DeviceConfig &config, Rom &&rom)
 
- Protected Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const DeviceConfig &config, std::string_view name)
 Every MSXDevice has a config entry; this constructor gets some device properties from that config entry.
 
 MSXDevice (const DeviceConfig &config)
 
virtual void init ()
 
virtual bool allowUnaligned () const
 By default we don't allow unaligned <mem> specifications in the config file.
 
byte getPrimarySlot () const
 

Protected Attributes

std::array< const byte *, NUM_BANKSbankPtr
 
std::unique_ptr< SRAMsram
 
std::array< byte, NUM_BANKSblockNr
 
- Protected Attributes inherited from openmsx::MSXRom
Rom rom
 
- Protected Attributes inherited from openmsx::MSXDevice
std::string deviceName
 

Additional Inherited Members

- Public Types inherited from openmsx::MSXDevice
using Devices = std::vector< MSXDevice * >
 

Detailed Description

template<unsigned BANK_SIZE_>
class openmsx::RomBlocks< BANK_SIZE_ >

Definition at line 14 of file RomBlocks.hh.

Constructor & Destructor Documentation

◆ RomBlocks()

template<unsigned BANK_SIZE>
openmsx::RomBlocks< BANK_SIZE >::RomBlocks ( const DeviceConfig config,
Rom &&  rom,
unsigned  debugBankSizeShift = 0 
)
protected

Constructor.

Parameters
config
rom
debugBankSizeShiftSometimes the mapper is implemented with a smaller block size than the blocks that get logically switched. For example RomGameMaster2 is implemented as a 4kB mapper but blocks get switched in 8kB chunks (done like this because there is only 4kB SRAM, that needs to be mirrored in a 8kB chunk). This parameter indicates how much bigger the logical blocks are compared to the implementation block size, it's only used to correctly implement the 'romblocks' debuggable.

Definition at line 16 of file RomBlocks.cc.

References openmsx::Rom::addPadding(), openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, openmsx::DeviceConfig::findChild(), openmsx::DeviceConfig::getCliComm(), openmsx::XMLElement::getData(), openmsx::Rom::getOriginalSHA1(), openmsx::RomBlocks< BANK_SIZE_ >::NUM_BANKS, openmsx::CliComm::printWarning(), openmsx::MSXRom::rom, openmsx::RomBlocks< BANK_SIZE_ >::setRom(), openmsx::Rom::size(), and xrange().

◆ ~RomBlocks()

template<unsigned BANK_SIZE>
openmsx::RomBlocks< BANK_SIZE >::~RomBlocks ( )
overrideprotecteddefault

Member Function Documentation

◆ getBaseSizeAlignment()

template<unsigned BANK_SIZE>
unsigned openmsx::RomBlocks< BANK_SIZE >::getBaseSizeAlignment ( ) const
overridevirtual

The 'base' and 'size' attribute values need to be at least aligned to CacheLine::SIZE.

Though some devices may need a stricter alignment. In that case they must override this method.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::RomPlain.

Definition at line 54 of file RomBlocks.cc.

◆ getReadCacheLine()

template<unsigned BANK_SIZE>
const byte * openmsx::RomBlocks< BANK_SIZE >::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::RomFSA1FM2, openmsx::RomHalnote, openmsx::RomKonamiSCC, openmsx::RomMitsubishiMLTS2, openmsx::RomNational, openmsx::RomPanasonic, openmsx::RomPlayBall, and openmsx::RomColecoMegaCart.

Definition at line 72 of file RomBlocks.cc.

Referenced by openmsx::RomAscii16_2::getReadCacheLine(), openmsx::RomAscii8_8::getReadCacheLine(), openmsx::RomFSA1FM2::getReadCacheLine(), openmsx::RomHalnote::getReadCacheLine(), openmsx::RomKonamiSCC::getReadCacheLine(), openmsx::RomMitsubishiMLTS2::getReadCacheLine(), openmsx::RomNational::getReadCacheLine(), openmsx::RomPanasonic::getReadCacheLine(), openmsx::RomPlayBall::getReadCacheLine(), and openmsx::RomColecoMegaCart::getReadCacheLine().

◆ peekMem()

template<unsigned BANK_SIZE>
byte openmsx::RomBlocks< BANK_SIZE >::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::RomFSA1FM2, openmsx::RomKonamiSCC, openmsx::RomMitsubishiMLTS2, openmsx::RomNational, openmsx::RomPanasonic, and openmsx::RomPlayBall.

Definition at line 60 of file RomBlocks.cc.

Referenced by openmsx::RomFSA1FM2::peekMem(), openmsx::RomKonamiSCC::peekMem(), openmsx::RomMitsubishiMLTS2::peekMem(), openmsx::RomNational::peekMem(), openmsx::RomPanasonic::peekMem(), openmsx::RomPlayBall::peekMem(), and openmsx::RomBlocks< BANK_SIZE_ >::readMem().

◆ readMem()

template<unsigned BANK_SIZE>
byte openmsx::RomBlocks< BANK_SIZE >::readMem ( word  address,
EmuTime::param  time 
)
overridevirtual

◆ serialize()

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

Definition at line 121 of file RomBlocks.cc.

References UNREACHABLE, and xrange().

◆ setBank()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setBank ( unsigned  region,
const byte adr,
byte  block 
)
protected

Sets the memory visible for reading in a certain region.

Parameters
regionnumber of 8kB region in Z80 address space (region i starts at Z80 address i * 0x2000)
adrpointer to memory, area must be at least 0x2000 bytes long
blockBlock number, only used for the 'romblock' debuggable, limited to 8-bit.

Definition at line 78 of file RomBlocks.cc.

Referenced by openmsx::RomAscii8_8::writeMem(), openmsx::RomGameMaster2::writeMem(), and openmsx::RomHalnote::writeMem().

◆ setBlockMask()

template<unsigned BANK_SIZE_>
void openmsx::RomBlocks< BANK_SIZE_ >::setBlockMask ( int  mask)
inlineprotected

Sets a mask for the block numbers.

On every call to setRom, the given block number is AND-ed with this mask; if the resulting number if outside of the ROM, unmapped memory is selected. By default the mask is set up to wrap at the end of the ROM image, meaning the entire ROM is reachable and there is no unmapped memory.

Definition at line 74 of file RomBlocks.hh.

Referenced by openmsx::RomKonami::RomKonami().

◆ setExtraMemory()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setExtraMemory ( std::span< const byte mem)
protected

Inform this base class of extra mappable memory block.

This is needed for serialization of mappings in this block. Should only be called from subclass constructor. (e.g. used by RomPanasonic)

Definition at line 98 of file RomBlocks.cc.

Referenced by openmsx::RomPanasonic::RomPanasonic().

◆ setRom()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setRom ( unsigned  region,
unsigned  block 
)
protected

Selects a block of the ROM image for reading in a certain region.

Parameters
regionnumber of 8kB region in Z80 address space (region i starts at Z80 address i * 0x2000)
blocknumber of 8kB block in the ROM image (block i starts at ROM image offset i * 0x2000)

Definition at line 104 of file RomBlocks.cc.

Referenced by openmsx::RomSuperLodeRunner::globalWrite(), openmsx::RomColecoMegaCart::readMem(), openmsx::RomAscii16kB::reset(), openmsx::RomAscii8_8::reset(), openmsx::RomAscii8kB::reset(), openmsx::RomColecoMegaCart::reset(), openmsx::RomGameMaster2::reset(), openmsx::RomGeneric16kB::reset(), openmsx::RomGeneric8kB::reset(), openmsx::RomHalnote::reset(), openmsx::RomHarryFox::reset(), openmsx::RomHolyQuran::reset(), openmsx::RomMatraCompilation::reset(), openmsx::RomMitsubishiMLTS2::reset(), openmsx::RomMSXDOS2::reset(), openmsx::RomMSXWrite::reset(), openmsx::RomMultiRom::reset(), openmsx::RomNational::reset(), openmsx::RomNeo16::reset(), openmsx::RomNeo8::reset(), openmsx::RomNettouYakyuu::reset(), openmsx::RomPadial16kB::reset(), openmsx::RomPadial8kB::reset(), openmsx::RomPanasonic::reset(), openmsx::RomRType::reset(), openmsx::RomSuperLodeRunner::reset(), openmsx::RomSuperSwangi::reset(), openmsx::RomZemina126in1::reset(), openmsx::RomZemina80in1::reset(), openmsx::RomArc::RomArc(), openmsx::RomBlocks< BANK_SIZE_ >::RomBlocks(), openmsx::RomKonamiKeyboardMaster::RomKonamiKeyboardMaster(), openmsx::RomPageNN::RomPageNN(), openmsx::RomPlain::RomPlain(), openmsx::RomPlayBall::RomPlayBall(), openmsx::RomSynthesizer::RomSynthesizer(), openmsx::RomAlAlamiah30in1::writeIO(), openmsx::RomRetroHard31in1::writeIO(), openmsx::RomZemina90in1::writeIO(), openmsx::RomAscii16_2::writeMem(), openmsx::RomAscii16kB::writeMem(), openmsx::RomAscii8_8::writeMem(), openmsx::RomAscii8kB::writeMem(), openmsx::RomCrossBlaim::writeMem(), openmsx::RomGameMaster2::writeMem(), openmsx::RomGeneric16kB::writeMem(), openmsx::RomGeneric8kB::writeMem(), openmsx::RomHalnote::writeMem(), openmsx::RomHarryFox::writeMem(), openmsx::RomHolyQuran::writeMem(), openmsx::RomMatraCompilation::writeMem(), openmsx::RomMitsubishiMLTS2::writeMem(), openmsx::RomMSXDOS2::writeMem(), openmsx::RomMSXWrite::writeMem(), openmsx::RomNational::writeMem(), openmsx::RomNeo16::writeMem(), openmsx::RomNeo8::writeMem(), openmsx::RomNettouYakyuu::writeMem(), openmsx::RomRType::writeMem(), openmsx::RomSuperSwangi::writeMem(), openmsx::RomZemina126in1::writeMem(), openmsx::RomZemina25in1::writeMem(), and openmsx::RomZemina80in1::writeMem().

◆ setUnmapped()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setUnmapped ( unsigned  region)
protected

Member Data Documentation

◆ BANK_MASK

template<unsigned BANK_SIZE_>
constexpr unsigned openmsx::RomBlocks< BANK_SIZE_ >::BANK_MASK = BANK_SIZE - 1
staticconstexpr

◆ BANK_SIZE

template<unsigned BANK_SIZE_>
constexpr unsigned openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE = BANK_SIZE_
staticconstexpr

◆ bankPtr

template<unsigned BANK_SIZE_>
std::array<const byte*, NUM_BANKS> openmsx::RomBlocks< BANK_SIZE_ >::bankPtr
protected

◆ blockNr

template<unsigned BANK_SIZE_>
std::array<byte, NUM_BANKS> openmsx::RomBlocks< BANK_SIZE_ >::blockNr
protected

Definition at line 86 of file RomBlocks.hh.

Referenced by openmsx::RomMatraCompilation::writeMem().

◆ NUM_BANKS

template<unsigned BANK_SIZE_>
constexpr unsigned openmsx::RomBlocks< BANK_SIZE_ >::NUM_BANKS = 0x10000 / BANK_SIZE
staticconstexpr

Definition at line 18 of file RomBlocks.hh.

Referenced by openmsx::RomBlocks< BANK_SIZE_ >::RomBlocks().

◆ sram

template<unsigned BANK_SIZE_>
std::unique_ptr<SRAM> openmsx::RomBlocks< BANK_SIZE_ >::sram
protected

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