summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
commitc0f366c61374775f8f8b7661e84705b568134dea (patch)
tree626e95fa31e6e8480983abbe305c0415ded783d2 /src/devices/machine
parent5933d47ed740fd08c2f66f37fdca4f95e08df3d4 (diff)
Devfind revision phase 1, cleaning out some legacy stuff
- Eliminate the cached device_t::m_region pointer and its region() getter method. Devices that need to bind to a region with the same tag should use optional/required_memory_region or optional/required_region_ptr with DEVICE_SELF as the subtag; this improves error checking. (DEVICE_SELF has been moved to device.h for greater visibility in the source.) - Allow required/optional_region_ptr to specify a specific length which must match that of the region found. - Implement finder_base::finder_tag() getter for diagnostic purposes. - Perform some (not very efficient) validity checks on memory region finders instead of allowing them to automatically pass. - Privatize device_memory_interface::m_addrspace.
Diffstat (limited to 'src/devices/machine')
-rw-r--r--src/devices/machine/at28c16.cpp33
-rw-r--r--src/devices/machine/at28c16.h1
-rw-r--r--src/devices/machine/at45dbxx.cpp7
-rw-r--r--src/devices/machine/ds1204.cpp3
-rw-r--r--src/devices/machine/ds1204.h2
-rw-r--r--src/devices/machine/ds2401.cpp9
-rw-r--r--src/devices/machine/eeprom.cpp27
-rw-r--r--src/devices/machine/eeprom.h2
-rw-r--r--src/devices/machine/er2055.cpp15
-rw-r--r--src/devices/machine/er2055.h2
-rw-r--r--src/devices/machine/gt64xxx.cpp3
-rw-r--r--src/devices/machine/gt64xxx.h2
-rw-r--r--src/devices/machine/i2cmem.cpp17
-rw-r--r--src/devices/machine/i2cmem.h2
-rw-r--r--src/devices/machine/i6300esb.cpp3
-rw-r--r--src/devices/machine/i6300esb.h1
-rw-r--r--src/devices/machine/intelfsh.cpp59
-rw-r--r--src/devices/machine/intelfsh.h10
-rw-r--r--src/devices/machine/k033906.cpp5
-rw-r--r--src/devices/machine/k033906.h7
-rw-r--r--src/devices/machine/k053252.cpp13
-rw-r--r--src/devices/machine/k053252.h5
-rw-r--r--src/devices/machine/mc146818.cpp9
-rw-r--r--src/devices/machine/mc146818.h2
-rw-r--r--src/devices/machine/mos6530n.cpp1
-rw-r--r--src/devices/machine/mos6530n.h3
-rw-r--r--src/devices/machine/nvram.cpp5
-rw-r--r--src/devices/machine/nvram.h1
-rw-r--r--src/devices/machine/pci.cpp3
-rw-r--r--src/devices/machine/pci.h2
-rw-r--r--src/devices/machine/pla.cpp6
-rw-r--r--src/devices/machine/pla.h2
-rw-r--r--src/devices/machine/rp5h01.cpp15
-rw-r--r--src/devices/machine/rp5h01.h5
-rw-r--r--src/devices/machine/timekpr.cpp27
-rw-r--r--src/devices/machine/timekpr.h2
-rw-r--r--src/devices/machine/vrc4373.cpp4
-rw-r--r--src/devices/machine/vrc4373.h1
-rw-r--r--src/devices/machine/x2212.cpp60
-rw-r--r--src/devices/machine/x2212.h11
-rw-r--r--src/devices/machine/x76f041.cpp3
-rw-r--r--src/devices/machine/x76f041.h2
-rw-r--r--src/devices/machine/x76f100.cpp3
-rw-r--r--src/devices/machine/x76f100.h2
44 files changed, 188 insertions, 209 deletions
diff --git a/src/devices/machine/at28c16.cpp b/src/devices/machine/at28c16.cpp
index 9461850043d..f54e28f8bda 100644
--- a/src/devices/machine/at28c16.cpp
+++ b/src/devices/machine/at28c16.cpp
@@ -45,7 +45,8 @@ at28c16_device::at28c16_device( const machine_config &mconfig, const char *tag,
device_nvram_interface(mconfig, *this),
m_a9_12v( 0 ),
m_oe_12v( 0 ),
- m_last_write( -1 )
+ m_last_write( -1 ),
+ m_default_data(*this, DEVICE_SELF, AT28C16_DATA_BYTES)
{
}
@@ -116,26 +117,14 @@ void at28c16_device::nvram_default()
UINT16 default_value = 0xff;
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, default_value );
+ space(AS_PROGRAM).write_byte( offs, default_value );
}
/* populate from a memory region if present */
- if( m_region != nullptr )
+ if (m_default_data.found())
{
- if( m_region->bytes() != AT28C16_DATA_BYTES )
- {
- fatalerror( "at28c16 region '%s' wrong size (expected size = 0x%X)\n", tag(), AT28C16_DATA_BYTES );
- }
-
- if( m_region->bytewidth() != 1 )
- {
- fatalerror( "at28c16 region '%s' needs to be an 8-bit region\n", tag() );
- }
-
- UINT8 *default_data = m_region->base();
-
for( offs_t offs = 0; offs < AT28C16_DATA_BYTES; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
+ space(AS_PROGRAM).write_byte(offs, m_default_data[offs]);
}
}
@@ -153,7 +142,7 @@ void at28c16_device::nvram_read( emu_file &file )
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
+ space(AS_PROGRAM).write_byte( offs, buffer[ offs ] );
}
}
@@ -168,7 +157,7 @@ void at28c16_device::nvram_write( emu_file &file )
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
+ buffer[ offs ] = space(AS_PROGRAM).read_byte( offs );
}
file.write( &buffer[0], AT28C16_TOTAL_BYTES );
@@ -193,7 +182,7 @@ WRITE8_MEMBER( at28c16_device::write )
{
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, 0xff );
+ this->space(AS_PROGRAM).write_byte( offs, 0xff );
}
m_last_write = 0xff;
@@ -208,9 +197,9 @@ WRITE8_MEMBER( at28c16_device::write )
}
// logerror( "%s: AT28C16: write( %04x, %02x )\n", machine.describe_context(), offset, data );
- if( m_last_write < 0 && m_addrspace[ 0 ]->read_byte( offset ) != data )
+ if( m_last_write < 0 && this->space(AS_PROGRAM).read_byte( offset ) != data )
{
- m_addrspace[ 0 ]->write_byte( offset, data );
+ this->space(AS_PROGRAM).write_byte( offset, data );
m_last_write = data;
m_write_timer->adjust( attotime::from_usec( 200 ) );
}
@@ -233,7 +222,7 @@ READ8_MEMBER( at28c16_device::read )
offset += AT28C16_ID_BYTES;
}
- UINT8 data = m_addrspace[ 0 ]->read_byte( offset );
+ UINT8 data = this->space(AS_PROGRAM).read_byte( offset );
// logerror( "%s: AT28C16: read( %04x ) data %02x\n", machine.describe_context(), offset, data );
return data;
}
diff --git a/src/devices/machine/at28c16.h b/src/devices/machine/at28c16.h
index 5cc51cf9078..c33f92785e8 100644
--- a/src/devices/machine/at28c16.h
+++ b/src/devices/machine/at28c16.h
@@ -65,6 +65,7 @@ protected:
int m_a9_12v;
int m_oe_12v;
int m_last_write;
+ optional_region_ptr<UINT8> m_default_data;
};
diff --git a/src/devices/machine/at45dbxx.cpp b/src/devices/machine/at45dbxx.cpp
index e61fcca498a..8b127986679 100644
--- a/src/devices/machine/at45dbxx.cpp
+++ b/src/devices/machine/at45dbxx.cpp
@@ -144,13 +144,14 @@ void at45db041_device::nvram_default()
{
memset(&m_data[0], 0xff, m_data.size());
- if (region() != nullptr)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- UINT32 bytes = region()->bytes();
+ UINT32 bytes = region->bytes();
if (bytes > m_size)
bytes = m_size;
- memcpy(&m_data[0], region()->base(), bytes);
+ memcpy(&m_data[0], region->base(), bytes);
}
}
diff --git a/src/devices/machine/ds1204.cpp b/src/devices/machine/ds1204.cpp
index 72029b2aecc..56d57267ad3 100644
--- a/src/devices/machine/ds1204.cpp
+++ b/src/devices/machine/ds1204.cpp
@@ -32,6 +32,7 @@ const device_type DS1204 = &device_creator<ds1204_device>;
ds1204_device::ds1204_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, DS1204, "DS1204", tag, owner, clock, "ds1204", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_rst( 0 ),
m_clk( 0 ),
m_dqw( 0 ), m_dqr(0), m_state(0), m_bit(0)
@@ -69,7 +70,7 @@ void ds1204_device::nvram_default()
int expected_bytes = sizeof( m_unique_pattern ) + sizeof( m_identification ) + sizeof( m_security_match ) + sizeof( m_secure_memory );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "ds1204(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/ds1204.h b/src/devices/machine/ds1204.h
index 42b68de7538..35e84c7771f 100644
--- a/src/devices/machine/ds1204.h
+++ b/src/devices/machine/ds1204.h
@@ -72,6 +72,8 @@ private:
static const int DQ_HIGH_IMPEDANCE = -1;
+ optional_memory_region m_region;
+
int m_rst;
int m_clk;
int m_dqw;
diff --git a/src/devices/machine/ds2401.cpp b/src/devices/machine/ds2401.cpp
index 7298fa888ee..7c74924404a 100644
--- a/src/devices/machine/ds2401.cpp
+++ b/src/devices/machine/ds2401.cpp
@@ -65,15 +65,16 @@ void ds2401_device::device_reset()
m_rx = true;
m_tx = true;
- if(m_region)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- if(m_region->bytes() == SIZE_DATA)
+ if (region->bytes() == SIZE_DATA)
{
- memcpy(m_data, m_region->base(), SIZE_DATA);
+ memcpy(m_data, region->base(), SIZE_DATA);
return;
}
- logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n", tag(), SIZE_DATA, m_region->bytes());
+ logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n", tag(), SIZE_DATA, region->bytes());
}
else
{
diff --git a/src/devices/machine/eeprom.cpp b/src/devices/machine/eeprom.cpp
index 042e4535918..43523c18fb1 100644
--- a/src/devices/machine/eeprom.cpp
+++ b/src/devices/machine/eeprom.cpp
@@ -48,6 +48,7 @@ eeprom_base_device::eeprom_base_device(const machine_config &mconfig, device_typ
: device_t(mconfig, devtype, name, tag, owner, 0, shortname, file),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cells(0),
m_address_bits(0),
m_data_bits(0),
@@ -271,9 +272,9 @@ void eeprom_base_device::nvram_default()
UINT32 default_value = m_default_value_set ? m_default_value : ~0;
for (offs_t offs = 0; offs < eeprom_length; offs++)
if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, default_value);
+ space(AS_PROGRAM).write_byte(offs, default_value);
else
- m_addrspace[0]->write_word(offs * 2, default_value);
+ space(AS_PROGRAM).write_word(offs * 2, default_value);
// handle hard-coded data from the driver
if (m_default_data.u8 != nullptr)
@@ -282,14 +283,14 @@ void eeprom_base_device::nvram_default()
for (offs_t offs = 0; offs < m_default_data_size; offs++)
{
if (m_data_bits == 8)
- m_addrspace[0]->write_byte(offs, m_default_data.u8[offs]);
+ space(AS_PROGRAM).write_byte(offs, m_default_data.u8[offs]);
else
- m_addrspace[0]->write_word(offs * 2, m_default_data.u16[offs]);
+ space(AS_PROGRAM).write_word(offs * 2, m_default_data.u16[offs]);
}
}
// populate from a memory region if present
- if (m_region != nullptr)
+ if (m_region.found())
{
if (m_region->bytes() != eeprom_bytes)
fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)\n", tag(), eeprom_bytes);
@@ -303,13 +304,13 @@ void eeprom_base_device::nvram_default()
{
UINT8 *default_data = m_region->base();
for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_byte(offs, default_data[offs]);
+ space(AS_PROGRAM).write_byte(offs, default_data[offs]);
}
else
{
UINT16 *default_data = (UINT16 *)(m_region->base());
for (offs_t offs = 0; offs < eeprom_length; offs++)
- m_addrspace[0]->write_word(offs * 2, default_data[offs]);
+ space(AS_PROGRAM).write_word(offs * 2, default_data[offs]);
}
}
}
@@ -328,7 +329,7 @@ void eeprom_base_device::nvram_read(emu_file &file)
dynamic_buffer buffer(eeprom_bytes);
file.read(&buffer[0], eeprom_bytes);
for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- m_addrspace[0]->write_byte(offs, buffer[offs]);
+ space(AS_PROGRAM).write_byte(offs, buffer[offs]);
}
@@ -344,7 +345,7 @@ void eeprom_base_device::nvram_write(emu_file &file)
dynamic_buffer buffer(eeprom_bytes);
for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- buffer[offs] = m_addrspace[0]->read_byte(offs);
+ buffer[offs] = space(AS_PROGRAM).read_byte(offs);
file.write(&buffer[0], eeprom_bytes);
}
@@ -356,9 +357,9 @@ void eeprom_base_device::nvram_write(emu_file &file)
UINT32 eeprom_base_device::internal_read(offs_t address)
{
if (m_data_bits == 16)
- return m_addrspace[0]->read_word(address * 2);
+ return space(AS_PROGRAM).read_word(address * 2);
else
- return m_addrspace[0]->read_byte(address);
+ return space(AS_PROGRAM).read_byte(address);
}
@@ -370,7 +371,7 @@ UINT32 eeprom_base_device::internal_read(offs_t address)
void eeprom_base_device::internal_write(offs_t address, UINT32 data)
{
if (m_data_bits == 16)
- m_addrspace[0]->write_word(address * 2, data);
+ space(AS_PROGRAM).write_word(address * 2, data);
else
- m_addrspace[0]->write_byte(address, data);
+ space(AS_PROGRAM).write_byte(address, data);
}
diff --git a/src/devices/machine/eeprom.h b/src/devices/machine/eeprom.h
index 23ba81cf42f..6eb802641e3 100644
--- a/src/devices/machine/eeprom.h
+++ b/src/devices/machine/eeprom.h
@@ -97,6 +97,8 @@ protected:
UINT32 internal_read(offs_t address);
void internal_write(offs_t address, UINT32 data);
+ optional_memory_region m_region;
+
// configuration state
UINT32 m_cells;
UINT8 m_address_bits;
diff --git a/src/devices/machine/er2055.cpp b/src/devices/machine/er2055.cpp
index 7c395a83b62..c0c5966b5a9 100644
--- a/src/devices/machine/er2055.cpp
+++ b/src/devices/machine/er2055.cpp
@@ -37,6 +37,7 @@ er2055_device::er2055_device(const machine_config &mconfig, const char *tag, dev
: device_t(mconfig, ER2055, "ER2055 EAROM", tag, owner, clock, "er2055", __FILE__),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_space_config("EAROM", ENDIANNESS_BIG, 8, 6, 0, *ADDRESS_MAP_NAME(er2055_map)),
m_control_state(0),
m_address(0),
@@ -79,7 +80,7 @@ void er2055_device::nvram_default()
{
// default to all-0xff
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, 0xff);
+ space(AS_PROGRAM).write_byte(byte, 0xff);
// populate from a memory region if present
if (m_region != nullptr)
@@ -91,7 +92,7 @@ void er2055_device::nvram_default()
UINT8 *default_data = m_region->base();
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, default_data[byte]);
+ space(AS_PROGRAM).write_byte(byte, default_data[byte]);
}
}
@@ -106,7 +107,7 @@ void er2055_device::nvram_read(emu_file &file)
UINT8 buffer[SIZE_DATA];
file.read(buffer, sizeof(buffer));
for (int byte = 0; byte < SIZE_DATA; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
+ space(AS_PROGRAM).write_byte(byte, buffer[byte]);
}
@@ -119,7 +120,7 @@ void er2055_device::nvram_write(emu_file &file)
{
UINT8 buffer[SIZE_DATA];
for (int byte = 0; byte < SIZE_DATA; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
+ buffer[byte] = space(AS_PROGRAM).read_byte(byte);
file.write(buffer, sizeof(buffer));
}
@@ -155,13 +156,13 @@ void er2055_device::set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8
// write mode; erasing is required, so we perform an AND against previous
// data to simulate incorrect behavior if erasing was not done
case 0:
- m_addrspace[0]->write_byte(m_address, m_addrspace[0]->read_byte(m_address) & m_data);
+ space(AS_PROGRAM).write_byte(m_address, space(AS_PROGRAM).read_byte(m_address) & m_data);
//printf("Write %02X = %02X\n", m_address, m_data);
break;
// erase mode
case C2:
- m_addrspace[0]->write_byte(m_address, 0xff);
+ space(AS_PROGRAM).write_byte(m_address, 0xff);
//printf("Erase %02X\n", m_address);
break;
@@ -169,7 +170,7 @@ void er2055_device::set_control(UINT8 cs1, UINT8 cs2, UINT8 c1, UINT8 c2, UINT8
case C1:
if ((oldstate & CK) != 0 && (m_control_state & CK) == 0)
{
- m_data = m_addrspace[0]->read_byte(m_address);
+ m_data = space(AS_PROGRAM).read_byte(m_address);
//printf("Read %02X = %02X\n", m_address, m_data);
}
break;
diff --git a/src/devices/machine/er2055.h b/src/devices/machine/er2055.h
index 900cac15b06..82ad9d2c0e9 100644
--- a/src/devices/machine/er2055.h
+++ b/src/devices/machine/er2055.h
@@ -66,6 +66,8 @@ protected:
static const UINT8 CS1 = 0x08;
static const UINT8 CS2 = 0x10;
+ optional_memory_region m_region;
+
// configuration state
address_space_config m_space_config;
diff --git a/src/devices/machine/gt64xxx.cpp b/src/devices/machine/gt64xxx.cpp
index b11d55160bb..126741f3730 100644
--- a/src/devices/machine/gt64xxx.cpp
+++ b/src/devices/machine/gt64xxx.cpp
@@ -27,7 +27,8 @@ gt64xxx_device::gt64xxx_device(const machine_config &mconfig, const char *tag, d
: pci_host_device(mconfig, GT64XXX, "Galileo GT-64XXX System Controller", tag, owner, clock, "gt64xxx", __FILE__),
m_be(0), m_autoconfig(0), m_irq_num(-1),
m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
- m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32)
+ m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/gt64xxx.h b/src/devices/machine/gt64xxx.h
index e29637bae00..6653c9ca552 100644
--- a/src/devices/machine/gt64xxx.h
+++ b/src/devices/machine/gt64xxx.h
@@ -231,6 +231,8 @@ private:
address_space_config m_mem_config, m_io_config;
+ required_memory_region m_region;
+
DECLARE_ADDRESS_MAP(cpu_map, 32);
void map_cpu_space();
diff --git a/src/devices/machine/i2cmem.cpp b/src/devices/machine/i2cmem.cpp
index d77e12ef4be..ba320d1f5cd 100644
--- a/src/devices/machine/i2cmem.cpp
+++ b/src/devices/machine/i2cmem.cpp
@@ -78,6 +78,7 @@ i2cmem_device::i2cmem_device( const machine_config &mconfig, const char *tag, de
: device_t(mconfig, I2CMEM, "I2C Memory", tag, owner, clock, "i2cmem", __FILE__),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_slave_address( I2CMEM_SLAVE_ADDRESS ),
m_page_size( 0 ),
m_data_size( 0 ),
@@ -175,11 +176,11 @@ void i2cmem_device::nvram_default()
UINT16 default_value = 0xff;
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, default_value );
+ space(AS_PROGRAM).write_byte( offs, default_value );
}
/* populate from a memory region if present */
- if( m_region != nullptr )
+ if (m_region.found())
{
if( m_region->bytes() != i2cmem_bytes )
{
@@ -193,7 +194,7 @@ void i2cmem_device::nvram_default()
UINT8 *default_data = m_region->base();
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
- m_addrspace[ 0 ]->write_byte( offs, default_data[offs] );
+ space(AS_PROGRAM).write_byte( offs, default_data[offs] );
}
}
@@ -212,7 +213,7 @@ void i2cmem_device::nvram_read( emu_file &file )
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
+ space(AS_PROGRAM).write_byte( offs, buffer[ offs ] );
}
}
@@ -228,7 +229,7 @@ void i2cmem_device::nvram_write( emu_file &file )
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
- buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
+ buffer[ offs ] = space(AS_PROGRAM).read_byte( offs );
}
file.write( &buffer[0], i2cmem_bytes );
@@ -375,7 +376,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
for( int i = 0; i < m_page_size; i++ )
{
- m_addrspace[ 0 ]->write_byte( offset + i, m_page[ i ] );
+ space(AS_PROGRAM).write_byte( offset + i, m_page[ i ] );
}
m_page_offset = 0;
@@ -386,7 +387,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
int offset = data_offset();
verboselog( this, 1, "data[ %04x ] <- %02x\n", offset, m_shift );
- m_addrspace[ 0 ]->write_byte( offset, m_shift );
+ space(AS_PROGRAM).write_byte( offset, m_shift );
m_byteaddr++;
}
@@ -419,7 +420,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl )
{
int offset = data_offset();
- m_shift = m_addrspace[ 0 ]->read_byte( offset );
+ m_shift = space(AS_PROGRAM).read_byte( offset );
verboselog( this, 1, "data[ %04x ] -> %02x\n", offset, m_shift );
m_byteaddr++;
}
diff --git a/src/devices/machine/i2cmem.h b/src/devices/machine/i2cmem.h
index d17d6f2f277..a45a51098e3 100644
--- a/src/devices/machine/i2cmem.h
+++ b/src/devices/machine/i2cmem.h
@@ -128,6 +128,8 @@ protected:
int select_device();
int data_offset();
+ optional_memory_region m_region;
+
// device-specific configuration
address_space_config m_space_config;
diff --git a/src/devices/machine/i6300esb.cpp b/src/devices/machine/i6300esb.cpp
index ec7ca934d31..649c437befd 100644
--- a/src/devices/machine/i6300esb.cpp
+++ b/src/devices/machine/i6300esb.cpp
@@ -90,7 +90,8 @@ i6300esb_lpc_device::i6300esb_lpc_device(const machine_config &mconfig, const ch
: pci_device(mconfig, I6300ESB_LPC, "i6300ESB southbridge ISA/LPC bridge", tag, owner, clock, "i6300esb_lpc", __FILE__),
acpi(*this, "acpi"),
rtc (*this, "rtc"),
- pit (*this, "pit")
+ pit (*this, "pit"),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/i6300esb.h b/src/devices/machine/i6300esb.h
index 325e768dbba..e3f216123bc 100644
--- a/src/devices/machine/i6300esb.h
+++ b/src/devices/machine/i6300esb.h
@@ -35,6 +35,7 @@ private:
required_device<lpc_acpi_device> acpi;
required_device<lpc_rtc_device> rtc;
required_device<lpc_pit_device> pit;
+ required_memory_region m_region;
DECLARE_ADDRESS_MAP(internal_io_map, 32);
diff --git a/src/devices/machine/intelfsh.cpp b/src/devices/machine/intelfsh.cpp
index 54f9d4f722f..5f2c0a154ac 100644
--- a/src/devices/machine/intelfsh.cpp
+++ b/src/devices/machine/intelfsh.cpp
@@ -165,6 +165,7 @@ intelfsh_device::intelfsh_device(const machine_config &mconfig, device_type type
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_type(variant),
m_size(0),
m_bits(8),
@@ -543,7 +544,7 @@ const address_space_config *intelfsh_device::memory_space_config(address_spacenu
void intelfsh_device::nvram_default()
{
// region always wins
- if (m_region != nullptr)
+ if (m_region.found())
{
UINT32 bytes = m_region->bytes();
if (bytes > m_size)
@@ -552,19 +553,19 @@ void intelfsh_device::nvram_default()
if (m_bits == 8)
{
for (offs_t offs = 0; offs < bytes; offs++)
- m_addrspace[0]->write_byte(offs, m_region->u8(offs));
+ space(AS_PROGRAM).write_byte(offs, m_region->u8(offs));
}
else
{
for (offs_t offs = 0; offs < bytes; offs += 2)
- m_addrspace[0]->write_word(offs, m_region->u16(offs / 2));
+ space(AS_PROGRAM).write_word(offs, m_region->u16(offs / 2));
}
return;
}
// otherwise, default to 0xff
for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
+ space(AS_PROGRAM).write_byte(offs, 0xff);
}
@@ -578,7 +579,7 @@ void intelfsh_device::nvram_read(emu_file &file)
dynamic_buffer buffer(m_size);
file.read(&buffer[0], m_size);
for (int byte = 0; byte < m_size; byte++)
- m_addrspace[0]->write_byte(byte, buffer[byte]);
+ space(AS_PROGRAM).write_byte(byte, buffer[byte]);
}
@@ -591,7 +592,7 @@ void intelfsh_device::nvram_write(emu_file &file)
{
dynamic_buffer buffer(m_size);
for (int byte = 0; byte < m_size; byte++)
- buffer[byte] = m_addrspace[0]->read_byte(byte);
+ buffer[byte] = space(AS_PROGRAM).read_byte(byte);
file.write(&buffer[0], m_size);
}
@@ -613,12 +614,12 @@ UINT32 intelfsh_device::read_full(UINT32 address)
{
case 8:
{
- data = m_addrspace[0]->read_byte(address);
+ data = space(AS_PROGRAM).read_byte(address);
}
break;
case 16:
{
- data = m_addrspace[0]->read_word(address * 2);
+ data = space(AS_PROGRAM).read_word(address * 2);
}
break;
}
@@ -692,12 +693,12 @@ UINT32 intelfsh_device::read_full(UINT32 address)
{
case 8:
{
- data = m_addrspace[0]->read_byte(address);
+ data = space(AS_PROGRAM).read_byte(address);
}
break;
case 16:
{
- data = m_addrspace[0]->read_word(address * 2);
+ data = space(AS_PROGRAM).read_word(address * 2);
}
break;
}
@@ -921,7 +922,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
{
// chip erase
for (offs_t offs = 0; offs < m_size; offs++)
- m_addrspace[0]->write_byte(offs, 0xff);
+ space(AS_PROGRAM).write_byte(offs, 0xff);
m_status = 1 << 3;
m_flash_mode = FM_ERASEAMD4;
@@ -947,14 +948,14 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
if (m_sector_is_4k)
{
for (offs_t offs = 0; offs < 4 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xfff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xfff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x7ff : ~0xfff);
m_timer->adjust( attotime::from_msec( 125 ) );
}
else if(m_sector_is_16k)
{
for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x3fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
@@ -963,21 +964,21 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
if (address >= (m_size - (16*1024)))
{
for (offs_t offs = 0; offs < 16 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x3fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x3fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x1fff : ~0x3fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
else if (address >= (m_size - (32*1024)))
{
for (offs_t offs = 0; offs < 8 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x1fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x1fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0xfff : ~0x1fff);
m_timer->adjust( attotime::from_msec( 250 ) );
}
else
{
for (offs_t offs = 0; offs < 32 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0x7fff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0x7fff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x3fff : ~0x7fff);
m_timer->adjust( attotime::from_msec( 500 ) );
}
@@ -985,7 +986,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
else
{
for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xffff) + offs, 0xff);
m_erase_sector = address & ((m_bits == 16) ? ~0x7fff : ~0xffff);
m_timer->adjust( attotime::from_seconds( 1 ) );
}
@@ -1003,7 +1004,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
{
case 8:
{
- m_addrspace[0]->write_byte(address, data);
+ space(AS_PROGRAM).write_byte(address, data);
}
break;
default:
@@ -1016,14 +1017,10 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
switch( m_bits )
{
case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
+ space(AS_PROGRAM).write_byte(address, data);
break;
case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
+ space(AS_PROGRAM).write_word(address * 2, data);
break;
default:
logerror( "FM_WRITEPART1 not supported when m_bits == %d\n", m_bits );
@@ -1039,14 +1036,10 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
switch( m_bits )
{
case 8:
- {
- m_addrspace[0]->write_byte(address, data);
- }
+ space(AS_PROGRAM).write_byte(address, data);
break;
case 16:
- {
- m_addrspace[0]->write_word(address * 2, data);
- }
+ space(AS_PROGRAM).write_word(address * 2, data);
break;
default:
logerror( "FM_WRITEPAGEATMEL not supported when m_bits == %d\n", m_bits );
@@ -1068,7 +1061,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the 256 bytes block containing the current address to all 0xffs
UINT32 base = address * ((m_bits == 16) ? 2 : 1);
for (offs_t offs = 0; offs < 256; offs++)
- m_addrspace[0]->write_byte((base & ~0xff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xff) + offs, 0xff);
m_timer->adjust( attotime::from_msec( 4 ) );
}
@@ -1111,7 +1104,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the block containing the current address to all 0xffffs
for (offs_t offs = 0; offs < size / 2; offs += 2)
- m_addrspace[0]->write_word(base | offs, 0xffff);
+ space(AS_PROGRAM).write_word(base | offs, 0xffff);
m_timer->adjust( attotime::from_msec( duration ) );
}
@@ -1120,7 +1113,7 @@ void intelfsh_device::write_full(UINT32 address, UINT32 data)
// clear the 64k block containing the current address to all 0xffs
UINT32 base = address * ((m_bits == 16) ? 2 : 1);
for (offs_t offs = 0; offs < 64 * 1024; offs++)
- m_addrspace[0]->write_byte((base & ~0xffff) + offs, 0xff);
+ space(AS_PROGRAM).write_byte((base & ~0xffff) + offs, 0xff);
m_timer->adjust( attotime::from_seconds( 1 ) );
}
diff --git a/src/devices/machine/intelfsh.h b/src/devices/machine/intelfsh.h
index 437d8c946c2..611c2a01d49 100644
--- a/src/devices/machine/intelfsh.h
+++ b/src/devices/machine/intelfsh.h
@@ -166,6 +166,8 @@ protected:
UINT32 read_full(UINT32 offset);
void write_full(UINT32 offset, UINT32 data);
+ optional_memory_region m_region;
+
// configuration state
address_space_config m_space_config;
UINT32 m_type;
@@ -205,8 +207,8 @@ public:
DECLARE_READ8_MEMBER(read) { return read_full(offset); }
DECLARE_WRITE8_MEMBER(write) { write_full(offset, data); }
- UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); }
- void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); }
+ UINT8 read_raw(offs_t offset) { return space(AS_PROGRAM).read_byte(offset); }
+ void write_raw(offs_t offset, UINT8 data) { space(AS_PROGRAM).write_byte(offset, data); }
};
@@ -225,8 +227,8 @@ public:
DECLARE_READ16_MEMBER(read) { return read_full(offset); }
DECLARE_WRITE16_MEMBER(write) { write_full(offset, data); }
- UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); }
- void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); }
+ UINT16 read_raw(offs_t offset) { return space(AS_PROGRAM).read_word(offset * 2); }
+ void write_raw(offs_t offset, UINT16 data) { space(AS_PROGRAM).write_word(offset * 2, data); }
};
diff --git a/src/devices/machine/k033906.cpp b/src/devices/machine/k033906.cpp
index d9953d2864f..b799ad11cd0 100644
--- a/src/devices/machine/k033906.cpp
+++ b/src/devices/machine/k033906.cpp
@@ -8,7 +8,6 @@
#include "emu.h"
#include "k033906.h"
-#include "video/voodoo.h"
//**************************************************************************
@@ -23,7 +22,7 @@ const device_type K033906 = &device_creator<k033906_device>;
//-------------------------------------------------
k033906_device::k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, K033906, "K033906 PCI bridge", tag, owner, clock, "k033906", __FILE__), m_reg_set(0), m_voodoo_tag(nullptr), m_voodoo(nullptr)
+ : device_t(mconfig, K033906, "K033906 PCI bridge", tag, owner, clock, "k033906", __FILE__), m_reg_set(0), m_voodoo(*this)
{
}
@@ -33,8 +32,6 @@ k033906_device::k033906_device(const machine_config &mconfig, const char *tag, d
void k033906_device::device_start()
{
- m_voodoo = (voodoo_device*)machine().device(m_voodoo_tag);
-
m_reg_set = 0;
save_item(NAME(m_reg));
diff --git a/src/devices/machine/k033906.h b/src/devices/machine/k033906.h
index 438cc5796ab..e493244ce81 100644
--- a/src/devices/machine/k033906.h
+++ b/src/devices/machine/k033906.h
@@ -20,7 +20,7 @@
***************************************************************************/
#define MCFG_K033906_VOODOO(_tag) \
- k033906_device::set_voodoo_tag(*device, _tag);
+ k033906_device::set_voodoo_tag(*device, "^" _tag);
/***************************************************************************
TYPE DEFINITIONS
@@ -35,7 +35,7 @@ public:
// construction/destruction
k033906_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- static void set_voodoo_tag(device_t &device, const char *tag) { downcast<k033906_device &>(device).m_voodoo_tag = tag; }
+ static void set_voodoo_tag(device_t &device, const char *tag) { downcast<k033906_device &>(device).m_voodoo.set_tag(tag); }
DECLARE_READ32_MEMBER( read );
DECLARE_WRITE32_MEMBER( write );
@@ -57,8 +57,7 @@ private:
int m_reg_set; // 1 = access reg / 0 = access ram
- const char *m_voodoo_tag;
- voodoo_device *m_voodoo;
+ required_device<voodoo_device> m_voodoo;
UINT32 m_reg[256];
UINT32 m_ram[32768];
diff --git a/src/devices/machine/k053252.cpp b/src/devices/machine/k053252.cpp
index 45020926ace..2a857d04bf5 100644
--- a/src/devices/machine/k053252.cpp
+++ b/src/devices/machine/k053252.cpp
@@ -76,8 +76,7 @@ k053252_device::k053252_device(const machine_config &mconfig, const char *tag, d
m_offsx(0),
m_offsy(0),
// ugly, needed to work with the rungun etc. video demux board
- m_slave_screen_tag(nullptr),
- m_slave_screen(nullptr)
+ m_slave_screen(*this)
{
}
@@ -103,12 +102,6 @@ void k053252_device::device_start()
save_item(NAME(m_vbp));
save_item(NAME(m_vsw));
save_item(NAME(m_hsw));
-
- if (m_slave_screen_tag != nullptr)
- {
- // find the screen device if explicitly configured
- m_slave_screen = device().siblingdevice<screen_device>(m_slave_screen_tag);
- }
}
//-------------------------------------------------
@@ -181,7 +174,7 @@ void k053252_device::res_change()
m_screen->configure(m_hc, m_vc, visarea, refresh);
- if (m_slave_screen)
+ if (m_slave_screen.found())
m_slave_screen->configure(m_hc, m_vc, visarea, refresh);
#if 0
@@ -262,5 +255,5 @@ WRITE8_MEMBER( k053252_device::write )
void k053252_device::static_set_slave_screen(device_t &device, const char *tag)
{
k053252_device &dev = downcast<k053252_device &>(device);
- dev.m_slave_screen_tag = tag;
+ dev.m_slave_screen.set_tag(tag);
}
diff --git a/src/devices/machine/k053252.h b/src/devices/machine/k053252.h
index a00743789ad..54787a6ee78 100644
--- a/src/devices/machine/k053252.h
+++ b/src/devices/machine/k053252.h
@@ -27,7 +27,7 @@
k053252_device::set_offsets(*device, _offsx, _offsy);
#define MCFG_K053252_SET_SLAVE_SCREEN(_tag) \
- k053252_device::static_set_slave_screen(*device, _tag);
+ k053252_device::static_set_slave_screen(*device, "^" _tag);
class k053252_device : public device_t,
@@ -75,8 +75,7 @@ protected:
int m_offsx;
int m_offsy;
- const char * m_slave_screen_tag;
- screen_device * m_slave_screen;
+ optional_device<screen_device> m_slave_screen;
};
diff --git a/src/devices/machine/mc146818.cpp b/src/devices/machine/mc146818.cpp
index 9166e189952..1b659a610a0 100644
--- a/src/devices/machine/mc146818.cpp
+++ b/src/devices/machine/mc146818.cpp
@@ -33,6 +33,7 @@ const device_type MC146818 = &device_creator<mc146818_device>;
mc146818_device::mc146818_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MC146818, "MC146818 RTC", tag, owner, clock, "mc146818", __FILE__),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_index(0),
m_last_refresh(attotime::zero), m_clock_timer(nullptr), m_periodic_timer(nullptr),
m_write_irq(*this),
@@ -48,6 +49,7 @@ mc146818_device::mc146818_device(const machine_config &mconfig, const char *tag,
mc146818_device::mc146818_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_index(0),
m_last_refresh(attotime::zero), m_clock_timer(nullptr), m_periodic_timer(nullptr),
m_write_irq(*this),
@@ -193,14 +195,15 @@ void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int par
void mc146818_device::nvram_default()
{
// populate from a memory region if present
- if (m_region != nullptr)
+ memory_region *region = memregion(DEVICE_SELF);
+ if (region != nullptr)
{
- UINT32 bytes = m_region->bytes();
+ UINT32 bytes = region->bytes();
if (bytes > data_size())
bytes = data_size();
- memcpy(&m_data[0], m_region->base(), bytes);
+ memcpy(&m_data[0], region->base(), bytes);
}
else
{
diff --git a/src/devices/machine/mc146818.h b/src/devices/machine/mc146818.h
index c1c30eae17e..a7f16300b4b 100644
--- a/src/devices/machine/mc146818.h
+++ b/src/devices/machine/mc146818.h
@@ -167,6 +167,8 @@ private:
int get_year();
void set_year(int year);
+ optional_memory_region m_region;
+
// internal state
UINT8 m_index;
diff --git a/src/devices/machine/mos6530n.cpp b/src/devices/machine/mos6530n.cpp
index 31c15c65e1d..8f43b58405c 100644
--- a/src/devices/machine/mos6530n.cpp
+++ b/src/devices/machine/mos6530n.cpp
@@ -116,6 +116,7 @@ WRITE8_MEMBER(mos6532_t::io_w)
mos6530_base_t::mos6530_base_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
m_ram(*this),
+ m_rom(*this, DEVICE_SELF),
m_irq_cb(*this),
m_in_pa_cb(*this),
m_out_pa_cb(*this),
diff --git a/src/devices/machine/mos6530n.h b/src/devices/machine/mos6530n.h
index 71688040e89..b29fea9af93 100644
--- a/src/devices/machine/mos6530n.h
+++ b/src/devices/machine/mos6530n.h
@@ -268,7 +268,7 @@ protected:
void timer_w(offs_t offset, UINT8 data, bool ie);
UINT8 timer_r(bool ie);
- DECLARE_READ8_MEMBER( rom_r ) { return m_region->base()[offset]; }
+ DECLARE_READ8_MEMBER( rom_r ) { return m_rom[offset]; }
DECLARE_READ8_MEMBER( ram_r ) { return m_ram[offset]; }
DECLARE_WRITE8_MEMBER( ram_w ) { m_ram[offset] = data; }
DECLARE_READ8_MEMBER( pa_data_r );
@@ -287,6 +287,7 @@ protected:
DECLARE_WRITE8_MEMBER( edge_w );
optional_shared_ptr<UINT8> m_ram;
+ optional_region_ptr<UINT8> m_rom;
devcb_write_line m_irq_cb;
devcb_read8 m_in_pa_cb;
diff --git a/src/devices/machine/nvram.cpp b/src/devices/machine/nvram.cpp
index 88d1191187a..3a88345eab3 100644
--- a/src/devices/machine/nvram.cpp
+++ b/src/devices/machine/nvram.cpp
@@ -25,6 +25,7 @@ const device_type NVRAM = &device_creator<nvram_device>;
nvram_device::nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, NVRAM, "NVRAM", tag, owner, clock, "nvram", __FILE__),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_default_value(DEFAULT_ALL_1),
m_base(nullptr),
m_length(0)
@@ -79,7 +80,7 @@ void nvram_device::nvram_default()
determine_final_base();
// region always wins
- if (m_region != nullptr)
+ if (m_region.found())
{
memcpy(m_base, m_region->base(), m_length);
return;
@@ -164,6 +165,6 @@ void nvram_device::determine_final_base()
}
// if we are region-backed for the default, find it now and make sure it's the right size
- if (m_region != nullptr && m_region->bytes() != m_length)
+ if (m_region.found() && m_region->bytes() != m_length)
throw emu_fatalerror("%s",string_format("NVRAM device '%s' has a default region, but it should be 0x%I64uX bytes", tag(), m_length).c_str());
}
diff --git a/src/devices/machine/nvram.h b/src/devices/machine/nvram.h
index ac6b62e7bca..c1a733a3953 100644
--- a/src/devices/machine/nvram.h
+++ b/src/devices/machine/nvram.h
@@ -99,6 +99,7 @@ protected:
void determine_final_base();
// configuration state
+ optional_memory_region m_region;
default_value m_default_value;
nvram_init_delegate m_custom_handler;
diff --git a/src/devices/machine/pci.cpp b/src/devices/machine/pci.cpp
index 5987a423a09..859b44dc939 100644
--- a/src/devices/machine/pci.cpp
+++ b/src/devices/machine/pci.cpp
@@ -59,7 +59,8 @@ DEVICE_ADDRESS_MAP_START(config_map, 32, pci_bridge_device)
ADDRESS_MAP_END
pci_device::pci_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
+ m_region(*this, DEVICE_SELF)
{
main_id = 0xffffffff;
revision = 0x00;
diff --git a/src/devices/machine/pci.h b/src/devices/machine/pci.h
index a88f0a3b7fb..9650efa8132 100644
--- a/src/devices/machine/pci.h
+++ b/src/devices/machine/pci.h
@@ -82,6 +82,8 @@ public:
virtual DECLARE_READ8_MEMBER(capptr_r);
protected:
+ optional_memory_region m_region;
+
enum {
M_MEM = 0,
M_IO = 1,
diff --git a/src/devices/machine/pla.cpp b/src/devices/machine/pla.cpp
index f96a2bd8f60..f2310201771 100644
--- a/src/devices/machine/pla.cpp
+++ b/src/devices/machine/pla.cpp
@@ -19,6 +19,7 @@ const device_type PLA = &device_creator<pla_device>;
pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, PLA, "PLA", tag, owner, clock, "pla", __FILE__),
+ m_region(*this, DEVICE_SELF),
m_format(PLA_FMT_JEDBIN),
m_inputs(0),
m_outputs(0),
@@ -35,7 +36,6 @@ pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t
void pla_device::device_start()
{
- assert(region() != nullptr);
assert(m_terms < MAX_TERMS);
assert(m_inputs < 32 && m_outputs <= 32);
@@ -74,11 +74,11 @@ void pla_device::parse_fusemap()
switch (m_format)
{
case PLA_FMT_JEDBIN:
- result = jedbin_parse(region()->base(), region()->bytes(), &jed);
+ result = jedbin_parse(m_region->base(), m_region->bytes(), &jed);
break;
case PLA_FMT_BERKELEY:
- result = pla_parse(region()->base(), region()->bytes(), &jed);
+ result = pla_parse(m_region->base(), m_region->bytes(), &jed);
break;
}
diff --git a/src/devices/machine/pla.h b/src/devices/machine/pla.h
index 9f14a155ac5..1fdffd023d9 100644
--- a/src/devices/machine/pla.h
+++ b/src/devices/machine/pla.h
@@ -109,6 +109,8 @@ protected:
private:
void parse_fusemap();
+ required_memory_region m_region;
+
int m_format;
UINT32 m_inputs;
diff --git a/src/devices/machine/rp5h01.cpp b/src/devices/machine/rp5h01.cpp
index 4a3138225a7..009757b6acf 100644
--- a/src/devices/machine/rp5h01.cpp
+++ b/src/devices/machine/rp5h01.cpp
@@ -20,7 +20,7 @@
#include "machine/rp5h01.h"
// this is the contents of an unprogrammed PROM
-static const UINT8 initial_data[0x10] =
+UINT8 rp5h01_device::s_initial_data[0x10] =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00
@@ -34,7 +34,7 @@ const device_type RP5H01 = &device_creator<rp5h01_device>;
rp5h01_device::rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, RP5H01, "RP5H01 6/7-bit Counter", tag, owner, clock, "rp5h01", __FILE__)
- , m_rom_ptr(*this, DEVICE_SELF)
+ , m_data(*this, DEVICE_SELF, 0x10)
{
}
@@ -54,15 +54,8 @@ void rp5h01_device::device_config_complete()
void rp5h01_device::device_start()
{
- if (m_rom_ptr == nullptr)
- {
- m_data = initial_data;
- }
- else
- {
- m_data = m_rom_ptr;
- assert(region()->bytes() == 0x10);
- }
+ if (!m_data.found())
+ m_data.set_target(s_initial_data, 0x10);
/* register for state saving */
save_item(NAME(m_counter));
diff --git a/src/devices/machine/rp5h01.h b/src/devices/machine/rp5h01.h
index 0585b5ddf55..c33a80a998b 100644
--- a/src/devices/machine/rp5h01.h
+++ b/src/devices/machine/rp5h01.h
@@ -36,6 +36,8 @@ enum {
class rp5h01_device : public device_t
{
+ static UINT8 s_initial_data[0x10];
+
public:
rp5h01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
@@ -60,8 +62,7 @@ private:
int m_enabled; /* chip enable */
int m_old_reset; /* reset pin state (level-triggered) */
int m_old_clock; /* clock pin state (level-triggered) */
- const UINT8 *m_data;
- optional_region_ptr<UINT8> m_rom_ptr;
+ optional_region_ptr<UINT8> m_data;
};
extern const device_type RP5H01;
diff --git a/src/devices/machine/timekpr.cpp b/src/devices/machine/timekpr.cpp
index 7b602c896c6..06aba0b7221 100644
--- a/src/devices/machine/timekpr.cpp
+++ b/src/devices/machine/timekpr.cpp
@@ -119,15 +119,16 @@ static int counter_from_ram( UINT8 *data, int offset )
// timekeeper_device_config - constructor
//-------------------------------------------------
-timekeeper_device::timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
+timekeeper_device::timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source)
, device_nvram_interface(mconfig, *this)
- , m_default_data(*this, DEVICE_SELF)
+ , m_default_data(*this, DEVICE_SELF, size)
+ , m_size(size)
{
}
m48t02_device::m48t02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T02, "M48T02 Timekeeper", tag, owner, clock, "m48t02", __FILE__)
+ : timekeeper_device(mconfig, M48T02, "M48T02 Timekeeper", tag, owner, clock, "m48t02", __FILE__, 0x800)
{
m_offset_control = 0x7f8;
m_offset_seconds = 0x7f9;
@@ -139,11 +140,10 @@ m48t02_device::m48t02_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7ff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x800;
}
m48t35_device::m48t35_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T35, "M48T35 Timekeeper", tag, owner, clock, "m48t35", __FILE__)
+ : timekeeper_device(mconfig, M48T35, "M48T35 Timekeeper", tag, owner, clock, "m48t35", __FILE__, 0x8000)
{
m_offset_control = 0x7ff8;
m_offset_seconds = 0x7ff9;
@@ -155,11 +155,10 @@ m48t35_device::m48t35_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7fff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x8000;
}
m48t37_device::m48t37_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T37, "M48T37 Timekeeper", tag, owner, clock, "m48t37", __FILE__)
+ : timekeeper_device(mconfig, M48T37, "M48T37 Timekeeper", tag, owner, clock, "m48t37", __FILE__, 0x8000)
{
m_offset_control = 0x7ff8;
m_offset_seconds = 0x7ff9;
@@ -171,11 +170,10 @@ m48t37_device::m48t37_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x7fff;
m_offset_century = 0x7ff1;
m_offset_flags = 0x7ff0;
- m_size = 0x8000;
}
m48t58_device::m48t58_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, M48T58, "M48T58 Timekeeper", tag, owner, clock, "m48t58", __FILE__)
+ : timekeeper_device(mconfig, M48T58, "M48T58 Timekeeper", tag, owner, clock, "m48t58", __FILE__, 0x2000)
{
m_offset_control = 0x1ff8;
m_offset_seconds = 0x1ff9;
@@ -187,11 +185,10 @@ m48t58_device::m48t58_device(const machine_config &mconfig, const char *tag, dev
m_offset_year = 0x1fff;
m_offset_century = -1;
m_offset_flags = -1;
- m_size = 0x2000;
}
mk48t08_device::mk48t08_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : timekeeper_device(mconfig, MK48T08, "MK48T08 Timekeeper", tag, owner, clock, "m48t08", __FILE__)
+ : timekeeper_device(mconfig, MK48T08, "MK48T08 Timekeeper", tag, owner, clock, "m48t08", __FILE__, 0x2000)
{
m_offset_control = 0x1ff8;
m_offset_seconds = 0x1ff9;
@@ -203,7 +200,6 @@ mk48t08_device::mk48t08_device(const machine_config &mconfig, const char *tag, d
m_offset_year = 0x1fff;
m_offset_century = 0x1ff1;
m_offset_flags = 0x1ff0;
- m_size = 0x2000;
}
@@ -231,11 +227,6 @@ void timekeeper_device::device_start()
m_century = make_bcd( systime.local_time.year / 100 );
m_data.resize( m_size );
- if (m_default_data)
- {
- assert(m_default_data.bytes() == m_size);
- }
-
save_item( NAME(m_control) );
save_item( NAME(m_seconds) );
save_item( NAME(m_minutes) );
@@ -398,7 +389,7 @@ READ8_MEMBER( timekeeper_device::read )
void timekeeper_device::nvram_default()
{
- if( m_default_data != nullptr )
+ if (m_default_data.found())
{
memcpy( &m_data[0], m_default_data, m_size );
}
diff --git a/src/devices/machine/timekpr.h b/src/devices/machine/timekpr.h
index 84c969b076d..3d96d2f394a 100644
--- a/src/devices/machine/timekpr.h
+++ b/src/devices/machine/timekpr.h
@@ -55,7 +55,7 @@ class timekeeper_device : public device_t,
{
protected:
// construction/destruction
- timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+ timekeeper_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size);
public:
DECLARE_WRITE8_MEMBER( write );
diff --git a/src/devices/machine/vrc4373.cpp b/src/devices/machine/vrc4373.cpp
index c6797193c49..50257a2d076 100644
--- a/src/devices/machine/vrc4373.cpp
+++ b/src/devices/machine/vrc4373.cpp
@@ -31,8 +31,8 @@ ADDRESS_MAP_END
vrc4373_device::vrc4373_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: pci_host_device(mconfig, VRC4373, "NEC VRC4373 System Controller", tag, owner, clock, "vrc4373", __FILE__), m_cpu_space(nullptr), m_cpu(nullptr), cpu_tag(nullptr),
m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32),
- m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32), m_ram_size(0), m_ram_base(0), m_simm_size(0), m_simm_base(0), m_pci1_laddr(0), m_pci2_laddr(0), m_pci_io_laddr(0), m_target1_laddr(0), m_target2_laddr(0)
-
+ m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32), m_ram_size(0), m_ram_base(0), m_simm_size(0), m_simm_base(0), m_pci1_laddr(0), m_pci2_laddr(0), m_pci_io_laddr(0), m_target1_laddr(0), m_target2_laddr(0),
+ m_region(*this, DEVICE_SELF)
{
}
diff --git a/src/devices/machine/vrc4373.h b/src/devices/machine/vrc4373.h
index bbd740b8084..9c9e65588a8 100644
--- a/src/devices/machine/vrc4373.h
+++ b/src/devices/machine/vrc4373.h
@@ -124,6 +124,7 @@ private:
UINT32 m_pci1_laddr, m_pci2_laddr, m_pci_io_laddr;
UINT32 m_target1_laddr, m_target2_laddr;
+ required_memory_region m_region;
};
diff --git a/src/devices/machine/x2212.cpp b/src/devices/machine/x2212.cpp
index cb6fc2b57e9..63d28a322e4 100644
--- a/src/devices/machine/x2212.cpp
+++ b/src/devices/machine/x2212.cpp
@@ -46,11 +46,13 @@ x2212_device::x2212_device(const machine_config &mconfig, const char *tag, devic
m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
m_store(false),
- m_array_recall(false)
+ m_array_recall(false),
+ m_size_data(0x100),
+ m_default_data(*this, DEVICE_SELF, 0x100)
{
}
-x2212_device::x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
+x2212_device::x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size_data)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_memory_interface(mconfig, *this),
device_nvram_interface(mconfig, *this),
@@ -58,7 +60,9 @@ x2212_device::x2212_device(const machine_config &mconfig, device_type type, cons
m_sram_space_config("SRAM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_sram_map)),
m_e2prom_space_config("E2PROM", ENDIANNESS_BIG, 8, 8, 0, *ADDRESS_MAP_NAME(x2212_e2prom_map)),
m_store(false),
- m_array_recall(false)
+ m_array_recall(false),
+ m_size_data(size_data),
+ m_default_data(*this, DEVICE_SELF, size_data)
{
}
@@ -81,22 +85,8 @@ void x2212_device::device_start()
{
save_item(NAME(m_store));
save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x100;
-}
-
-void x2210_device::device_start()
-{
- save_item(NAME(m_store));
- save_item(NAME(m_array_recall));
-
- m_sram = m_addrspace[0];
- m_e2prom = m_addrspace[1];
-
- SIZE_DATA = 0x40;
+ m_sram = &space(AS_0);
+ m_e2prom = &space(AS_1);
}
@@ -119,23 +109,17 @@ const address_space_config *x2212_device::memory_space_config(address_spacenum s
void x2212_device::nvram_default()
{
// default to all-0xff
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
{
m_sram->write_byte(byte, 0xff);
m_e2prom->write_byte(byte, 0xff);
}
// populate from a memory region if present
- if (m_region != nullptr)
+ if (m_default_data.found())
{
- if (m_region->bytes() != SIZE_DATA)
- fatalerror("x2212 region '%s' wrong size (expected size = 0x100)\n", tag());
- if (m_region->bytewidth() != 1)
- fatalerror("x2212 region '%s' needs to be an 8-bit region\n", tag());
-
- UINT8 *default_data = m_region->base();
- for (int byte = 0; byte < SIZE_DATA; byte++)
- m_e2prom->write_byte(byte, default_data[byte]);
+ for (int byte = 0; byte < m_size_data; byte++)
+ m_e2prom->write_byte(byte, m_default_data[byte]);
}
}
@@ -147,9 +131,9 @@ void x2212_device::nvram_default()
void x2212_device::nvram_read(emu_file &file)
{
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- file.read(buffer, SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ UINT8 *buffer = (UINT8 *) alloca(m_size_data);
+ file.read(buffer, m_size_data);
+ for (int byte = 0; byte < m_size_data; byte++)
{
m_sram->write_byte(byte, 0xff);
m_e2prom->write_byte(byte, buffer[byte]);
@@ -168,10 +152,10 @@ void x2212_device::nvram_write(emu_file &file)
if (m_auto_save)
store();
- UINT8 *buffer = (UINT8 *) alloca(SIZE_DATA);
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ UINT8 *buffer = (UINT8 *) alloca(m_size_data);
+ for (int byte = 0; byte < m_size_data; byte++)
buffer[byte] = m_e2prom->read_byte(byte);
- file.write(buffer, SIZE_DATA);
+ file.write(buffer, m_size_data);
}
@@ -187,7 +171,7 @@ void x2212_device::nvram_write(emu_file &file)
void x2212_device::store()
{
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
m_e2prom->write_byte(byte, m_sram->read_byte(byte));
}
@@ -199,7 +183,7 @@ void x2212_device::store()
void x2212_device::recall()
{
- for (int byte = 0; byte < SIZE_DATA; byte++)
+ for (int byte = 0; byte < m_size_data; byte++)
m_sram->write_byte(byte, m_e2prom->read_byte(byte));
}
@@ -256,6 +240,6 @@ WRITE_LINE_MEMBER( x2212_device::recall )
x2210_device::x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : x2212_device(mconfig, X2210, "X2210", tag, owner, clock, "x2210", __FILE__)
+ : x2212_device(mconfig, X2210, "X2210", tag, owner, clock, "x2210", __FILE__, 0x40)
{
}
diff --git a/src/devices/machine/x2212.h b/src/devices/machine/x2212.h
index 161cf399457..ffcc1dcf84b 100644
--- a/src/devices/machine/x2212.h
+++ b/src/devices/machine/x2212.h
@@ -49,7 +49,7 @@ class x2212_device : public device_t,
public:
// construction/destruction
x2212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+ x2212_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int size_data);
// inline configuration helpers
static void static_set_auto_save(device_t &device);
@@ -77,8 +77,6 @@ protected:
virtual void nvram_read(emu_file &file) override;
virtual void nvram_write(emu_file &file) override;
- int SIZE_DATA;
-
// configuration state
bool m_auto_save;
@@ -92,16 +90,15 @@ protected:
bool m_store;
bool m_array_recall;
+
+ int m_size_data;
+ optional_region_ptr<UINT8> m_default_data;
};
class x2210_device : public x2212_device
{
public:
x2210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
-protected:
- // device-level overrides
- virtual void device_start() override;
};
diff --git a/src/devices/machine/x76f041.cpp b/src/devices/machine/x76f041.cpp
index 21dea0ae141..481434abc77 100644
--- a/src/devices/machine/x76f041.cpp
+++ b/src/devices/machine/x76f041.cpp
@@ -37,6 +37,7 @@ const device_type X76F041 = &device_creator<x76f041_device>;
x76f041_device::x76f041_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, X76F041, "X76F041 Flash", tag, owner, clock, "x76f041", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cs( 0 ),
m_rst( 0 ),
m_scl( 0 ),
@@ -498,7 +499,7 @@ void x76f041_device::nvram_default()
int expected_bytes = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) +
sizeof( m_configuration_password ) + sizeof( m_configuration_registers ) + sizeof( m_data );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "x76f041(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/x76f041.h b/src/devices/machine/x76f041.h
index 228540969eb..5c453aad6ee 100644
--- a/src/devices/machine/x76f041.h
+++ b/src/devices/machine/x76f041.h
@@ -99,6 +99,8 @@ private:
STATE_WRITE_CONFIGURATION_REGISTERS
};
+ optional_memory_region m_region;
+
// internal state
int m_cs;
int m_rst;
diff --git a/src/devices/machine/x76f100.cpp b/src/devices/machine/x76f100.cpp
index 830a0e51448..f254eed7ffc 100644
--- a/src/devices/machine/x76f100.cpp
+++ b/src/devices/machine/x76f100.cpp
@@ -35,6 +35,7 @@ const device_type X76F100 = &device_creator<x76f100_device>;
x76f100_device::x76f100_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, X76F100, "X76F100 Flash", tag, owner, clock, "x76f100", __FILE__ ),
device_nvram_interface(mconfig, *this),
+ m_region(*this, DEVICE_SELF),
m_cs( 0 ),
m_rst( 0 ),
m_scl( 0 ),
@@ -391,7 +392,7 @@ void x76f100_device::nvram_default()
int expected_size = sizeof( m_response_to_reset ) + sizeof( m_write_password ) + sizeof( m_read_password ) + sizeof( m_data );
- if( !m_region )
+ if (!m_region.found())
{
logerror( "x76f100(%s) region not found\n", tag() );
}
diff --git a/src/devices/machine/x76f100.h b/src/devices/machine/x76f100.h
index 287a4a17a56..5ce4b5241c9 100644
--- a/src/devices/machine/x76f100.h
+++ b/src/devices/machine/x76f100.h
@@ -66,6 +66,8 @@ private:
STATE_WRITE_DATA
};
+ optional_memory_region m_region;
+
// internal state
int m_cs;
int m_rst;