diff options
Diffstat (limited to 'src/emu/machine/eeprom.h')
-rw-r--r-- | src/emu/machine/eeprom.h | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/src/emu/machine/eeprom.h b/src/emu/machine/eeprom.h index 7ac10097ef5..e90228d7a55 100644 --- a/src/emu/machine/eeprom.h +++ b/src/emu/machine/eeprom.h @@ -49,11 +49,20 @@ //************************************************************************** #define MCFG_EEPROM_SIZE(_cells, _cellbits) \ - base_eeprom_device::static_set_size(*device, _cells, _cellbits); + eeprom_base_device::static_set_size(*device, _cells, _cellbits); #define MCFG_EEPROM_DATA(_data, _size) \ - base_eeprom_device::static_set_default_data(*device, _data, _size); + eeprom_base_device::static_set_default_data(*device, _data, _size); #define MCFG_EEPROM_DEFAULT_VALUE(_value) \ - base_eeprom_device::static_set_default_value(*device, _value); + eeprom_base_device::static_set_default_value(*device, _value); + +#define MCFG_EEPROM_WRITE_TIME(_value) \ + eeprom_base_device::static_set_timing(*device, eeprom_base_device::WRITE_TIME, _value); +#define MCFG_EEPROM_WRITE_ALL_TIME(_value) \ + eeprom_base_device::static_set_timing(*device, eeprom_base_device::WRITE_ALL_TIME, _value); +#define MCFG_EEPROM_ERASE_TIME(_value) \ + eeprom_base_device::static_set_timing(*device, eeprom_base_device::ERASE_TIME, _value); +#define MCFG_EEPROM_ERASE_ALL_TIME(_value) \ + eeprom_base_device::static_set_timing(*device, eeprom_base_device::ERASE_ALL_TIME, _value); @@ -61,27 +70,44 @@ // TYPE DEFINITIONS //************************************************************************** -// ======================> base_eeprom_device +// ======================> eeprom_base_device -class base_eeprom_device : public device_t, +class eeprom_base_device : public device_t, public device_memory_interface, public device_nvram_interface { protected: // construction/destruction - base_eeprom_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file); + 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); public: + // timing constants + enum timing_type + { + WRITE_TIME, // default = 2ms + WRITE_ALL_TIME, // default = 8ms + ERASE_TIME, // default = 1ms + ERASE_ALL_TIME, // default = 8ms + TIMING_COUNT + }; + // inline configuration helpers static void static_set_size(device_t &device, int cells, int cellbits); static void static_set_default_data(device_t &device, const UINT8 *data, UINT32 size); static void static_set_default_data(device_t &device, const UINT16 *data, UINT32 size); static void static_set_default_value(device_t &device, UINT32 value); - - // read/write data - UINT32 read_data(offs_t address); - void write_data(offs_t address, UINT32 data); - + static void static_set_timing(device_t &device, timing_type type, attotime duration); + + // read/write/erase data + UINT32 read(offs_t address); + void write(offs_t address, UINT32 data); + void write_all(UINT32 data); + void erase(offs_t address); + void erase_all(); + + // status + bool ready() const { return machine().time() >= m_completion_time; } + protected: // device-level overrides virtual void device_validity_check(validity_checker &valid) const; @@ -96,6 +122,10 @@ protected: virtual void nvram_read(emu_file &file); virtual void nvram_write(emu_file &file); + // internal read/write without side-effects + UINT32 internal_read(offs_t address); + void internal_write(offs_t address, UINT32 data); + // configuration state UINT32 m_cells; UINT8 m_address_bits; @@ -105,6 +135,10 @@ protected: UINT32 m_default_data_size; UINT32 m_default_value; bool m_default_value_set; + attotime m_operation_time[TIMING_COUNT]; + + // live state + attotime m_completion_time; }; |