src/emu/machine/intelfsh.c
| r9152 | r9153 | |
| 14 | 14 | #include "emu.h" |
| 15 | 15 | #include "intelfsh.h" |
| 16 | 16 | |
| 17 | |
| 18 | //************************************************************************** |
| 19 | // CONSTANTS |
| 20 | //************************************************************************** |
| 21 | |
| 17 | 22 | enum |
| 18 | 23 | { |
| 19 | 24 | FM_NORMAL, // normal read/write |
| r9152 | r9153 | |
| 32 | 37 | FM_BYTEPROGRAM, |
| 33 | 38 | }; |
| 34 | 39 | |
| 35 | | struct flash_chip |
| 36 | | { |
| 37 | | int type; |
| 38 | | int size; |
| 39 | | int bits; |
| 40 | | int status; |
| 41 | | int erase_sector; |
| 42 | | int sector_is_4k; |
| 43 | | INT32 flash_mode; |
| 44 | | INT32 flash_master_lock; |
| 45 | | int device_id; |
| 46 | | int maker_id; |
| 47 | | emu_timer *timer; |
| 48 | | void *flash_memory; |
| 49 | | }; |
| 50 | 40 | |
| 51 | | static struct flash_chip chips[FLASH_CHIPS_MAX]; |
| 52 | 41 | |
| 53 | | static TIMER_CALLBACK( erase_finished ) |
| 54 | | { |
| 55 | | struct flash_chip *c = (struct flash_chip *)ptr; |
| 42 | //************************************************************************** |
| 43 | // DEVICE DEFINITIONS |
| 44 | //************************************************************************** |
| 56 | 45 | |
| 57 | | switch( c->flash_mode ) |
| 58 | | { |
| 59 | | case FM_READSTATUS: |
| 60 | | c->status = 0x80; |
| 61 | | break; |
| 46 | // 8-bit variants |
| 47 | DEFINE_TRIVIAL_DERIVED_DEVICE(intel_28f016s5_device_config, intelfsh8_device_config, intel_28f016s5_device, intelfsh8_device, "Sharp LH28F400 Flash", intelfsh_device_config::FLASH_SHARP_LH28F400) |
| 48 | DEFINE_TRIVIAL_DERIVED_DEVICE(fujitsu_29f016a_device_config, intelfsh8_device_config, fujitsu_29f016a_device, intelfsh8_device, "Fujitsu 29F016A Flash", intelfsh_device_config::FLASH_FUJITSU_29F016A) |
| 49 | DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f016s_device_config, intelfsh8_device_config, sharp_lh28f016s_device, intelfsh8_device, "Sharp LH28F016S Flash", intelfsh_device_config::FLASH_SHARP_LH28F016S) |
| 50 | DEFINE_TRIVIAL_DERIVED_DEVICE(intel_e28f008sa_device_config, intelfsh8_device_config, intel_e28f008sa_device, intelfsh8_device, "Intel E28F008SA Flash", intelfsh_device_config::FLASH_INTEL_E28F008SA) |
| 51 | DEFINE_TRIVIAL_DERIVED_DEVICE(macronix_29l001mc_device_config, intelfsh8_device_config, macronix_29l001mc_device, intelfsh8_device, "Macronix 29L001MC Flash", intelfsh_device_config::FLASH_MACRONIX_29L001MC) |
| 52 | DEFINE_TRIVIAL_DERIVED_DEVICE(panasonic_mn63f805mnp_device_config, intelfsh8_device_config, panasonic_mn63f805mnp_device, intelfsh8_device, "Panasonic MN63F805MNP Flash", intelfsh_device_config::FLASH_PANASONIC_MN63F805MNP) |
| 53 | DEFINE_TRIVIAL_DERIVED_DEVICE(sanyo_le26fv10n1ts_device_config, intelfsh8_device_config, sanyo_le26fv10n1ts_device, intelfsh8_device, "Sanyo LE26FV10N1TS Flash", intelfsh_device_config::FLASH_SANYO_LE26FV10N1TS) |
| 62 | 54 | |
| 63 | | case FM_ERASEAMD4: |
| 64 | | c->flash_mode = FM_NORMAL; |
| 65 | | break; |
| 66 | | } |
| 67 | | } |
| 55 | const device_type INTEL_28F016S5 = intel_28f016s5_device_config::static_alloc_device_config; |
| 56 | const device_type SHARP_LH28F016S = sharp_lh28f016s_device_config::static_alloc_device_config; |
| 57 | const device_type FUJITSU_29F016A = fujitsu_29f016a_device_config::static_alloc_device_config; |
| 58 | const device_type INTEL_E28F008SA = intel_e28f008sa_device_config::static_alloc_device_config; |
| 59 | const device_type MACRONIX_29L001MC = macronix_29l001mc_device_config::static_alloc_device_config; |
| 60 | const device_type PANASONIC_MN63F805MNP = panasonic_mn63f805mnp_device_config::static_alloc_device_config; |
| 61 | const device_type SANYO_LE26FV10N1TS = sanyo_le26fv10n1ts_device_config::static_alloc_device_config; |
| 68 | 62 | |
| 69 | | void* intelflash_getmemptr(int chip) |
| 70 | | { |
| 71 | | struct flash_chip *c; |
| 72 | | if( chip >= FLASH_CHIPS_MAX ) |
| 73 | | { |
| 74 | | logerror( "intelflash_init: invalid chip %d\n", chip ); |
| 75 | | return 0; |
| 76 | | } |
| 77 | | c = &chips[ chip ]; |
| 78 | 63 | |
| 79 | | return c->flash_memory; |
| 80 | | } |
| 64 | // 16-bit variants |
| 65 | DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f400_device_config, intelfsh16_device_config, sharp_lh28f400_device, intelfsh16_device, "Sharp LH28F400 Flash", intelfsh_device_config::FLASH_SHARP_LH28F400) |
| 66 | DEFINE_TRIVIAL_DERIVED_DEVICE(intel_te28f160_device_config, intelfsh16_device_config, intel_te28f160_device, intelfsh16_device, "Intel TE28F160 Flash", intelfsh_device_config::FLASH_INTEL_TE28F160) |
| 67 | DEFINE_TRIVIAL_DERIVED_DEVICE(intel_e28f400_device_config, intelfsh16_device_config, intel_e28f400_device, intelfsh16_device, "Intel E28F400 Flash", intelfsh_device_config::FLASH_INTEL_E28F400) |
| 68 | DEFINE_TRIVIAL_DERIVED_DEVICE(sharp_unk128mbit_device_config, intelfsh16_device_config, sharp_unk128mbit_device, intelfsh16_device, "Sharp Unknown 128Mb Flash", intelfsh_device_config::FLASH_SHARP_UNK128MBIT) |
| 81 | 69 | |
| 82 | | void intelflash_init(running_machine *machine, int chip, int type, void *data) |
| 70 | const device_type SHARP_LH28F400 = sharp_lh28f400_device_config::static_alloc_device_config; |
| 71 | const device_type INTEL_TE28F160 = intel_te28f160_device_config::static_alloc_device_config; |
| 72 | const device_type INTEL_E28F400 = intel_e28f400_device_config::static_alloc_device_config; |
| 73 | const device_type SHARP_UNK128MBIT = sharp_unk128mbit_device_config::static_alloc_device_config; |
| 74 | |
| 75 | |
| 76 | |
| 77 | //************************************************************************** |
| 78 | // GLOBAL VARIABLES |
| 79 | //************************************************************************** |
| 80 | |
| 81 | static ADDRESS_MAP_START( memory_map8_512Kb, ADDRESS_SPACE_PROGRAM, 8 ) |
| 82 | AM_RANGE(0x00000, 0x00ffff) AM_RAM |
| 83 | ADDRESS_MAP_END |
| 84 | |
| 85 | static ADDRESS_MAP_START( memory_map8_1Mb, ADDRESS_SPACE_PROGRAM, 8 ) |
| 86 | AM_RANGE(0x00000, 0x01ffff) AM_RAM |
| 87 | ADDRESS_MAP_END |
| 88 | |
| 89 | static ADDRESS_MAP_START( memory_map8_8Mb, ADDRESS_SPACE_PROGRAM, 8 ) |
| 90 | AM_RANGE(0x00000, 0x0fffff) AM_RAM |
| 91 | ADDRESS_MAP_END |
| 92 | |
| 93 | static ADDRESS_MAP_START( memory_map8_16Mb, ADDRESS_SPACE_PROGRAM, 8 ) |
| 94 | AM_RANGE(0x00000, 0x1fffff) AM_RAM |
| 95 | ADDRESS_MAP_END |
| 96 | |
| 97 | |
| 98 | static ADDRESS_MAP_START( memory_map16_4Mb, ADDRESS_SPACE_PROGRAM, 16 ) |
| 99 | AM_RANGE(0x00000, 0x07ffff) AM_RAM |
| 100 | ADDRESS_MAP_END |
| 101 | |
| 102 | static ADDRESS_MAP_START( memory_map16_16Mb, ADDRESS_SPACE_PROGRAM, 16 ) |
| 103 | AM_RANGE(0x00000, 0x1fffff) AM_RAM |
| 104 | ADDRESS_MAP_END |
| 105 | |
| 106 | static ADDRESS_MAP_START( memory_map16_64Mb, ADDRESS_SPACE_PROGRAM, 16 ) |
| 107 | AM_RANGE(0x00000, 0x7fffff) AM_RAM |
| 108 | ADDRESS_MAP_END |
| 109 | |
| 110 | |
| 111 | |
| 112 | //************************************************************************** |
| 113 | // DEVICE CONFIGURATION |
| 114 | //************************************************************************** |
| 115 | |
| 116 | //------------------------------------------------- |
| 117 | // intelfsh_device_config - constructor |
| 118 | //------------------------------------------------- |
| 119 | |
| 120 | intelfsh_device_config::intelfsh_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant) |
| 121 | : device_config(mconfig, type, name, tag, owner, clock), |
| 122 | device_config_memory_interface(mconfig, *this), |
| 123 | device_config_nvram_interface(mconfig, *this), |
| 124 | m_type(variant), |
| 125 | m_size(0), |
| 126 | m_bits(8), |
| 127 | m_device_id(0), |
| 128 | m_maker_id(0), |
| 129 | m_sector_is_4k(false) |
| 83 | 130 | { |
| 84 | | struct flash_chip *c; |
| 85 | | if( chip >= FLASH_CHIPS_MAX ) |
| 86 | | { |
| 87 | | logerror( "intelflash_init: invalid chip %d\n", chip ); |
| 88 | | return; |
| 89 | | } |
| 90 | | c = &chips[ chip ]; |
| 131 | address_map_constructor map = NULL; |
| 91 | 132 | |
| 92 | | c->type = type; |
| 93 | | c->sector_is_4k = 0; |
| 94 | | switch( c->type ) |
| 133 | switch( variant ) |
| 95 | 134 | { |
| 96 | 135 | case FLASH_INTEL_28F016S5: |
| 97 | 136 | case FLASH_SHARP_LH28F016S: |
| 98 | | c->bits = 8; |
| 99 | | c->size = 0x200000; |
| 100 | | c->maker_id = 0x89; |
| 101 | | c->device_id = 0xaa; |
| 137 | m_bits = 8; |
| 138 | m_size = 0x200000; |
| 139 | m_maker_id = 0x89; |
| 140 | m_device_id = 0xaa; |
| 141 | map = ADDRESS_MAP_NAME( memory_map8_16Mb ); |
| 102 | 142 | break; |
| 103 | 143 | case FLASH_SHARP_LH28F400: |
| 104 | 144 | case FLASH_INTEL_E28F400: |
| 105 | | c->bits = 16; |
| 106 | | c->size = 0x80000; |
| 107 | | c->maker_id = 0xb0; |
| 108 | | c->device_id = 0xed; |
| 145 | m_bits = 16; |
| 146 | m_size = 0x80000; |
| 147 | m_maker_id = 0xb0; |
| 148 | m_device_id = 0xed; |
| 149 | map = ADDRESS_MAP_NAME( memory_map16_4Mb ); |
| 109 | 150 | break; |
| 110 | 151 | case FLASH_FUJITSU_29F016A: |
| 111 | | c->bits = 8; |
| 112 | | c->size = 0x200000; |
| 113 | | c->maker_id = 0x04; |
| 114 | | c->device_id = 0xad; |
| 152 | m_bits = 8; |
| 153 | m_size = 0x200000; |
| 154 | m_maker_id = 0x04; |
| 155 | m_device_id = 0xad; |
| 156 | map = ADDRESS_MAP_NAME( memory_map8_16Mb ); |
| 115 | 157 | break; |
| 116 | 158 | case FLASH_INTEL_E28F008SA: |
| 117 | | c->bits = 8; |
| 118 | | c->size = 0x100000; |
| 119 | | c->maker_id = 0x89; |
| 120 | | c->device_id = 0xa2; |
| 159 | m_bits = 8; |
| 160 | m_size = 0x100000; |
| 161 | m_maker_id = 0x89; |
| 162 | m_device_id = 0xa2; |
| 163 | map = ADDRESS_MAP_NAME( memory_map8_8Mb ); |
| 121 | 164 | break; |
| 122 | 165 | case FLASH_INTEL_TE28F160: |
| 123 | | c->bits = 16; |
| 124 | | c->size = 0x200000; |
| 125 | | c->maker_id = 0xb0; |
| 126 | | c->device_id = 0xd0; |
| 166 | m_bits = 16; |
| 167 | m_size = 0x200000; |
| 168 | m_maker_id = 0xb0; |
| 169 | m_device_id = 0xd0; |
| 170 | map = ADDRESS_MAP_NAME( memory_map16_16Mb ); |
| 127 | 171 | break; |
| 128 | 172 | case FLASH_SHARP_UNK128MBIT: |
| 129 | | c->bits = 16; |
| 130 | | c->size = 0x800000; |
| 131 | | c->maker_id = 0xb0; |
| 132 | | c->device_id = 0xb0; |
| 173 | m_bits = 16; |
| 174 | m_size = 0x800000; |
| 175 | m_maker_id = 0xb0; |
| 176 | m_device_id = 0xb0; |
| 177 | map = ADDRESS_MAP_NAME( memory_map16_64Mb ); |
| 133 | 178 | break; |
| 134 | 179 | case FLASH_MACRONIX_29L001MC: |
| 135 | | c->bits = 8; |
| 136 | | c->size = 0x20000; |
| 137 | | c->maker_id = 0xc2; |
| 138 | | c->device_id = 0x51; |
| 180 | m_bits = 8; |
| 181 | m_size = 0x20000; |
| 182 | m_maker_id = 0xc2; |
| 183 | m_device_id = 0x51; |
| 184 | map = ADDRESS_MAP_NAME( memory_map8_1Mb ); |
| 139 | 185 | break; |
| 140 | | |
| 141 | 186 | case FLASH_PANASONIC_MN63F805MNP: |
| 142 | | c->bits = 8; |
| 143 | | c->size = 0x10000; |
| 144 | | c->maker_id = 0x32; |
| 145 | | c->device_id = 0x1b; |
| 146 | | c->sector_is_4k = 1; |
| 187 | m_bits = 8; |
| 188 | m_size = 0x10000; |
| 189 | m_maker_id = 0x32; |
| 190 | m_device_id = 0x1b; |
| 191 | m_sector_is_4k = true; |
| 192 | map = ADDRESS_MAP_NAME( memory_map8_512Kb ); |
| 147 | 193 | break; |
| 148 | | |
| 149 | 194 | case FLASH_SANYO_LE26FV10N1TS: |
| 150 | | c->bits = 8; |
| 151 | | c->size = 0x20000; |
| 152 | | c->maker_id = 0x62; |
| 153 | | c->device_id = 0x13; |
| 154 | | c->sector_is_4k = 1; |
| 195 | m_bits = 8; |
| 196 | m_size = 0x20000; |
| 197 | m_maker_id = 0x62; |
| 198 | m_device_id = 0x13; |
| 199 | m_sector_is_4k = true; |
| 200 | map = ADDRESS_MAP_NAME( memory_map8_1Mb ); |
| 155 | 201 | break; |
| 156 | 202 | } |
| 157 | | if( data == NULL ) |
| 203 | |
| 204 | int addrbits; |
| 205 | for (addrbits = 24; addrbits > 0; addrbits--) |
| 206 | if ((m_size & (1 << addrbits)) != 0) |
| 207 | break; |
| 208 | |
| 209 | m_space_config = address_space_config("flash", ENDIANNESS_BIG, m_bits, addrbits, 0, map); |
| 210 | } |
| 211 | |
| 212 | intelfsh8_device_config::intelfsh8_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant) |
| 213 | : intelfsh_device_config(mconfig, type, name, tag, owner, clock, variant) |
| 214 | { |
| 215 | } |
| 216 | |
| 217 | intelfsh16_device_config::intelfsh16_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant) |
| 218 | : intelfsh_device_config(mconfig, type, name, tag, owner, clock, variant) |
| 219 | { |
| 220 | } |
| 221 | |
| 222 | |
| 223 | //------------------------------------------------- |
| 224 | // memory_space_config - return a description of |
| 225 | // any address spaces owned by this device |
| 226 | //------------------------------------------------- |
| 227 | |
| 228 | const address_space_config *intelfsh_device_config::memory_space_config(int spacenum) const |
| 229 | { |
| 230 | return (spacenum == 0) ? &m_space_config : NULL; |
| 231 | } |
| 232 | |
| 233 | |
| 234 | |
| 235 | //************************************************************************** |
| 236 | // LIVE DEVICE |
| 237 | //************************************************************************** |
| 238 | |
| 239 | //------------------------------------------------- |
| 240 | // intelfsh_device - constructor |
| 241 | //------------------------------------------------- |
| 242 | |
| 243 | intelfsh_device::intelfsh_device(running_machine &_machine, const intelfsh_device_config &config) |
| 244 | : device_t(_machine, config), |
| 245 | device_memory_interface(_machine, config, *this), |
| 246 | device_nvram_interface(_machine, config, *this), |
| 247 | m_config(config), |
| 248 | m_status(0x80), |
| 249 | m_erase_sector(0), |
| 250 | m_flash_mode(FM_NORMAL), |
| 251 | m_flash_master_lock(false), |
| 252 | m_timer(NULL) |
| 253 | { |
| 254 | } |
| 255 | |
| 256 | intelfsh8_device::intelfsh8_device(running_machine &_machine, const intelfsh_device_config &config) |
| 257 | : intelfsh_device(_machine, config) { } |
| 258 | |
| 259 | intelfsh16_device::intelfsh16_device(running_machine &_machine, const intelfsh_device_config &config) |
| 260 | : intelfsh_device(_machine, config) { } |
| 261 | |
| 262 | |
| 263 | //------------------------------------------------- |
| 264 | // device_start - device-specific startup |
| 265 | //------------------------------------------------- |
| 266 | |
| 267 | void intelfsh_device::device_start() |
| 268 | { |
| 269 | m_timer = device_timer_alloc(*this); |
| 270 | |
| 271 | state_save_register_device_item( this, 0, m_status ); |
| 272 | state_save_register_device_item( this, 0, m_flash_mode ); |
| 273 | state_save_register_device_item( this, 0, m_flash_master_lock ); |
| 274 | } |
| 275 | |
| 276 | |
| 277 | //------------------------------------------------- |
| 278 | // device_timer - handler timer events |
| 279 | //------------------------------------------------- |
| 280 | |
| 281 | void intelfsh_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 282 | { |
| 283 | switch( m_flash_mode ) |
| 158 | 284 | { |
| 159 | | data = auto_alloc_array( machine, UINT8, c->size ); |
| 160 | | memset( data, 0xff, c->size ); |
| 285 | case FM_READSTATUS: |
| 286 | m_status = 0x80; |
| 287 | break; |
| 288 | |
| 289 | case FM_ERASEAMD4: |
| 290 | m_flash_mode = FM_NORMAL; |
| 291 | break; |
| 161 | 292 | } |
| 293 | } |
| 162 | 294 | |
| 163 | | c->status = 0x80; |
| 164 | | c->flash_mode = FM_NORMAL; |
| 165 | | c->flash_master_lock = 0; |
| 166 | | c->timer = timer_alloc(machine, erase_finished, c); |
| 167 | | c->flash_memory = data; |
| 168 | 295 | |
| 169 | | state_save_register_item( machine, "intelfsh", NULL, chip, c->status ); |
| 170 | | state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_mode ); |
| 171 | | state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_master_lock ); |
| 172 | | state_save_register_memory( machine, "intelfsh", NULL, chip, "flash_memory", c->flash_memory, c->bits/8, c->size / (c->bits/8), __FILE__, __LINE__ ); |
| 173 | | } |
| 296 | //------------------------------------------------- |
| 297 | // nvram_default - called to initialize NVRAM to |
| 298 | // its default state |
| 299 | //------------------------------------------------- |
| 174 | 300 | |
| 175 | | UINT32 intelflash_read(int chip, UINT32 address) |
| 301 | void intelfsh_device::nvram_default() |
| 176 | 302 | { |
| 177 | | UINT32 data = 0; |
| 178 | | struct flash_chip *c; |
| 179 | | if( chip >= FLASH_CHIPS_MAX ) |
| 303 | // region always wins |
| 304 | if (m_region != NULL) |
| 180 | 305 | { |
| 181 | | logerror( "intelflash_read: invalid chip %d\n", chip ); |
| 182 | | return 0; |
| 306 | UINT32 bytes = m_region->bytes(); |
| 307 | if (bytes > m_config.m_size) |
| 308 | bytes = m_config.m_size; |
| 309 | |
| 310 | if (m_config.m_bits == 8) |
| 311 | { |
| 312 | for (offs_t offs = 0; offs < bytes; offs++) |
| 313 | m_addrspace[0]->write_byte(offs, m_region->u8(offs)); |
| 314 | } |
| 315 | else |
| 316 | { |
| 317 | for (offs_t offs = 0; offs < bytes; offs += 2) |
| 318 | m_addrspace[0]->write_word(offs, m_region->u16(offs / 2)); |
| 319 | } |
| 320 | return; |
| 183 | 321 | } |
| 184 | | c = &chips[ chip ]; |
| 185 | 322 | |
| 186 | | switch( c->flash_mode ) |
| 323 | // otherwise, default to 0xff |
| 324 | for (offs_t offs = 0; offs < m_config.m_size; offs++) |
| 325 | m_addrspace[0]->write_byte(offs, 0xff); |
| 326 | } |
| 327 | |
| 328 | |
| 329 | //------------------------------------------------- |
| 330 | // nvram_read - called to read NVRAM from the |
| 331 | // .nv file |
| 332 | //------------------------------------------------- |
| 333 | |
| 334 | void intelfsh_device::nvram_read(mame_file &file) |
| 335 | { |
| 336 | UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size); |
| 337 | mame_fread(&file, buffer, m_config.m_size); |
| 338 | for (int byte = 0; byte < m_config.m_size; byte++) |
| 339 | m_addrspace[0]->write_byte(byte, buffer[byte]); |
| 340 | global_free(buffer); |
| 341 | } |
| 342 | |
| 343 | |
| 344 | //------------------------------------------------- |
| 345 | // nvram_write - called to write NVRAM to the |
| 346 | // .nv file |
| 347 | //------------------------------------------------- |
| 348 | |
| 349 | void intelfsh_device::nvram_write(mame_file &file) |
| 350 | { |
| 351 | UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size); |
| 352 | for (int byte = 0; byte < m_config.m_size; byte++) |
| 353 | buffer[byte] = m_addrspace[0]->read_byte(byte); |
| 354 | mame_fwrite(&file, buffer, m_config.m_size); |
| 355 | global_free(buffer); |
| 356 | } |
| 357 | |
| 358 | |
| 359 | //------------------------------------------------- |
| 360 | // read_full - generic read, called by the |
| 361 | // bit-width-specific readers |
| 362 | //------------------------------------------------- |
| 363 | |
| 364 | UINT32 intelfsh_device::read_full(UINT32 address) |
| 365 | { |
| 366 | UINT32 data = 0; |
| 367 | switch( m_flash_mode ) |
| 187 | 368 | { |
| 188 | 369 | default: |
| 189 | 370 | case FM_NORMAL: |
| 190 | | switch( c->bits ) |
| 371 | switch( m_config.m_bits ) |
| 191 | 372 | { |
| 192 | 373 | case 8: |
| 193 | 374 | { |
| 194 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 195 | | data = flash_memory[ address ]; |
| 375 | data = m_addrspace[0]->read_byte(address); |
| 196 | 376 | } |
| 197 | 377 | break; |
| 198 | 378 | case 16: |
| 199 | 379 | { |
| 200 | | UINT16 *flash_memory = (UINT16 *)c->flash_memory; |
| 201 | | data = flash_memory[ address ]; |
| 380 | data = m_addrspace[0]->read_word(address * 2); |
| 202 | 381 | } |
| 203 | 382 | break; |
| 204 | 383 | } |
| 205 | 384 | break; |
| 206 | 385 | case FM_READSTATUS: |
| 207 | | data = c->status; |
| 386 | data = m_status; |
| 208 | 387 | break; |
| 209 | 388 | case FM_READAMDID3: |
| 210 | 389 | switch (address) |
| 211 | 390 | { |
| 212 | | case 0: data = c->maker_id; break; |
| 213 | | case 1: data = c->device_id; break; |
| 391 | case 0: data = m_config.m_maker_id; break; |
| 392 | case 1: data = m_config.m_device_id; break; |
| 214 | 393 | case 2: data = 0; break; |
| 215 | 394 | } |
| 216 | 395 | break; |
| r9152 | r9153 | |
| 218 | 397 | switch (address) |
| 219 | 398 | { |
| 220 | 399 | case 0: // maker ID |
| 221 | | data = c->maker_id; |
| 400 | data = m_config.m_maker_id; |
| 222 | 401 | break; |
| 223 | 402 | case 1: // chip ID |
| 224 | | data = c->device_id; |
| 403 | data = m_config.m_device_id; |
| 225 | 404 | break; |
| 226 | 405 | case 2: // block lock config |
| 227 | 406 | data = 0; // we don't support this yet |
| 228 | 407 | break; |
| 229 | 408 | case 3: // master lock config |
| 230 | | if (c->flash_master_lock) |
| 409 | if (m_flash_master_lock) |
| 231 | 410 | { |
| 232 | 411 | data = 1; |
| 233 | 412 | } |
| r9152 | r9153 | |
| 240 | 419 | break; |
| 241 | 420 | case FM_ERASEAMD4: |
| 242 | 421 | // reads outside of the erasing sector return normal data |
| 243 | | if ((address < c->erase_sector) || (address >= c->erase_sector+(64*1024))) |
| 422 | if ((address < m_erase_sector) || (address >= m_erase_sector+(64*1024))) |
| 244 | 423 | { |
| 245 | | switch( c->bits ) |
| 424 | switch( m_config.m_bits ) |
| 246 | 425 | { |
| 247 | 426 | case 8: |
| 248 | 427 | { |
| 249 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 250 | | data = flash_memory[ address ]; |
| 428 | data = m_addrspace[0]->read_byte(address); |
| 251 | 429 | } |
| 252 | 430 | break; |
| 253 | 431 | case 16: |
| 254 | 432 | { |
| 255 | | UINT16 *flash_memory = (UINT16 *)c->flash_memory; |
| 256 | | data = flash_memory[ address ]; |
| 433 | data = m_addrspace[0]->read_word(address * 2); |
| 257 | 434 | } |
| 258 | 435 | break; |
| 259 | 436 | } |
| 260 | 437 | } |
| 261 | 438 | else |
| 262 | 439 | { |
| 263 | | c->status ^= ( 1 << 6 ) | ( 1 << 2 ); |
| 264 | | data = c->status; |
| 440 | m_status ^= ( 1 << 6 ) | ( 1 << 2 ); |
| 441 | data = m_status; |
| 265 | 442 | } |
| 266 | 443 | break; |
| 267 | 444 | } |
| r9152 | r9153 | |
| 271 | 448 | return data; |
| 272 | 449 | } |
| 273 | 450 | |
| 274 | | void intelflash_write(int chip, UINT32 address, UINT32 data) |
| 451 | |
| 452 | //------------------------------------------------- |
| 453 | // write_full - generic write, called by the |
| 454 | // bit-width-specific writers |
| 455 | //------------------------------------------------- |
| 456 | |
| 457 | void intelfsh_device::write_full(UINT32 address, UINT32 data) |
| 275 | 458 | { |
| 276 | | struct flash_chip *c; |
| 277 | | if( chip >= FLASH_CHIPS_MAX ) |
| 278 | | { |
| 279 | | logerror( "intelflash_write: invalid chip %d\n", chip ); |
| 280 | | return; |
| 281 | | } |
| 282 | | c = &chips[ chip ]; |
| 283 | | |
| 284 | 459 | // logerror( "intelflash_write( %d, %08x, %08x )\n", chip, address, data ); |
| 285 | 460 | |
| 286 | | switch( c->flash_mode ) |
| 461 | switch( m_flash_mode ) |
| 287 | 462 | { |
| 288 | 463 | case FM_NORMAL: |
| 289 | 464 | case FM_READSTATUS: |
| r9152 | r9153 | |
| 293 | 468 | { |
| 294 | 469 | case 0xf0: |
| 295 | 470 | case 0xff: // reset chip mode |
| 296 | | c->flash_mode = FM_NORMAL; |
| 471 | m_flash_mode = FM_NORMAL; |
| 297 | 472 | break; |
| 298 | 473 | case 0x90: // read ID |
| 299 | | c->flash_mode = FM_READID; |
| 474 | m_flash_mode = FM_READID; |
| 300 | 475 | break; |
| 301 | 476 | case 0x40: |
| 302 | 477 | case 0x10: // program |
| 303 | | c->flash_mode = FM_WRITEPART1; |
| 478 | m_flash_mode = FM_WRITEPART1; |
| 304 | 479 | break; |
| 305 | 480 | case 0x50: // clear status reg |
| 306 | | c->status = 0x80; |
| 307 | | c->flash_mode = FM_READSTATUS; |
| 481 | m_status = 0x80; |
| 482 | m_flash_mode = FM_READSTATUS; |
| 308 | 483 | break; |
| 309 | 484 | case 0x20: // block erase |
| 310 | | c->flash_mode = FM_CLEARPART1; |
| 485 | m_flash_mode = FM_CLEARPART1; |
| 311 | 486 | break; |
| 312 | 487 | case 0x60: // set master lock |
| 313 | | c->flash_mode = FM_SETMASTER; |
| 488 | m_flash_mode = FM_SETMASTER; |
| 314 | 489 | break; |
| 315 | 490 | case 0x70: // read status |
| 316 | | c->flash_mode = FM_READSTATUS; |
| 491 | m_flash_mode = FM_READSTATUS; |
| 317 | 492 | break; |
| 318 | 493 | case 0xaa: // AMD ID select part 1 |
| 319 | 494 | if( ( address & 0xfff ) == 0x555 ) |
| 320 | 495 | { |
| 321 | | c->flash_mode = FM_READAMDID1; |
| 496 | m_flash_mode = FM_READAMDID1; |
| 322 | 497 | } |
| 323 | 498 | break; |
| 324 | 499 | default: |
| r9152 | r9153 | |
| 329 | 504 | case FM_READAMDID1: |
| 330 | 505 | if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 ) |
| 331 | 506 | { |
| 332 | | c->flash_mode = FM_READAMDID2; |
| 507 | m_flash_mode = FM_READAMDID2; |
| 333 | 508 | } |
| 334 | 509 | else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 ) |
| 335 | 510 | { |
| 336 | | c->flash_mode = FM_READAMDID2; |
| 511 | m_flash_mode = FM_READAMDID2; |
| 337 | 512 | } |
| 338 | 513 | else |
| 339 | 514 | { |
| 340 | 515 | logerror( "unexpected %08x=%02x in FM_READAMDID1\n", address, data & 0xff ); |
| 341 | | c->flash_mode = FM_NORMAL; |
| 516 | m_flash_mode = FM_NORMAL; |
| 342 | 517 | } |
| 343 | 518 | break; |
| 344 | 519 | case FM_READAMDID2: |
| 345 | 520 | if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x90 ) |
| 346 | 521 | { |
| 347 | | c->flash_mode = FM_READAMDID3; |
| 522 | m_flash_mode = FM_READAMDID3; |
| 348 | 523 | } |
| 349 | 524 | else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x90 ) |
| 350 | 525 | { |
| 351 | | c->flash_mode = FM_READAMDID3; |
| 526 | m_flash_mode = FM_READAMDID3; |
| 352 | 527 | } |
| 353 | 528 | else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0x80 ) |
| 354 | 529 | { |
| 355 | | c->flash_mode = FM_ERASEAMD1; |
| 530 | m_flash_mode = FM_ERASEAMD1; |
| 356 | 531 | } |
| 357 | 532 | else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0x80 ) |
| 358 | 533 | { |
| 359 | | c->flash_mode = FM_ERASEAMD1; |
| 534 | m_flash_mode = FM_ERASEAMD1; |
| 360 | 535 | } |
| 361 | 536 | else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xa0 ) |
| 362 | 537 | { |
| 363 | | c->flash_mode = FM_BYTEPROGRAM; |
| 538 | m_flash_mode = FM_BYTEPROGRAM; |
| 364 | 539 | } |
| 365 | 540 | else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xa0 ) |
| 366 | 541 | { |
| 367 | | c->flash_mode = FM_BYTEPROGRAM; |
| 542 | m_flash_mode = FM_BYTEPROGRAM; |
| 368 | 543 | } |
| 369 | 544 | else if( ( address & 0xffff ) == 0x555 && ( data & 0xff ) == 0xf0 ) |
| 370 | 545 | { |
| 371 | | c->flash_mode = FM_NORMAL; |
| 546 | m_flash_mode = FM_NORMAL; |
| 372 | 547 | } |
| 373 | 548 | else if( ( address & 0xffff ) == 0x5555 && ( data & 0xff ) == 0xf0 ) |
| 374 | 549 | { |
| 375 | | c->flash_mode = FM_NORMAL; |
| 550 | m_flash_mode = FM_NORMAL; |
| 376 | 551 | } |
| 377 | 552 | else |
| 378 | 553 | { |
| 379 | 554 | logerror( "unexpected %08x=%02x in FM_READAMDID2\n", address, data & 0xff ); |
| 380 | | c->flash_mode = FM_NORMAL; |
| 555 | m_flash_mode = FM_NORMAL; |
| 381 | 556 | } |
| 382 | 557 | break; |
| 383 | 558 | case FM_ERASEAMD1: |
| 384 | 559 | if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0xaa ) |
| 385 | 560 | { |
| 386 | | c->flash_mode = FM_ERASEAMD2; |
| 561 | m_flash_mode = FM_ERASEAMD2; |
| 387 | 562 | } |
| 388 | 563 | else |
| 389 | 564 | { |
| r9152 | r9153 | |
| 393 | 568 | case FM_ERASEAMD2: |
| 394 | 569 | if( ( address & 0xffff ) == 0x2aa && ( data & 0xff ) == 0x55 ) |
| 395 | 570 | { |
| 396 | | c->flash_mode = FM_ERASEAMD3; |
| 571 | m_flash_mode = FM_ERASEAMD3; |
| 397 | 572 | } |
| 398 | 573 | else if( ( address & 0xffff ) == 0x2aaa && ( data & 0xff ) == 0x55 ) |
| 399 | 574 | { |
| 400 | | c->flash_mode = FM_ERASEAMD3; |
| 575 | m_flash_mode = FM_ERASEAMD3; |
| 401 | 576 | } |
| 402 | 577 | else |
| 403 | 578 | { |
| r9152 | r9153 | |
| 408 | 583 | if( ( address & 0xfff ) == 0x555 && ( data & 0xff ) == 0x10 ) |
| 409 | 584 | { |
| 410 | 585 | // chip erase |
| 411 | | memset( c->flash_memory, 0xff, c->size); |
| 586 | for (offs_t offs = 0; offs < m_config.m_size; offs++) |
| 587 | m_addrspace[0]->write_byte(offs, 0xff); |
| 412 | 588 | |
| 413 | | c->status = 1 << 3; |
| 414 | | c->flash_mode = FM_ERASEAMD4; |
| 589 | m_status = 1 << 3; |
| 590 | m_flash_mode = FM_ERASEAMD4; |
| 415 | 591 | |
| 416 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 17 ), 0 ); |
| 592 | timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 17 ), 0 ); |
| 417 | 593 | } |
| 418 | 594 | else if( ( data & 0xff ) == 0x30 ) |
| 419 | 595 | { |
| 420 | 596 | // sector erase |
| 421 | 597 | // clear the 4k/64k block containing the current address to all 0xffs |
| 422 | | switch( c->bits ) |
| 598 | if (m_config.m_sector_is_4k) |
| 423 | 599 | { |
| 424 | | case 8: |
| 425 | | { |
| 426 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 427 | | if (c->sector_is_4k) |
| 428 | | { |
| 429 | | memset( &flash_memory[ address & ~0xfff ], 0xff, 4 * 1024 ); |
| 430 | | c->erase_sector = address & ~0xfff; |
| 431 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_MSEC( 125 ), 0 ); |
| 432 | | } |
| 433 | | else |
| 434 | | { |
| 435 | | memset( &flash_memory[ address & ~0xffff ], 0xff, 64 * 1024 ); |
| 436 | | c->erase_sector = address & ~0xffff; |
| 437 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 ); |
| 438 | | } |
| 439 | | } |
| 440 | | break; |
| 441 | | case 16: |
| 442 | | { |
| 443 | | UINT16 *flash_memory = (UINT16 *)c->flash_memory; |
| 444 | | if (c->sector_is_4k) |
| 445 | | { |
| 446 | | memset( &flash_memory[ address & ~0x7ff ], 0xff, 4 * 1024 ); |
| 447 | | c->erase_sector = address & ~0x7ff; |
| 448 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_MSEC( 125 ), 0 ); |
| 449 | | } |
| 450 | | else |
| 451 | | { |
| 452 | | memset( &flash_memory[ address & ~0x7fff ], 0xff, 64 * 1024 ); |
| 453 | | c->erase_sector = address & ~0x7fff; |
| 454 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 ); |
| 455 | | } |
| 456 | | } |
| 457 | | break; |
| 600 | for (offs_t offs = 0; offs < 4 * 1024; offs++) |
| 601 | m_addrspace[0]->write_byte((address & ~0xfff) + offs, 0xff); |
| 602 | m_erase_sector = address & ~0xfff; |
| 603 | timer_adjust_oneshot( m_timer, ATTOTIME_IN_MSEC( 125 ), 0 ); |
| 458 | 604 | } |
| 605 | else |
| 606 | { |
| 607 | for (offs_t offs = 0; offs < 64 * 1024; offs++) |
| 608 | m_addrspace[0]->write_byte((address & ~0xffff) + offs, 0xff); |
| 609 | m_erase_sector = address & ~0xffff; |
| 610 | timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 1 ), 0 ); |
| 611 | } |
| 459 | 612 | |
| 460 | | c->status = 1 << 3; |
| 461 | | c->flash_mode = FM_ERASEAMD4; |
| 613 | m_status = 1 << 3; |
| 614 | m_flash_mode = FM_ERASEAMD4; |
| 462 | 615 | } |
| 463 | 616 | else |
| 464 | 617 | { |
| r9152 | r9153 | |
| 466 | 619 | } |
| 467 | 620 | break; |
| 468 | 621 | case FM_BYTEPROGRAM: |
| 469 | | switch( c->bits ) |
| 622 | switch( m_config.m_bits ) |
| 470 | 623 | { |
| 471 | 624 | case 8: |
| 472 | 625 | { |
| 473 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 474 | | flash_memory[ address ] = data; |
| 626 | m_addrspace[0]->write_byte(address, data); |
| 475 | 627 | } |
| 476 | 628 | break; |
| 477 | 629 | default: |
| 478 | | logerror( "FM_BYTEPROGRAM not supported when c->bits == %d\n", c->bits ); |
| 630 | logerror( "FM_BYTEPROGRAM not supported when m_bits == %d\n", m_config.m_bits ); |
| 479 | 631 | break; |
| 480 | 632 | } |
| 481 | | c->flash_mode = FM_NORMAL; |
| 633 | m_flash_mode = FM_NORMAL; |
| 482 | 634 | break; |
| 483 | 635 | case FM_WRITEPART1: |
| 484 | | switch( c->bits ) |
| 636 | switch( m_config.m_bits ) |
| 485 | 637 | { |
| 486 | 638 | case 8: |
| 487 | 639 | { |
| 488 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 489 | | flash_memory[ address ] = data; |
| 640 | m_addrspace[0]->write_byte(address, data); |
| 490 | 641 | } |
| 491 | 642 | break; |
| 492 | 643 | case 16: |
| 493 | 644 | { |
| 494 | | UINT16 *flash_memory = (UINT16 *)c->flash_memory; |
| 495 | | flash_memory[ address ] = data; |
| 645 | m_addrspace[0]->write_word(address * 2, data); |
| 496 | 646 | } |
| 497 | 647 | break; |
| 498 | 648 | default: |
| 499 | | logerror( "FM_WRITEPART1 not supported when c->bits == %d\n", c->bits ); |
| 649 | logerror( "FM_WRITEPART1 not supported when m_bits == %d\n", m_config.m_bits ); |
| 500 | 650 | break; |
| 501 | 651 | } |
| 502 | | c->status = 0x80; |
| 503 | | c->flash_mode = FM_READSTATUS; |
| 652 | m_status = 0x80; |
| 653 | m_flash_mode = FM_READSTATUS; |
| 504 | 654 | break; |
| 505 | 655 | case FM_CLEARPART1: |
| 506 | 656 | if( ( data & 0xff ) == 0xd0 ) |
| 507 | 657 | { |
| 508 | 658 | // clear the 64k block containing the current address to all 0xffs |
| 509 | | switch( c->bits ) |
| 510 | | { |
| 511 | | case 8: |
| 512 | | { |
| 513 | | UINT8 *flash_memory = (UINT8 *)c->flash_memory; |
| 514 | | memset( &flash_memory[ address & ~0xffff ], 0xff, 64 * 1024 ); |
| 515 | | } |
| 516 | | break; |
| 517 | | case 16: |
| 518 | | { |
| 519 | | UINT16 *flash_memory = (UINT16 *)c->flash_memory; |
| 520 | | memset( &flash_memory[ address & ~0x7fff ], 0xff, 64 * 1024 ); |
| 521 | | } |
| 522 | | break; |
| 523 | | default: |
| 524 | | logerror( "FM_CLEARPART1 not supported when c->bits == %d\n", c->bits ); |
| 525 | | break; |
| 526 | | } |
| 527 | | c->status = 0x00; |
| 528 | | c->flash_mode = FM_READSTATUS; |
| 659 | for (offs_t offs = 0; offs < 64 * 1024; offs++) |
| 660 | m_addrspace[0]->write_byte((address & ~0xffff) + offs, 0xff); |
| 529 | 661 | |
| 530 | | timer_adjust_oneshot( c->timer, ATTOTIME_IN_SEC( 1 ), 0 ); |
| 662 | m_status = 0x00; |
| 663 | m_flash_mode = FM_READSTATUS; |
| 664 | |
| 665 | timer_adjust_oneshot( m_timer, ATTOTIME_IN_SEC( 1 ), 0 ); |
| 531 | 666 | break; |
| 532 | 667 | } |
| 533 | 668 | else |
| r9152 | r9153 | |
| 539 | 674 | switch( data & 0xff ) |
| 540 | 675 | { |
| 541 | 676 | case 0xf1: |
| 542 | | c->flash_master_lock = 1; |
| 677 | m_flash_master_lock = true; |
| 543 | 678 | break; |
| 544 | 679 | case 0xd0: |
| 545 | | c->flash_master_lock = 0; |
| 680 | m_flash_master_lock = false; |
| 546 | 681 | break; |
| 547 | 682 | default: |
| 548 | 683 | logerror( "unexpected %08x=%02x in FM_SETMASTER:\n", address, data & 0xff ); |
| 549 | 684 | break; |
| 550 | 685 | } |
| 551 | | c->flash_mode = FM_NORMAL; |
| 686 | m_flash_mode = FM_NORMAL; |
| 552 | 687 | break; |
| 553 | 688 | } |
| 554 | 689 | } |
| 555 | | |
| 556 | | void nvram_handler_intelflash(running_machine *machine, int chip,mame_file *file,int read_or_write) |
| 557 | | { |
| 558 | | struct flash_chip *c; |
| 559 | | if( chip >= FLASH_CHIPS_MAX ) |
| 560 | | { |
| 561 | | logerror( "intelflash_nvram: invalid chip %d\n", chip ); |
| 562 | | return; |
| 563 | | } |
| 564 | | c = &chips[ chip ]; |
| 565 | | |
| 566 | | switch( c->bits ) |
| 567 | | { |
| 568 | | case 8: |
| 569 | | if (read_or_write) |
| 570 | | { |
| 571 | | mame_fwrite( file, c->flash_memory, c->size ); |
| 572 | | } |
| 573 | | else if (file) |
| 574 | | { |
| 575 | | mame_fread( file, c->flash_memory, c->size ); |
| 576 | | } |
| 577 | | break; |
| 578 | | case 16: |
| 579 | | if (read_or_write) |
| 580 | | { |
| 581 | | /// TODO: endian conversion |
| 582 | | mame_fwrite( file, c->flash_memory, c->size ); |
| 583 | | } |
| 584 | | else if (file) |
| 585 | | { |
| 586 | | mame_fread( file, c->flash_memory, c->size ); |
| 587 | | /// TODO: endian conversion |
| 588 | | } |
| 589 | | break; |
| 590 | | } |
| 591 | | } |
src/emu/machine/intelfsh.h
| r9152 | r9153 | |
| 5 | 5 | #ifndef _INTELFLASH_H_ |
| 6 | 6 | #define _INTELFLASH_H_ |
| 7 | 7 | |
| 8 | | #define FLASH_CHIPS_MAX ( 56 ) |
| 9 | 8 | |
| 10 | | #define FLASH_INTEL_28F016S5 ( 0 ) |
| 11 | | #define FLASH_SHARP_LH28F400 ( 1 ) |
| 12 | | #define FLASH_FUJITSU_29F016A ( 2 ) |
| 13 | | #define FLASH_INTEL_E28F008SA ( 3 ) |
| 14 | | #define FLASH_INTEL_TE28F160 ( 4 ) |
| 15 | | #define FLASH_SHARP_LH28F016S ( 5 ) |
| 16 | | #define FLASH_INTEL_E28F400 ( 6 ) |
| 17 | | #define FLASH_SHARP_UNK128MBIT ( 7 ) |
| 18 | | #define FLASH_MACRONIX_29L001MC ( 8 ) |
| 19 | | #define FLASH_PANASONIC_MN63F805MNP ( 9 ) |
| 20 | | #define FLASH_SANYO_LE26FV10N1TS ( 10 ) |
| 9 | //************************************************************************** |
| 10 | // INTERFACE CONFIGURATION MACROS |
| 11 | //************************************************************************** |
| 21 | 12 | |
| 22 | | extern void intelflash_init( running_machine *machine, int chip, int type, void *data ); |
| 23 | | extern UINT32 intelflash_read( int chip, UINT32 address ); |
| 24 | | extern void intelflash_write( int chip, UINT32 address, UINT32 value ); |
| 25 | | extern void nvram_handler_intelflash( running_machine *machine, int chip, mame_file *file, int read_or_write ); |
| 26 | | extern void* intelflash_getmemptr(int chip); |
| 13 | #define MDRV_INTEL_28F016S5_ADD(_tag) \ |
| 14 | MDRV_DEVICE_ADD(_tag, INTEL_28F016S5, 0) |
| 27 | 15 | |
| 16 | #define MDRV_SHARP_LH28F016S_ADD(_tag) \ |
| 17 | MDRV_DEVICE_ADD(_tag, SHARP_LH28F016S, 0) |
| 18 | |
| 19 | #define MDRV_FUJITSU_29F016A_ADD(_tag) \ |
| 20 | MDRV_DEVICE_ADD(_tag, FUJITSU_29F016A, 0) |
| 21 | |
| 22 | #define MDRV_INTEL_E28F400_ADD(_tag) \ |
| 23 | MDRV_DEVICE_ADD(_tag, INTEL_E28F400, 0) |
| 24 | |
| 25 | #define MDRV_MACRONIX_29L001MC_ADD(_tag) \ |
| 26 | MDRV_DEVICE_ADD(_tag, MACRONIX_29L001MC, 0) |
| 27 | |
| 28 | #define MDRV_PANASONIC_MN63F805MNP_ADD(_tag) \ |
| 29 | MDRV_DEVICE_ADD(_tag, PANASONIC_MN63F805MNP, 0) |
| 30 | |
| 31 | #define MDRV_SANYO_LE26FV10N1TS_ADD(_tag) \ |
| 32 | MDRV_DEVICE_ADD(_tag, SANYO_LE26FV10N1TS, 0) |
| 33 | |
| 34 | #define MDRV_SHARP_LH28F400_ADD(_tag) \ |
| 35 | MDRV_DEVICE_ADD(_tag, SHARP_LH28F400, 0) |
| 36 | |
| 37 | #define MDRV_INTEL_E28F008SA_ADD(_tag) \ |
| 38 | MDRV_DEVICE_ADD(_tag, INTEL_E28F008SA, 0) |
| 39 | |
| 40 | #define MDRV_INTEL_TE28F160_ADD(_tag) \ |
| 41 | MDRV_DEVICE_ADD(_tag, INTEL_TE28F160, 0) |
| 42 | |
| 43 | #define MDRV_SHARP_UNK128MBIT_ADD(_tag) \ |
| 44 | MDRV_DEVICE_ADD(_tag, SHARP_UNK128MBIT, 0) |
| 45 | |
| 46 | |
| 47 | |
| 48 | //************************************************************************** |
| 49 | // TYPE DEFINITIONS |
| 50 | //************************************************************************** |
| 51 | |
| 52 | class intelfsh_device; |
| 53 | |
| 54 | |
| 55 | // ======================> intelfsh_device_config |
| 56 | |
| 57 | class intelfsh_device_config : public device_config, |
| 58 | public device_config_memory_interface, |
| 59 | public device_config_nvram_interface |
| 60 | { |
| 61 | friend class intelfsh_device; |
| 62 | |
| 63 | protected: |
| 64 | // constants |
| 65 | enum |
| 66 | { |
| 67 | // 8-bit variants |
| 68 | FLASH_INTEL_28F016S5 = 0x0800, |
| 69 | FLASH_FUJITSU_29F016A, |
| 70 | FLASH_SHARP_LH28F016S, |
| 71 | FLASH_INTEL_E28F400, |
| 72 | FLASH_MACRONIX_29L001MC, |
| 73 | FLASH_PANASONIC_MN63F805MNP, |
| 74 | FLASH_SANYO_LE26FV10N1TS, |
| 75 | |
| 76 | // 16-bit variants |
| 77 | FLASH_SHARP_LH28F400 = 0x1000, |
| 78 | FLASH_INTEL_E28F008SA, |
| 79 | FLASH_INTEL_TE28F160, |
| 80 | FLASH_SHARP_UNK128MBIT |
| 81 | }; |
| 82 | |
| 83 | // construction/destruction |
| 84 | intelfsh_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); |
| 85 | |
| 86 | // device_config_memory_interface overrides |
| 87 | virtual const address_space_config *memory_space_config(int spacenum = 0) const; |
| 88 | |
| 89 | // internal state |
| 90 | address_space_config m_space_config; |
| 91 | UINT32 m_type; |
| 92 | INT32 m_size; |
| 93 | UINT8 m_bits; |
| 94 | UINT8 m_device_id; |
| 95 | UINT8 m_maker_id; |
| 96 | bool m_sector_is_4k; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | // ======================> intelfsh_device |
| 101 | |
| 102 | class intelfsh_device : public device_t, |
| 103 | public device_memory_interface, |
| 104 | public device_nvram_interface |
| 105 | { |
| 106 | friend class intelfsh_device_config; |
| 107 | |
| 108 | protected: |
| 109 | // construction/destruction |
| 110 | intelfsh_device(running_machine &_machine, const intelfsh_device_config &config); |
| 111 | |
| 112 | protected: |
| 113 | // device-level overrides |
| 114 | virtual void device_start(); |
| 115 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 116 | |
| 117 | // device_config_nvram_interface overrides |
| 118 | virtual void nvram_default(); |
| 119 | virtual void nvram_read(mame_file &file); |
| 120 | virtual void nvram_write(mame_file &file); |
| 121 | |
| 122 | // derived helpers |
| 123 | UINT32 read_full(UINT32 offset); |
| 124 | void write_full(UINT32 offset, UINT32 data); |
| 125 | |
| 126 | // internal state |
| 127 | const intelfsh_device_config & m_config; |
| 128 | |
| 129 | UINT8 m_status; |
| 130 | INT32 m_erase_sector; |
| 131 | INT32 m_flash_mode; |
| 132 | bool m_flash_master_lock; |
| 133 | emu_timer * m_timer; |
| 134 | }; |
| 135 | |
| 136 | |
| 137 | // ======================> intelfsh8_device_config |
| 138 | |
| 139 | class intelfsh8_device_config : public intelfsh_device_config |
| 140 | { |
| 141 | friend class intelfsh8_device; |
| 142 | |
| 143 | protected: |
| 144 | // construction/destruction |
| 145 | intelfsh8_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); |
| 146 | }; |
| 147 | |
| 148 | |
| 149 | // ======================> intelfsh8_device |
| 150 | |
| 151 | class intelfsh8_device : public intelfsh_device |
| 152 | { |
| 153 | friend class intelfsh8_device_config; |
| 154 | friend class intel_28f016s5_device_config; |
| 155 | friend class fujitsu_29f016a_device_config; |
| 156 | friend class sharp_lh28f016s_device_config; |
| 157 | friend class intel_e28f008sa_device_config; |
| 158 | friend class macronix_29l001mc_device_config; |
| 159 | friend class panasonic_mn63f805mnp_device_config; |
| 160 | friend class sanyo_le26fv10n1ts_device_config; |
| 161 | |
| 162 | protected: |
| 163 | // construction/destruction |
| 164 | intelfsh8_device(running_machine &_machine, const intelfsh_device_config &config); |
| 165 | |
| 166 | public: |
| 167 | // public interface |
| 168 | UINT8 read(offs_t offset) { return read_full(offset); } |
| 169 | void write(offs_t offset, UINT8 data) { write_full(offset, data); } |
| 170 | |
| 171 | UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); } |
| 172 | void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); } |
| 173 | }; |
| 174 | |
| 175 | |
| 176 | // ======================> intelfsh16_device_config |
| 177 | |
| 178 | class intelfsh16_device_config : public intelfsh_device_config |
| 179 | { |
| 180 | friend class intelfsh16_device; |
| 181 | |
| 182 | protected: |
| 183 | // construction/destruction |
| 184 | intelfsh16_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); |
| 185 | }; |
| 186 | |
| 187 | |
| 188 | // ======================> intelfsh16_device |
| 189 | |
| 190 | class intelfsh16_device : public intelfsh_device |
| 191 | { |
| 192 | friend class intelfsh16_device_config; |
| 193 | friend class sharp_lh28f400_device_config; |
| 194 | friend class intel_te28f160_device_config; |
| 195 | friend class intel_e28f400_device_config; |
| 196 | friend class sharp_unk128mbit_device_config; |
| 197 | |
| 198 | protected: |
| 199 | // construction/destruction |
| 200 | intelfsh16_device(running_machine &_machine, const intelfsh_device_config &config); |
| 201 | |
| 202 | public: |
| 203 | // public interface |
| 204 | UINT16 read(offs_t offset) { return read_full(offset); } |
| 205 | void write(offs_t offset, UINT16 data) { write_full(offset, data); } |
| 206 | |
| 207 | UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); } |
| 208 | void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); } |
| 209 | }; |
| 210 | |
| 211 | |
| 212 | // ======================> trivial variants |
| 213 | |
| 214 | // 8-bit variants |
| 215 | DECLARE_TRIVIAL_DERIVED_DEVICE(intel_28f016s5_device_config, intelfsh8_device_config, intel_28f016s5_device, intelfsh8_device) |
| 216 | DECLARE_TRIVIAL_DERIVED_DEVICE(fujitsu_29f016a_device_config, intelfsh8_device_config, fujitsu_29f016a_device, intelfsh8_device) |
| 217 | DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f016s_device_config, intelfsh8_device_config, sharp_lh28f016s_device, intelfsh8_device) |
| 218 | DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f008sa_device_config, intelfsh8_device_config, intel_e28f008sa_device, intelfsh8_device) |
| 219 | DECLARE_TRIVIAL_DERIVED_DEVICE(macronix_29l001mc_device_config, intelfsh8_device_config, macronix_29l001mc_device, intelfsh8_device) |
| 220 | DECLARE_TRIVIAL_DERIVED_DEVICE(panasonic_mn63f805mnp_device_config, intelfsh8_device_config, panasonic_mn63f805mnp_device, intelfsh8_device) |
| 221 | DECLARE_TRIVIAL_DERIVED_DEVICE(sanyo_le26fv10n1ts_device_config, intelfsh8_device_config, sanyo_le26fv10n1ts_device, intelfsh8_device) |
| 222 | |
| 223 | |
| 224 | // 16-bit variants |
| 225 | DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f400_device_config, intelfsh16_device_config, sharp_lh28f400_device, intelfsh16_device) |
| 226 | DECLARE_TRIVIAL_DERIVED_DEVICE(intel_te28f160_device_config, intelfsh16_device_config, intel_te28f160_device, intelfsh16_device) |
| 227 | DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f400_device_config, intelfsh16_device_config, intel_e28f400_device, intelfsh16_device) |
| 228 | DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_unk128mbit_device_config, intelfsh16_device_config, sharp_unk128mbit_device, intelfsh16_device) |
| 229 | |
| 230 | |
| 231 | |
| 232 | // device type definition |
| 233 | extern const device_type INTEL_28F016S5; |
| 234 | extern const device_type SHARP_LH28F016S; |
| 235 | extern const device_type FUJITSU_29F016A; |
| 236 | extern const device_type INTEL_E28F400; |
| 237 | extern const device_type MACRONIX_29L001MC; |
| 238 | extern const device_type PANASONIC_MN63F805MNP; |
| 239 | extern const device_type SANYO_LE26FV10N1TS; |
| 240 | |
| 241 | extern const device_type SHARP_LH28F400; |
| 242 | extern const device_type INTEL_E28F008SA; |
| 243 | extern const device_type INTEL_TE28F160; |
| 244 | extern const device_type SHARP_UNK128MBIT; |
| 245 | |
| 246 | |
| 28 | 247 | #endif |
src/emu/timer.c
| r9152 | r9153 | |
| 57 | 57 | attotime start; /* time when the timer was started */ |
| 58 | 58 | attotime expire; /* time when the timer will expire */ |
| 59 | 59 | device_t * device; /* for device timers, a pointer to the device */ |
| 60 | device_timer_id id; /* for device timers, the ID of the timer */ |
| 60 | 61 | }; |
| 61 | 62 | |
| 62 | 63 | |
| r9152 | r9153 | |
| 372 | 373 | if (was_enabled) |
| 373 | 374 | { |
| 374 | 375 | if (timer->device != NULL) |
| 375 | | timer->device->timer_fired(*timer, timer->param, timer->ptr); |
| 376 | timer->device->timer_fired(*timer, timer->id, timer->param, timer->ptr); |
| 376 | 377 | else if (timer->callback != NULL) |
| 377 | 378 | { |
| 378 | 379 | LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9))); |
| r9152 | r9153 | |
| 519 | 520 | state_save_register_item(timer->machine, "timer", timer->func, count, timer->start.attoseconds); |
| 520 | 521 | state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.seconds); |
| 521 | 522 | state_save_register_item(timer->machine, "timer", timer->func, count, timer->expire.attoseconds); |
| 523 | if (timer->device != NULL) |
| 524 | state_save_register_item(timer->machine, "timer", timer->func, count, timer->id); |
| 522 | 525 | } |
| 523 | 526 | |
| 524 | 527 | |
| r9152 | r9153 | |
| 594 | 597 | isn't primed yet |
| 595 | 598 | -------------------------------------------------*/ |
| 596 | 599 | |
| 597 | | INLINE emu_timer *_timer_alloc_common(running_machine *machine, timer_fired_func callback, void *ptr, const char *file, int line, const char *func, int temp) |
| 600 | INLINE emu_timer *_timer_alloc_common(running_machine *machine, device_t *device, device_timer_id id, timer_fired_func callback, void *ptr, const char *file, int line, const char *func, int temp) |
| 598 | 601 | { |
| 599 | 602 | attotime time = get_current_time(machine); |
| 600 | 603 | emu_timer *timer = timer_new(machine); |
| r9152 | r9153 | |
| 609 | 612 | timer->file = file; |
| 610 | 613 | timer->line = line; |
| 611 | 614 | timer->func = func; |
| 612 | | timer->device = NULL; |
| 615 | timer->device = device; |
| 616 | timer->id = id; |
| 613 | 617 | |
| 614 | 618 | /* compute the time of the next firing and insert into the list */ |
| 615 | 619 | timer->start = time; |
| r9152 | r9153 | |
| 630 | 634 | |
| 631 | 635 | emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func callback, void *ptr, const char *file, int line, const char *func) |
| 632 | 636 | { |
| 633 | | return _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE); |
| 637 | return _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE); |
| 634 | 638 | } |
| 635 | 639 | |
| 636 | | emu_timer *device_timer_alloc(device_t &device, void *ptr, int param) |
| 640 | emu_timer *device_timer_alloc(device_t &device, UINT32 id, void *ptr) |
| 637 | 641 | { |
| 638 | | emu_timer *timer = _timer_alloc_common(device.machine, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE); |
| 639 | | timer->param = param; |
| 640 | | timer->device = &device; |
| 641 | | return timer; |
| 642 | return _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), FALSE); |
| 642 | 643 | } |
| 643 | 644 | |
| 644 | 645 | |
| r9152 | r9153 | |
| 728 | 729 | SIMPLIFIED ANONYMOUS TIMER MANAGEMENT |
| 729 | 730 | ***************************************************************************/ |
| 730 | 731 | |
| 732 | void device_timer_call_after_resynch(device_t &device, device_timer_id id, INT32 param, void *ptr) |
| 733 | { |
| 734 | emu_timer *timer = _timer_alloc_common(device.machine, &device, id, NULL, ptr, __FILE__, __LINE__, device.tag(), TRUE); |
| 735 | timer_adjust_oneshot(timer, attotime_zero, param); |
| 736 | } |
| 737 | |
| 738 | |
| 731 | 739 | /*------------------------------------------------- |
| 732 | 740 | timer_pulse - allocate a pulse timer, which |
| 733 | 741 | repeatedly calls the callback using the given |
| r9152 | r9153 | |
| 736 | 744 | |
| 737 | 745 | void _timer_pulse_internal(running_machine *machine, attotime period, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func) |
| 738 | 746 | { |
| 739 | | emu_timer *timer = _timer_alloc_common(machine, callback, ptr, file, line, func, FALSE); |
| 747 | emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, FALSE); |
| 740 | 748 | timer_adjust_periodic(timer, period, param, period); |
| 741 | 749 | } |
| 742 | 750 | |
| r9152 | r9153 | |
| 748 | 756 | |
| 749 | 757 | void _timer_set_internal(running_machine *machine, attotime duration, void *ptr, INT32 param, timer_fired_func callback, const char *file, int line, const char *func) |
| 750 | 758 | { |
| 751 | | emu_timer *timer = _timer_alloc_common(machine, callback, ptr, file, line, func, TRUE); |
| 759 | emu_timer *timer = _timer_alloc_common(machine, NULL, 0, callback, ptr, file, line, func, TRUE); |
| 752 | 760 | timer_adjust_oneshot(timer, duration, param); |
| 753 | 761 | } |
| 754 | 762 | |
src/mess/drivers/pcw16.c
| r9152 | r9153 | |
| 192 | 192 | /* PCW16 Flash interface */ |
| 193 | 193 | /* PCW16 can have two 1mb flash chips */ |
| 194 | 194 | |
| 195 | | static NVRAM_HANDLER( pcw16 ) |
| 196 | | { |
| 197 | | nvram_handler_intelflash( machine, 0, file, read_or_write ); |
| 198 | | nvram_handler_intelflash( machine, 1, file, read_or_write ); |
| 199 | | } |
| 200 | | |
| 201 | 195 | /* read flash0 */ |
| 202 | | static int pcw16_flash0_bank_handler_r(int bank, int offset) |
| 196 | static int pcw16_flash0_bank_handler_r(running_machine *machine, int bank, int offset) |
| 203 | 197 | { |
| 204 | | int flash_offset = (pcw16_banks[bank]<<14) | offset; |
| 205 | | |
| 206 | | return intelflash_read(0, flash_offset); |
| 198 | intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash0"); |
| 199 | int flash_offset = (pcw16_banks[bank]<<14) | offset; |
| 200 | return flash->read(flash_offset); |
| 207 | 201 | } |
| 208 | 202 | |
| 209 | 203 | /* read flash1 */ |
| 210 | | static int pcw16_flash1_bank_handler_r(int bank, int offset) |
| 204 | static int pcw16_flash1_bank_handler_r(running_machine *machine, int bank, int offset) |
| 211 | 205 | { |
| 206 | intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash1"); |
| 212 | 207 | int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset; |
| 213 | 208 | |
| 214 | | return intelflash_read(1, flash_offset); |
| 209 | return flash->read(flash_offset); |
| 215 | 210 | } |
| 216 | 211 | |
| 217 | 212 | /* flash 0 */ |
| 218 | 213 | static READ8_HANDLER(pcw16_flash0_bank_handler0_r) |
| 219 | 214 | { |
| 220 | | return pcw16_flash0_bank_handler_r(0, offset); |
| 215 | return pcw16_flash0_bank_handler_r(space->machine,0, offset); |
| 221 | 216 | } |
| 222 | 217 | |
| 223 | 218 | static READ8_HANDLER(pcw16_flash0_bank_handler1_r) |
| 224 | 219 | { |
| 225 | | return pcw16_flash0_bank_handler_r(1, offset); |
| 220 | return pcw16_flash0_bank_handler_r(space->machine,1, offset); |
| 226 | 221 | } |
| 227 | 222 | |
| 228 | 223 | static READ8_HANDLER(pcw16_flash0_bank_handler2_r) |
| 229 | 224 | { |
| 230 | | return pcw16_flash0_bank_handler_r(2, offset); |
| 225 | return pcw16_flash0_bank_handler_r(space->machine,2, offset); |
| 231 | 226 | } |
| 232 | 227 | |
| 233 | 228 | static READ8_HANDLER(pcw16_flash0_bank_handler3_r) |
| 234 | 229 | { |
| 235 | | return pcw16_flash0_bank_handler_r(3, offset); |
| 230 | return pcw16_flash0_bank_handler_r(space->machine,3, offset); |
| 236 | 231 | } |
| 237 | 232 | |
| 238 | 233 | /* flash 1 */ |
| 239 | 234 | static READ8_HANDLER(pcw16_flash1_bank_handler0_r) |
| 240 | 235 | { |
| 241 | | return pcw16_flash1_bank_handler_r(0, offset); |
| 236 | return pcw16_flash1_bank_handler_r(space->machine,0, offset); |
| 242 | 237 | } |
| 243 | 238 | |
| 244 | 239 | static READ8_HANDLER(pcw16_flash1_bank_handler1_r) |
| 245 | 240 | { |
| 246 | | return pcw16_flash1_bank_handler_r(1, offset); |
| 241 | return pcw16_flash1_bank_handler_r(space->machine,1, offset); |
| 247 | 242 | } |
| 248 | 243 | |
| 249 | 244 | static READ8_HANDLER(pcw16_flash1_bank_handler2_r) |
| 250 | 245 | { |
| 251 | | return pcw16_flash1_bank_handler_r(2, offset); |
| 246 | return pcw16_flash1_bank_handler_r(space->machine,2, offset); |
| 252 | 247 | } |
| 253 | 248 | |
| 254 | 249 | static READ8_HANDLER(pcw16_flash1_bank_handler3_r) |
| 255 | 250 | { |
| 256 | | return pcw16_flash1_bank_handler_r(3, offset); |
| 251 | return pcw16_flash1_bank_handler_r(space->machine,3, offset); |
| 257 | 252 | } |
| 258 | 253 | |
| 259 | 254 | static const read8_space_func pcw16_flash0_bank_handlers_r[4] = |
| r9152 | r9153 | |
| 273 | 268 | }; |
| 274 | 269 | |
| 275 | 270 | /* write flash0 */ |
| 276 | | static void pcw16_flash0_bank_handler_w(int bank, int offset, int data) |
| 271 | static void pcw16_flash0_bank_handler_w(running_machine *machine, int bank, int offset, int data) |
| 277 | 272 | { |
| 273 | intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash0"); |
| 274 | |
| 278 | 275 | int flash_offset = (pcw16_banks[bank]<<14) | offset; |
| 279 | 276 | |
| 280 | | intelflash_write(0, flash_offset, data); |
| 277 | flash->write(flash_offset, data); |
| 281 | 278 | } |
| 282 | 279 | |
| 283 | 280 | /* read flash1 */ |
| 284 | | static void pcw16_flash1_bank_handler_w(int bank, int offset, int data) |
| 281 | static void pcw16_flash1_bank_handler_w(running_machine *machine, int bank, int offset, int data) |
| 285 | 282 | { |
| 283 | intel_e28f008sa_device *flash = machine->device<intel_e28f008sa_device>("flash1"); |
| 284 | |
| 286 | 285 | int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset; |
| 287 | 286 | |
| 288 | | intelflash_write(1, flash_offset,data); |
| 287 | flash->write(flash_offset,data); |
| 289 | 288 | } |
| 290 | 289 | |
| 291 | 290 | /* flash 0 */ |
| 292 | 291 | static WRITE8_HANDLER(pcw16_flash0_bank_handler0_w) |
| 293 | 292 | { |
| 294 | | pcw16_flash0_bank_handler_w(0, offset, data); |
| 293 | pcw16_flash0_bank_handler_w(space->machine,0, offset, data); |
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | |
| 298 | 297 | static WRITE8_HANDLER(pcw16_flash0_bank_handler1_w) |
| 299 | 298 | { |
| 300 | | pcw16_flash0_bank_handler_w(1, offset, data); |
| 299 | pcw16_flash0_bank_handler_w(space->machine,1, offset, data); |
| 301 | 300 | } |
| 302 | 301 | |
| 303 | 302 | static WRITE8_HANDLER(pcw16_flash0_bank_handler2_w) |
| 304 | 303 | { |
| 305 | | pcw16_flash0_bank_handler_w(2, offset, data); |
| 304 | pcw16_flash0_bank_handler_w(space->machine,2, offset, data); |
| 306 | 305 | } |
| 307 | 306 | |
| 308 | 307 | static WRITE8_HANDLER(pcw16_flash0_bank_handler3_w) |
| 309 | 308 | { |
| 310 | | pcw16_flash0_bank_handler_w(3, offset, data); |
| 309 | pcw16_flash0_bank_handler_w(space->machine,3, offset, data); |
| 311 | 310 | } |
| 312 | 311 | |
| 313 | 312 | |
| 314 | 313 | /* flash 1 */ |
| 315 | 314 | static WRITE8_HANDLER(pcw16_flash1_bank_handler0_w) |
| 316 | 315 | { |
| 317 | | pcw16_flash1_bank_handler_w(0, offset, data); |
| 316 | pcw16_flash1_bank_handler_w(space->machine,0, offset, data); |
| 318 | 317 | } |
| 319 | 318 | |
| 320 | 319 | |
| 321 | 320 | static WRITE8_HANDLER(pcw16_flash1_bank_handler1_w) |
| 322 | 321 | { |
| 323 | | pcw16_flash1_bank_handler_w(1, offset, data); |
| 322 | pcw16_flash1_bank_handler_w(space->machine,1, offset, data); |
| 324 | 323 | } |
| 325 | 324 | |
| 326 | 325 | static WRITE8_HANDLER(pcw16_flash1_bank_handler2_w) |
| 327 | 326 | { |
| 328 | | pcw16_flash1_bank_handler_w(2, offset, data); |
| 327 | pcw16_flash1_bank_handler_w(space->machine,2, offset, data); |
| 329 | 328 | } |
| 330 | 329 | |
| 331 | 330 | static WRITE8_HANDLER(pcw16_flash1_bank_handler3_w) |
| 332 | 331 | { |
| 333 | | pcw16_flash1_bank_handler_w(3, offset, data); |
| 332 | pcw16_flash1_bank_handler_w(space->machine,3, offset, data); |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | 335 | static const write8_space_func pcw16_flash0_bank_handlers_w[4] = |
| r9152 | r9153 | |
| 431 | 430 | { |
| 432 | 431 | /* nvram */ |
| 433 | 432 | if ((bank_id & 0x040)==0) |
| 434 | | { |
| 433 | { |
| 435 | 434 | mem_ptr = (unsigned char *)intelflash_getmemptr(0); |
| 436 | 435 | } |
| 437 | 436 | else |
| r9152 | r9153 | |
| 1399 | 1398 | MDRV_QUANTUM_TIME(HZ(60)) |
| 1400 | 1399 | |
| 1401 | 1400 | MDRV_MACHINE_START( pcw16 ) |
| 1402 | | MDRV_NVRAM_HANDLER( pcw16 ) |
| 1403 | 1401 | |
| 1404 | 1402 | MDRV_NS16550_ADD( "ns16550_1", pcw16_com_interface[0] ) /* TODO: Verify uart model */ |
| 1405 | 1403 | |
| r9152 | r9153 | |
| 1431 | 1429 | /* internal ram */ |
| 1432 | 1430 | MDRV_RAM_ADD("messram") |
| 1433 | 1431 | MDRV_RAM_DEFAULT_SIZE("2M") |
| 1432 | MDRV_INTEL_E28F008SA_ADD("flash0") |
| 1433 | MDRV_INTEL_E28F008SA_ADD("flash1") |
| 1434 | 1434 | MACHINE_CONFIG_END |
| 1435 | 1435 | |
| 1436 | | |
| 1437 | | static DRIVER_INIT( pcw16 ) |
| 1438 | | { |
| 1439 | | /* init flashes */ |
| 1440 | | intelflash_init(machine, 0, FLASH_INTEL_E28F008SA, NULL); |
| 1441 | | intelflash_init(machine, 1, FLASH_INTEL_E28F008SA, NULL); |
| 1442 | | } |
| 1443 | | |
| 1444 | 1436 | /*************************************************************************** |
| 1445 | 1437 | |
| 1446 | 1438 | Game driver(s) |
| r9152 | r9153 | |
| 1456 | 1448 | |
| 1457 | 1449 | |
| 1458 | 1450 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 1459 | | COMP( 1995, pcw16, 0, 0, pcw16, pcw16, pcw16, "Amstrad plc", "PCW16", GAME_NOT_WORKING ) |
| 1451 | COMP( 1995, pcw16, 0, 0, pcw16, pcw16, 0, "Amstrad plc", "PCW16", GAME_NOT_WORKING ) |