1
/***************************************************************************
5
Generic non-volatile RAM.
7
****************************************************************************
12
Redistribution and use in source and binary forms, with or without
13
modification, are permitted provided that the following conditions are
16
* Redistributions of source code must retain the above copyright
17
notice, this list of conditions and the following disclaimer.
18
* Redistributions in binary form must reproduce the above copyright
19
notice, this list of conditions and the following disclaimer in
20
the documentation and/or other materials provided with the
22
* Neither the name 'MAME' nor the names of its contributors may be
23
used to endorse or promote products derived from this software
24
without specific prior written permission.
26
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
POSSIBILITY OF SUCH DAMAGE.
38
***************************************************************************/
47
//**************************************************************************
48
// INTERFACE CONFIGURATION MACROS
49
//**************************************************************************
51
#define MCFG_NVRAM_ADD_0FILL(_tag) \
52
MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
53
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_0); \
55
#define MCFG_NVRAM_ADD_1FILL(_tag) \
56
MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
57
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_1); \
59
#define MCFG_NVRAM_ADD_RANDOM_FILL(_tag) \
60
MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
61
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_RANDOM); \
63
#define MCFG_NVRAM_ADD_NO_FILL(_tag) \
64
MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
65
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_NONE); \
67
#define MCFG_NVRAM_ADD_CUSTOM(_tag, _class, _method) \
68
MCFG_DEVICE_ADD(_tag, NVRAM, 0) \
69
nvram_device::static_set_custom_handler(*device, nvram_init_delegate(&_class::_method, #_class "::" #_method, (_class *)0)); \
72
#define MCFG_NVRAM_REPLACE_0FILL(_tag) \
73
MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
74
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_0); \
76
#define MCFG_NVRAM_REPLACE_1FILL(_tag) \
77
MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
78
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_ALL_1); \
80
#define MCFG_NVRAM_REPLACE_RANDOM_FILL(_tag) \
81
MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
82
nvram_device::static_set_default_value(*device, nvram_device::DEFAULT_RANDOM); \
84
#define MCFG_NVRAM_REPLACE_CUSTOM(_tag, _class, _method) \
85
MCFG_DEVICE_REPLACE(_tag, NVRAM, 0) \
86
nvram_device::static_set_custom_handler(*device, nvram_init_delegate(&_class::_method, #_class "::" #_method, (_class *)0)); \
90
//**************************************************************************
92
//**************************************************************************
97
// custom initialization for default state
98
typedef delegate<void (nvram_device &, void *, size_t)> nvram_init_delegate;
101
// ======================> nvram_device
103
class nvram_device : public device_t,
104
public device_nvram_interface
117
// construction/destruction
118
nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
120
// inline configuration helpers
121
static void static_set_default_value(device_t &device, default_value value);
122
static void static_set_custom_handler(device_t &device, nvram_init_delegate callback);
125
void set_base(void *base, size_t length) { m_base = base; m_length = length; }
128
// device-level overrides
129
virtual void device_start();
131
// device_nvram_interface overrides
132
virtual void nvram_default();
133
virtual void nvram_read(emu_file &file);
134
virtual void nvram_write(emu_file &file);
137
void determine_final_base();
139
// configuration state
140
default_value m_default_value;
141
nvram_init_delegate m_custom_handler;
149
// device type definition
150
extern const device_type NVRAM;