src/mess/machine/isa_ide_cd.c
| r0 | r14719 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | ISA 16 bit IDE controller
|
| 4 | |
| 5 | ***************************************************************************/
|
| 6 | |
| 7 | #include "emu.h"
|
| 8 | #include "isa_ide_cd.h"
|
| 9 | |
| 10 | static void atapi_irq(device_t *device, int state)
|
| 11 | {
|
| 12 | isa16_ide_cd_device *ide = downcast<isa16_ide_cd_device *>(device);
|
| 13 | if (ide->is_primary()) {
|
| 14 | ide->m_isa->irq14_w(state);
|
| 15 | } else {
|
| 16 | ide->m_isa->irq15_w(state);
|
| 17 | }
|
| 18 | }
|
| 19 | |
| 20 | WRITE16_MEMBER( isa16_ide_cd_device::atapi_cmd_w )
|
| 21 | {
|
| 22 | }
|
| 23 | READ16_MEMBER( isa16_ide_cd_device::atapi_status_r )
|
| 24 | {
|
| 25 | UINT8 *atapi_regs = m_atapi_regs;
|
| 26 | int shift;
|
| 27 | shift = 0;
|
| 28 | int reg = offset<<1;
|
| 29 | switch(mem_mask)
|
| 30 | {
|
| 31 | case 0x000000ff:
|
| 32 | break;
|
| 33 | case 0x0000ff00:
|
| 34 | reg+=1;
|
| 35 | shift=8;
|
| 36 | break;
|
| 37 | }
|
| 38 | UINT32 data = atapi_regs[ATAPI_REG_CMDSTATUS];
|
| 39 | data <<= shift;
|
| 40 | return data;
|
| 41 | }
|
| 42 | |
| 43 | READ16_MEMBER( isa16_ide_cd_device::atapi_r )
|
| 44 | {
|
| 45 | UINT8 *atapi_regs = m_atapi_regs;
|
| 46 | //running_machine &machine = machine();
|
| 47 | int reg, data;
|
| 48 | if (mem_mask == 0x0000ffff) // word-wide command read
|
| 49 | {
|
| 50 | logerror("ATAPI: packet read = %04x\n", m_atapi_data[m_atapi_data_ptr]);
|
| 51 | |
| 52 | // assert IRQ and drop DRQ
|
| 53 | if (m_atapi_data_ptr == 0 && m_atapi_data_len == 0)
|
| 54 | {
|
| 55 | // get the data from the device
|
| 56 | if( m_atapi_xferlen > 0 )
|
| 57 | {
|
| 58 | SCSIReadData( m_inserted_cdrom, m_atapi_data, m_atapi_xferlen );
|
| 59 | m_atapi_data_len = m_atapi_xferlen;
|
| 60 | }
|
| 61 | |
| 62 | if (m_atapi_xfermod > MAX_TRANSFER_SIZE)
|
| 63 | {
|
| 64 | m_atapi_xferlen = MAX_TRANSFER_SIZE;
|
| 65 | m_atapi_xfermod = m_atapi_xfermod - MAX_TRANSFER_SIZE;
|
| 66 | }
|
| 67 | else
|
| 68 | {
|
| 69 | m_atapi_xferlen = m_atapi_xfermod;
|
| 70 | m_atapi_xfermod = 0;
|
| 71 | }
|
| 72 | |
| 73 | //verboselog\\( machine, 2, "atapi_r: atapi_xferlen=%d\n", m_atapi_xferlen );
|
| 74 | if( m_atapi_xferlen != 0 )
|
| 75 | {
|
| 76 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
|
| 77 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
|
| 78 | }
|
| 79 | else
|
| 80 | {
|
| 81 | logerror("ATAPI: dropping DRQ\n");
|
| 82 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 83 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
|
| 84 | }
|
| 85 | |
| 86 | atapi_regs[ATAPI_REG_COUNTLOW] = m_atapi_xferlen & 0xff;
|
| 87 | atapi_regs[ATAPI_REG_COUNTHIGH] = (m_atapi_xferlen>>8)&0xff;
|
| 88 | |
| 89 | atapi_irq(this, ASSERT_LINE);
|
| 90 | }
|
| 91 | |
| 92 | if( m_atapi_data_ptr < m_atapi_data_len )
|
| 93 | {
|
| 94 | data = m_atapi_data[m_atapi_data_ptr++];
|
| 95 | data |= ( m_atapi_data[m_atapi_data_ptr++] << 8 );
|
| 96 | if( m_atapi_data_ptr >= m_atapi_data_len )
|
| 97 | {
|
| 98 | |
| 99 | m_atapi_data_ptr = 0;
|
| 100 | m_atapi_data_len = 0;
|
| 101 | |
| 102 | if( m_atapi_xferlen == 0 )
|
| 103 | {
|
| 104 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 105 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
|
| 106 | atapi_irq(this, ASSERT_LINE);
|
| 107 | }
|
| 108 | }
|
| 109 | }
|
| 110 | else
|
| 111 | {
|
| 112 | data = 0;
|
| 113 | }
|
| 114 | }
|
| 115 | else
|
| 116 | {
|
| 117 | atapi_irq(this, CLEAR_LINE);
|
| 118 | int shift;
|
| 119 | shift = 0;
|
| 120 | reg = offset<<1;
|
| 121 | switch(mem_mask)
|
| 122 | {
|
| 123 | case 0x000000ff:
|
| 124 | break;
|
| 125 | case 0x0000ff00:
|
| 126 | reg+=1;
|
| 127 | shift=8;
|
| 128 | break;
|
| 129 | }
|
| 130 | data = atapi_regs[reg];
|
| 131 | logerror("ATAPI: reg %d = %x (offset %x mask %x) [read]\n", reg, data, offset, mem_mask); |
| 132 | data <<= shift;
|
| 133 | }
|
| 134 | return data;
|
| 135 | }
|
| 136 | |
| 137 | WRITE16_MEMBER( isa16_ide_cd_device::atapi_w )
|
| 138 | {
|
| 139 | UINT8 *atapi_regs = m_atapi_regs;
|
| 140 | UINT8 *atapi_data = m_atapi_data;
|
| 141 | int reg;
|
| 142 | if (mem_mask == 0x0000ffff) // word-wide command write
|
| 143 | {
|
| 144 | atapi_data[m_atapi_data_ptr++] = data & 0xff;
|
| 145 | atapi_data[m_atapi_data_ptr++] = data >> 8;
|
| 146 | |
| 147 | if (m_atapi_cdata_wait)
|
| 148 | {
|
| 149 | logerror("ATAPI: waiting, ptr %d wait %d\n", m_atapi_data_ptr, m_atapi_cdata_wait);
|
| 150 | if (m_atapi_data_ptr == m_atapi_cdata_wait)
|
| 151 | {
|
| 152 | // send it to the device
|
| 153 | SCSIWriteData( m_inserted_cdrom, atapi_data, m_atapi_cdata_wait );
|
| 154 | |
| 155 | // assert IRQ
|
| 156 | atapi_irq(this, ASSERT_LINE);
|
| 157 | |
| 158 | // not sure here, but clear DRQ at least?
|
| 159 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 160 | }
|
| 161 | }
|
| 162 | |
| 163 | else if ( m_atapi_data_ptr == 12 )
|
| 164 | {
|
| 165 | int phase;
|
| 166 | // reset data pointer for reading SCSI results
|
| 167 | m_atapi_data_ptr = 0;
|
| 168 | m_atapi_data_len = 0;
|
| 169 | |
| 170 | // send it to the SCSI device
|
| 171 | SCSISetCommand( m_inserted_cdrom, m_atapi_data, 12 );
|
| 172 | SCSIExecCommand( m_inserted_cdrom, &m_atapi_xferlen );
|
| 173 | SCSIGetPhase( m_inserted_cdrom, &phase );
|
| 174 | |
| 175 | if (m_atapi_xferlen != -1)
|
| 176 | {
|
| 177 | logerror("ATAPI: SCSI command %02x returned %d bytes from the device\n", atapi_data[0]&0xff, m_atapi_xferlen);
|
| 178 | // store the returned command length in the ATAPI regs, splitting into
|
| 179 | // multiple transfers if necessary
|
| 180 | m_atapi_xfermod = 0;
|
| 181 | if (m_atapi_xferlen > MAX_TRANSFER_SIZE)
|
| 182 | {
|
| 183 | m_atapi_xfermod = m_atapi_xferlen - MAX_TRANSFER_SIZE;
|
| 184 | m_atapi_xferlen = MAX_TRANSFER_SIZE;
|
| 185 | }
|
| 186 |
|
| 187 | atapi_regs[ATAPI_REG_COUNTLOW] = m_atapi_xferlen & 0xff;
|
| 188 | atapi_regs[ATAPI_REG_COUNTHIGH] = (m_atapi_xferlen>>8)&0xff;
|
| 189 | |
| 190 | if (m_atapi_xferlen == 0)
|
| 191 | {
|
| 192 | // if no data to return, set the registers properly
|
| 193 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY;
|
| 194 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO|ATAPI_INTREASON_COMMAND;
|
| 195 | }
|
| 196 | else
|
| 197 | {
|
| 198 | // indicate data ready: set DRQ and DMA ready, and IO in INTREASON
|
| 199 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
|
| 200 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
|
| 201 | }
|
| 202 | |
| 203 | switch( phase )
|
| 204 | {
|
| 205 | case SCSI_PHASE_DATAOUT:
|
| 206 | m_atapi_cdata_wait = m_atapi_xferlen;
|
| 207 | break;
|
| 208 | }
|
| 209 | |
| 210 | // perform special ATAPI processing of certain commands
|
| 211 | switch (atapi_data[0]&0xff)
|
| 212 | {
|
| 213 | case 0x00: // BUS RESET / TEST UNIT READY
|
| 214 | case 0xbb: // SET CDROM SPEED
|
| 215 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 216 | break;
|
| 217 | |
| 218 | case 0x45: // PLAY
|
| 219 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY;
|
| 220 | //m_atapi_timer->adjust( downcast<cpu_device *>(this)->cycles_to_attotime( ATAPI_CYCLES_PER_SECTOR ) );
|
| 221 | break;
|
| 222 | }
|
| 223 | |
| 224 | // assert IRQ
|
| 225 | atapi_irq(this, ASSERT_LINE);
|
| 226 | logerror("IRQ\n");
|
| 227 | }
|
| 228 | else
|
| 229 | {
|
| 230 | logerror("ATAPI: SCSI device returned error!\n");
|
| 231 | |
| 232 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_CHECK;
|
| 233 | atapi_regs[ATAPI_REG_ERRFEAT] = 0x50; // sense key = ILLEGAL REQUEST
|
| 234 | atapi_regs[ATAPI_REG_COUNTLOW] = 0;
|
| 235 | atapi_regs[ATAPI_REG_COUNTHIGH] = 0;
|
| 236 | }
|
| 237 | }
|
| 238 | }
|
| 239 | else
|
| 240 | {
|
| 241 | reg = offset<<1;
|
| 242 | switch(mem_mask)
|
| 243 | {
|
| 244 | case 0x000000ff:
|
| 245 | break;
|
| 246 | case 0x0000ff00:
|
| 247 | reg+=1;
|
| 248 | data >>= 8;
|
| 249 | break;
|
| 250 | }
|
| 251 | |
| 252 | atapi_regs[reg] = data;
|
| 253 | logerror("ATAPI: reg %d = %x (offset %x mask %x)\n", reg, data, offset, mem_mask);
|
| 254 | |
| 255 | if (reg == ATAPI_REG_CMDSTATUS)
|
| 256 | {
|
| 257 | logerror("ATAPI command %x issued!\n", data);
|
| 258 | switch (data)
|
| 259 | {
|
| 260 | case 0xa0: // PACKET
|
| 261 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ;
|
| 262 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_COMMAND;
|
| 263 | |
| 264 | m_atapi_data_ptr = 0;
|
| 265 | m_atapi_data_len = 0;
|
| 266 | |
| 267 | /* we have no data */
|
| 268 | m_atapi_xferlen = 0;
|
| 269 | m_atapi_xfermod = 0;
|
| 270 | |
| 271 | m_atapi_cdata_wait = 0;
|
| 272 | break;
|
| 273 | |
| 274 | case 0xa1: // IDENTIFY PACKET DEVICE
|
| 275 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ;
|
| 276 | |
| 277 | m_atapi_data_ptr = 0;
|
| 278 | m_atapi_data_len = 512;
|
| 279 | |
| 280 | /* we have no data */
|
| 281 | m_atapi_xferlen = 0;
|
| 282 | m_atapi_xfermod = 0;
|
| 283 | |
| 284 | memset( atapi_data, 0, m_atapi_data_len );
|
| 285 | |
| 286 | atapi_data[ 0 ^ 1 ] = 0x85; // ATAPI device, cmd set 5 compliant, DRQ within 3 ms of PACKET command
|
| 287 | atapi_data[ 1 ^ 1 ] = 0x80; // ATAPI device, removable media
|
| 288 | |
| 289 | memset( &atapi_data[ 46 ], ' ', 8 );
|
| 290 | atapi_data[ 46 ^ 1 ] = '1';
|
| 291 | atapi_data[ 47 ^ 1 ] = '.';
|
| 292 | atapi_data[ 48 ^ 1 ] = '0';
|
| 293 |
|
| 294 |
|
| 295 | memset( &atapi_data[ 54 ], ' ', 40 );
|
| 296 | atapi_data[ 54 ^ 1 ] = 'T';
|
| 297 | atapi_data[ 55 ^ 1 ] = 'O';
|
| 298 | atapi_data[ 56 ^ 1 ] = 'S';
|
| 299 | atapi_data[ 57 ^ 1 ] = 'H';
|
| 300 | atapi_data[ 58 ^ 1 ] = 'I';
|
| 301 | atapi_data[ 59 ^ 1 ] = 'B';
|
| 302 | atapi_data[ 60 ^ 1 ] = 'A';
|
| 303 | atapi_data[ 61 ^ 1 ] = ' ';
|
| 304 | atapi_data[ 62 ^ 1 ] = 'X';
|
| 305 | atapi_data[ 63 ^ 1 ] = 'M';
|
| 306 | atapi_data[ 64 ^ 1 ] = '-';
|
| 307 | atapi_data[ 65 ^ 1 ] = '3';
|
| 308 | atapi_data[ 66 ^ 1 ] = '3';
|
| 309 | atapi_data[ 67 ^ 1 ] = '0';
|
| 310 | atapi_data[ 68 ^ 1 ] = '1';
|
| 311 | atapi_data[ 69 ^ 1 ] = ' ';
|
| 312 | |
| 313 | atapi_data[ 98 ^ 1 ] = 0x06; // Word 49=Capabilities, IORDY may be disabled (bit_10), LBA Supported mandatory (bit_9)
|
| 314 | atapi_data[ 99 ^ 1 ] = 0x00;
|
| 315 | |
| 316 | atapi_regs[ATAPI_REG_COUNTLOW] = 0;
|
| 317 | atapi_regs[ATAPI_REG_COUNTHIGH] = 2;
|
| 318 | |
| 319 | atapi_irq(this, ASSERT_LINE);
|
| 320 | break;
|
| 321 | case 0xec: //IDENTIFY DEVICE - Must abort here and set for packet data
|
| 322 | atapi_regs[ATAPI_REG_ERRFEAT] = ATAPI_ERRFEAT_ABRT;
|
| 323 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_CHECK;
|
| 324 |
|
| 325 | atapi_irq(this, ASSERT_LINE);
|
| 326 | break;
|
| 327 | case 0xef: // SET FEATURES
|
| 328 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 329 | |
| 330 | m_atapi_data_ptr = 0;
|
| 331 | m_atapi_data_len = 0;
|
| 332 | |
| 333 | atapi_irq(this, ASSERT_LINE);
|
| 334 | break;
|
| 335 | |
| 336 | case 0x08: // ATAPI RESET
|
| 337 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0x00;
|
| 338 | atapi_regs[ATAPI_REG_ERRFEAT] = 0x01;
|
| 339 | atapi_regs[ATAPI_REG_INTREASON] = 0x01; // SECTOR_COUNT
|
| 340 | atapi_regs[ATAPI_REG_SAMTAG] = 0x01; // SECTOR_NUMBER
|
| 341 | atapi_regs[ATAPI_REG_COUNTLOW] = 0x14; // CYLINDER_LSB
|
| 342 | atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb; // CYLINDER_MSB
|
| 343 | atapi_regs[ATAPI_REG_DRIVESEL] &= 0xf0; // HEAD_NUMBER
|
| 344 |
|
| 345 | atapi_irq(this, ASSERT_LINE);
|
| 346 | break;
|
| 347 | default:
|
| 348 | logerror("ATAPI: Unknown IDE command %x\n", data);
|
| 349 | atapi_regs[ATAPI_REG_ERRFEAT] = ATAPI_ERRFEAT_ABRT;
|
| 350 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_CHECK;
|
| 351 | |
| 352 | atapi_irq(this, ASSERT_LINE);
|
| 353 | break;
|
| 354 | }
|
| 355 | }
|
| 356 | }
|
| 357 | }
|
| 358 | |
| 359 | static struct cdrom_interface ide_cdrom =
|
| 360 | {
|
| 361 | NULL,
|
| 362 | NULL
|
| 363 | };
|
| 364 | |
| 365 | static MACHINE_CONFIG_FRAGMENT( ide )
|
| 366 | MCFG_CDROM_ADD( "cdrom", ide_cdrom )
|
| 367 | MACHINE_CONFIG_END
|
| 368 | |
| 369 | static INPUT_PORTS_START( ide )
|
| 370 | PORT_START("DSW")
|
| 371 | PORT_DIPNAME( 0x01, 0x00, "IDE Configuration")
|
| 372 | PORT_DIPSETTING( 0x00, "Primary" )
|
| 373 | PORT_DIPSETTING( 0x01, "Secondary" )
|
| 374 | INPUT_PORTS_END
|
| 375 | |
| 376 | //**************************************************************************
|
| 377 | // GLOBAL VARIABLES
|
| 378 | //**************************************************************************
|
| 379 | |
| 380 | const device_type ISA16_IDE_CD = &device_creator<isa16_ide_cd_device>;
|
| 381 | |
| 382 | //-------------------------------------------------
|
| 383 | // machine_config_additions - device-specific
|
| 384 | // machine configurations
|
| 385 | //-------------------------------------------------
|
| 386 | |
| 387 | machine_config_constructor isa16_ide_cd_device::device_mconfig_additions() const
|
| 388 | {
|
| 389 | return MACHINE_CONFIG_NAME( ide );
|
| 390 | }
|
| 391 | |
| 392 | //-------------------------------------------------
|
| 393 | // input_ports - device-specific input ports
|
| 394 | //-------------------------------------------------
|
| 395 | |
| 396 | ioport_constructor isa16_ide_cd_device::device_input_ports() const
|
| 397 | {
|
| 398 | return INPUT_PORTS_NAME( ide );
|
| 399 | }
|
| 400 | |
| 401 | //**************************************************************************
|
| 402 | // LIVE DEVICE
|
| 403 | //**************************************************************************
|
| 404 | |
| 405 | //-------------------------------------------------
|
| 406 | // isa16_ide_cd_device - constructor
|
| 407 | //-------------------------------------------------
|
| 408 | |
| 409 | isa16_ide_cd_device::isa16_ide_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
| 410 | : device_t(mconfig, ISA16_IDE_CD, "IDE CD Drive Adapter", tag, owner, clock),
|
| 411 | device_isa16_card_interface( mconfig, *this ),
|
| 412 | m_is_primary(true),
|
| 413 | m_inserted_cdrom(NULL)
|
| 414 | {
|
| 415 | }
|
| 416 | |
| 417 | //-------------------------------------------------
|
| 418 | // device_start - device-specific startup
|
| 419 | //-------------------------------------------------
|
| 420 | |
| 421 | void isa16_ide_cd_device::device_start()
|
| 422 | {
|
| 423 | set_isa_device();
|
| 424 | }
|
| 425 | |
| 426 | //-------------------------------------------------
|
| 427 | // device_stop - device-specific startup
|
| 428 | //-------------------------------------------------
|
| 429 | |
| 430 | void isa16_ide_cd_device::device_stop()
|
| 431 | {
|
| 432 | SCSIDeleteInstance(m_inserted_cdrom);
|
| 433 | }
|
| 434 | |
| 435 | //-------------------------------------------------
|
| 436 | // device_reset - device-specific reset
|
| 437 | //-------------------------------------------------
|
| 438 | |
| 439 | void isa16_ide_cd_device::device_reset()
|
| 440 | {
|
| 441 | astring tempstring;
|
| 442 | if (m_inserted_cdrom) SCSIDeleteInstance(m_inserted_cdrom);
|
| 443 | SCSIAllocInstance( machine(), &SCSIClassCr589, &m_inserted_cdrom, subtag(tempstring, "cdrom"));
|
| 444 | m_is_primary = (input_port_read(*this, "DSW") & 1) ? false : true;
|
| 445 | if (m_is_primary) {
|
| 446 | m_isa->install16_device(0x01f0, 0x01f7, 0, 0, read16_delegate(FUNC(isa16_ide_cd_device::atapi_r), this), write16_delegate(FUNC(isa16_ide_cd_device::atapi_w), this)); |
| 447 | //m_isa->install16_device(0x03f0, 0x03f7, 0, 0, read16_delegate(FUNC(isa16_ide_cd_device::atapi_status_r), this), write16_delegate(FUNC(isa16_ide_cd_device::atapi_cmd_w), this)); |
| 448 | } else {
|
| 449 | m_isa->install16_device(0x0170, 0x0177, 0, 0, read16_delegate(FUNC(isa16_ide_cd_device::atapi_r), this), write16_delegate(FUNC(isa16_ide_cd_device::atapi_w), this)); |
| 450 | m_isa->install16_device(0x0370, 0x0377, 0, 0, read16_delegate(FUNC(isa16_ide_cd_device::atapi_status_r), this), write16_delegate(FUNC(isa16_ide_cd_device::atapi_cmd_w), this)); |
| 451 | }
|
| 452 | }
|
src/mess/machine/isa_ide_cd.h
| r0 | r14719 | |
| 1 | #pragma once
|
| 2 | |
| 3 | #ifndef __ISA_IDE_CD_H__
|
| 4 | #define __ISA_IDE_CD_H__
|
| 5 | |
| 6 | #include "emu.h"
|
| 7 | #include "machine/isa.h"
|
| 8 | #include "imagedev/chd_cd.h"
|
| 9 | #include "machine/cr589.h"
|
| 10 | |
| 11 | //**************************************************************************
|
| 12 | // TYPE DEFINITIONS
|
| 13 | //**************************************************************************
|
| 14 | #define ATAPI_CYCLES_PER_SECTOR (5000) // plenty of time to allow DMA setup etc. BIOS requires this be at least 2000, individual games may vary.
|
| 15 | |
| 16 | #define ATAPI_ERRFEAT_ABRT 0x04
|
| 17 | |
| 18 | #define ATAPI_STAT_BSY 0x80
|
| 19 | #define ATAPI_STAT_DRDY 0x40
|
| 20 | #define ATAPI_STAT_DMARDDF 0x20
|
| 21 | #define ATAPI_STAT_SERVDSC 0x10
|
| 22 | #define ATAPI_STAT_DRQ 0x08
|
| 23 | #define ATAPI_STAT_CORR 0x04
|
| 24 | #define ATAPI_STAT_CHECK 0x01
|
| 25 | |
| 26 | #define ATAPI_INTREASON_COMMAND 0x01
|
| 27 | #define ATAPI_INTREASON_IO 0x02
|
| 28 | #define ATAPI_INTREASON_RELEASE 0x04
|
| 29 | |
| 30 | #define ATAPI_REG_DATA 0
|
| 31 | #define ATAPI_REG_ERRFEAT 1
|
| 32 | #define ATAPI_REG_INTREASON 2
|
| 33 | #define ATAPI_REG_SAMTAG 3
|
| 34 | #define ATAPI_REG_COUNTLOW 4
|
| 35 | #define ATAPI_REG_COUNTHIGH 5
|
| 36 | #define ATAPI_REG_DRIVESEL 6
|
| 37 | #define ATAPI_REG_CMDSTATUS 7
|
| 38 | #define ATAPI_REG_MAX 16
|
| 39 | |
| 40 | #define ATAPI_DATA_SIZE ( 64 * 1024 )
|
| 41 | |
| 42 | #define MAX_TRANSFER_SIZE ( 63488 )
|
| 43 | |
| 44 | // ======================> isa16_ide_cd_device
|
| 45 | |
| 46 | class isa16_ide_cd_device :
|
| 47 | public device_t,
|
| 48 | public device_isa16_card_interface
|
| 49 | {
|
| 50 | public:
|
| 51 | // construction/destruction
|
| 52 | isa16_ide_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
| 53 | |
| 54 | // optional information overrides
|
| 55 | virtual machine_config_constructor device_mconfig_additions() const;
|
| 56 | virtual ioport_constructor device_input_ports() const;
|
| 57 | |
| 58 | bool is_primary() { return m_is_primary; }
|
| 59 | |
| 60 | |
| 61 | DECLARE_READ16_MEMBER(atapi_r);
|
| 62 | DECLARE_WRITE16_MEMBER(atapi_w);
|
| 63 | DECLARE_READ16_MEMBER(atapi_status_r);
|
| 64 | DECLARE_WRITE16_MEMBER(atapi_cmd_w);
|
| 65 | protected:
|
| 66 | // device-level overrides
|
| 67 | virtual void device_start();
|
| 68 | virtual void device_reset();
|
| 69 | virtual void device_stop();
|
| 70 | virtual void device_config_complete() { m_shortname = "isa_ide_cd"; }
|
| 71 | private:
|
| 72 | // internal state
|
| 73 | bool m_is_primary;
|
| 74 |
|
| 75 | // CDROM
|
| 76 | SCSIInstance *m_inserted_cdrom;
|
| 77 | |
| 78 | int m_atapi_data_ptr;
|
| 79 | int m_atapi_data_len;
|
| 80 | int m_atapi_xferlen;
|
| 81 | int m_atapi_cdata_wait;
|
| 82 | int m_atapi_xfermod;
|
| 83 | /* memory */
|
| 84 | UINT8 m_atapi_regs[ATAPI_REG_MAX];
|
| 85 | UINT8 m_atapi_data[ATAPI_DATA_SIZE]; |
| 86 | };
|
| 87 | |
| 88 | |
| 89 | // device type definition
|
| 90 | extern const device_type ISA16_IDE_CD;
|
| 91 | |
| 92 | #endif /* __ISA_IDE_CD_H__ */
|
src/mess/drivers/at.c
| r14718 | r14719 | |
| 382 | 382 | SLOT_INTERFACE("ibm_mfc", ISA8_IBM_MFC) |
| 383 | 383 | // ISA 16 bit |
| 384 | 384 | SLOT_INTERFACE("ide", ISA16_IDE) |
| 385 | SLOT_INTERFACE("ide_cd", ISA16_IDE_CD) |
| 385 | 386 | SLOT_INTERFACE("ne2000", NE2000) |
| 386 | 387 | SLOT_INTERFACE("aha1542", AHA1542) |
| 387 | 388 | SLOT_INTERFACE("gus",ISA16_GUS) |
| r14718 | r14719 | |
| 589 | 590 | MCFG_CPU_IO_MAP(at386_io) |
| 590 | 591 | MACHINE_CONFIG_END |
| 591 | 592 | |
| 593 | //------------------------------------------------- |
| 594 | // DEVICE_INPUT_DEFAULTS( ide_2nd) |
| 595 | //------------------------------------------------- |
| 592 | 596 | |
| 597 | static DEVICE_INPUT_DEFAULTS_START( ide_2nd ) |
| 598 | DEVICE_INPUT_DEFAULTS("DSW", 0x01, 0x01) |
| 599 | DEVICE_INPUT_DEFAULTS_END |
| 600 | |
| 593 | 601 | static MACHINE_CONFIG_DERIVED( ct486, at386 ) |
| 594 | 602 | MCFG_CPU_REPLACE("maincpu", I486, 25000000) |
| 595 | 603 | MCFG_CPU_PROGRAM_MAP(ct486_map) |
| r14718 | r14719 | |
| 597 | 605 | |
| 598 | 606 | MCFG_CS4031_ADD("cs4031", "maincpu", "isa", "bios") |
| 599 | 607 | |
| 608 | MCFG_ISA16_SLOT_ADD("isabus","isa5", pc_isa16_cards, "ide_cd", ide_2nd) //2nd-ary IDE |
| 609 | |
| 600 | 610 | MCFG_DEVICE_REMOVE(RAM_TAG) |
| 601 | 611 | MCFG_RAM_ADD(RAM_TAG) |
| 602 | 612 | MCFG_RAM_DEFAULT_SIZE("4M") |
| 603 | 613 | MCFG_RAM_EXTRA_OPTIONS("1M,2M,8M,16M,32M,64M") |
| 604 | 614 | MACHINE_CONFIG_END |
| 605 | 615 | |
| 606 | | //------------------------------------------------- |
| 607 | | // DEVICE_INPUT_DEFAULTS( ide_2nd) |
| 608 | | //------------------------------------------------- |
| 609 | 616 | |
| 610 | | static DEVICE_INPUT_DEFAULTS_START( ide_2nd ) |
| 611 | | DEVICE_INPUT_DEFAULTS("DSW", 0x01, 0x01) |
| 612 | | DEVICE_INPUT_DEFAULTS_END |
| 613 | | |
| 614 | | |
| 615 | 617 | static MACHINE_CONFIG_DERIVED( at586, at386 ) |
| 616 | 618 | MCFG_CPU_REPLACE("maincpu", PENTIUM, 60000000) |
| 617 | 619 | MCFG_CPU_PROGRAM_MAP(at586_map) |
| r14718 | r14719 | |
| 624 | 626 | MCFG_PCI_BUS_DEVICE(0, "i82439tx", i82439tx_pci_read, i82439tx_pci_write) |
| 625 | 627 | MCFG_PCI_BUS_DEVICE(1, "i82371ab", i82371ab_pci_read, i82371ab_pci_write) |
| 626 | 628 | |
| 627 | | MCFG_ISA16_SLOT_ADD("isabus","isa5", pc_isa16_cards, "ide", ide_2nd) //2nd-ary IDE |
| 628 | | |
| 629 | 629 | MCFG_DEVICE_REMOVE(RAM_TAG) |
| 630 | 630 | MCFG_RAM_ADD(RAM_TAG) |
| 631 | 631 | MCFG_RAM_DEFAULT_SIZE("4M") |