summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Olivier Galibert <olivier.galibert@lne.fr>2016-06-16 15:32:05 +0200
committer Olivier Galibert <galibert@pobox.com>2016-06-16 15:37:01 +0200
commitc275ec564355323339fb8aae0d1f00740d184095 (patch)
tree75dd16f37e70b7aad05fa5cbea73ff35fcbb5106 /src
parentdeac5db4dbe86ae7e1e17f6facd66c24eb7429f1 (diff)
eeprom: Not a device_memory_interface [O. Galibert]
Diffstat (limited to 'src')
-rw-r--r--src/devices/machine/eeprom.cpp81
-rw-r--r--src/devices/machine/eeprom.h16
-rw-r--r--src/mame/drivers/deco32.cpp8
-rw-r--r--src/mame/machine/kaneko_calc3.cpp8
-rw-r--r--src/mame/machine/kaneko_toybox.cpp13
5 files changed, 37 insertions, 89 deletions
diff --git a/src/devices/machine/eeprom.cpp b/src/devices/machine/eeprom.cpp
index 43523c18fb1..c7374775042 100644
--- a/src/devices/machine/eeprom.cpp
+++ b/src/devices/machine/eeprom.cpp
@@ -21,21 +21,6 @@
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-static ADDRESS_MAP_START( eeprom_map8, AS_PROGRAM, 8, eeprom_base_device )
- AM_RANGE(0x00000, 0xfffff) AM_RAM
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( eeprom_map16, AS_PROGRAM, 16, eeprom_base_device )
- AM_RANGE(0x00000, 0x7ffff) AM_RAM
-ADDRESS_MAP_END
-
-
-
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
@@ -46,7 +31,6 @@ ADDRESS_MAP_END
eeprom_base_device::eeprom_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file)
: 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),
@@ -85,12 +69,6 @@ void eeprom_base_device::static_set_size(device_t &device, int cells, int cellbi
cells >>= 1;
eeprom.m_address_bits++;
}
-
- // describe our address space
- if (eeprom.m_data_bits == 8)
- eeprom.m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 8, eeprom.m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map8));
- else
- eeprom.m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 16, eeprom.m_address_bits * 2, 0, *ADDRESS_MAP_NAME(eeprom_map16));
}
@@ -231,8 +209,12 @@ void eeprom_base_device::device_validity_check(validity_checker &valid) const
void eeprom_base_device::device_start()
{
+ UINT32 size = (m_data_bits == 8 ? 1 : 2) << m_address_bits;
+ m_data = std::make_unique<UINT8 []>(size);
+
// save states
save_item(NAME(m_completion_time));
+ save_pointer(m_data.get(), "m_data", size);
}
@@ -248,17 +230,6 @@ void eeprom_base_device::device_reset()
//-------------------------------------------------
-// memory_space_config - return a description of
-// any address spaces owned by this device
-//-------------------------------------------------
-
-const address_space_config *eeprom_base_device::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == 0) ? &m_space_config : nullptr;
-}
-
-
-//-------------------------------------------------
// nvram_default - called to initialize NVRAM to
// its default state
//-------------------------------------------------
@@ -271,10 +242,7 @@ void eeprom_base_device::nvram_default()
// initialize to the default value
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)
- space(AS_PROGRAM).write_byte(offs, default_value);
- else
- space(AS_PROGRAM).write_word(offs * 2, default_value);
+ internal_write(offs, default_value);
// handle hard-coded data from the driver
if (m_default_data.u8 != nullptr)
@@ -283,9 +251,9 @@ void eeprom_base_device::nvram_default()
for (offs_t offs = 0; offs < m_default_data_size; offs++)
{
if (m_data_bits == 8)
- space(AS_PROGRAM).write_byte(offs, m_default_data.u8[offs]);
+ internal_write(offs, m_default_data.u8[offs]);
else
- space(AS_PROGRAM).write_word(offs * 2, m_default_data.u16[offs]);
+ internal_write(offs, m_default_data.u16[offs]);
}
}
@@ -300,18 +268,7 @@ void eeprom_base_device::nvram_default()
fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region\n", tag());
osd_printf_verbose("Loading data from EEPROM region '%s'\n", tag());
- if (m_data_bits == 8)
- {
- UINT8 *default_data = m_region->base();
- for (offs_t offs = 0; offs < eeprom_length; 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++)
- space(AS_PROGRAM).write_word(offs * 2, default_data[offs]);
- }
+ memcpy(&m_data[0], m_region->base(), eeprom_bytes);
}
}
@@ -326,10 +283,7 @@ void eeprom_base_device::nvram_read(emu_file &file)
UINT32 eeprom_length = 1 << m_address_bits;
UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8;
- dynamic_buffer buffer(eeprom_bytes);
- file.read(&buffer[0], eeprom_bytes);
- for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- space(AS_PROGRAM).write_byte(offs, buffer[offs]);
+ file.read(&m_data[0], eeprom_bytes);
}
@@ -343,10 +297,7 @@ void eeprom_base_device::nvram_write(emu_file &file)
UINT32 eeprom_length = 1 << m_address_bits;
UINT32 eeprom_bytes = eeprom_length * m_data_bits / 8;
- dynamic_buffer buffer(eeprom_bytes);
- for (offs_t offs = 0; offs < eeprom_bytes; offs++)
- buffer[offs] = space(AS_PROGRAM).read_byte(offs);
- file.write(&buffer[0], eeprom_bytes);
+ file.write(&m_data[0], eeprom_bytes);
}
@@ -357,9 +308,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 space(AS_PROGRAM).read_word(address * 2);
+ return m_data[address * 2] | (m_data[address * 2 + 1] << 8);
else
- return space(AS_PROGRAM).read_byte(address);
+ return m_data[address];
}
@@ -371,7 +322,9 @@ 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)
- space(AS_PROGRAM).write_word(address * 2, data);
- else
- space(AS_PROGRAM).write_byte(address, data);
+ {
+ m_data[address*2] = data;
+ m_data[address*2+1] = data >> 8;
+ } else
+ m_data[address] = data;
}
diff --git a/src/devices/machine/eeprom.h b/src/devices/machine/eeprom.h
index 6eb802641e3..c4cfc73f255 100644
--- a/src/devices/machine/eeprom.h
+++ b/src/devices/machine/eeprom.h
@@ -44,8 +44,7 @@
// ======================> eeprom_base_device
class eeprom_base_device : public device_t,
- public device_memory_interface,
- public device_nvram_interface
+ public device_nvram_interface
{
protected:
// construction/destruction
@@ -79,26 +78,25 @@ public:
// status
bool ready() const { return machine().time() >= m_completion_time; }
+ // internal read/write without side-effects
+ UINT32 internal_read(offs_t address);
+ void internal_write(offs_t address, UINT32 data);
+
protected:
// device-level overrides
virtual void device_validity_check(validity_checker &valid) const override;
virtual void device_start() override;
virtual void device_reset() override;
- // device_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override;
-
// device_nvram_interface overrides
virtual void nvram_default() override;
virtual void nvram_read(emu_file &file) override;
virtual void nvram_write(emu_file &file) override;
- // internal read/write without side-effects
- UINT32 internal_read(offs_t address);
- void internal_write(offs_t address, UINT32 data);
-
optional_memory_region m_region;
+ std::unique_ptr<UINT8 []> m_data;
+
// configuration state
UINT32 m_cells;
UINT8 m_address_bits;
diff --git a/src/mame/drivers/deco32.cpp b/src/mame/drivers/deco32.cpp
index 7459d638f55..176419ce338 100644
--- a/src/mame/drivers/deco32.cpp
+++ b/src/mame/drivers/deco32.cpp
@@ -554,8 +554,6 @@ WRITE32_MEMBER(dragngun_state::eeprom_w)
WRITE32_MEMBER(deco32_state::tattass_control_w)
{
- address_space &eeprom_space = m_eeprom->space();
-
/* Eprom in low byte */
if (mem_mask==0x000000ff) { /* Byte write to low byte only (different from word writing including low byte) */
/*
@@ -604,7 +602,7 @@ WRITE32_MEMBER(deco32_state::tattass_control_w)
int d=m_readBitCount/8;
int m=7-(m_readBitCount%8);
int a=(m_byteAddr+d)%1024;
- int b=eeprom_space.read_byte(a);
+ int b=m_eeprom->internal_read(a);
m_tattass_eprom_bit=(b>>m)&1;
@@ -621,7 +619,7 @@ WRITE32_MEMBER(deco32_state::tattass_control_w)
int b=(m_buffer[24]<<7)|(m_buffer[25]<<6)|(m_buffer[26]<<5)|(m_buffer[27]<<4)
|(m_buffer[28]<<3)|(m_buffer[29]<<2)|(m_buffer[30]<<1)|(m_buffer[31]<<0);
- eeprom_space.write_byte(m_byteAddr, b);
+ m_eeprom->internal_write(m_byteAddr, b);
}
m_lastClock=data&0x20;
return;
@@ -636,7 +634,7 @@ WRITE32_MEMBER(deco32_state::tattass_control_w)
/* Check for read command */
if (m_buffer[0] && m_buffer[1]) {
- m_tattass_eprom_bit=(eeprom_space.read_byte(m_byteAddr)>>7)&1;
+ m_tattass_eprom_bit=(m_eeprom->internal_read(m_byteAddr)>>7)&1;
m_readBitCount=1;
m_pendingCommand=1;
}
diff --git a/src/mame/machine/kaneko_calc3.cpp b/src/mame/machine/kaneko_calc3.cpp
index 10390dae679..79b20362875 100644
--- a/src/mame/machine/kaneko_calc3.cpp
+++ b/src/mame/machine/kaneko_calc3.cpp
@@ -1336,11 +1336,11 @@ int kaneko_calc3_device::decompress_table(int tabnum, UINT8* dstram, int dstoffs
//printf("save to eeprom\n");
{
- address_space &eeprom_space = space.machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
+ eeprom_serial_93cxx_device *eeprom = space.machine().device<eeprom_serial_93cxx_device>(":eeprom");
for (i=0;i<0x80;i++)
{
- eeprom_space.write_byte(i, space.read_byte(m_eeprom_addr+0x200000+i));
+ eeprom->internal_write(i, space.read_byte(m_eeprom_addr+0x200000+i));
}
}
@@ -1672,11 +1672,11 @@ void kaneko_calc3_device::mcu_run()
}
#endif
{
- address_space &eeprom_space = space.machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
+ eeprom_serial_93cxx_device *eeprom = space.machine().device<eeprom_serial_93cxx_device>(":eeprom");
for (i=0;i<0x80;i++)
{
- space.write_byte(m_eeprom_addr+0x200000+i, eeprom_space.read_byte(i));
+ space.write_byte(m_eeprom_addr+0x200000+i, eeprom->internal_read(i));
}
}
diff --git a/src/mame/machine/kaneko_toybox.cpp b/src/mame/machine/kaneko_toybox.cpp
index 73e8927b7ed..ee863a303d7 100644
--- a/src/mame/machine/kaneko_toybox.cpp
+++ b/src/mame/machine/kaneko_toybox.cpp
@@ -178,11 +178,11 @@ void kaneko_toybox_device::mcu_run()
{
UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
- address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
+ eeprom_serial_93cxx_device *eeprom = machine().device<eeprom_serial_93cxx_device>(":eeprom");
for (int i=0;i<0x80;i++)
{
- nvdat[i] = eeprom_space.read_byte(i);
+ nvdat[i] = eeprom->internal_read(i);
}
logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
@@ -192,11 +192,11 @@ void kaneko_toybox_device::mcu_run()
case 0x42: // Write to NVRAM
{
- address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
+ eeprom_serial_93cxx_device *eeprom = machine().device<eeprom_serial_93cxx_device>(":eeprom");
UINT8* nvdat = (UINT8*)&m_mcuram[mcu_offset];
for (int i=0;i<0x80;i++)
{
- eeprom_space.write_byte(i, nvdat[i]);
+ eeprom->internal_write(i, nvdat[i]);
}
logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
@@ -210,12 +210,11 @@ void kaneko_toybox_device::mcu_run()
{
//memcpy(m_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
-
- address_space &eeprom_space = machine().device<eeprom_serial_93cxx_device>(":eeprom")->space();
+ eeprom_serial_93cxx_device *eeprom = machine().device<eeprom_serial_93cxx_device>(":eeprom");
UINT8* nvdat = (UINT8*)&bonkadv_mcu_43[0];
for (int i=0;i<0x80;i++)
{
- eeprom_space.write_byte(i, nvdat[i]);
+ eeprom->internal_write(i, nvdat[i]);
}
logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine().describe_context(), mcu_command, mcu_offset*2);
}