summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/t10spc.c
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2013-09-17 18:23:52 +0000
committer smf- <smf-@users.noreply.github.com>2013-09-17 18:23:52 +0000
commit0839767cb356a6fe3d2512b8aaa317b0b17fc578 (patch)
tree3a62c7f1823b84fe21f4a15576ae460b31b6bce7 /src/emu/machine/t10spc.c
parent46781347cd06f6b837944c92da630f4d45232c34 (diff)
Use virtual multiple inheritance to share command processing between SCSI & ATAPI instead of having a SCSI subdevice. This allows matsushita_cr589_device & gdrom_device to derive from atapi_cdrom_device. [smf]
Diffstat (limited to 'src/emu/machine/t10spc.c')
-rw-r--r--src/emu/machine/t10spc.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/emu/machine/t10spc.c b/src/emu/machine/t10spc.c
new file mode 100644
index 00000000000..1ffdc4ea8b7
--- /dev/null
+++ b/src/emu/machine/t10spc.c
@@ -0,0 +1,90 @@
+#include "t10spc.h"
+
+#define SCSI_SENSE_SIZE 4
+
+void t10spc::t10_start(device_t &device)
+{
+ device.save_item(NAME(command));
+ device.save_item(NAME(commandLength));
+ device.save_item(NAME(m_phase));
+ device.save_item(NAME(m_transfer_length));
+}
+
+void t10spc::t10_reset()
+{
+ m_phase = SCSI_PHASE_BUS_FREE;
+}
+
+void t10spc::ExecCommand()
+{
+ switch( command[ 0 ] )
+ {
+ case SCSI_CMD_TEST_UNIT_READY:
+ m_phase = SCSI_PHASE_STATUS;
+ m_transfer_length = 0;
+ break;
+
+ case SCSI_CMD_RECALIBRATE:
+ m_phase = SCSI_PHASE_STATUS;
+ m_transfer_length = 0;
+ break;
+
+ case SCSI_CMD_REQUEST_SENSE:
+ m_phase = SCSI_PHASE_DATAOUT;
+ m_transfer_length = SCSI_SENSE_SIZE;
+ break;
+
+ case SCSI_CMD_SEND_DIAGNOSTIC:
+ m_phase = SCSI_PHASE_DATAOUT;
+ m_transfer_length = SCSILengthFromUINT16(&command[3]);
+ break;
+
+ default:
+ logerror( "SCSIDEV unknown command %02x\n", command[ 0 ] );
+ m_transfer_length = 0;
+ break;
+ }
+}
+
+void t10spc::ReadData( UINT8 *data, int dataLength )
+{
+ switch( command[ 0 ] )
+ {
+ case SCSI_CMD_REQUEST_SENSE:
+ data[ 0 ] = SCSI_SENSE_NO_SENSE;
+ data[ 1 ] = 0x00;
+ data[ 2 ] = 0x00;
+ data[ 3 ] = 0x00;
+ break;
+ default:
+ logerror( "SCSIDEV unknown read %02x\n", command[ 0 ] );
+ break;
+ }
+}
+
+void t10spc::WriteData( UINT8 *data, int dataLength )
+{
+ switch( command[ 0 ] )
+ {
+ case SCSI_CMD_SEND_DIAGNOSTIC:
+ break;
+
+ default:
+ logerror( "SCSIDEV unknown write %02x\n", command[ 0 ] );
+ break;
+ }
+}
+
+void t10spc::SetCommand( UINT8 *_command, int _commandLength )
+{
+ if( _commandLength > sizeof( command ) )
+ {
+ /// TODO: output an error.
+ return;
+ }
+
+ memcpy( command, _command, _commandLength );
+ commandLength = _commandLength;
+
+ m_phase = SCSI_PHASE_COMMAND;
+}