src/mess/machine/isa_fdc.c
| r0 | r10772 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | ISA 8 bit Floppy Disk Controller |
| 4 | |
| 5 | **********************************************************************/ |
| 6 | |
| 7 | #include "emu.h" |
| 8 | #include "machine/isa_fdc.h" |
| 9 | #include "machine/upd765.h" |
| 10 | #include "imagedev/flopdrv.h" |
| 11 | #include "formats/pc_dsk.h" |
| 12 | #include "memconv.h" |
| 13 | |
| 14 | static READ8_DEVICE_HANDLER ( pc_fdc_r ); |
| 15 | static WRITE8_DEVICE_HANDLER ( pc_fdc_w ); |
| 16 | |
| 17 | /* if not 1, DACK and TC inputs to FDC are disabled, and DRQ and IRQ are held |
| 18 | * at high impedance i.e they are not affective */ |
| 19 | #define PC_FDC_FLAGS_DOR_DMA_ENABLED (1<<3) |
| 20 | #define PC_FDC_FLAGS_DOR_FDC_ENABLED (1<<2) |
| 21 | #define PC_FDC_FLAGS_DOR_MOTOR_ON (1<<4) |
| 22 | |
| 23 | #define LOG_FDC 0 |
| 24 | |
| 25 | static const floppy_config ibmpc_floppy_config = |
| 26 | { |
| 27 | DEVCB_NULL, |
| 28 | DEVCB_NULL, |
| 29 | DEVCB_NULL, |
| 30 | DEVCB_NULL, |
| 31 | DEVCB_NULL, |
| 32 | FLOPPY_STANDARD_5_25_DSHD, |
| 33 | FLOPPY_OPTIONS_NAME(pc), |
| 34 | NULL |
| 35 | }; |
| 36 | |
| 37 | static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_interrupt ); |
| 38 | static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_dma_drq ); |
| 39 | |
| 40 | const upd765_interface pc_fdc_upd765_not_connected_interface = |
| 41 | { |
| 42 | DEVCB_LINE(pc_fdc_hw_interrupt), |
| 43 | DEVCB_LINE(pc_fdc_hw_dma_drq), |
| 44 | NULL, |
| 45 | UPD765_RDY_PIN_NOT_CONNECTED, |
| 46 | {FLOPPY_0, FLOPPY_1, NULL, NULL} |
| 47 | }; |
| 48 | |
| 49 | static MACHINE_CONFIG_FRAGMENT( fdc_config ) |
| 50 | MCFG_UPD765A_ADD("upd765", pc_fdc_upd765_not_connected_interface) |
| 51 | |
| 52 | MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config) |
| 53 | MACHINE_CONFIG_END |
| 54 | |
| 55 | //************************************************************************** |
| 56 | // GLOBAL VARIABLES |
| 57 | //************************************************************************** |
| 58 | |
| 59 | const device_type ISA8_FDC = isa8_fdc_device_config::static_alloc_device_config; |
| 60 | |
| 61 | //************************************************************************** |
| 62 | // DEVICE CONFIGURATION |
| 63 | //************************************************************************** |
| 64 | |
| 65 | //------------------------------------------------- |
| 66 | // isa8_fdc_device_config - constructor |
| 67 | //------------------------------------------------- |
| 68 | |
| 69 | isa8_fdc_device_config::isa8_fdc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 70 | : device_config(mconfig, static_alloc_device_config, "ISA8_FDC", tag, owner, clock), |
| 71 | device_config_isa8_card_interface(mconfig, *this) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | //------------------------------------------------- |
| 76 | // static_alloc_device_config - allocate a new |
| 77 | // configuration object |
| 78 | //------------------------------------------------- |
| 79 | |
| 80 | device_config *isa8_fdc_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 81 | { |
| 82 | return global_alloc(isa8_fdc_device_config(mconfig, tag, owner, clock)); |
| 83 | } |
| 84 | |
| 85 | //------------------------------------------------- |
| 86 | // alloc_device - allocate a new device object |
| 87 | //------------------------------------------------- |
| 88 | |
| 89 | device_t *isa8_fdc_device_config::alloc_device(running_machine &machine) const |
| 90 | { |
| 91 | return auto_alloc(&machine, isa8_fdc_device(machine, *this)); |
| 92 | } |
| 93 | |
| 94 | //------------------------------------------------- |
| 95 | // machine_config_additions - device-specific |
| 96 | // machine configurations |
| 97 | //------------------------------------------------- |
| 98 | |
| 99 | machine_config_constructor isa8_fdc_device_config::machine_config_additions() const |
| 100 | { |
| 101 | return MACHINE_CONFIG_NAME( fdc_config ); |
| 102 | } |
| 103 | |
| 104 | //************************************************************************** |
| 105 | // LIVE DEVICE |
| 106 | //************************************************************************** |
| 107 | |
| 108 | //------------------------------------------------- |
| 109 | // isa8_fdc_device - constructor |
| 110 | //------------------------------------------------- |
| 111 | |
| 112 | isa8_fdc_device::isa8_fdc_device(running_machine &_machine, const isa8_fdc_device_config &config) : |
| 113 | device_t(_machine, config), |
| 114 | device_isa8_card_interface( _machine, config, *this ), |
| 115 | m_config(config), |
| 116 | m_upd765(*this, "upd765"), |
| 117 | m_isa(*this->owner(), config.m_isa_tag) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | //------------------------------------------------- |
| 122 | // device_start - device-specific startup |
| 123 | //------------------------------------------------- |
| 124 | |
| 125 | void isa8_fdc_device::device_start() |
| 126 | { |
| 127 | m_isa->add_isa_card(this, m_config.m_isa_num); |
| 128 | m_isa->install_device(this, 0x03f0, 0x03f7, 0, 0, pc_fdc_r, pc_fdc_w ); |
| 129 | } |
| 130 | |
| 131 | //------------------------------------------------- |
| 132 | // device_reset - device-specific reset |
| 133 | //------------------------------------------------- |
| 134 | |
| 135 | void isa8_fdc_device::device_reset() |
| 136 | { |
| 137 | status_register_a = 0; |
| 138 | status_register_b = 0; |
| 139 | digital_output_register = 0; |
| 140 | tape_drive_register = 0; |
| 141 | data_rate_register = 2; |
| 142 | digital_input_register = 0x07f; |
| 143 | configuration_control_register = 0; |
| 144 | tc_state = 0; |
| 145 | dma_state = 0; |
| 146 | int_state = 0; |
| 147 | |
| 148 | upd765_reset(m_upd765,0); |
| 149 | |
| 150 | /* set FDC at reset */ |
| 151 | upd765_reset_w(m_upd765, 1); |
| 152 | } |
| 153 | |
| 154 | static WRITE_LINE_DEVICE_HANDLER( pc_fdc_set_tc_state) |
| 155 | { |
| 156 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 157 | /* store state */ |
| 158 | fdc->tc_state = state; |
| 159 | |
| 160 | /* if dma is not enabled, tc's are not acknowledged */ |
| 161 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 162 | { |
| 163 | upd765_tc_w(fdc->m_upd765, state); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_interrupt ) |
| 168 | { |
| 169 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device->owner()); |
| 170 | |
| 171 | fdc->int_state = state; |
| 172 | |
| 173 | /* if dma is not enabled, irq's are masked */ |
| 174 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)==0) |
| 175 | return; |
| 176 | |
| 177 | /* send irq */ |
| 178 | fdc->m_isa->set_irq_line(6, state); |
| 179 | } |
| 180 | |
| 181 | |
| 182 | static READ8_DEVICE_HANDLER(pc_fdc_dack_r) |
| 183 | { |
| 184 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 185 | /* what is output if dack is not acknowledged? */ |
| 186 | int data = 0x0ff; |
| 187 | |
| 188 | /* if dma is not enabled, dacks are not acknowledged */ |
| 189 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 190 | { |
| 191 | data = upd765_dack_r(fdc->m_upd765, 0); |
| 192 | } |
| 193 | |
| 194 | return data; |
| 195 | } |
| 196 | |
| 197 | |
| 198 | |
| 199 | static WRITE8_DEVICE_HANDLER(pc_fdc_dack_w) |
| 200 | { |
| 201 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 202 | /* if dma is not enabled, dacks are not issued */ |
| 203 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0) |
| 204 | { |
| 205 | /* dma acknowledge - and send byte to fdc */ |
| 206 | upd765_dack_w(fdc->m_upd765, 0,data); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | |
| 211 | |
| 212 | static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_dma_drq ) |
| 213 | { |
| 214 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device->owner()); |
| 215 | fdc->dma_state = state; |
| 216 | |
| 217 | /* if dma is not enabled, drqs are masked */ |
| 218 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)==0) |
| 219 | return; |
| 220 | |
| 221 | fdc->m_isa->set_dreq_line(2,state); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | |
| 226 | static WRITE8_DEVICE_HANDLER( pc_fdc_data_rate_w ) |
| 227 | { |
| 228 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 229 | if ((data & 0x080)!=0) |
| 230 | { |
| 231 | /* set ready state */ |
| 232 | upd765_ready_w(fdc->m_upd765,1); |
| 233 | |
| 234 | /* toggle reset state */ |
| 235 | upd765_reset_w(fdc->m_upd765, 1); |
| 236 | upd765_reset_w(fdc->m_upd765, 0); |
| 237 | |
| 238 | /* bit is self-clearing */ |
| 239 | data &= ~0x080; |
| 240 | } |
| 241 | |
| 242 | fdc->data_rate_register = data; |
| 243 | } |
| 244 | |
| 245 | |
| 246 | |
| 247 | /* FDC Digitial Output Register (DOR) |
| 248 | |
| 249 | |7|6|5|4|3|2|1|0| |
| 250 | | | | | | | `------ floppy drive select (0=A, 1=B, 2=floppy C, ...) |
| 251 | | | | | | `-------- 1 = FDC enable, 0 = hold FDC at reset |
| 252 | | | | | `---------- 1 = DMA & I/O interface enabled |
| 253 | | | | `------------ 1 = turn floppy drive A motor on |
| 254 | | | `-------------- 1 = turn floppy drive B motor on |
| 255 | | `---------------- 1 = turn floppy drive C motor on |
| 256 | `------------------ 1 = turn floppy drive D motor on |
| 257 | */ |
| 258 | |
| 259 | static WRITE8_DEVICE_HANDLER( pc_fdc_dor_w ) |
| 260 | { |
| 261 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 262 | int selected_drive; |
| 263 | int floppy_count; |
| 264 | |
| 265 | floppy_count = floppy_get_count(device->machine); |
| 266 | |
| 267 | if (floppy_count > (fdc->digital_output_register & 0x03)) |
| 268 | floppy_drive_set_ready_state(floppy_get_device(device->machine, fdc->digital_output_register & 0x03), 1, 0); |
| 269 | |
| 270 | fdc->digital_output_register = data; |
| 271 | |
| 272 | selected_drive = data & 0x03; |
| 273 | |
| 274 | /* set floppy drive motor state */ |
| 275 | if (floppy_count > 0) |
| 276 | floppy_mon_w(floppy_get_device(device->machine, 0), !BIT(data, 4)); |
| 277 | if (floppy_count > 1) |
| 278 | floppy_mon_w(floppy_get_device(device->machine, 1), !BIT(data, 5)); |
| 279 | if (floppy_count > 2) |
| 280 | floppy_mon_w(floppy_get_device(device->machine, 2), !BIT(data, 6)); |
| 281 | if (floppy_count > 3) |
| 282 | floppy_mon_w(floppy_get_device(device->machine, 3), !BIT(data, 7)); |
| 283 | |
| 284 | if ((data>>4) & (1<<selected_drive)) |
| 285 | { |
| 286 | if (floppy_count > selected_drive) |
| 287 | floppy_drive_set_ready_state(floppy_get_device(device->machine, selected_drive), 1, 0); |
| 288 | } |
| 289 | |
| 290 | /* changing the DMA enable bit, will affect the terminal count state |
| 291 | from reaching the fdc - if dma is enabled this will send it through |
| 292 | otherwise it will be ignored */ |
| 293 | pc_fdc_set_tc_state(device, fdc->tc_state); |
| 294 | |
| 295 | /* changing the DMA enable bit, will affect the dma drq state |
| 296 | from reaching us - if dma is enabled this will send it through |
| 297 | otherwise it will be ignored */ |
| 298 | pc_fdc_hw_dma_drq(fdc->m_upd765, fdc->dma_state); |
| 299 | |
| 300 | /* changing the DMA enable bit, will affect the irq state |
| 301 | from reaching us - if dma is enabled this will send it through |
| 302 | otherwise it will be ignored */ |
| 303 | pc_fdc_hw_interrupt(fdc->m_upd765, fdc->int_state); |
| 304 | |
| 305 | /* reset? */ |
| 306 | if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_FDC_ENABLED)==0) |
| 307 | { |
| 308 | /* yes */ |
| 309 | |
| 310 | /* pc-xt expects a interrupt to be generated |
| 311 | when the fdc is reset. |
| 312 | In the FDC docs, it states that a INT will |
| 313 | be generated if READY input is true when the |
| 314 | fdc is reset. |
| 315 | |
| 316 | It also states, that outputs to drive are set to 0. |
| 317 | Maybe this causes the drive motor to go on, and therefore |
| 318 | the ready line is set. |
| 319 | |
| 320 | This in return causes a int?? --- |
| 321 | |
| 322 | |
| 323 | what is not yet clear is if this is a result of the drives ready state |
| 324 | changing... |
| 325 | */ |
| 326 | upd765_ready_w(fdc->m_upd765, 1); |
| 327 | |
| 328 | /* set FDC at reset */ |
| 329 | upd765_reset_w(fdc->m_upd765, 1); |
| 330 | } |
| 331 | else |
| 332 | { |
| 333 | pc_fdc_set_tc_state(device, 0); |
| 334 | |
| 335 | /* release reset on fdc */ |
| 336 | upd765_reset_w(fdc->m_upd765, 0); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | static READ8_DEVICE_HANDLER ( pc_fdc_r ) |
| 341 | { |
| 342 | UINT8 data = 0xff; |
| 343 | |
| 344 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 345 | |
| 346 | switch(offset) |
| 347 | { |
| 348 | case 0: /* status register a */ |
| 349 | case 1: /* status register b */ |
| 350 | data = 0x00; |
| 351 | case 2: |
| 352 | data = fdc->digital_output_register; |
| 353 | break; |
| 354 | case 3: /* tape drive select? */ |
| 355 | break; |
| 356 | case 4: |
| 357 | data = upd765_status_r(fdc->m_upd765, 0); |
| 358 | break; |
| 359 | case 5: |
| 360 | data = upd765_data_r(fdc->m_upd765, offset); |
| 361 | break; |
| 362 | case 6: /* FDC reserved */ |
| 363 | break; |
| 364 | case 7: |
| 365 | data = fdc->digital_input_register; |
| 366 | break; |
| 367 | } |
| 368 | |
| 369 | if (LOG_FDC) |
| 370 | logerror("pc_fdc_r(): pc=0x%08x offset=%d result=0x%02X\n", (unsigned) cpu_get_reg(device->machine->firstcpu,STATE_GENPC), offset, data); |
| 371 | return data; |
| 372 | } |
| 373 | |
| 374 | |
| 375 | |
| 376 | static WRITE8_DEVICE_HANDLER ( pc_fdc_w ) |
| 377 | { |
| 378 | isa8_fdc_device *fdc = downcast<isa8_fdc_device *>(device); |
| 379 | |
| 380 | if (LOG_FDC) |
| 381 | logerror("pc_fdc_w(): pc=0x%08x offset=%d data=0x%02X\n", (unsigned) cpu_get_reg(device->machine->firstcpu,STATE_GENPC), offset, data); |
| 382 | |
| 383 | switch(offset) |
| 384 | { |
| 385 | case 0: /* n/a */ |
| 386 | case 1: /* n/a */ |
| 387 | break; |
| 388 | case 2: |
| 389 | pc_fdc_dor_w(device, 0, data); |
| 390 | break; |
| 391 | case 3: |
| 392 | /* tape drive select? */ |
| 393 | break; |
| 394 | case 4: |
| 395 | pc_fdc_data_rate_w(device, 0, data); |
| 396 | break; |
| 397 | case 5: |
| 398 | upd765_data_w(fdc->m_upd765, 0, data); |
| 399 | break; |
| 400 | case 6: |
| 401 | /* FDC reserved */ |
| 402 | break; |
| 403 | case 7: |
| 404 | /* Configuration Control Register |
| 405 | * |
| 406 | * Currently unimplemented; bits 1-0 are supposed to control data |
| 407 | * flow rates: |
| 408 | * 0 0 500 kbps |
| 409 | * 0 1 300 kbps |
| 410 | * 1 0 250 kbps |
| 411 | * 1 1 1000 kbps |
| 412 | */ |
| 413 | break; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | UINT8 isa8_fdc_device::dack_r(int line) |
| 418 | { |
| 419 | return pc_fdc_dack_r(this,0); |
| 420 | } |
| 421 | void isa8_fdc_device::dack_w(int line,UINT8 data) |
| 422 | { |
| 423 | pc_fdc_dack_w( this, 0, data ); |
| 424 | } |
| 425 | void isa8_fdc_device::eop_w(int state) |
| 426 | { |
| 427 | pc_fdc_set_tc_state( this, state); |
| 428 | } |
| 429 | |
| 430 | bool isa8_fdc_device::have_dack(int line) |
| 431 | { |
| 432 | if (line==2) return TRUE; |
| 433 | return FALSE; |
| 434 | } |
src/mess/machine/isa.c
| r10771 | r10772 | |
| 6 | 6 | |
| 7 | 7 | #include "emu.h" |
| 8 | 8 | #include "machine/isa.h" |
| 9 | #include "machine/pic8259.h" |
| 10 | #include "machine/8237dma.h" |
| 11 | |
| 9 | 12 | |
| 10 | 13 | |
| 11 | 14 | //************************************************************************** |
| r10771 | r10772 | |
| 51 | 54 | isa8_device_config *isa = downcast<isa8_device_config *>(device); |
| 52 | 55 | isa->m_cputag = tag; |
| 53 | 56 | } |
| 57 | void isa8_device_config::static_set_dmatag(device_config *device, const char *tag) |
| 58 | { |
| 59 | isa8_device_config *isa = downcast<isa8_device_config *>(device); |
| 60 | isa->m_dmatag = tag; |
| 61 | } |
| 62 | void isa8_device_config::static_set_pictag(device_config *device, const char *tag) |
| 63 | { |
| 64 | isa8_device_config *isa = downcast<isa8_device_config *>(device); |
| 65 | isa->m_pictag = tag; |
| 66 | } |
| 54 | 67 | |
| 55 | 68 | //************************************************************************** |
| 56 | 69 | // LIVE DEVICE |
| r10771 | r10772 | |
| 62 | 75 | |
| 63 | 76 | isa8_device::isa8_device(running_machine &_machine, const isa8_device_config &config) : |
| 64 | 77 | device_t(_machine, config), |
| 65 | | m_config(config) |
| 78 | m_config(config), |
| 79 | m_maincpu(NULL), |
| 80 | m_pic8259(NULL), |
| 81 | m_dma8237(NULL) |
| 66 | 82 | { |
| 83 | for(int i=0;i<8;i++) |
| 84 | m_isa_device[i] = NULL; |
| 67 | 85 | } |
| 68 | 86 | |
| 69 | 87 | //------------------------------------------------- |
| r10771 | r10772 | |
| 72 | 90 | |
| 73 | 91 | void isa8_device::device_start() |
| 74 | 92 | { |
| 75 | | device_t *cpu = m_machine.device(m_config.m_cputag); |
| 76 | | m_space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); |
| 93 | m_maincpu = m_machine.device(m_config.m_cputag); |
| 94 | m_pic8259 = m_machine.device(m_config.m_pictag); |
| 95 | m_dma8237 = m_machine.device(m_config.m_dmatag); |
| 77 | 96 | } |
| 78 | 97 | |
| 79 | 98 | //------------------------------------------------- |
| 80 | 99 | // device_reset - device-specific reset |
| 81 | 100 | //------------------------------------------------- |
| 82 | | |
| 101 | |
| 83 | 102 | void isa8_device::device_reset() |
| 84 | 103 | { |
| 85 | 104 | } |
| 86 | 105 | |
| 106 | void isa8_device::add_isa_card(device_isa8_card_interface *card,int pos) |
| 107 | { |
| 108 | m_isa_device[pos] = card; |
| 109 | } |
| 87 | 110 | |
| 111 | void isa8_device::install_device(device_t *dev, offs_t start, offs_t end, offs_t mask, offs_t mirror, read8_device_func rhandler, write8_device_func whandler) |
| 112 | { |
| 113 | int buswidth = device_memory(m_maincpu)->space_config(AS_PROGRAM)->m_databus_width; |
| 114 | switch(buswidth) |
| 115 | { |
| 116 | case 8: |
| 117 | memory_install_readwrite8_device_handler(cpu_get_address_space(m_maincpu, ADDRESS_SPACE_IO), dev, start, end, mask, mirror, rhandler, whandler ); |
| 118 | break; |
| 119 | |
| 120 | default: |
| 121 | fatalerror("ISA8: Bus width %d not supported", buswidth); |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | void isa8_device::install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data) |
| 127 | { |
| 128 | address_space *space = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM); |
| 129 | memory_install_readwrite_bank(space, start, end, mask, mirror, tag ); |
| 130 | memory_set_bankptr(&m_machine, tag, data); |
| 131 | } |
| 132 | |
| 133 | void isa8_device::set_irq_line(int irq, int state) |
| 134 | { |
| 135 | switch (irq) |
| 136 | { |
| 137 | case 0: pic8259_ir0_w(m_pic8259, state); break; |
| 138 | case 1: pic8259_ir1_w(m_pic8259, state); break; |
| 139 | case 2: pic8259_ir2_w(m_pic8259, state); break; |
| 140 | case 3: pic8259_ir3_w(m_pic8259, state); break; |
| 141 | case 4: pic8259_ir4_w(m_pic8259, state); break; |
| 142 | case 5: pic8259_ir5_w(m_pic8259, state); break; |
| 143 | case 6: pic8259_ir6_w(m_pic8259, state); break; |
| 144 | case 7: pic8259_ir7_w(m_pic8259, state); break; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | void isa8_device::set_dreq_line(int line, int state) |
| 149 | { |
| 150 | switch (line) |
| 151 | { |
| 152 | case 0: i8237_dreq0_w(m_dma8237, state); break; |
| 153 | case 1: i8237_dreq1_w(m_dma8237, state); break; |
| 154 | case 2: i8237_dreq2_w(m_dma8237, state); break; |
| 155 | case 3: i8237_dreq3_w(m_dma8237, state); break; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | UINT8 isa8_device::dack_r(int line) |
| 160 | { |
| 161 | UINT8 retVal = 0xff; |
| 162 | for(int i=0;i<8;i++) { |
| 163 | if (m_isa_device[i] != NULL && m_isa_device[i]->have_dack(line)) { |
| 164 | retVal = m_isa_device[i]->dack_r(line); |
| 165 | } |
| 166 | } |
| 167 | return retVal; |
| 168 | } |
| 169 | void isa8_device::dack_w(int line,UINT8 data) |
| 170 | { |
| 171 | for(int i=0;i<8;i++) { |
| 172 | if (m_isa_device[i] != NULL && m_isa_device[i]->have_dack(line)) { |
| 173 | m_isa_device[i]->dack_w(line,data); |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | void isa8_device::eop_w(int state) |
| 178 | { |
| 179 | for(int i=0;i<8;i++) { |
| 180 | if (m_isa_device[i] != NULL) m_isa_device[i]->eop_w(state); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | |
| 88 | 185 | //************************************************************************** |
| 89 | 186 | // DEVICE CONFIG ISA8 CARD INTERFACE |
| 90 | 187 | //************************************************************************** |
| r10771 | r10772 | |
| 142 | 239 | device_isa8_card_interface::~device_isa8_card_interface() |
| 143 | 240 | { |
| 144 | 241 | } |
| 242 | |
| 243 | UINT8 device_isa8_card_interface::dack_r(int line) |
| 244 | { |
| 245 | return 0; |
| 246 | } |
| 247 | void device_isa8_card_interface::dack_w(int line,UINT8 data) |
| 248 | { |
| 249 | } |
| 250 | void device_isa8_card_interface::eop_w(int state) |
| 251 | { |
| 252 | } |
| 253 | |
| 254 | bool device_isa8_card_interface::have_dack(int line) |
| 255 | { |
| 256 | return FALSE; |
| 257 | } |
src/mess/machine/isa.h
| r10771 | r10772 | |
| 16 | 16 | // INTERFACE CONFIGURATION MACROS |
| 17 | 17 | //************************************************************************** |
| 18 | 18 | |
| 19 | | #define MCFG_ISA8_BUS_ADD(_tag, _cputag) \ |
| 19 | #define MCFG_ISA8_BUS_ADD(_tag, _cputag, _dmatag, _pictag) \ |
| 20 | 20 | MCFG_DEVICE_ADD(_tag, ISA8, 0) \ |
| 21 | 21 | isa8_device_config::static_set_cputag(device, _cputag); \ |
| 22 | isa8_device_config::static_set_dmatag(device, _dmatag); \ |
| 23 | isa8_device_config::static_set_pictag(device, _pictag); \ |
| 22 | 24 | |
| 23 | 25 | #define MCFG_ISA8_BUS_DEVICE(_isatag, _num, _tag, _dev_type) \ |
| 24 | 26 | MCFG_DEVICE_ADD(_tag, _dev_type, 0) \ |
| r10771 | r10772 | |
| 46 | 48 | |
| 47 | 49 | // inline configuration |
| 48 | 50 | static void static_set_cputag(device_config *device, const char *tag); |
| 51 | static void static_set_dmatag(device_config *device, const char *tag); |
| 52 | static void static_set_pictag(device_config *device, const char *tag); |
| 49 | 53 | |
| 50 | 54 | const char *m_cputag; |
| 55 | const char *m_dmatag; |
| 56 | const char *m_pictag; |
| 51 | 57 | }; |
| 52 | 58 | |
| 53 | 59 | |
| 54 | 60 | // ======================> isa8_device |
| 55 | | |
| 61 | class device_isa8_card_interface; |
| 56 | 62 | class isa8_device : public device_t |
| 57 | 63 | { |
| 58 | 64 | friend class isa8_device_config; |
| 59 | 65 | |
| 60 | 66 | // construction/destruction |
| 61 | 67 | isa8_device(running_machine &_machine, const isa8_device_config &config); |
| 68 | public: |
| 69 | void add_isa_card(device_isa8_card_interface *card,int pos); |
| 70 | void install_device(device_t *dev, offs_t start, offs_t end, offs_t mask, offs_t mirror, read8_device_func rhandler, write8_device_func whandler); |
| 71 | void install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data); |
| 62 | 72 | |
| 73 | void set_irq_line(int irq, int state); |
| 74 | void set_dreq_line(int line, int state); |
| 75 | |
| 76 | UINT8 dack_r(int line); |
| 77 | void dack_w(int line,UINT8 data); |
| 78 | void eop_w(int state); |
| 63 | 79 | protected: |
| 64 | 80 | // device-level overrides |
| 65 | 81 | virtual void device_start(); |
| r10771 | r10772 | |
| 69 | 85 | // internal state |
| 70 | 86 | const isa8_device_config &m_config; |
| 71 | 87 | |
| 72 | | address_space *m_space; |
| 88 | device_t *m_maincpu; |
| 89 | device_t *m_pic8259; |
| 90 | device_t *m_dma8237; |
| 91 | |
| 92 | device_isa8_card_interface *m_isa_device[8]; |
| 73 | 93 | }; |
| 74 | 94 | |
| 75 | 95 | |
| r10771 | r10772 | |
| 82 | 102 | // class representing interface-specific configuration isa8 card |
| 83 | 103 | class device_config_isa8_card_interface : public device_config_interface |
| 84 | 104 | { |
| 105 | friend class device_isa8_card_interface; |
| 85 | 106 | public: |
| 86 | 107 | // construction/destruction |
| 87 | 108 | device_config_isa8_card_interface(const machine_config &mconfig, device_config &device); |
| r10771 | r10772 | |
| 100 | 121 | // class representing interface-specific live isa8 card |
| 101 | 122 | class device_isa8_card_interface : public device_interface |
| 102 | 123 | { |
| 124 | friend class isa8_device; |
| 125 | friend class device_config_isa8_card_interface; |
| 103 | 126 | public: |
| 104 | 127 | // construction/destruction |
| 105 | 128 | device_isa8_card_interface(running_machine &machine, const device_config &config, device_t &device); |
| r10771 | r10772 | |
| 107 | 130 | |
| 108 | 131 | // configuration access |
| 109 | 132 | const device_config_isa8_card_interface &isa8_card_config() const { return m_isa8_card_config; } |
| 110 | | |
| 133 | |
| 134 | virtual UINT8 dack_r(int line); |
| 135 | virtual void dack_w(int line,UINT8 data); |
| 136 | virtual void eop_w(int state); |
| 137 | virtual bool have_dack(int line); |
| 111 | 138 | protected: |
| 112 | 139 | |
| 113 | 140 | // configuration |
| 114 | | const device_config_isa8_card_interface &m_isa8_card_config; // reference to our device_config_execute_interface |
| 141 | const device_config_isa8_card_interface &m_isa8_card_config; // reference to our device_config_execute_interface |
| 115 | 142 | }; |
| 116 | 143 | |
| 117 | 144 | #endif /* __ISA_H__ */ |
src/mess/video/isa_mda.c
| r10771 | r10772 | |
| 179 | 179 | isa8_mda_device::isa8_mda_device(running_machine &_machine, const isa8_mda_device_config &config) : |
| 180 | 180 | device_t(_machine, config), |
| 181 | 181 | device_isa8_card_interface( _machine, config, *this ), |
| 182 | | m_config(config) |
| 182 | m_config(config), |
| 183 | m_isa(*this->owner(), config.m_isa_tag) |
| 183 | 184 | { |
| 184 | 185 | } |
| 185 | 186 | |
| r10771 | r10772 | |
| 189 | 190 | |
| 190 | 191 | void isa8_mda_device::device_start() |
| 191 | 192 | { |
| 192 | | int buswidth; |
| 193 | | address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 194 | | |
| 195 | | buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width; |
| 196 | | switch(buswidth) |
| 197 | | { |
| 198 | | case 8: |
| 199 | | memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank_mda" ); |
| 200 | | memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w ); |
| 201 | | break; |
| 202 | | |
| 203 | | default: |
| 204 | | fatalerror("MDA: Bus width %d not supported", buswidth); |
| 205 | | break; |
| 206 | | } |
| 207 | | |
| 193 | m_isa->add_isa_card(this, m_config.m_isa_num); |
| 208 | 194 | videoram = auto_alloc_array(machine, UINT8, 0x1000); |
| 195 | m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w ); |
| 196 | m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", videoram); |
| 209 | 197 | |
| 210 | | memory_set_bankptr(machine,"bank_mda", videoram); |
| 211 | | |
| 212 | 198 | /* Initialise the mda palette */ |
| 213 | 199 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| 214 | 200 | palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]); |
| r10771 | r10772 | |
| 643 | 629 | |
| 644 | 630 | void isa8_hercules_device::device_start() |
| 645 | 631 | { |
| 646 | | int buswidth; |
| 647 | | address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 648 | | |
| 649 | | buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width; |
| 650 | | switch(buswidth) |
| 651 | | { |
| 652 | | case 8: |
| 653 | | memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank_hercules" ); |
| 654 | | memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w ); |
| 655 | | break; |
| 656 | | |
| 657 | | default: |
| 658 | | fatalerror("MDA: Bus width %d not supported", buswidth); |
| 659 | | break; |
| 660 | | } |
| 661 | | |
| 662 | 632 | videoram = auto_alloc_array(machine, UINT8, 0x10000); |
| 663 | | |
| 664 | | memory_set_bankptr(machine,"bank_hercules", videoram); |
| 665 | 633 | |
| 634 | m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w ); |
| 635 | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", videoram); |
| 636 | |
| 666 | 637 | /* Initialise the mda palette */ |
| 667 | 638 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| 668 | 639 | palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]); |