Moved the phase callback handler to hdc_ide.c, where it belongs, rather than in each SCSI(-like) device's code, and made it no longer used when a device's bus type is set to SCSI.

This commit is contained in:
OBattler
2018-10-31 12:23:49 +01:00
parent aaa31dbd57
commit f30e048ad7
7 changed files with 211 additions and 427 deletions

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI device command handler.
*
* Version: @(#)scsi_device.c 1.0.22 2018/10/28
* Version: @(#)scsi_device.c 1.0.23 2018/10/31
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -47,29 +47,6 @@ scsi_device_target_command(scsi_device_t *dev, uint8_t *cdb)
}
static void
scsi_device_target_callback(scsi_device_t *dev)
{
if (dev->callback)
dev->callback(dev->sc);
return;
}
static int
scsi_device_target_err_stat_to_scsi(scsi_device_t *dev)
{
if (dev->sc)
if (dev->sc->status & ERR_STAT)
return SCSI_STATUS_CHECK_CONDITION;
else
return SCSI_STATUS_OK;
else
return SCSI_STATUS_CHECK_CONDITION;
}
int64_t
scsi_device_get_callback(scsi_device_t *dev)
{
@@ -148,12 +125,16 @@ scsi_device_command_phase0(scsi_device_t *dev, uint8_t *cdb)
/* Finally, execute the SCSI command immediately and get the transfer length. */
dev->phase = SCSI_PHASE_COMMAND;
dev->status = scsi_device_target_command(dev, cdb);
}
if (dev->phase == SCSI_PHASE_STATUS) {
/* Command completed (either OK or error) - call the phase callback to complete the command. */
scsi_device_target_callback(dev);
void
scsi_device_command_stop(scsi_device_t *dev)
{
if (dev->command_stop) {
dev->command_stop(dev->sc);
dev->status = SCSI_STATUS_OK;
}
/* If the phase is DATA IN or DATA OUT, finish this here. */
}
@@ -164,19 +145,16 @@ scsi_device_command_phase1(scsi_device_t *dev)
return;
/* Call the second phase. */
scsi_device_target_callback(dev);
dev->status = scsi_device_target_err_stat_to_scsi(dev);
/* Command second phase complete - call the callback to complete the command. */
scsi_device_target_callback(dev);
}
if (dev->phase == SCSI_PHASE_DATA_OUT) {
if (dev->phase_data_out)
dev->phase_data_out(dev->sc);
} else
scsi_device_command_stop(dev);
void
scsi_device_command_stop(scsi_device_t *dev)
{
if (!dev->command_stop)
dev->command_stop(dev->sc);
scsi_device_target_callback(dev);
if (dev->sc->status & ERR_STAT)
dev->status = SCSI_STATUS_CHECK_CONDITION;
else
dev->status = SCSI_STATUS_OK;
}