src/mess/machine/isa_ide_cd.c
| r14726 | r14727 | |
| 166 | 166 | // reset data pointer for reading SCSI results
|
| 167 | 167 | m_atapi_data_ptr = 0;
|
| 168 | 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)
|
| 169 | cdrom_image_device *cdrom = subdevice<cdrom_image_device>("cdrom");
|
| 170 | bool checkready = false;
|
| 171 | switch(atapi_data[0]&0xff) {
|
| 172 | case 0x00 :
|
| 173 | case 0x25 :
|
| 174 | case 0x28 :
|
| 175 | case 0x2b :
|
| 176 | case 0x43 :
|
| 177 | case 0xa8 :
|
| 178 | case 0xad :
|
| 179 | case 0xbe :
|
| 180 | checkready = true;
|
| 181 | break;
|
| 182 | }
|
| 183 |
|
| 184 | if (checkready && cdrom_get_toc(cdrom->get_cdrom_file())==NULL) |
| 176 | 185 | {
|
| 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;
|
| 186 | logerror("ATAPI: SCSI command %02x returned not ready\n", atapi_data[0]&0xff);
|
| 187 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY | ATAPI_STAT_CHECK;
|
| 188 | atapi_regs[ATAPI_REG_ERRFEAT] = (2 << 4) | ATAPI_ERRFEAT_ABRT;
|
| 189 | // assert IRQ
|
| 190 | atapi_irq(this, ASSERT_LINE); |
| 191 | } else {
|
| 192 | // send it to the SCSI device
|
| 193 | SCSISetCommand( m_inserted_cdrom, m_atapi_data, 12 );
|
| 194 | SCSIExecCommand( m_inserted_cdrom, &m_atapi_xferlen );
|
| 195 | SCSIGetPhase( m_inserted_cdrom, &phase );
|
| 189 | 196 | |
| 190 | | if (m_atapi_xferlen == 0)
|
| 197 | if (m_atapi_xferlen != -1)
|
| 191 | 198 | {
|
| 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 | | }
|
| 199 | logerror("ATAPI: SCSI command %02x returned %d bytes from the device\n", atapi_data[0]&0xff, m_atapi_xferlen);
|
| 200 | // store the returned command length in the ATAPI regs, splitting into
|
| 201 | // multiple transfers if necessary
|
| 202 | m_atapi_xfermod = 0;
|
| 203 | if (m_atapi_xferlen > MAX_TRANSFER_SIZE)
|
| 204 | {
|
| 205 | m_atapi_xfermod = m_atapi_xferlen - MAX_TRANSFER_SIZE;
|
| 206 | m_atapi_xferlen = MAX_TRANSFER_SIZE;
|
| 207 | }
|
| 208 | |
| 209 | atapi_regs[ATAPI_REG_COUNTLOW] = m_atapi_xferlen & 0xff;
|
| 210 | atapi_regs[ATAPI_REG_COUNTHIGH] = (m_atapi_xferlen>>8)&0xff;
|
| 202 | 211 | |
| 203 | | switch( phase )
|
| 204 | | {
|
| 205 | | case SCSI_PHASE_DATAOUT:
|
| 206 | | m_atapi_cdata_wait = m_atapi_xferlen;
|
| 207 | | break;
|
| 208 | | }
|
| 212 | if (m_atapi_xferlen == 0)
|
| 213 | {
|
| 214 | // if no data to return, set the registers properly
|
| 215 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY;
|
| 216 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO|ATAPI_INTREASON_COMMAND;
|
| 217 | }
|
| 218 | else
|
| 219 | {
|
| 220 | // indicate data ready: set DRQ and DMA ready, and IO in INTREASON
|
| 221 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
|
| 222 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
|
| 223 | }
|
| 209 | 224 | |
| 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;
|
| 225 | switch( phase )
|
| 226 | {
|
| 227 | case SCSI_PHASE_DATAOUT:
|
| 228 | m_atapi_cdata_wait = m_atapi_xferlen;
|
| 216 | 229 | break;
|
| 230 | }
|
| 217 | 231 | |
| 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;
|
| 232 | // perform special ATAPI processing of certain commands
|
| 233 | switch (atapi_data[0]&0xff)
|
| 234 | {
|
| 235 | case 0x00: // BUS RESET / TEST UNIT READY
|
| 236 | case 0xbb: // SET CDROM SPEED
|
| 237 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
|
| 238 | break;
|
| 239 | |
| 240 | case 0x45: // PLAY
|
| 241 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY;
|
| 242 | //m_atapi_timer->adjust( downcast<cpu_device *>(this)->cycles_to_attotime( ATAPI_CYCLES_PER_SECTOR ) );
|
| 243 | break;
|
| 244 | }
|
| 245 | |
| 246 | // assert IRQ
|
| 247 | atapi_irq(this, ASSERT_LINE);
|
| 222 | 248 | }
|
| 249 | else
|
| 250 | {
|
| 251 | logerror("ATAPI: SCSI device returned error!\n");
|
| 223 | 252 | |
| 224 | | // assert IRQ
|
| 225 | | atapi_irq(this, ASSERT_LINE);
|
| 226 | | logerror("IRQ\n");
|
| 253 | atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_CHECK;
|
| 254 | atapi_regs[ATAPI_REG_ERRFEAT] = 0x50; // sense key = ILLEGAL REQUEST
|
| 255 | atapi_regs[ATAPI_REG_COUNTLOW] = 0;
|
| 256 | atapi_regs[ATAPI_REG_COUNTHIGH] = 0;
|
| 257 | }
|
| 227 | 258 | }
|
| 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 | 259 | }
|
| 238 | 260 | }
|
| 239 | 261 | else
|